# Optimal Opacity-Enforcing Supervisory Control of Discrete Event Systems on Choosing Cost
## 5 Scenario 1: Secret \(K\) Is Opaque with Respect to \(L(G)\) and \(\Sigma_{a}\)
### Case 1: \(\overline{K}=L(G)\)
As shown in Line 1 of Algorithm 3, it is obvious that language \(L\) contains all the non-secrets in \(L(G)\), which cannot be distinguished from all the secrets of \(\underline{K}\). So, if we want to make \(V(L(f/G)-\overline{K})\) minimal, all the strings \(s\) in \(L(f/G)-\overline{K}\) must come from \(L\). And then \(L(f/G)-\overline{K}\subseteq L\) holds. According to Lines 3-11 of Algorithm 3, we have \(L=\cup_{j}H_{j}\). And all the strings in \(H_{j}\) can confuse one secret of \(\underline{K}\) and its equivalent secret. Only one string is chosen in each set, \(H_{j}\) of \(H\), which is the necessary condition to minimize \(V(L(f/G)-\overline{K})\). At Line 13 of Algorithm 3 (i.e., function 1 of Algorithm 4), all the strings \(s=s_{i}t\) in \(L\) are traversed and choosing cost \(V_{s_{i}}(t)\) after \(s_{i}\in\overline{K}\) can be obtained, where \(t=\sigma_{i+1}\cdots\sigma_{n}\) and \(s_{i}\sigma_{i+1}\
ot\in\overline{K}\). At Line 14 of Algorithm 3, a diagram with multi-stages is constructed in \(\cup_{j}H_{j}\cup\{t_{s}\}\cup\{t_{t}\}\), where initial node \(t_{s}\) and ending node \(t_{t}\) are virtual, \(H_{j}\) is the set of nodes in the \(j\)th stage. To only pick a string in each \(H_{j}\), we find a path from \(t_{s}\) to \(t_{t}\). And then, Algorithm 6 is proposed to optimize weight \(a_{s^{\prime}s}\) of transition from node \(s^{\prime}\) to node \(s\) between adjacent stages. For optimal weight, it is obvious that the discount total choosing cost of each node (i.e., string) of the path is equal to the total weight of the path (at Line 12 of Algorithm 5). At Lines 3-19 of Algorithm 5, the shortest path Label\({}_{s}\) and its minimal discount total choosing cost \(V_{\min}(s)\) of the \(j\)th stage can be obtained by Label\({}_{s^{\prime}}\) and \(V_{\min}(s^{\prime})\) of the \((j-1)\)th stage based on dynamical programming. As shown in the above analysis about Line 14 of Algorithm 3 (i.e., Function 2 in Algorithm 5), the first element Label\({}_{s^{\prime}}\) of the ordered pair (Label\({}_{s^{\prime}}\), \(V_{\min}(s^{\prime})\)) is the shorted path (i.e., the set of strings) with minimal discount total choosing cost from starting node \(t_{s}\) to current node \(s^{\prime}\), and the second \(V_{\min}(s^{\prime})\) is the discount total choosing cost of the path. When the current node is \(t_{t}\) (i.e., Line 20 of Algorithm 5), Label\({}_{t}\) is the shorted path from the initial to the ending node and \(V_{\min}(t_{t})\) is the minimal discount total choosing cost of the path (see Lines 21-25 of Algorithm 5). So, Label\({}_{t}\) is the subset of \(L\), whose discount total choosing cost is minimal and whose strings can confuse all the secrets of \(\underline{K}\). At Lines 16 and 17 of Algorithm 3, closed-loop behavior \(L(f/G)\) can be ensured to be controllable and closed by Corollary 2. The discount total choosing \(L(f/G)\) is minimal as shown in the above analysis. All in all, closed-loop behavior \(L(f/G)\) produced in Algorithm 3 is an optimal solution of Model (2). We consider finite transition system \(G=(Q,\Sigma,\delta,q_{0})\) and secret \(K=\{a,ab,aebg,aebgt\}\) shown in Figure 7, where \(\Sigma_{u}=\{f,t\}\) and \(K\) can be recognized by \(Q_{s}=\{3,6,13,16\}\). We suppose that the adversary has complete knowledge of the supervisor's control policy, and the observed set of events by the adversary is \(\Sigma_{a}=\{a,d,f,g,t\}\). It is verified that \(K\) is opaque with respect to \(L(G)\) and \(\Sigma_{a}\). But \(K\) is not opaque with respect to \(\overline{K}\) and \(\Sigma_{a}\), i.e., secret eabeg,aebgt cannot be confused by any non-secret of \(\overline{K}\). Case 3 of Scenario 1 is fulfilled and Assumption 1 is true. Next, we construct closed-loop behavior \(L(f/G)\) using Algorithm 3. Figure 7: System \(G\). For system \(G\) and secret \(K\), we obtain language \(\underline{K}=\{aebg,aebgt\}\), where the strings in \(\underline{K}\) cannot be confused by any strings of \(\overline{K}\).