Generation of Minimum Tree-Like Witnesses for Existential CTL

. An advantage of model checking is its ability to generate wit-nessesorcounterexamples.Approachesexisttogeneratesmallorminimum witnessesforsimpleunnestedformulas,butnoexistingmethodguarantees minimalityforgeneralnestedones.Here,wegiveadeﬁnitionofwitness size,useedge-valueddecisiondiagramstorecursivelycomputethemin-imumwitnesssizeforeachsubformula,anddescribeageneralapproach tobuildminimumtree-likewitnessesforexistentialCTL.Experimental resultsshowthatforsomemodels,ourapproachisabletogeneratemini-mumwitnesseswhilethetraditionalapproachisnot.


Introduction
Model checking is an automated technique to rigorously establish the correctness of a system by exploring its computation graph, explicitly or symbolically. Instead of merely answering "yes" or "no", model checkers may be able to return a witness or counterexample to verify satisfaction or violation of a specification. Since witnesses and counterexamples provide important debugging information and may be inspected by engineers, smaller ones are always preferable.
Computation Tree Logic (CTL) is widely used to express temporal properties due to its simple yet expressive semantics. Although much work has been published on witness or counterexample generation [8,11,14], to the best of our knowledge, no existing method guarantees their minimality for a general CTL formula with nested temporal quantifiers. Clarke et al. [7] showed that the general form of a counterexample to a universal CTL formula is tree-like; of course, for CTL, counterexample generation for a universal formula can be converted to witness generation for an existential formula, thus we choose to limit our discussion to witness generation for the existential fragment of CTL. The use of backward exploration to verify EX, EF, and EU properties inherently guarantees minimality of their linear witnesses, while a minimum lasso-shaped EG witness can be generated by computing transitive closures, for example using the saturation algorithm [17]. However, these approaches do not extend to general tree-like witnesses, i.e., local minimality does not imply global minimality.
By recursively computing local fixpoints, the saturation algorithm [3] has clear advantages over traditional symbolic breadth-first approaches for statespace generation. It has also been applied to the computation of minimum EF [4] and EG [17] witnesses. Here, we extend these ideas into a global approach to build minimum witnesses for arbitrary existential CTL formulas.
Our paper is organized as follows. Section 2 summarizes background on CTL, decision diagrams, and symbolic CTL model checking. Section 3 defines the witness size and formalizes the computation of its minimum. Section 4 proposes saturation-based algorithms to symbolically encode minimum witness sizes for each existential temporal operator, needed to obtain an overall minimum witness size. Section 5 describes how to generate a witness from the computed witness size functions. Section 6 presents experimental results, Sect. 7 comments on our definition of witness size, and Sect. 8 concludes and outlines future work.

Kripke Structures, CTL, and Witnesses
A Kripke structure is a tuple (S, S init , N , A, L), where S is the state space, S init ⊆ S are the initial states, N : S → 2 S is the next-state function, A is a set of atomic propositions, and L : S → 2 A is a labeling that gives the atomic propositions holding in each state (subject to true ∈ A holding in every state).
We assume S to be the product S 1 ×· · ·×S L of L finite state spaces, i.e., each global state i ∈ S is a tuple (i 1 , ..., i L ), where i k ∈ S k is the local state for the k th submodel. We also assume N to be disjunctively partitioned according to a set E of asynchronous events, i.e., N = e∈E N e and, for each e ∈ E, N e : S → 2 S . N e (i) contains the states that can be nondeterministically reached in one step when event e occurs in state i. Correspondingly, we let N −1 e denote the previousstate function, i.e., N −1 e (j) = {i : j ∈ N e (i)}, the set of states that can reach j in one step through the occurrence of event e, and we let N −1 = e∈E N −1 e . Let P(i) be the set of paths starting at i ∈ S, i.e., finite sequences (i 0 , i 1 , ..., i n ) for n ≥ 0, or infinite sequences (i 0 , i 1 , ...), where i 0 = i and i m ∈ N (i m−1 ) for all applicable m. Let C(i) ⊆ P(i) be the set of cycles starting at i, i.e., finite paths (i 0 , i 1 , ..., i n ) with n > 0 and i 0 = i n = i.
We consider ECTL, the existential fragment of the temporal logic CTL [6], where formulas have syntax (φ and ρ are formulas, a is an atomic proposition): and the conditions for state i to satisfy formula φ, written i |= φ, are as follows: (formula EFφ is just a shorthand for EtrueUφ, so we do not discuss it separately).
Since the state space S is finite, all infinite paths contain a cycle. Thus, path (i 0 , i 1 , ...) demonstrating i |= EGφ must have a finite prefix (i 0 , ..., i m , ..., i n ), for some m ≥ 0 and n > m, where i m = i n , that is, it is a "lasso" formed by merging (on state i m ) a possibly empty "handle" (i 0 , ..., i m ) and a "cycle" (i m , ..., i n ).
We focus on witness generation, i.e., the computation of "tree-like" subgraphs demonstrating how a state satisfies an ECTL formula. This also serves to generate counterexamples for ACTL, the universal fragment of CTL, since a counterexample to AXφ, AGφ, or A[φUρ] is a witness to EX(¬φ), EF(¬φ), or E[¬ρU(¬φ ∧ ¬ρ)] ∨ EG(¬ρ), respectively (where the negation ¬ can be "pushed down" to atomic propositions), i.e., the negation of an ACTL formula is an ECTL formula.

Decision Diagrams
We encode sets and relations symbolically with (ordered) multiway decision diagrams (MDDs) [10]. An L-level MDD over S = S 1 ×· · ·×S L is an acyclic directed edge-labeled level graph with terminal nodes 0 and 1, at level 0, while each nonterminal node p is at some level p.lvl = k ∈ {1, ..., L}, and, for i k ∈ S k , has an outgoing edge labeled with i k and pointing to a child To encode relations over S, we use 2L-level MDDs over (S 1 ×S 1 )×· · ·×(S L ×S L ), where the first set in each pair corresponds to a "from", or "unprimed ", local state and the second set corresponds to a "to", or "primed ", local state.
We use instead (ordered) additive edge-valued MDDs, (EV + MDDs) [4] to encode partial integer-valued functions. An EV + MDD is an acyclic directed edgelabeled and edge-valued level graph with terminal node Ω, at level 0, while each nonterminal node p is at some level p.lvl = k ∈ {1, ..., L}, and, for i k ∈ S k , has an outgoing edge with label i k , pointing to a child p[i k ].c at a level p[i k ].c.lvl < k, For efficiency, we restrict ourselves to canonical forms of decision diagrams, where each function that can be encoded by a given class of decision diagrams has a unique representation in that class. All such forms forbid duplicate nodes: For ease of exposition, we only consider the quasi-reduced form in this paper, achieved by forbidding skipped levels: all roots (nodes without parent nodes) are at level L and, if p.lvl = k, then all p's children are at level k − 1. For EV + MDDs, in addition, we require normalized nodes: each nonterminal node must have at least one edge with value 0 and all edges with value ∞ must point to Ω. This means that the minimum value of the function encoded by any node is 0, but we can encode any partial function g : S → N ∞ with a "root edge" σ, p , where σ is the minimum value assumed by g, while p at level L satisfies f p = g − σ. However, our algorithms are actually implemented using the more efficient fully-identity-reduced form for 2L-level MDDs and EV + MDDs (indicated MDD2 and EV + MDD2 in our algorithms, respectively) [5]. This form allows us to exploit independence of events from local states: given e ∈ E, let Top(e) = k if e affects or depends on the k th local state but not the l th one, for any l > k. In the following, we then define N k = e:Top(e)=k N e .
Procedure Min in Fig. 1 shows the classic recursive manipulation of decision diagrams. Given functions f, g : S → N ∞ , let Min f,g : S → N ∞ be their elementwise minimum: for i ∈ S, Min f,g (i) = min{f (i), g(i)}. Given two EV + MDDs α, p and β, q encoding f and g, procedure Min returns the EV + MDD encoding Min f,g . As the EV + MDDs are quasi-reduced, p.lvl = q.lvl unless α = ∞ or β = ∞.
Procedure Normalize (line 8) normalizes a node u by subtracting the minimum edge value μ from all its edge values, so that at least one is 0, stores the normalized u in the unique table (if not already there), and returns μ, u .
Throughout this paper, procedures XxxGet (line 4) or XxxPut (line 10) are queries to or insertions into compute tables (or "caches"), commonly used in decision diagrams operations to avoid re-computation. The structure of the hash key and returned value may of course depend on the specific operation Xxx .

Symbolic CTL Algorithms
McMillan proposed symbolic CTL model checking based on binary decision diagrams (BDDs) [12]. Given the BDDs encoding the set of states satisfying φ and ρ, algorithms to compute the BDD encoding the set of states satisfying EXφ, EφUρ, and EGφ suffice, since all CTL formulas can be expressed using these three CTL operators, plus the standard logical operations of negation, conjunction, and disjunction. Using MDDs instead of BDDs is a relatively obvious extension.
Clarke et al. [8] proposed the first symbolic approach to CTL witness generation. Considering first unnested CTL formulas, a witness for EXa can be generated by one image computation, and is by definition minimum since all witnesses have size two. Using a symbolic breadth-first search, witness generation for EaUb also guarantees minimality, while minimality is more difficult to satisfy for EGa, where a witness is a path from an initial state to a cycle, such that all states along that path and on the cycle satisfy a. In other words, a state i satisfying EGa must have a successor also satisfying EGa; thus, we can incrementally build a path of states satisfying EGa, which must finally lead to a state already on the path, closing the cycle and resulting in a witness. A witness generation algorithm for (weakly fair) EG was proposed in [8] based on this idea. Since i might have multiple successors satisfying EGa, the algorithm is nondeterministic and the size of the witness depends on the state chosen at each step. While the algorithm uses a symbolic encoding, the approach is largely explicit, as it follows a single specific path. Decision diagrams help by efficiently encoding all states satisfying EG, but offer no help at all when deciding which of the states in N (i) satisfying EG should be chosen next, to continue the path from i.
Witness generation for arbitrarily nested CTL formulas is much harder. Of course, we cannot exhibit witnesses for universal formulas, only counterexamples, thus the presence of both existential and universal (non-negated) quantifiers in a CTL formula φ means that we can neither provide a witness (in case φ holds) nor a counterexample (in case φ does not hold). The most general approach to date is by Clarke et al. [7] for general (nested) ACTL formulas, which proposed algorithms to generate tree-like counterexamples, or witnesses for general (nested) ECTL formulas. However, their work did not address minimality.

Defining the Minimum Witness Size
We focus on the generation of minimum witnesses for general (nested) ECTL formulas. As discussed by Clarke et al. [7], these witnesses are finite tree-like Kripke structures and complete for ECTL. To discuss their size, we unfold these witnesses, i.e., the same state may appear multiple times and each appearance contributes to the count defining the size of the witness. For example, consider the (portion of a) Kripke structure shown in Fig. 2(a), satisfying formula E(EGa)Ub (state are identified by numbers and the atomic propositions holding in each state are listed close to it). An unfolded tree-like witness for this formula is shown in Fig. 2(b), where state 5's self-loop is repeated three times, once for each of the states 1, 2, and 3, since we need to show that each of them satisfies EGa (for clarity, a cycle is represented as a linear path along which the first and the last states are the same; dashed nodes represent the states closing cycles). Another way to think of this witness is that the first states of paths [ [1,5,5]], [ [2,5,5]], and [ [3,5,5]], each satisfying the inner formula φ = EGa, are "glued" onto the first three states of path [ [1,2,3,4]], satisfying the outermost formula Eφ Uφ , as is the first (and only) state of path [ [4]], satisfying the (atomic) inner formula φ = b. We write 5 for the last state of the EG witnesses to stress that state 5 does not need to have its witness repeated, since it is just closing the cycle. We define the size of a witness as the number of nodes in the resulting tree-like graph. Thus, a witness for a is path [ [1]], of size 1, a witness for EXa We recursively define function π φ : S → N ∞ describing the minimum witness size for an ECTL formula φ starting from a state i ∈ S as follows: where C(i) is the set of cycles starting at i, and χ φ (i) is the minimum witness size among cycles satisfying EGφ and starting at i. In the sum for χ φ (i), we exclude π φ (i 0 ) and add 1 because state i = i 0 = i n starting and ending the cycle appears twice, but we should not count the witness for i |= φ twice.

Computing the Minimum Witness Size
The first and most complex step to generate a minimum tree-like witness for an arbitrary ECTL formula φ * is to build: (1) for each subformula φ of φ * , starting from the innermost atomic propositions, an EV + MDD encoding the size π φ (i) of a minimum witness for φ starting from each state i, and (2) for each subformula EGφ of φ * , an EV + MDD2 encoding the size, T C φ (i, j), of a minimum witness for a path of states satisfying φ from each state i to each state j.
We present algorithms to compute the minimum witness size for EU and EG, while we omit the simpler ones for logical operators, EX, and atomic propositions.

Computing the Minimum Witness Size for EU Formulas
In [15], we introduced a "constrained" variant of saturation that restricts exploration to states satisfying a given property. Instead of applying "after-the-fact" intersections, this approach employs a "check-and-fire" policy, firing an event only when the next states to be obtained satisfy the given property, through an on-the-fly check. Now, we further extend this idea to take into account the sizes of subwitnesses demonstrating the satisfaction of subformulas. Fig. 3 is the top-level procedure to compute π EφUρ , given α ρ , p ρ encoding π ρ and β φ , q φ encoding π φ (both obtained by computing the minimum witness size function of subformulas). ConsSat computes a fixpoint for the subfunction encoded by α, p , under constraint β, q , w.r.t. events affecting variables up to p's level. ConsRelProdSat first recursively computes the β, q -constrained relational product of α, p and r (specifically, it serves as a constrained version of the pre-image operation since we use the previous-state function), then it saturates the resulting node to ensure that it reaches a local fixpoint.

EUSat in
When exploring the pre-image of state i, we compute, for each predecessor j ∈ N(i), the sum of π ρ (j) and the value currently associated to i (line 3 in ConsRelProdSat), and use it to reduce the value associated to j, if smaller (line 12 in ConsSat and line 8 in ConsRelProdSat). Upon reaching a fixpoint, we have the size of the minimum tree-like EφUρ witness for each state i (∞ if i |= EφUρ).
The hash-key for the cache entries of ConsSat and ConsRelProdSat consists of two nodes, p and q, plus the value β attached to the edge for q, representing the constraint. Storing the difference α − β, as done for Min, would be incorrect because saturation computes local fixpoints and thus may fire an event multiple times in one call, and α just serves as an offset to all the values in the final function, while, for each individual state, it does not affect whether the new value obtained from one firing is smaller than the currently associated value. In other words, if it is known that ConsSat( 0, p , β, q ) = γ, u , then we can conclude that ConsSat( α, p , β, q ) = α + γ, u , for any α > 0.

Computing the Minimum Witness Size for EG Formulas
A witness of EGp is a lasso-shaped infinite path consisting of a finite prefix leading to a cycle [1]. Thus, two steps are needed to compute a minimum treelike witness for EGφ: (1) identify all states in cycles of states satisfying φ, and their minimum witness size; (2) starting from these states, explore the model backward to find all states satisfying EGp, and their minimum witness size. This second step is essentially an EU computation, thus we focus on the first step.
Given a graph, the transitive closure (TC) describes the reachability between any pair of nodes. Computing TCs was deemed infeasible for large models [13], but recent attempts using saturation to compute TCs symbolically have been successful [16,17]. We generalize this approach so that, for EGφ, the size of a minimum φ witness for each state in a φ cycle contributes to the cycle size.
We compute function T C φ : S × S → N ∞ s.t. T C φ (i, j) is the minimum size of any path i, i 1 , · · · , j, computed as π φ (i 1 ) + · · · + π φ (j), or ∞ if no such path exists. We do not include π φ (i) because we compute T C φ to obtain the minimum witness size of cycles, χ φ (i) = T C φ (i, i)+1, and π φ (i) should not be added twice.
The procedure to compute T C φ is analogous to a symbolic implementation of Dijkstra's algorithm in a weighted graph. We initialize the function and repeat the following computation until reaching a fixpoint: This iteration never increases the value of λ φ , thus it terminates, and when it does the resulting fixpoint is T C φ . Procedures TCSat and TCRelProdSat in Fig. 4 are similar to ConsSat and ConsRelProdSat in Fig. 3, except that they apply saturation to an EV + MDD2. TCMin (line 14 in TCSat, line 11 in TCRelProdSat) is an implementation of Min over pairs of states: for each i, j ∈ S, TCMin f,g (i, j) = min{f (i, j), g(i, j)}.

Generating a Minimum Tree-Like Witness
Recall that, if function f is encoded as an EV + MDD, one can retrieve MinVal (f ), the minimum value of f , in constant time (as the value labeling the edge pointing to the root node) and MinState(f ), a state achieving that minimum value, in time proportional to the number of levels L (follow a path of 0-valued edges from the root to Ω). Evaluating f (i) for a given state i also requires just L steps.
To obtain a minimum overall witness recursively, we start from an initial state i * with a minimum witness for φ * . This state can be found by building an EV + MDD encoding the function f init : S → {0, ∞} evaluating to 0 iff i ∈ S init , and then the EV + MDD encoding π φ * ∧init , the elementwise maximum of f init and π φ * (i.e., the restriction of the minimum witness size for φ * to the initial states). If MinVal (π φ * ∧init ) = ∞, no initial state satisfies φ * , thus no witness exists. Otherwise, there is a minimum witness of size MinVal (π φ * ∧init ) starting from an initial state i * = MinState(π φ * ∧init ), and the call MinWit(i * , φ * , π φ * (i * )) (see Fig. 5) will recursively generate one such minimum witness.

Experimental Results
We implemented both our EV + MDD-based approach to generate minimum treelike witnesses (MinWit) and the traditional MDD-aided BFS approach [7] to generate (not necessarily minimum) tree-like witnesses (Wit) in our model checker SMART [2]. Then we ran them on a benchmark suite consisting of nine Petri net models from the 2017 Model Checking Contest (https://mcc.lip6.fr/2017/). All models have one or more scaling parameters affecting the number of states and state-to-state transitions, thus the model size and complexity. To generate treelike witnesses, we define an ECTL formula that the model satisfies (the specific formula is listed in the results presented in Table 1). The datasets we utilized are available in the figshare repository [9].

MinWit(state i, ECTLformula φ, size n)
1: if φ ∈ A then return i n = 1, φ is an atomic proposition if π ρ (i) = n then a minimum witness for i |= ρ works for i |= Eφ Uρ 12: return [[MinWit(i, ρ , n)]] 13: else no witness for i |= ρ is minimum for i |= Eφ Uρ 14: choose j ∈ N (i) s.t. π φ (j) = n − π φ (i) there exists at least one such j 15: if T C φ (i,i) = n−1 then a minimum cycle witness for i works for i |= EGφ 18: return CloseCycle(i, i, φ , n − 1) 19: else i is on the handle of a lasso for a minimum witness for i |= EGφ 20: CloseCycle(state j, state i, ECTLformula φ, size n) 1: if π φ (i) = n then it must be that i ∈ N (j), close the cycle with i 2: return [[MinWit(j, φ, π φ (j))]], i 3: else 4: choose k ∈ N (j) s.t. T C φ (k, i) = n − π φ (k) there exists at least one such k 5: return [[MinWit(j, φ, π φ (j))]], CloseCycle(k, i, φ, n − π φ (k)) For MinWit, we run each model instance with a timeout of one hour, and report the runtime, the peak memory consumption, and the size of the minimum witness. For Wit, we run each instance 100 times and report the total runtime, the peak memory consumption, and the minimum, average and maximum size among the all the generated witnesses. The minimum witness size is in bold when Wit did not manage to generate a minimum witness in any of the 100 runs. Obviously, the choice of R = 100 runs is arbitrary: the larger R is, the more likely Wit is to generate smaller witnesses, possibly a minimum one, but, on the other hand, the overall time Wit spends for witness generation is roughly proportional to R. Fundamentally, however, we have no easy way to know if the smallest witness generated by Wit is a minimum one, regardless of how large R is, while MinWit guarantees minimality.
A few observations are in order. First, it is not surprising that MinWit is sometimes orders of magnitude slower and requires more memory than Wit. E(EF(P client ack 1 = 1) U ((P server ack 1 = 1) ∧ (P server ack 2 = 1))) SimpleLoadBal (2)  Building EV + MDDs or EV + MDD2s encoding both states and size information is much more expensive than the image computations on MDDs used to just run the model checking phase, as Wit does. However, this is offset by a minimality guarantee. Interestingly, there are cases where MinWit completes with a runtime and memory consumption comparable to a single run of Wit (e.g., Kanban) or even faster (e.g., SmallOS). We give credit to the saturation algorithm for its efficient locality-exploiting exploration. Second, for models where small, simple witnesses exist, Wit may be able to generate a minimum witness. Since the backward exploration guarantees the local minimality of subwitnesses for EX, EF and EU segments, such greedy strategy may result in a global minimum witness, determined by the structure of the model. But this occurrence cannot be guaranteed, regardless of whether we use 100 runs or 10,000 runs, so that, even when Wit happens to generate a minimum witness, users do not know that this is indeed the case.
Third, for models where only large, complex witnesses exist, generating a minimum witness is almost impossible for Wit, while the witness from MinWit can be only 40% as large as the smallest one generated by Wit (e.g., Circular-Train with N = 24). Additionally, Wit's greedy strategy may trap itself into a local optimum. For example, the ECTL formula used for model MAPK does not contain EG, and the minimum, average, and maximum witness sizes generated by Wit are equal, implying that Wit is unaware of other possibilities when it chooses branching states. Adopting a probabilistic non-optimal strategy like simulated annealing may alleviate this problem, but it still would not provide guarantees and would likely require many more runs.
The main limitation of MinWit is that, since computing the minimum witness size function is computationally intensive, long runtimes and large amounts of memory are required as the model complexity scales up. However, engineers usually debug models with small scaling parameters first, perhaps running model checking tools overnight, thus, the resource requirement of MinWit may often be acceptable in practice. In real-world applications, we believe that MinWit and Wit can complement each other. Wit generates a large number of witnesses in a short time, but if all the witnesses are complex, MinWit can be run to find a smaller, easier-to-inspect one. Conversely, if MinWit fails to generate a minimum witness due to time or memory limitation, Wit can be run to obtain not-necessarily-minimum ones by running it repeatedly, as many times as one can afford. The best approach, given enough resources and in the presence of critical deadlines, may well be to run both methods in parallel, so that we can be sure to have a minimum witness if MinWit completes, but we have at least some witnesses from Wit, if MinWit fails to complete in time.

A Comment About Our Definition of Witness Size
In Sect. 3, we defined the witness size as "the number of appearances of states in the unfolded tree-like witness". An alternative definition could have been "the number of distinct states in the unfolded tree-like witness". However, a state may appear multiple times for different purposes in a witness. For example, the witness for EF(a ∧ EGb) in Fig. 6 contains state 2 twice, one in [ [3,2,3]] to verify for the EG fragment, the other in [ [1,2,3]] to verify the EF fragment. Considering each appearance separately makes each subpath independently verifiable, while merging states that appear multiple times and counting only distinct states loses this information. Admittedly, our definition of witness size also enables our approach to obtain minimum witnesses, while we do not know a practical algorithm that can derive minimum witnesses according to a definition of size where common paths and states appearing multiple times are counted without repetition. Of course, after obtaining a minimum witness according to our definition, we could attempt to merge shared portions among subpaths that demonstrate the same property, but doing so would not generally result in minimum witnesses according to this alternative view of witness size.

Conclusions
We presented a definition of witness size and an approach to compute minimum tree-like witnesses for ECTL formulas, based on edge-valued decision diagrams to capture a global view of witness size. Experimental results demonstrate that our approach is able to generate minimum witnesses (with a guarantee that it is doing so) for some models, while the traditional approach is not. While the runtime and memory requirements of our approach tend to be higher, sometimes they are comparable to that of the traditional approach. There are several directions for future work to improve this approach itself or extend its applicability. One interesting possibility is to selectively employ our approach or the traditional approach for different subformulas; this would not guarantee witness minimality, but could generate smaller witness than with the traditional approach alone, while being faster than using our approach alone. Especially for EG formulas, the traditional approach has no global view about the size of witnesses it generates, while, for formulas where the minimum witness size from each state varies widely, the EV + MDDs and EV + MDD2s built by our method tend to be large and costly to compute. Thus, heuristics that consider both the structure of the model and of the formula are needed.
Finally, our approach could be further extended by generalizing the concept of "size" to "weight". Specifically, by assigning a weight to each state, engineers could convey their preference to model checkers, which would then tend to generate witnesses containing the desired states and subpaths, instead of just counting the number of states in the witness. The algorithmic difference in doing so would be negligible, the only additional cost could be a potential growth in the size of the corresponding EV + MDDs and EV + MDD2s, as the functions being encoded might have less sharing of nodes.