Verifying Weak and Strong k-Step Opacity
in Discrete-Event Systems
Abstract
Opacity is an important system-theoretic property expressing whether a system may reveal its secret to a passive observer (an intruder) who knows the structure of the system but has only limited observations of its behavior. Several notions of opacity have been discussed in the literature, including current-state opacity, -step opacity, and infinite-step opacity. We investigate weak and strong -step opacity, the notions that generalize both current-state opacity and infinite-step opacity, and ask whether the intruder is not able to decide, at any time instant, when respectively whether the system was in a secret state during the last observable steps. We design a new algorithm verifying weak -step opacity, the complexity of which is lower than the complexity of existing algorithms and does not depend on the parameter , and show how to use it to verify strong -step opacity by reducing strong -step opacity to weak -step opacity. The complexity of the resulting algorithm is again better than the complexity of existing algorithms and does not depend on the parameter .
keywords:
Discrete event systems, finite automata, opacity, verification, complexity, algorithms.and
1 Introduction
Opacity is an information-flow property used to study security and privacy questions of discrete-event systems, communication protocols, and computer systems. Besides security and privacy, an interesting application of opacity is its ability to express other state-estimation properties. In particular, Lin (2011) has shown how to express and verify observability, diagnosability, and detectability in terms of opacity.
Opacity guarantees that a system prevents an intruder from revealing its secret. The intruder is a passive observer that knows the structure of the system but has only limited observations of system’s behavior. Intuitively, the intruder estimates the behavior of the system, and the system is opaque if for every secret behavior, there is a nonsecret behavior that looks the same to the intruder. The secret is modeled as a set of secret states or as a set of secret behaviors. Modeling the secret as a set of secret states results in state-based opacity, introduced by Bryans et al. (2005, 2008) for Petri nets and transition systems, and adapted to automata by Saboori and Hadjicostis (2007). Modeling the secret as a set of secret behaviors results in language-based opacity, introduced by Badouel et al. (2007) and Dubreil et al. (2008). See the overview by Jacob et al. (2016) for more details.
Many notions of opacity have been discussed in the literature, including initial-state opacity and current-state opacity. While initial-state opacity prevents the intruder from revealing, at any time instant, whether the system started in a secret state, current-state opacity prevents the intruder “only” from revealing whether the system is currently in a secret state. This, however, does not exclude the possibility that the intruder later realizes that the system was in a secret state at a former step of the computation. For instance, if the intruder estimates that the system is in one of two possible states and, in the next step, the system proceeds by an observable event enabled only in one of the states, then the intruder reveals the state in which the system was one step ago.
Saboori and Hadjicostis (2007, 2012) addressed this issue and introduce the notion of weak -step opacity. Weak -step opacity requires that the intruder is not able to ascertain the secret in the current state and subsequent observable steps. For and , weak -step opacity coincides with current-state opacity and infinite-step opacity, respectively. The notion of infinite-step opacity may be confusing in the context of finite automata, because an -state automaton is infinite-step opaque if and only if it is -step opaque, see Yin and Lafortune (2017).
The verification of weak -step opacity has been intensively studied in the literature, resulting in (at least) five different approaches: (1) the secret observer approach with complexity , where is the number of states and is the number of observable events, (2) the reverse comparison approach with complexity , where is the number of transitions in an involved NFA, (3) the state estimator approach of Saboori and Hadjicostis (2011) with complexity , (4) the two-way observer approach of Yin and Lafortune (2017) with complexity , already corrected by Lan et al. (2020), and (5) the projected automaton approach of Balun and Masopust (2021) of complexity ; see also Wintenberg et al. (2022) for more details on the state complexity and an experimental comparison. The reader can see that the complexity of all the algorithms depends on the parameter . A partial exception is the two-way observer algorithm that does not depend on the parameter if , that is, if is larger than the number of states divided by the logarithm of the number of observable events.
In this paper, we design a new algorithm verifying weak -step opacity, the complexity of which does not depend on the parameter . The state complexity of our algorithm is and the time complexity is , where is the number of states of the input automaton and is the number of transitions of the projected input automaton. Hence, our algorithm is faster than all the existing algorithms, with the exception of a very small parameter ; namely, if is smaller than , where is the number of states of the input automaton and is its number of observable events, then the algorithms based on the state estimator and on the two-way observer are, in the worst-case, faster than our algorithm.
However, Falcone and Marchand (2015) have later noticed that even weak -step opacity may not be as confidential as intuitively expected. In particular, the intruder may realize that the system was in a secret state, although it cannot deduce the exact time when this has happened (see an example in Section 4 or in Falcone and Marchand (2015) for more details). This problem motivated Falcone and Marchand (2015) to introduce strong -step opacity as the notion of -step opacity with a higher level of confidentiality. The idea is that whereas weak -step opacity prevents the intruder from revealing the exact time when the system was in a secret state during the last observable steps, strong -step opacity prevents the intruder from revealing that the system was in a secret state during the last observable steps.
Ma et al. (2021) pointed out without proofs that strong and weak -step opacity are incomparable in the sense that neither strong -step opacity implies weak -step opacity nor vice versa. In fact, under the assumption that there are no neutral states (states that are neither secret nor nonsecret), which is assumed in most of the literature, including this paper, strong -step opacity implies weak -step opacity (see Appendix A for more details).
However, the verification of one type of -step opacity cannot be directly used for the verification of the other. We show how to do it indirectly. Namely, we construct a polynomial-time transformation of strong -step opacity to weak -step opacity, which makes it possible to verify strong -step opacity by the algorithms for weak -step opacity. In addition, using our new algorithm verifying weak -step opacity results in a new algorithm to verify strong -step opacity with a lower complexity that does not depend on the parameter .
2 Preliminaries
We assume that the reader is familiar with discrete-event systems, see Cassandras and Lafortune (2021) for more details. For a set , denotes the cardinality of , and denotes the power set of . An alphabet is a finite nonempty set of events. A string over is a sequence of events from ; the empty string is denoted by . The set of all finite strings over is denoted by . A language over is a subset of . For a string , denotes the length of .
A nondeterministic finite automaton (NFA) over an alphabet is a structure , where is a finite set of states, is a nonempty set of initial states, is a set of marked states, and is a transition function that can be extended to the domain by induction; we often consider the transition function as the corresponding relation . In addition, for a set , we define . For a set , the set is the language marked by from the states of , and is the language generated by from the states of . The languages marked and generated by are defined as and , respectively. The NFA is deterministic (DFA) if and for every and . In this case, we identify the singleton with its element , and simply write instead of .
A discrete-event system (DES) over is an NFA over together with the partition of into and of observable and unobservable events, respectively. If we want to specify that the DES is modeled by a DFA, we talk about deterministic DES. If the marked states are irrelevant, we omit them and simply write .
The state estimation is modeled by projection , which is a morphism for concatenation defined by if , and if . The action of on a string is to erase all unobservable events, that is, . The definition can be readily extended to languages.
Let be a DES over , and let be the corresponding projection. The projected automaton of is the NFA obtained from by replacing every transition by , followed by the standard elimination of the -transitions. In particular, if is the transition function of , then the transition function of is defined as . The projected automaton is an NFA over with the same states as that recognizes the language and that can be constructed in polynomial time, see Hopcroft et al. (2006).
We call the DFA constructed from by the standard subset construction a full observer of . The accessible part of the full observer of is called an observer of , cf. Cassandras and Lafortune (2021). The full observer has exponentially many states compared with . In the worst case, the same holds for the observer as well, see Wong (1998); Jirásková and Masopust (2012) for more details.
For two DESs , , over the common alphabet , the product automaton of and is defined as the DES , where , for every pair of states and every event . Notice that the definition does not restrict the state space of the product automaton to its reachable part.
3 Verification of Weak k-Step Opacity
In this section, we recall the definition of weak -step opacity for DESs, and design a new algorithm to verify weak -step opacity. To this end, we denote by the set of all nonnegative integers together with their limit. For , weak -step opacity asks whether the intruder cannot reveal the secret of a system in the current and subsequent states.
Definition 1.
Given a DES and . System is weakly -step opaque (-SO) with respect to the sets of secret and of nonsecret states and observation if for every string with and , there exists a string such that , , and .
Verification of weak -step opacity
Algorithm 3 describes our new algorithm verifying weak -step opacity. The idea of the algorithm is as follows. We first compute the observer of , denoted by , and the projected automaton of , denoted by . Then, for every reachable state of , we add the pairs to the set , where is a secret state of and is the set of all nonsecret states of . Intuitively, in these states, the intruder estimates that may be in the secret state or in the nonsecret states of . To verify that the intruder does not reveal the secret state, we need to check that every possible path of length up to starting in is accompanied by a path with the same observation starting in a nonsecret state of . To this end, we construct the automaton as the part of the full observer of consisting only of states reachable from the states forming the second components of the pairs in , and the automaton as the product automaton of the projected automaton of and . In , all transitions are observable, and every path from a secret state is synchronized with all the possible paths with the same observation starting in the states of . Thus, if there is a path from the secret state of length up to that is not accompanied by a path with the same observation from a state of , then this path from the state in ends up in a state, say, , whereas all paths in with the same observation from the state end up in the state . Here, and are understood as the states of the full observer of . Thus, if the DES is not weakly -step opaque, there is a state of from which a state of the from is reachable in at most steps. Therefore, we search the automaton and mark all its states that are reachable from a state of in at most steps. If a state of the from is marked, then is not weakly -step opaque; otherwise, it is.
We prove the correctness of Algorithm 3 and analyze its complexity in detail below. Intuitively, the correctness follows from the fact that the BFS visits all nodes at distance before visiting any nodes at distance . In other words, all states of reachable from the states of in at most steps are visited (and marked) before any state at distance . The implementation of the BFS is, however, the key step to obtain the claimed complexity. Namely, the classical BFS of Cormen et al. (2009) maintains an array to store the shortest distances (aka the number of hops) of every node to an initial node. Since storing a number less than or equal to requires bits, using the classical BFS requires the space of size to store the shortest distance of every state of to a state of , because has states.
For our purposes, we do not need to know the shortest distance of every state to a state of , but we rather need to keep track of the number of hops from the states of made so far.
We can achieve this by modifying the classical BFS so that we do not store the shortest distances for every state of , but only the current distance. We store the current distance in the queue used by the BFS, see Algorithm 3. In particular, we first push number 0 to the queue, followed by all the states of . Assuming that , number 0 is processed in such a way that it is dequeued from the queue, and number 1 is enqueued. After processing all the states of from the queue, that is, having number 1 at the head of the queue, we know that all the elements of the queue after number 1 are the states at distance one from the states of and not less. The algorithm proceeds this way until it has either visited all the states of or the number stored in the queue is . The algorithm marks all states of that it visits.
This approach requires to store only one -bit number at a time rather than such numbers, and hence the complexity of the algorithm then basically follows from the fact that the distance is bounded by the number of states of , and not by the parameter .
Since Algorithm 3 is a minor modification of the BFS of Cormen et al. (2009), very similar arguments show its correctness and complexity. For this reason, we do not further discuss the correctness and complexity of Algorithm 3.
The Breadth-First Search used in Algorithm 3
Before we prove Theorem 2 below showing that is weakly -step opaque if and only if no state of the form is marked in , we illustrate Algorithm 3 in the following two examples.
In the first example, we consider one-step opacity of the DES depicted in Figure 1(a) where all events are observable, state is secret, and state is nonsecret. The other states are neutral, meaning that they are neither secret nor nonsecret.111The meaning of neutral states is not yet clear in the literature. They are fundamental in language-based opacity, but questionable in state-based opacity. In any case, we cannot simply handle neutral states as nonsecret states. The observer of is depicted in Figure 1(b).


Since has no unobservable events, the projected automaton . Now, only the state of contains a secret state, and hence intersecting it with results in the set . Notice that state is not in the observer , and therefore we need to add it to together with all the states that are reachable from state in the full observer of . The resulting automaton is depicted in Figure 1(b) and is formed by the observer together with the dashed state and the dashed transition from to . Notice that, by the definition of the (full) observer, all the missing transitions in Figure 1(b) indeed lead to state , for instance, . However, to keep the figures simple, we do not depict state and the transitions to state . The marked part of the automaton reachable from the states of in at most one step is depicted in Figure 2. Since state is marked in , is not one-step opaque; indeed, observing the string , the intruder reveals that must have been in the secret state one step ago.

To illustrate an affirmative case, we again consider the DES , but this time we assume that the event is unobservable. We denote by the DES where events are observable, the event is unobservable, state is secret, and state is nonsecret. The projected automaton and the observer are depicted in Figure 3. The only state of containing a secret state is the state , which results in the set . Again, state is not in , and hence we construct the relevant part of the full observer of by extending by state and all the reachable states from it. The result (without state and the transitions to state ) is depicted in Figure 3(b), both the solid and the dashed part. The marked part of is depicted in Figure 4. Since no state of the form is marked in , is one-step opaque.



We now prove the correctness of our algorithm.
Theorem 2.
A DES is weakly -step opaque with respect to , , and if and only if Algorithm 3 returns true.
Proof 3.1.
If is not weakly -step opaque, then there is such that , , and . We have two cases.
(i) If , then is not weakly -step opaque. Algorithm 3 detects this case, because for the state of the observer of , we have that and , and hence there is resulting in adding the pair to the set in line 8.
(ii) If , then all pairs of the form are added to . Since , there is a pair such that generating the string in the automaton from state changes the state to a state . On the other hand, implies that generating in the full observer of from state changes the state to state , and hence the pair is reachable in from the state in at most steps. In both cases, Algorithm 3 marks , and returns false.
On the other hand, if is weakly -step opaque, we show that no pair of the form is reachable in from a state of in at most steps. For the sake of contradiction, we assume that a pair is marked in . However, this means that, in , there is a string and a state such that , the state of the observer of reached under the string is , and, for , the pair is reachable in from the pair by a string of length at most . In particular, there is a string such that when generates , it changes its state from to . Therefore, . However, , because generating in changes the pair to , and hence the full observer of changes its state from to when generating . This shows that is not weakly -step opaque, which is a contradiction.
We now discuss the complexity of our algorithm.
Theorem 3.
The space and time complexity of Algorithm 3 is and , respectively, where is the number of states of the input DES and is the number of transitions of . In particular, , where is the number of observable events.
Proof 3.2.
Computing the observer and the projected NFA of , lines 4 and 5, takes time and , respectively. The cycle on lines 6–10 takes time . Constructing the part of the full observer of , line 11, takes time . Constructing , line 12, takes time , where is the number of states and is the number of transitions of . The bounds come from the fact that we create at most copies of the automaton . The BFS takes time linear in the size of , and the condition of line 13 can be processed during the BFS. Since , the proof is complete.
We now briefly review the complexity of existing algorithms verifying weak -step opacity. First, notice that the complexity of existing algorithms is exponential, which seems unavoidable because the problem is PSpace-complete, see Balun and Masopust (2021, 2022a) for more details.222It is a long-standing open problem of computer science whether PSpace-complete problems can be solved in polynomial time. In particular, Saboori and Hadjicostis (2011) designed an algorithm with complexity , where is the number of states and is the number of observable events. Considering the verification of weak -step opacity, Saboori and Hadjicostis (2012) designed an algorithm with complexity . Yin and Lafortune (2017) introduced the notion of a two-way observer and applied it to the verification of weak -step opacity with complexity , and to the verification of weak -step opacity with complexity ; the formulae already include a correction by Lan et al. (2020). Balun and Masopust (2021) designed algorithms verifying weak -step opacity and weak -step opacity with complexities and , respectively, where is the number of transitions in the projected automaton. These algorithms outperform the two-way observer if is polynomial in or larger than , since weak -step opacity and weak -step opacity coincide, see Yin and Lafortune (2017). Wintenberg et al. (2022) discussed and experimentally compared four approaches to the verification of weak -step opacity based on (i) the secret observer, (ii) the reverse comparison, (iii) the state estimator, and (iv) the two-way observer. Their respective state complexities are , , , and .333The state complexity of the two-way observer is correct. The correction of Lan et al. (2020) consists in adding a time bound to compute the intersection of two sets, and hence it does not influence the number of states.
Notice that these bounds are formulated only in the number of states of the constructed automata, disregarding the number of transitions and the time of the construction. Therefore, the time-complexity bounds differ from the state-complexity bounds at least by the factor of , if the constructed automata are deterministic, or by a factor of if the construction of the automaton involves an NFA, such as in the case of the reverse comparison. Namely, the time-complexity bounds are for the secret observer, where is the number of states and is the number of observable events, for the reverse comparison, where is the number of transitions in an involved NFA, for the state estimator, and for the two-way observer.
As the reader may notice, the above complexities depend on the parameter . A partial exception is the two-way observer that does not depend on if , that is, if is larger than the number of states divided by the logarithm of the number of observable events.
Since the complexity of Algorithm 3 is , where is the number of states of the input DES and is the number of transitions of the projected automaton of , it does not depend on the parameter and, in general, outperforms the existing algorithms. An exception is the case of a very small parameter . In particular, if , the algorithms based on the state estimator and on the two-way observer are, in the worst-case, faster than our algorithm. Notice that this theoretical result agrees with the experimental results of Wintenberg et al. (2022).
4 Verification of Strong k-Step Opacity
Although weak -step opacity seems confidential enough, Falcone and Marchand (2015) have pointed out that it is actually not as confidential as intuitively expected. Namely, the intruder may realize that the system previously was in a secret state, though it is not able to deduce the exact time when that happened, see Falcone and Marchand (2015) for more details and examples. Consequently, they defined strong -step opacity as a variation of -step opacity with a higher level of confidentiality.
Before we recall the definition of strong -step opacity as formulated by Falcone and Marchand (2015), we illustrate the problem with weak -step opacity. To this end, we consider the system depicted in Figure 5, where state is secret and the other states are nonsecret, and where the event is observable and the event is unobservable. Observing the string , the intruder realizes that the system must have been in the secret state , though it cannot say whether it was one or two steps ago. Actually, even observing the string already reveals that the system currently is or one step ago was in the secret state .

In accordance with Falcone and Marchand (2015), we consider strong -step opacity only for deterministic DES where all states that are not secret are nonsecret, that is, . It means that every state has its own secret/nonsecret status and there are no neutral states.
Definition 4.
Given a deterministic DES and . System is strongly -step opaque (-SSO) with respect to the set of secret states and observation if for every string , there exists a string such that and for every prefix of , if , then .
Notice that whereas weak -step opacity prevents the intruder from revealing the exact time when the system was in a secret state during the last observable steps, strong -step opacity prevents the intruder from revealing that the system was in a secret state during the last observable steps.
For an illustration, we again consider the system depicted in Figure 5, where state is secret and event is unobservable. The system is weakly one-step opaque, but not strongly one-step opaque, because for , the only with the same observation as is , and hence the prefixes for which are the strings , , and . However, for , we obtain that , which violates the definition of strong one-step opacity.
In fact, the system is neither strongly 0-step opaque, because for , the only with the same observation as are the strings and , and therefore the prefixes for which is either or . However, for , we obtain that , which violates the definition of strong -step opacity. On the other hand, the system is obviously current-state opaque. Consequently, the notions of strong 0-step opacity and current-state opacity444Current-state opacity is a synonym for weak 0-step opacity. do not coincide.
We show in Theorem 8 below that unobservable transitions from secret states to nonsecret states, as in our example, are the only issues making the difference between strong 0-step opacity and weak 0-step (current-state) opacity. To this end, we define the notion of a normal DES.
4.1 Normalization
In what follows, we call the systems where there are no unobservable transitions from secret states to nonsecret states normal. For systems that are not normal, we provide a construction to normalize them, that is, we eliminate unobservable transitions from secret states to nonsecret states without affecting the property of being strongly -step opaque.
Construction 5.
Let be a deterministic DES, , be the set of secret states, and be the observations. We construct
where for being a disjoint copy of , and the transition function is defined as follows. We initialize and further modify it in the following four steps:
-
1.
For every , , and , we replace the transition by in .
-
2.
For every unobservable transition in , that is, , we add the transition to .
-
3.
For every observable transition in , that is, , we add the transition to .
-
4.
We remove unreachable states and corresponding transitions.
The set of secret states of is the set .
In the sequel, we call the normalization of . If and coincide, we say that is normal.
To illustrate Construction 5, consider the system depicted in Figure 6 (left). Its normalization is depicted in the same figure (right). States and of are secret, events and are observable, and is unobservable. The normalization of initially contains five new secret states , , , , . Step (1) of Construction 5 replaces transitions and by and , respectively, step (2) adds four unobservable transitions , , , and , and step (3) adds the observable transitions , , and . Finally, step (4) eliminates unreachable states , , , and the corresponding transitions.

The following lemma compares the behaviors of and its normalization .
Lemma 6.
Let be a deterministic DES, and let be the set of secret states. Let be the normalization of obtained by Construction 5. Then, for every and , the following holds:
-
1.
For , if and only if , where is a copy of ;
-
2.
For , ;
-
3.
.
Proof 4.1.
We prove (1) and (2) by induction on the length of . The induction hypothesis is that either , or and .
To prove (1), let be unobservable. We first consider the case . First, if is nonsecret, Construction 5 adds every transition to . On the other hand, if is secret, contains the transition for every transition with , and the transition for every transition with . In both cases, Construction 5 adds no other transition from state to , and hence if and only if . Notice that this case also covers the base case of the induction, since for , .
Now, we consider the case and . Since Construction 5 adds the transition to for every unobservable transition , we have that if and only if .
To prove (2), let be observable. We first consider the case . Then, from the state , Construction 5 adds to all and only the observable transitions of , and hence .
Now, we consider the case and . Then, Construction 5 adds the transition to for every observable transition , and therefore .
Finally, of (3) follows from (1) and (2), since, for every , is undefined if and only if is undefined.
The following lemma describes the meaning of normalization and states the main properties of a normalized DES.
Lemma 7.
For a deterministic DES , , the set of secret states , and the observation , let be the normalization of obtained by Construction 5. Then, the following holds true:
-
1.
is deterministic;
-
2.
In , there is no nonsecret state reachable from a secret state by a sequence of unobservable events, that is, ;
-
3.
is -SSO with respect to and if and only if is -SSO with respect to and .
Proof 4.2.
To prove , we analyze the steps of Construction 5 creating . First, is defined as , which is deterministic. Then, step (1) replaces some unobservable transitions, which is an operation that preserves determinism of . Step (2) adds the transition for every unobservable transition in . Similarly, step (3) adds the transition for every observable transition in . Since is deterministic, steps (2) and (3) preserve determinism. Altogether, is deterministic.
To prove , step (1) of Construction 5 replaces all unobservable transitions from a secret state to a nonsecret state by transitions from a secret state to a new secret state. Step (2) adds unobservable transitions only between the new states, which are all secret. Since no unobservable transition is defined from the new states to the old states, there is no nonsecret state in reachable from a secret state by a sequence of unobservable events.
To prove the first direction of , we assume that is -SSO with respect to and , and show that then is -SSO with respect to and . To this end, we show that for every string , there exists a string such that and, for every prefix of , if , then . Thus, let be an arbitrary string. Then, by Lemma 6, , and since is -SSO with respect to and , there is a string such that and, for every prefix of , if , then . By defining , we obtain that the string and that . It remains to show that for every prefix of , if , then . To this end, let be the decomposition of , where is the shortest prefix of such that . Then, is either empty or ends with an observable event. Hence, by Lemma 6, in . However, for every prefix of , the string is a prefix of satisfying , and hence . In other words, the computation of in does not go through a secret state, and therefore the same sequence of transitions exists in , that is, . Since every prefix of satisfying is of the form , where is a prefix of , we have shown that , which was to be shown.
To prove the other direction, we assume that is not -SSO with respect to and , and show that neither the is -SSO with respect to and . To this end, let be a string violating -SSO in ; that is, for every such that , there exists a prefix of such that and . However, by Lemma 6, and . Since both states are secret in , we conclude that is not -SSO with respect to and .
4.2 Weak versus Strong 0-Step Opacity
In this section, we discuss the relationship between strong -step opacity and weak -step (current-state) opacity for normal deterministic DES. The following result characterizes the relationship between these two notions and fixes the claim of Ma et al. (2021) stating that strong 0-step opacity reduces to current-state opacity, which is not the case as shown in the example of Figure 5.
Theorem 8.
A normal deterministic DES is strongly -step opaque with respect to and if and only if is weakly -step opaque with respect to , , and .
Proof 4.3.
We first assume that is -SSO with respect to and . To show that is -SO with respect to and , let be such that and . Since and is deterministic, is defined. Therefore, we need to show that there is a string such that , , and . However, since is -SSO with respect to and , there is a string such that and, for every prefix of with , . Let be any, but fixed, such prefix of . We set and . Then, , , and . Thus, we have shown that is -SO with respect to and .555Notice that the proof does not hold if we admit neutral states, that is, . However, it is not the case in this paper.
For the other direction, we assume that is not -SSO with respect to and . To show that is neither -SO with respect to and , we need to find a string with and such that, for every string with and , the state . However, from the assumption that is not -SSO with respect to and , we have a string such that , , and, for every string with , there is a prefix of such that and . To complete the proof, we show that for every with and , the state is secret. To this end, let be the decomposition of such that is the longest suffix of consisting only of unobservable events. Notice that is a prefix of , because . Since , there must be a prefix of such that and . However, the last event of is observable, and hence the only prefix of for which is , and therefore . Since is normal, there are no nonsecret states reachable from the secret state under a sequence of unobservable events. In particular, , where is a prefix of for which ; recall that is the longest suffix of consisting only of unobservable events. Thus, we have shown that is not -SO.
4.3 Weak versus Strong k-Step Opacity
In this section, we show how to reduce strong -step opacity to weak -step opacity. In the construction, we assume that is a normal deterministic DES. By Lemma 7, this assumption is without loss of generality, because if is not normal, then we can consider instead.
Construction 9.
Let be a normal deterministic DES, be the observation projection, and be the set of secret states. We construct
as a disjoint union of and , where is obtained from by removing all secret states and corresponding transitions, and is a copy of disjoint from . We use a new unobservable event to connect to so that we initialize and extend by additional transitions for every , cf. Figure 7 for an illustration. The states of are the only nonsecret states of , that is, the set of secret states of is the set . Finally, we define the projection .

The following theorem describes the relationship between strong -step opacity and weak -step opacity, and justifies the correctness of Algorithm 4.4 below.
Theorem 10.
Proof 4.4.
For the first implication, we assume that is -SSO with respect to and , and we show that is -SO with respect to , , and . To this end, let be such that and . We need to show that there is a string such that , , and .
Let denote the projection that removes every occurrence of event , that is, for , and . We first show that . Indeed, if does not contain , then . If contains , then, by the construction of , any string of contains at most one occurrence of . Since , we have that occurs in . Let . Then, there are states in such that , , and . However, by the construction, this means that and in , and hence .
Since is -SSO with respect to and , there exists a string such that and, for every prefix of , if , then . Since , we define to be a (fixed) decomposition of such that and . Then, , which implies that for some state that is not secret in . Therefore, the transition , and hence . Since the state for every prefix of , because is a prefix of with , the computation of in does not go through a secret state. Therefore, the same sequence of transitions is enabled in from state . Setting now and implies that , , , and is defined, which proves that is weakly -step opaque.
To prove the other direction, we assume that is not -SSO with respect to and , and we show that is not -SO with respect to , , and . To this end, we need to show that there is a string such that , , and for every such that and , the state .
However, since is not -SSO with respect to and , there exists a string such that, for every string with , there is a prefix of such that and . In particular, there is a prefix of such that and .
Let be the decomposition of such that is the longest suffix of containing at most observable events. We set and , for which we have that , is defined, and, since neither nor contains the event , the state . It remains to show that for every string with and , the state . We distinguish two cases.
In the first case, we assume that , and we consider any string such that and . If does not contain the event , then , and therefore . If, on the other hand, contains the event , then where neither nor contains the event . But then , where is a copy of . Since , the state , and hence by construction. In both cases, , which was to be shown.
In the second case, let , and consider any string with and . Using the projection removing the event , we set . Recall that the string does not contain the event , that is, , and therefore . Since is not -SSO with respect to and , there is a prefix of such that and . In particular, by the choice of , we have that . Furthermore, is normal, and hence there is no nonsecret state reachable from the secret state by a sequence of unobservable events.
In particular, the prefix of the string satisfies , where the last equality comes from the fact that does not contain the event . Then , and hence if , then . Thus, assume that . Then, the string is a strict prefix of ; otherwise, if was a strict prefix of , then we would have that , which, together with , would give that , and hence the nonsecret state would be reachable from the secret state by a sequence of unobservable events, which is a contradiction with the normality of . Consequently, generating the string from the state , must go through the secret state . In other words, is reachable from the state by a prefix of .
Thus, in , state , where . If , we are done. If , we show that is undefined, which contradicts the assumption that , and hence cannot happen. Indeed, if , then . Since the computation of in goes through the secret state , the computation of in has to go through the state , which is the primed copy of the state . But the computation is performed in the automaton , which is obtained from by removing all secret states and corresponding transitions. Since is a copy of a secret state, it does not exist in , and hence it does not belong to . Therefore, is undefined.
We have thus shown that is not -step opaque.
Both Construction 5 and Construction 9 are polynomial and preserve the number of observable events. Therefore, Theorem 10 and the existing results (Balun and Masopust, 2021, Table 1) immediately imply the following result.
Theorem 11.
Deciding whether a given deterministic DES is strongly -step opaque is (i) coNP-complete if has only a single observable event, and (ii) PSpace-complete if has at least two observable events. ∎
The motivation to consider the case of a single observable event comes from the timed discrete-event systems framework of Brandin and Wonham (1994), where the only observable event is the tick of the global clock.
4.4 Verifying Strong k-Step Opacity
Theorem 10 gives us a clue how to verify strong -step opacity of a given deterministic DES with the help of the verification algorithm for weak -step opacity from Section 3. This idea is formulated as Algorithm 4.4. Before analyzing the complexity of Algorithm 4.4 and comparing it with the existing algorithms, we illustrate it by two examples.
Verification of strong -step opacity

As the first example, we adopt the DES from Falcone and Marchand (2015) depicted in Figure 8 (left), where events , , are observable, event is unobservable, and states and are secret. Falcone and Marchand (2015) claimed that is strongly one-step opaque. However, it is not the case, as we show by using our transformation to weak -step opacity.
Since is normal, Algorithm 4.4 proceeds directly to the application of Construction 9, which results in the DES depicted in Figure 8 (right). Namely, was constructed from by adding six new nonsecret states and one new unobservable event , and by making states through secret, that is, and . Applying Algorithm 3 to , , , , and results in the observer of and the automaton depicted in Figure 9.

The set and the part of reachable from the states of in one step are depicted in Figure 10. Since, e.g., state is reachable in in one step from the state , is not weakly one-step opaque. By Theorem 10, is not strongly one-step opaque. Indeed, observing the string in , the intruder reveals that is either in the secret state at that time instant or must have been in the secret state one step ago.

As the second example, we consider the DES obtained from by replacing the transitions and by the transitions and , respectively, see Figure 11.

Then, Construction 9 results in the DES with and . Applying Algorithm 3 to , , , , and results in the observer of and the automaton depicted in Figure 12. The set and the part of reachable from the states of in one step are depicted in Figure 13. Since no state of the form is reachable from a state of in one step, is weakly one-step opaque. By Theorem 10, is strongly one-step opaque.


4.5 Complexity Analysis of Algorithm 4.4
Algorithms verifying strong -step opacity have been investigated in the literature. In particular, Falcone and Marchand (2015) designed an algorithm based on a -delay trajectory estimation, but they did not analyze its complexity. The complexity analyses in the literature are inconsistent. While Ma et al. (2021) state that the complexity is , where is the number of states and is the number of observable events of the verified deterministic DES, Wintenberg et al. (2022) state that the state complexity is . According to (Falcone and Marchand, 2015, Definition 7), however, the -delay trajectory estimator has states.
Recently, Ma et al. (2021) designed another algorithm with complexity , and even more recently, Wintenberg et al. (2022) discussed and experimentally compared algorithms based on (i) the secret observer with complexity , on (ii) the reverse comparison with complexity , where is the number of transitions in the involved projected NFA, and on (iii) the construction of the -delay trajectory estimator of Falcone and Marchand (2015), which they claim to be of complexity .
We now analyze the complexity of Algorithm 4.4 and show that its worst-case complexity is better than the complexity of existing algorithms. Namely, we show that the space and time complexity of Algorithm 4.4 is and , respectively, where is the number of states of and is the number of transitions of . Notice that the complexity does not depend on the parameter .
Before we prove this result, notice that , where is the number of observable events. Since is the maximum number of transitions in an -state NFA with events, is often significantly smaller than .
For a deterministic DES with states, Construction 5 results in a normalized DES with up to states, and hence it may seem that the observer of the normalized DES could have up to states. The following lemma shows that the observer of the normalized DES has in fact at most states.
Lemma 12.
Let be an -state deterministic DES, and let be its normalization obtained by Construction 5. Then, the observer of has at most states.
Proof 4.5.
Let be a deterministic DES with states, and let be the set of unobservable events. The application of Construction 5 on results in the deterministic DES , where and is a disjoint copy of . All states of are reachable in by construction. The observer of is defined as follows. The set of states is the subset of the power set of , namely, . The initial state is the unobservable reach (UR) of the initial state of the automaton , that is, . The transition function is defined for every and every observable event as the unobservable reach of the states reachable in from the states of by the event , that is,
where, for every , . By item (2) of Lemma 6,
and hence every state of the observer of is uniquely determined by a subset of . In particular, we define an injective mapping assigning subsets of to the states of the observer of as follows: , and for every state of the observer of , we pick and fix a state such that , for some observable event , and we define . Such a state exists because every state of the observer is reachable. Then, , and we have that if , then , which shows that the mapping is injective. Consequently, the number of states of the observer of is bounded by the number of subsets of the set , which is .
Notice that Lemma 12 does not claim that the number of states of the observer of and of the observer of its normalization coincide. It only provides an upper bound on the worst-case complexity.
Similarly, for a normal deterministic DES with states, Construction 9 results in a deterministic DES with up to states. The second lemma shows that the observer of has as many states as the observer of .
Lemma 13.
Let be a normal deterministic DES with states, and let be obtained from by Construction 9. Then, the numbers of states of the observer of and of the observer of coincide.
Proof 4.6.
Let be a normal deterministic DES, and let be the DES obtained from by Construction 9. Recall that is obtained as a disjoint union of and , where is a copy of without the secret states and the corresponding transitions, is a copy of disjoint from , and the event is unobservable. For every reachable state of the observer of , we show that contains a state if and only if contains the corresponding state . Consequently, the observer of and the observer of have the same number of states.
To prove one direction, let be a reachable state of the observer of . If contains a state , then the unobservable transition of implies that also contains the state .
To prove the other direction, let be a reachable state of the observer of , and assume that a state belongs to . Then, for every string under which the state is reachable from the initial state in the observer of , there exists a string such that and . Since , , and every string of contains at most one occurrence of the event , we can partition the string so that , , and , for some state . However, is executed in , which is obtained from by removing all secret states. Therefore, must be defined in . Altogether, we have shown that is defined in , and hence the string . Since , we have shown that .
We can now prove the following result analyzing the complexity of Algorithm 4.4.
Theorem 14.
The space and time complexity of Algorithm 4.4 is and , respectively, where is the number of states of and is the number of transitions of , that is, , where is the number of observable events.
Proof 4.7.
Let be an -state deterministic DES. In the first step, we construct the normalization of with at most states, the observer of which has at most states by Lemma 12. Then, we apply Algorithm 3 to obtained from by Construction 9. In particular, by Lemma 13, we compute the observer of with at most states, and the projected automaton with at most states. Then, for every reachable state of , and for every , we add the pair to the set . This computation takes time . Afterwards, we construct the automaton as the part of the full observer of that is accessible from the states of the second components of . Since consists only of the subsets of , of which there is at most , the automaton has states. The automaton thus has states and transitions, the sum of which is the time complexity of the BFS applied to mark states of reachable from the states of in at most steps. Therefore, the state complexity of Algorithm 4.4 is and the time complexity is .
Comparing the complexity of Algorithm 4.4 with the complexity of the existing algorithms, the reader may see that (1) the complexity of Algorithm 4.4 does not depend on the parameter , and (2) it is better than the complexity of the existing algorithms, because the minimum of the worst-case complexities , , , and of the existing algorithms discussed at the beginning of this subsection is for , and for . Notice that the minimum worst-case complexity for large is significantly higher than the complexity of Algorithm 4.4. In fact, the complexity of Algorithm 4.4, and the minimum worst-case complexity of the existing algorithms for very small , coincide. However, while the existing algorithms can handle only inputs with a very small with this complexity, our algorithm can handle inputs with of arbitrary value with this complexity. Consequently, our algorithm improves the complexity of the verification of strong -step opacity.
5 Conclusions
We investigated and discussed the relationship between the notions of weak and strong -step opacity. We designed an algorithm verifying weak -step opacity that, compared with the existing algorithms, does not depend on the parameter , and has a lower worst-case complexity than the existing algorithms. We further discussed strong -step opacity and transformed it to weak -step opacity in linear time, obtaining thus an algorithm to verify strong -step opacity. Again, this algorithm does not depend on the parameter , and has a lower worst-case complexity than the existing algorithms.
Finally, we point out that the complexity of our algorithms may be further optimized. For instance, rather than eliminating -transitions in , we may suitably redefine the product of two NFAs for NFAs with -transitions. In this case, the parameter in the complexity formula would be bounded by rather than . We leave these and further optimizations for the future work.
We gratefully acknowledge suggestions and comments of the anonymous referees.
Appendix A Relation between Strong and Weak -Step Opacity
As already mentioned in the introduction, Ma et al. (2021) pointed out that strong -step opacity and weak -step opacity are incomparable in the sense that neither strong -step opacity implies weak -step opacity nor the other way round.
We now show that under the assumption that the set of states is partitioned into secret and nonsecret states, disregarding neutral states, which is a common assumption in the literature (Saboori and Hadjicostis, 2011; Yin and Lafortune, 2017), including this paper, the two notions are comparable. This fact was also recently pointed out by Wintenberg et al. (2022).
Theorem 15.
Let be a deterministic DES, and let . If is -SSO with respect to and , then is -SO with respect to , , and .
Proof A.1.
Assume that is -SSO with respect to and . We show that is -SO with respect to , , and . To this end, we consider any string with such that ; since , we have is defined. Since is -SSO, there is a string such that and for every prefix of , if , then . Because , the string can be written as , where and . Since is a prefix of , and , we have , that is, . But then the string is such that , , , and is defined, because ; therefore, is -SO with respect to , , and .
It can be seen in the previous proof that if there are neutral states, then the implication does not hold in general.
References
- Badouel et al. (2007) Badouel, E., Bednarczyk, M., Borzyszkowski, A., Caillaud, B., Darondeau, P., 2007. Concurrent secrets. Discrete Event Dynamic Systems 17, 425–446.
- Balun and Masopust (2021) Balun, J., Masopust, T., 2021. Comparing the notions of opacity for discrete-event systems. Discrete Event Dynamic Systems 31, 553–582.
- Balun and Masopust (2022a) Balun, J., Masopust, T., 2022a. On transformations among opacity notions, in: IEEE International Conference on Systems, Man, and Cybernetics (SMC), pp. 3012–3017.
- Balun and Masopust (2022b) Balun, J., Masopust, T., 2022b. On verification of weak and strong k-step opacity for discrete-event systems. IFAC PapersOnLine 55, 108–113.
- Brandin and Wonham (1994) Brandin, B., Wonham, W., 1994. Supervisory control of timed discrete-event systems. IEEE Transactions on Automatic Control 39, 329–342.
- Bryans et al. (2008) Bryans, J.W., Koutny, M., Mazaré, L., Ryan, P.Y.A., 2008. Opacity generalised to transition systems. International Journal of Information Security 7, 421–435.
- Bryans et al. (2005) Bryans, J.W., Koutny, M., Ryan, P.Y., 2005. Modelling opacity using Petri nets. Electronic Notes in Theoretical Computer Science 121, 101–115.
- Cassandras and Lafortune (2021) Cassandras, C.G., Lafortune, S. (Eds.), 2021. Introduction to Discrete Event Systems. 3rd ed., Springer.
- Cormen et al. (2009) Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C., 2009. Introduction to Algorithms. MIT Press.
- Dubreil et al. (2008) Dubreil, J., Darondeau, P., Marchand, H., 2008. Opacity enforcing control synthesis, in: Workshop on Discrete Event Systems (WODES), pp. 28–35.
- Falcone and Marchand (2015) Falcone, Y., Marchand, H., 2015. Enforcement and validation (at runtime) of various notions of opacity. Discrete Event Dynamic Systems 25, 531–570.
- Hopcroft et al. (2006) Hopcroft, J.E., Motwani, R., Ullman, J.D., 2006. Introduction to Automata Theory, Languages, and Computation. Addison-Wesley.
- Jacob et al. (2016) Jacob, R., Lesage, J.J., Faure, J.M., 2016. Overview of discrete event systems opacity: Models, validation, and quantification. Annual Reviews in Control 41, 135–146.
- Jirásková and Masopust (2012) Jirásková, G., Masopust, T., 2012. On a structural property in the state complexity of projected regular languages. Theoretical Computer Science 449, 93–105.
- Lan et al. (2020) Lan, H., Tong, Y., Guo, J., Giua, A., 2020. Comments on “A new approach for the verification of infinite-step and K-step opacity using two-way observers” [Automatica 80 (2017) 162–171]. Automatica 122, 109290.
- Lin (2011) Lin, F., 2011. Opacity of discrete event systems and its applications. Automatica 47, 496–503.
- Ma et al. (2021) Ma, Z., Yin, X., Li, Z., 2021. Verification and enforcement of strong infinite- and k-step opacity using state recognizers. Automatica 133, 109838.
- Saboori and Hadjicostis (2007) Saboori, A., Hadjicostis, C.N., 2007. Notions of security and opacity in discrete event systems, in: IEEE Conference on Decision and Control, pp. 5056–5061.
- Saboori and Hadjicostis (2011) Saboori, A., Hadjicostis, C.N., 2011. Verification of -step opacity and analysis of its complexity. IEEE Transactions on Automation Science and Engineering 8, 549–559.
- Saboori and Hadjicostis (2012) Saboori, A., Hadjicostis, C.N., 2012. Verification of infinite-step opacity and complexity considerations. IEEE Transactions on Automatic Control 57, 1265–1269.
- Wintenberg et al. (2022) Wintenberg, A., Blischke, M., Lafortune, S., Ozay, N., 2022. A general language-based framework for specifying and verifying notions of opacity. Discrete Event Dynamic Systems 32, 253–289.
- Wong (1998) Wong, K., 1998. On the complexity of projections of discrete-event systems, in: Workshop on Discrete Event Systems (WODES), pp. 201–206.
- Yin and Lafortune (2017) Yin, X., Lafortune, S., 2017. A new approach for the verification of infinite-step and K-step opacity using two-way observers. Automatica 80, 162–171.