Documentation

CslibFrontier.Computability.Automata.MPDA.EmptinessSound

Soundness of the emptiness procedure #

If repaired Algorithm 1 of [AGKR20] (MPDA.isEmpty) answers false, the MPDA has a K-hole-bounded accepting run.

A list of the search abstracts each open hole by a triple (i, s, t) of HSᵢ. For every choice of a chain of atomic hole segments realizing each triple (MPDA.Realizes), a reachable list comes from a hole derivation (MPDA.HoleDerivation) together with a run of the MPDA whose stacks hold the symbols pushed by the chosen segments (MPDA.RunsTo). Each step of the search extends such a run: a new hole by a block of atomic segments (MPDA.BlockRun), a pop by the pop and a well-nested run (MPDA.RunsTo.pop, MPDA.RunsTo.popClose). The witness generation of Section 4 reuses these steps. A pop of the search splits off the last atomic segment of a hole, so the realization of the shrunk hole extends to one of the old hole that ends with the popped push. Hole derivations build K-hole-bounded sequences (MPDA.HoleDerivation.holeBounded).

Main results #

References #

Stack contents of open chains #

def Cslib.Automata.MPDA.stacksOf {n : ℕ} {Γ : Type u_3} (C : List (HoleChain n Γ)) :
Stacks n Γ

The stacks holding the pushes of open chains: on each stack, the pushes of later chains above those of earlier ones, the newest push of a chain on top.

theorem Cslib.Automata.MPDA.stacksOf_pop {n : ℕ} {Γ : Type u_3} {pre post : List (HoleChain n Γ)} {i : Fin n} {p : ℕ} {γ : Γ} {ps : List (ℕ × Γ)} (hpost : ∀ c ∈ post, c.stack ≠ i) :
stacksOf (pre ++ { stack := i, pushes := (p, γ) :: ps } :: post) = Function.update (stacksOf (pre ++ { stack := i, pushes := ps } :: post)) i (γ :: stacksOf (pre ++ { stack := i, pushes := ps } :: post) i)
theorem Cslib.Automata.MPDA.stacksOf_close {n : ℕ} {Γ : Type u_3} {pre post : List (HoleChain n Γ)} {i : Fin n} :
stacksOf (pre ++ { stack := i, pushes := [] } :: post) = stacksOf (pre ++ post)

Runs that reach a list #

def Cslib.Automata.MPDA.BlockRun {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : MPDA n State Symbol Γ) (i : Fin n) (s t : State) (r : List (Γ × State)) (v : List (Symbol × Op n Γ)) :

The run v from s to t is a hole block of stack i at every position, and pushes the symbols of the realization r on stack i from any stacks.

theorem Cslib.Automata.MPDA.blockRun_nil {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {i : Fin n} {s : State} :
M.BlockRun i s s [] []
theorem Cslib.Automata.MPDA.BlockRun.snoc {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {i : Fin n} {s t' s₁ t : State} {r : List (Γ × State)} {v ws : List (Symbol × Op n Γ)} {a : Symbol} {γ : Γ} (h : M.BlockRun i s t' r v) (hpush : M.Tr t' (a, Op.push i γ) s₁) (hws : WellNested ws) (hwsrun : M.MTr s₁ ws t) :
M.BlockRun i s t ((γ, t) :: r) (v ++ (a, Op.push i γ) :: ws)

A block extends by an atomic hole segment: a push of γ on stack i, then a well-nested run.

def Cslib.Automata.MPDA.RunsTo {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} (M : MPDA n State Symbol Γ) (K : ℕ) (μ : HoleList n State) (rs : List (List (Γ × State))) (w : List (Symbol × Op n Γ)) :

A run of the MPDA from an initial state with empty stacks to the last state of the list μ, with a hole derivation whose chains have the stacks of the hole triples of μ and push the symbols of the realizations rs.

theorem Cslib.Automata.MPDA.runsTo_init {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {K : ℕ} {s₀ s : State} {v : List (Symbol × Op n Γ)} (hs₀ : s₀ ∈ M.start) (hv : WellNested v) (hvrun : M.MTr s₀ v s) :
M.RunsTo K { holes := [], last := s } [] v

A well-nested run from an initial state reaches a list without holes.

theorem Cslib.Automata.MPDA.RunsTo.hole {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {K : ℕ} {ν : HoleList n State} {rs : List (List (Γ × State))} {w v : List (Symbol × Op n Γ)} {i : Fin n} {t : State} {r : List (Γ × State)} (h : M.RunsTo K ν rs w) (hK : ν.holes.length < K) (hv : M.BlockRun i ν.last t r v) :
M.RunsTo K { holes := ν.holes ++ [{ stack := i, src := ν.last, dst := t }], last := t } (rs ++ [r]) (w ++ v)

A new hole: a block run of a realization extends the run by the new hole triple, while fewer than K holes are open.

theorem Cslib.Automata.MPDA.RunsTo.pop {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {K : ℕ} {ν : HoleList n State} {w v : List (Symbol × Op n Γ)} {i : Fin n} {pre post : List (HoleTriple n State)} {s₁ s₂ s₃ s' s'' : State} {γ : Γ} {b : Symbol} {rpre rpost : List (List (Γ × State))} {r : List (Γ × State)} (h : M.RunsTo K ν (rpre ++ ((γ, s₃) :: r) :: rpost) w) (hsplit : splitLastHole i ν.holes = some (pre, (s₁, s₃), post)) (hlen : rpre.length = pre.length) (hb : M.Tr ν.last (b, Op.pop i γ) s') (hv : WellNested v) (hvrun : M.MTr s' v s'') :
M.RunsTo K { holes := pre ++ { stack := i, src := s₁, dst := s₂ } :: post, last := s'' } (rpre ++ r :: rpost) (w ++ (b, Op.pop i γ) :: v)

A pop that shrinks a hole: the pop of the newest push of the last hole of stack i, followed by a well-nested run, drops the last atomic segment of that hole's realization.

theorem Cslib.Automata.MPDA.RunsTo.popClose {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {K : ℕ} {ν : HoleList n State} {w v : List (Symbol × Op n Γ)} {i : Fin n} {pre post : List (HoleTriple n State)} {s₁ s₃ s' s'' : State} {γ : Γ} {b : Symbol} {rpre rpost : List (List (Γ × State))} (h : M.RunsTo K ν (rpre ++ [(γ, s₃)] :: rpost) w) (hsplit : splitLastHole i ν.holes = some (pre, (s₁, s₃), post)) (hlen : rpre.length = pre.length) (hb : M.Tr ν.last (b, Op.pop i γ) s') (hv : WellNested v) (hvrun : M.MTr s' v s'') :
M.RunsTo K { holes := pre ++ post, last := s'' } (rpre ++ rpost) (w ++ (b, Op.pop i γ) :: v)

A pop that closes a hole: the pop of the only pending push of the last hole of stack i, followed by a well-nested run, removes that hole.

theorem Cslib.Automata.MPDA.RunsTo.accepting {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} {M : MPDA n State Symbol Γ} {K : ℕ} {μ : HoleList n State} {w v : List (Symbol × Op n Γ)} {f : State} (h : M.RunsTo K μ [] w) (hholes : μ.holes = []) (hv : WellNested v) (hvrun : M.MTr μ.last v f) :
∃ s₀ ∈ M.start, M.configLTS.MTr { state := s₀, contents := Stacks.empty } (w ++ v) { state := f, contents := Stacks.empty } ∧ HoleBounded K (w ++ v)

A run reaching a list without holes, followed by a well-nested run to a final state, is an accepting K-hole-bounded run.

Realizations of hole triples #

inductive Cslib.Automata.MPDA.Realizes {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} [Fintype State] [DecidableEq State] [Fintype Symbol] [Fintype Γ] (M : MPDA n State Symbol Γ) [(s : State) → (μ : Symbol × Op n Γ) → (s' : State) → Decidable (M.Tr s μ s')] (i : Fin n) (s : State) :
State → List (Γ × State) → Prop

A chain of atomic hole segments of stack i from s to t, as the pushed symbols and the states after each segment, newest first.

theorem Cslib.Automata.MPDA.mem_holeSegments_iff_realizes {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')] {i : Fin n} {s t : State} :
(s, t) ∈ M.holeSegments i ↔ ∃ (r : List (Γ × State)), M.Realizes i s t r

The hole triples of HSᵢ are exactly those with a realization.

theorem Cslib.Automata.MPDA.Realizes.exists_blockRun {n : ℕ} {State : Type u_1} {Symbol : Type u_2} {Γ : Type u_3} [Fintype State] [DecidableEq State] [Fintype Symbol] [Fintype Γ] {M : MPDA n State Symbol Γ} [(s : State) → (μ : Symbol × Op n Γ) → (s' : State) → Decidable (M.Tr s μ s')] {i : Fin n} {s t : State} {r : List (Γ × State)} (hr : M.Realizes i s t r) :
∃ (v : List (Symbol × Op n Γ)), M.BlockRun i s t r v

A realization of a hole triple gives a run of the MPDA that is a hole block at every position and pushes the realization's symbols on stack i from any stacks (MPDA.BlockRun).

Reachable lists come from hole derivations #

theorem Cslib.Automata.MPDA.Reachable.exists_runsTo {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')] [DecidablePred fun (x : State) => x ∈ M.start] {K : ℕ} {μ : HoleList n State} (hμ : M.Reachable K M.initialLists μ) (rs : List (List (Γ × State))) :
List.Forall₂ (fun (r : List (Γ × State)) (h : HoleTriple n State) => M.Realizes h.stack h.src h.dst r) rs μ.holes → ∃ (w : List (Symbol × Op n Γ)), M.RunsTo K μ rs w

The soundness invariant: for every realization of the hole triples of a reachable list, some run of the MPDA reaches the list (MPDA.RunsTo).

theorem Cslib.Automata.MPDA.exists_mem_boundedLanguage_of_isEmpty_eq_false {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')] [DecidablePred fun (x : State) => x ∈ M.start] [DecidablePred fun (x : State) => x ∈ M.accept] {K : ℕ} (h : M.isEmpty K = false) :
∃ (x : List Symbol), x ∈ M.boundedLanguage (HoleBounded K)

Soundness of repaired Algorithm 1 of [AGKR20]: if the search answers false, some word has a K-hole-bounded accepting run.