Documentation

CslibFrontier.Computability.Automata.MPDA.Holes

Hole-bounded sequences of multistack pushdown automata #

Holes are the underapproximation introduced in Section 2.1 of [AGKR20] (Definition 1). A hole of stack i is a factor of the form (↓ᵢ ws)⁺: pending pushes on stack i, each followed by a well-nested sequence. Well-nested sequences do not distinguish stacks, so the sequences ws may use any stack, while the pending pushes of a hole all use the same stack. A push that is closed by a well-nested continuation, that is a push ↓ with matching pop ↑ such that ↓ ws ↑ is well-nested, belongs to a well-nested sequence and never opens a hole.

A sequence is K-hole-bounded if at most K holes are open at each position.

Main definitions #

Main results #

Implementation notes #

Positions are 0-indexed. Matching between a push and a pop is defined by counting the pushes and pops of the relevant stack in between, so it does not depend on the stack symbols. On runs of an MPDA the symbols of matching pushes and pops coincide.

Definition 1 of [AGKR20] takes holes to be maximal factors and counts the holes that have a pending push at a position. We count open holes through their pending pushes instead. At position x, take the hole pushes that are pending at x, in order. Two consecutive ones belong to the same hole exactly when they push on the same stack and the factor between them is well-nested. Each open hole is then counted once, through its first pending push.

References #

Matching pushes and pops #

The effect of an operation kind on the height of stack i.

def Cslib.Automata.MPDA.Op.net {n : ℕ} {Γ : Type u_1} (i : Fin n) (op : Op n Γ) :

The effect of an operation on the height of stack i: that of its kind.

def Cslib.Automata.MPDA.net {n : ℕ} {Γ : Type u_1} {α : Type u_2} (i : Fin n) (w : List (α × Op n Γ)) :

The net change of the height of stack i along a sequence of transitions.

def Cslib.Automata.MPDA.Matches {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (p m : ℕ) :

The push at position p of w is matched by the pop at position m: they act on the same stack i, and the factor strictly between them never pops below its initial height of stack i and returns to it.

def Cslib.Automata.MPDA.PendingAt {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (p x : ℕ) :

The push at position p of w is pending at position x: it occurs at or before x, and it has not been popped by position x.

Net effect on a stack #

@[simp]
theorem Cslib.Automata.MPDA.net_nil {n : ℕ} {Γ : Type u_1} {α : Type u_2} (i : Fin n) :
net i [] = 0
@[simp]
theorem Cslib.Automata.MPDA.net_cons {n : ℕ} {Γ : Type u_1} {α : Type u_2} (i : Fin n) (μ : α × Op n Γ) (w : List (α × Op n Γ)) :
net i (μ :: w) = Op.net i μ.2 + net i w
@[simp]
theorem Cslib.Automata.MPDA.net_append {n : ℕ} {Γ : Type u_1} {α : Type u_2} (i : Fin n) (u w : List (α × Op n Γ)) :
net i (u ++ w) = net i u + net i w
theorem Cslib.Automata.MPDA.net_eq_of_kind {n : ℕ} {Γ : Type u_1} {α : Type u_2} {κ : α → OpKind n} {w : List (α × Op n Γ)} (hw : ∀ μ ∈ w, μ.2.kind = κ μ.1) (i : Fin n) :
net i w = (List.map (fun (a : α) => OpKind.net i (κ a)) (List.map Prod.fst w)).sum

On a sequence whose operations have the kinds of their letters, the net effect on a stack only depends on the letters.

theorem Cslib.Automata.MPDA.Op.net_pop {n : ℕ} {Γ : Type u_1} (i j : Fin n) (γ γ' : Γ) :
net i (pop j γ) = -net i (push j γ')
theorem Cslib.Automata.MPDA.WellNested.net_eq_zero {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} (hw : WellNested w) (i : Fin n) :
net i w = 0

A well-nested sequence leaves the height of every stack unchanged.

theorem Cslib.Automata.MPDA.WellNested.net_take_nonneg {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} (hw : WellNested w) (i : Fin n) (k : ℕ) :
0 ≤ net i (List.take k w)

No prefix of a well-nested sequence pops below the initial height of any stack.

Shifting positions #

theorem Cslib.Automata.MPDA.matches_append_left {n : ℕ} {Γ : Type u_1} {α : Type u_2} (v w : List (α × Op n Γ)) (p m : ℕ) :
Matches (v ++ w) (v.length + p) (v.length + m) ↔ Matches w p m
theorem Cslib.Automata.MPDA.Matches.lt_length {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} {p m : ℕ} (h : Matches w p m) :
m < w.length
theorem Cslib.Automata.MPDA.Matches.append_right {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} {p m : ℕ} (h : Matches w p m) (v : List (α × Op n Γ)) :
Matches (w ++ v) p m

Hole pushes and open holes #

def Cslib.Automata.MPDA.IsPushOn {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (i : Fin n) (p : ℕ) :

Position p of w is a push on stack i.

theorem Cslib.Automata.MPDA.IsPushOn.unique {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} {i j : Fin n} {p : ℕ} (hi : IsPushOn w i p) (hj : IsPushOn w j p) :
i = j

A push is on one stack only.

def Cslib.Automata.MPDA.WellMatched {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (p : ℕ) :

The push at position p is closed by a well-nested continuation: it has a matching pop at some position m, and the factor from p to m is well-nested.

def Cslib.Automata.MPDA.HolePush {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (p : ℕ) :

A hole push is a push that is not closed by a well-nested continuation. Hole pushes are the pending pushes that make up holes.

def Cslib.Automata.MPDA.OpenHolePush {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (x p : ℕ) :

The push at position p is a hole push that is pending at position x.

def Cslib.Automata.MPDA.SameHole {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (x p q : ℕ) :

The pending hole pushes at positions p < q belong to the same hole at position x: they push on the same stack and the factor strictly between them is well-nested.

noncomputable def Cslib.Automata.MPDA.openHoles {n : ℕ} {Γ : Type u_1} {α : Type u_2} (w : List (α × Op n Γ)) (x : ℕ) :

The number of holes of w open at position x. Each open hole is counted through its first pending hole push.

def Cslib.Automata.MPDA.HoleBounded {n : ℕ} {Γ : Type u_1} {α : Type u_2} (K : ℕ) (w : List (α × Op n Γ)) :

A sequence is K-hole-bounded if at most K holes are open at each of its positions.

theorem Cslib.Automata.MPDA.HoleBounded.mono {n : ℕ} {Γ : Type u_1} {α : Type u_2} {K K' : ℕ} {w : List (α × Op n Γ)} (h : HoleBounded K w) (hK : K ≤ K') :

Well-nested sequences have no holes #

theorem Cslib.Automata.MPDA.WellNested.exists_wellMatched {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} (hw : WellNested w) {p : ℕ} {i : Fin n} (hp : IsPushOn w i p) :

Every push of a well-nested sequence is closed by a well-nested continuation.

theorem Cslib.Automata.MPDA.WellNested.holeBounded_zero {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} (hw : WellNested w) :

Well-nested sequences are 0-hole-bounded.

Hole pushes on adjacent positions #

theorem Cslib.Automata.MPDA.WellMatched.append {n : ℕ} {Γ : Type u_1} {α : Type u_2} {v : List (α × Op n Γ)} {k : ℕ} (h : WellMatched v k) (u u' : List (α × Op n Γ)) :
WellMatched (u ++ v ++ u') (u.length + k)

A push that is closed by a well-nested continuation inside a factor is closed by it in the whole sequence.

theorem Cslib.Automata.MPDA.OpenHolePush.sameHole_pred {n : ℕ} {Γ : Type u_1} {α : Type u_2} {w : List (α × Op n Γ)} {x q : ℕ} {i : Fin n} (h : OpenHolePush w x q) (hq : 0 < q) (hpq : IsPushOn w i (q - 1)) (hqi : IsPushOn w i q) :
SameHole w x (q - 1) q

A hole push directly preceded by a push on the same stack is not the first pending push of its hole: the two pushes belong to the same hole.