Computing well-nested reachability #
The emptiness procedure for hole-bounded MPDAs, Algorithm 1 of
[AGKR20], starts from the set WR of pairs of control states joined
by a well-nested run, computed by Algorithm 2 (WellNestedReach, Appendix B). This file computes
WR for an MPDA with finitely many control states, letters and stack symbols and a decidable
transition relation.
MPDA.wellNestedPairs M iterates the closure rules of MPDA.WellNestedReach on finite sets of
pairs, as many times as there are pairs. Algorithm 2 alternates a transitive closure with a
push-pop step until nothing changes; any order of applying the rules reaches the same least fixed
point, and the number of iterations is not part of the statements here.
The file then defines the search of repaired Algorithm 1 (MPDA.isEmpty). It differs from
the printed algorithm in two ways.
HSᵢis the reflexive-transitive closure ofAHSᵢ, where line 9 of Algorithm 1 takes the transitive closure. This letsAddPopremove a hole whose last atomic segment is popped. It also letsAddHoleopen a hole(i, s, s)without taking a transition, even from a state with no push; such a hole is realized by the empty factor, while Definition 1 counts nonempty factors. It only uses up one of theKholes, and soundness allows the empty realization.- The search starts from the states reached from an initial state by a well-nested run, not from the initial state alone (line 10).
Starting from the initial state alone is not complete: the module client test
CslibFrontierTests.MPDA.Emptiness defines this printed-start variant and checks a
counterexample.
Main definitions #
MPDA.wellNestedPairs: the setWRof Algorithm 2, as a computableFinset.MPDA.atomicHoles,MPDA.holeSegments: the setsAHSᵢandHSᵢof Algorithm 1.MPDA.isEmpty: repaired Algorithm 1.
Main results #
MPDA.mem_wellNestedPairs:(s, s') ∈ WRexactly whenMPDA.WellNestedReach M s s'. WithMPDA.wellNestedReach_iff, this is Lemma 1 of [AGKR20] for the computed set.MPDA.card_explore_le: when2 ≤ n |S|², the search visits at most|S| ^ (2 * K + 3) * n ^ (K + 1)lists, matching the list count in the complexity paragraph after Theorem 1.MPDA.card_successors_le: each list has at mostn (|S|² + 2 |S|)children underAddHoleandAddPop.
References #
- [S. Akshay, P. Gastin, S. Krishna, S. Roychowdhury, Revisiting Underapproximate Reachability for Multipushdown Systems] [AGKR20]
The closure rules of WR as a monotone map #
One application of the closure rules of WellNestedReach to a relation R: reflexive pairs,
a nop transition followed by R, and a push followed by R, a matching pop and R.
Computing WR #
One application of the closure rules of WellNestedReach to a finite relation.
The set WR of Algorithm 2 of [AGKR20]: the closure rules of
WellNestedReach, iterated from the empty relation once for each pair of control states.
Lemma 1 for the computed set: (s, s') ∈ WR exactly when the MPDA has a well-nested run
from s to s' (MPDA.wellNestedReach_iff).
Hole segments #
An atomic hole segment (s, α, s'): a push of α from s, followed by a well-nested run to
s'. The stack of the push is the index of the set AHSᵢ that contains the segment.
- src : State
The state where the push starts.
- sym : Γ
The pushed stack symbol.
- dst : State
The state where the well-nested run after the push ends.
Instances For
Atomic hole segments are in bijection with the triples of their fields.
The atomic hole segments AHSᵢ of stack i (Algorithm 1, lines 5–8, of
[AGKR20]): the segments (s, α, s') such that a push of α on stack
i from s, followed by a well-nested run, reaches s'.
An atomic hole segment is a push of α on stack i followed by a well-nested run.
The hole segments HSᵢ of stack i (Algorithm 1, line 9): the reflexive-transitive closure of
the atomic hole segments, forgetting the pushed symbols. The source writes TransitiveClosure;
the closure must be reflexive, since AddPop (Algorithm 4) splits off the only atomic segment of
a hole through a triple (i, s, s). Reflexivity also lets AddHole (Algorithm 3) open a hole
(i, s, s) without taking a transition, even from a state with no push; such a hole is realized
by the empty factor.
Lists and the search #
A hole triple (i, s, s') of a list of the search: an open hole of stack i, abstracted by a
hole segment from s to s'.
- stack : Fin n
The stack of the hole.
- src : State
The state where the hole starts, the source of its first push.
- dst : State
The state where the hole segment ends.
Instances For
Hole triples are in bijection with the triples of their fields.
A list of the search of Algorithm 1 of [AGKR20]: the open hole triples, oldest first, and the last control state. The source's lists also start with the initial state, which the search does not need.
- holes : List (HoleTriple n State)
The open hole triples, oldest first.
- last : State
The last control state.
Split a list of hole triples at its last triple of stack i, l = pre ++ ⟨i, s, s'⟩ :: post
where post has no triple of stack i: the result is pre, the endpoints (s, s') and post.
This is lastHoleᵢ of Algorithm 4.
AddHoleᵢ (Algorithm 3 of [AGKR20]): extend the list with a hole
segment of stack i that starts at its last state. Since HSᵢ is reflexive here, this includes
the empty hole (i, s, s) at the last state s, opened without a transition.
AddPopᵢ (Algorithm 4): a pop from stack i at the last state that matches the last pending
push of the last open hole (i, s₁, s₃) of stack i. The hole splits into a hole segment
(i, s₁, s₂) and an atomic hole segment (s₂, α, s₃) pushing α, the pop of α leads to s',
and a well-nested run continues to s''. The hole shrinks to (i, s₁, s₂); when s₁ = s₂ it may
also be removed. Without an open hole of stack i there is no successor.
The children of a list in the search: holes while fewer than K are open, and pops.
The worklist loop of Algorithm 1: add the new children of the lists to do, until there are none, or the fuel runs out.
The initial lists of the repaired search: a state reached from an initial state by a well-nested run, and no holes. The search as printed starts from the initial state itself (line 10 of Algorithm 1), and so misses runs whose first hole push follows a nonempty well-nested factor.
The search of Algorithm 1 from the lists init: true when no list reached without open
holes reaches an accepting state through a well-nested run. The source checks the initial state
before the loop (line 3) and each new list obtained by a pop (line 25); both checks are this
one.
Repaired Algorithm 1 of [AGKR20]. It differs from the
printed algorithm in two ways: the search starts from the states reached from an initial state by
a well-nested run (initialLists), not from the initial state alone; and HSᵢ is the
reflexive-transitive closure of AHSᵢ (holeSegments).
The search computes the reachable lists #
The lists the search of Algorithm 1 reaches from the lists init: closed under
successors.
- init {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} [Fintype State] [DecidableEq State] [Fintype Symbol] [Fintype Γ] [DecidableEq Γ] {M : MPDA n State Symbol Γ} [(s : State) → (μ : Symbol × Op n Γ) → (s' : State) → Decidable (M.Tr s μ s')] {K : ℕ} {init : Finset (HoleList n State)} {μ : HoleList n State} : μ ∈ init → M.Reachable K init μ
- step {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} [Fintype State] [DecidableEq State] [Fintype Symbol] [Fintype Γ] [DecidableEq Γ] {M : MPDA n State Symbol Γ} [(s : State) → (μ : Symbol × Op n Γ) → (s' : State) → Decidable (M.Tr s μ s')] {K : ℕ} {init : Finset (HoleList n State)} {μ ν : HoleList n State} : M.Reachable K init μ → ν ∈ M.successors K μ → M.Reachable K init ν
The search of Algorithm 1 returns exactly the reachable lists: the fuel listBound is never
exhausted.
The size of the search #
The complexity paragraph after Theorem 1 of [AGKR20] (printed p. 10)
bounds the running time by the number of lists the search may generate, times the work per list.
Whenever 2 ≤ n |S|², there are fewer than
|S| (n |S|²) ^ (K + 1) = |S| ^ (2 * K + 3) * n ^ (K + 1) lists with at most K holes, so the
search visits at most |S| ^ (2 * K + 3) * n ^ (K + 1) lists; the printed bound can fail only in
the degenerate range n |S|² ≤ 1 (for n = |S| = 1 and K ≥ 1, there are K + 1 lists with at
most K holes against the printed bound 1, and for n = 0, |S| ≥ 1, and nonempty init, the
printed bound is 0; it still holds when n = |S| = 1, K = 0 or |S| = 0). Each list also has at
most n (|S|² + 2 |S|) children under AddHole and AddPop.
The number of lists of the search: whenever 2 ≤ n * |S|², the search visits at most
|S| ^ (2 * K + 3) * n ^ (K + 1) lists, matching the list count in the complexity paragraph after
Theorem 1 of [AGKR20] (printed p. 10). The hypothesis
2 ≤ n * |S|² excludes only the degenerate range n * |S|² ≤ 1 where the printed bound can fail
(for n = |S| = 1 and K ≥ 1, there are K + 1 lists with at most K holes against the printed
bound 1; for n = 0, |S| ≥ 1, and nonempty init, the printed bound is 0; it still holds
when n = |S| = 1, K = 0 or |S| = 0).
The children of a list: a list has at most n (|S|² + 2 |S|) children in the search.