Documentation

CslibFrontier.Computability.Machines.AuxPDA.Sequential

Sequencing counting auxiliary pushdown automata #

Run the second phase on the exact tapes and stack left by the first phase. The first phase's halting transition transfers control directly to the second, preserving its occurrence index. This is the auxiliary-stack analogue of the sequential multi-tape machine construction.

def Turing.CountingAuxPDA.Sequential.left {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (second : CountingAuxPDA k Symbol StackSym Second) (cfg : AuxPDA.Cfg k Symbol StackSym First input) :
AuxPDA.Cfg k Symbol StackSym (First ⊕ Second) input

A first-phase configuration, dispatching its halt to the second phase.

def Turing.CountingAuxPDA.Sequential.start {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (second : CountingAuxPDA k Symbol StackSym Second) (cfg : AuxPDA.Cfg k Symbol StackSym First input) :
AuxPDA.Cfg k Symbol StackSym Second input

The second phase starts on the complete state of the tapes and stack left by the first.

def Turing.CountingAuxPDA.Sequential.right {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (cfg : AuxPDA.Cfg k Symbol StackSym Second input) :
AuxPDA.Cfg k Symbol StackSym (First ⊕ Second) input

A second-phase configuration embedded in the combined control states.

theorem Turing.CountingAuxPDA.Sequential.left_halted {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (second : CountingAuxPDA k Symbol StackSym Second) (cfg : AuxPDA.Cfg k Symbol StackSym First input) (h : cfg.Halted) :
left second cfg = right (start second cfg)
def Turing.CountingAuxPDA.seq {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) :
CountingAuxPDA k Symbol StackSym (First ⊕ Second)

Sequence two counting phases while retaining tapes, stack and occurrence order.

@[simp]
theorem Turing.CountingAuxPDA.seq_q₀ {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) :
(first.seq second).q₀ = Sum.inl first.q₀

A sequence enters the first machine's initial state.

theorem Turing.CountingAuxPDA.seq_actions_length_le_one {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) (hfirst : ∀ (cfg : AuxPDA.Cfg k Symbol StackSym First input), (first.actions cfg).length ≤ 1) (hsecond : ∀ (cfg : AuxPDA.Cfg k Symbol StackSym Second input), (second.actions cfg).length ≤ 1) (cfg : AuxPDA.Cfg k Symbol StackSym (First ⊕ Second) input) :
((first.seq second).actions cfg).length ≤ 1

Sequencing preserves the property that at most one occurrence is offered at each step.

theorem Turing.CountingAuxPDA.Sequential.runBranch_right {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) (cfg : AuxPDA.Cfg k Symbol StackSym Second input) (indices : List ℕ) :
(first.seq second).runBranch (right cfg) indices = Option.map right (second.runBranch cfg indices)

A trace in the right phase has the same effect as running the second machine alone.

theorem Turing.CountingAuxPDA.Sequential.runBranch_append {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) {cfg middle : AuxPDA.Cfg k Symbol StackSym First input} {final : AuxPDA.Cfg k Symbol StackSym Second input} {before after : List ℕ} (hfirst : first.runBranch cfg before = some middle) (hhalt : middle.Halted) (hsecond : second.runBranch (start second middle) after = some final) :
(first.seq second).runBranch (left second cfg) (before ++ after) = some (right final)

Concatenating the phase traces runs both phases with no added occurrence at handoff.

theorem Turing.CountingAuxPDA.Sequential.runBranch_eq_some_iff_unique_prefix {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) (cfg : AuxPDA.Cfg k Symbol StackSym First input) (final : AuxPDA.Cfg k Symbol StackSym Second input) (hfinal : final.Halted) (indices : List ℕ) :
(first.seq second).runBranch (left second cfg) indices = some (right final) ↔ ∃! before : List ℕ, ∃ (middle : AuxPDA.Cfg k Symbol StackSym First input) (after : List ℕ), indices = before ++ after ∧ first.runBranch cfg before = some middle ∧ middle.Halted ∧ second.runBranch (start second middle) after = some final

A complete composite trace splits uniquely at the first phase's halting transition. The prefix determines the intermediate configuration, and removing it determines the suffix.

theorem Turing.CountingAuxPDA.Sequential.haltsWithin_right {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) {cfg : AuxPDA.Cfg k Symbol StackSym Second input} {fuel : ℕ} (h : second.HaltsWithin fuel cfg) :
(first.seq second).HaltsWithin fuel (right cfg)

The second phase keeps its original all-branches clock in the combined machine.

theorem Turing.CountingAuxPDA.Sequential.haltsWithin_left {k : ℕ} {Symbol : Type u_1} {StackSym : Type u_2} {First : Type u_3} {Second : Type u_4} {input : List Symbol} (first : CountingAuxPDA k Symbol StackSym First) (second : CountingAuxPDA k Symbol StackSym Second) {cfg : AuxPDA.Cfg k Symbol StackSym First input} {fuel bound : ℕ} (h : first.HaltsWithin fuel cfg) (hcontinuation : ∀ (indices : List ℕ) (middle : AuxPDA.Cfg k Symbol StackSym First input), first.runBranch cfg indices = some middle → middle.Halted → second.HaltsWithin bound (start second middle)) :
(first.seq second).HaltsWithin (fuel + bound) (left second cfg)

A uniform bound on each reachable continuation gives the sum of the phase clocks.