Documentation

CslibFrontier.Computability.Machines.AuxPDA.Surface

Surface configurations and realizable pairs for auxiliary pushdown automata #

A surface configuration (Turing.AuxPDA.SurfaceCfg) of a binary auxiliary pushdown automaton retains the control state, input head position, work-tape contents and head positions (Turing.Storage), the top stack symbol (Option StackSym), and the three-value acceptance summary of the write-only output tape (Turing.AuxPDA.OutputSummary), discarding the stack contents below the top.

A realizable pair (Turing.AuxPDA.Realizable M input s₁ s₂ d) characterizes same-height non-dipping subcomputations of length d from surface configuration s₁ to s₂:

This file proves:

  1. Exact soundness and completeness (realizable_iff_exists_sameHeightRun): Realizable holds iff there exists a concrete same-height non-dipping RunPath of length d from any matching starting configuration, and every such path preserves the stack verbatim.
  2. Decomposition (realizable_decomp): every realizable pair of length d ≥ 2 splits either into a matched push/pop pair or at an intermediate surface configuration s_mid with positive sublengths d₁ + d₂ = d — the exact inductive structure needed for the semi-unbounded circuit reduction in Work Package 4 of #7920.
  3. Empty-stack halting normalization (withEmptyStackHalt, accepts_iff_exists_realizable_of_emptyStackHalt): adding one draining state preserves space and acceptance while emptying the stack before halting within 2 * t + 1 steps.
  4. Finiteness and polynomial cardinality (encard_reachable_surfaceCfg_le, encard_reachable_surfaceCfg_le_pow, surfaceCfgBound_log_polynomiallyBounded): under space s, at most (n + 2) * 2 ^ O(s) surface configurations are reachable — polynomial in n when s(n) = O(log n).

This is original formalization infrastructure for cslib-frontier #7920 (Work Package 3), preparing the surface-configuration / realizable-pair interface of Ruzzo and Venkateswaran for Work Package 4.

Main definitions #

Main results #

References #

Output summary and surface configurations #

Three-value summary of the write-only binary output tape sufficient to determine [true] acceptance: empty ([]), exactly [true], or any other word.

Instances For

    Summarize a binary output word.

    A canonical representative word realizing a given OutputSummary.

    Update an output summary when appending an optional output bit.

    ofList is a homomorphism with respect to appending an optional output bit.

    structure Turing.AuxPDA.SurfaceCfg (k : ℕ) (StackSym : Type u_1) (State : Type u_2) (input : List Bool) :
    Type (max u_1 u_2)

    A surface configuration of a binary AuxPDA on input: input head position, work-tape storage (control state, tape contents and head positions), top stack symbol (none if empty), and three-value output summary.

    • inputPos : Fin (input.length + 2)

      Input head position (shifted by one, matching Turing.Cfg.inputPos).

    • storage : Storage Bool State k

      Control state, work-tape contents and work-tape head positions.

    • topSym : Option StackSym

      Top symbol of the pushdown stack, or none when the stack is empty.

    • outputSummary : OutputSummary

      Acceptance summary of the write-only binary output tape.

    theorem Turing.AuxPDA.SurfaceCfg.ext_iff {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {x y : SurfaceCfg k StackSym State input} :
    theorem Turing.AuxPDA.SurfaceCfg.ext {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {x y : SurfaceCfg k StackSym State input} (inputPos : x.inputPos = y.inputPos) (storage : x.storage = y.storage) (topSym : x.topSym = y.topSym) (outputSummary : x.outputSummary = y.outputSummary) :
    x = y
    def Turing.AuxPDA.SurfaceCfg.inputSymbol {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :

    The input symbol under the head of a surface configuration (identical to Turing.Cfg.inputSymbol).

    def Turing.AuxPDA.SurfaceCfg.workTapeSymbols {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) (i : Fin k) :

    The symbols under the work-tape heads of a surface configuration.

    @[reducible, inline]
    abbrev Turing.AuxPDA.SurfaceCfg.Halted {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :

    A surface configuration is halted when its control state is none.

    @[reducible, inline]
    abbrev Turing.AuxPDA.SurfaceCfg.IsAccepting {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :

    A surface configuration is accepting when it is halted with output summary .accept.

    def Turing.AuxPDA.SurfaceCfg.toRepresentativeCfg {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :
    Cfg k Bool StackSym State input

    A canonical concrete configuration having surface s (stack s.topSym.toList and canonical output word s.outputSummary.toList).

    def Turing.AuxPDA.Cfg.surface {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (c : Cfg k Bool StackSym State input) :
    SurfaceCfg k StackSym State input

    Project a concrete binary AuxPDA configuration to its surface configuration.

    theorem Turing.AuxPDA.Cfg.surface_toRepresentativeCfg {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :
    theorem Turing.AuxPDA.Cfg.surface_inputSymbol {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (c : Cfg k Bool StackSym State input) :
    theorem Turing.AuxPDA.SurfaceCfg.inputSymbol_eq_inputAt {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (s : SurfaceCfg k StackSym State input) :

    The surface input head uses the same blank end cells as the native tape.

    theorem Turing.AuxPDA.Cfg.surface_workTapeSymbols {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (c : Cfg k Bool StackSym State input) :
    theorem Turing.AuxPDA.Cfg.isAccepting_surface_iff {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (c : Cfg k Bool StackSym State input) :
    def Turing.AuxPDA.initSurface {k : ℕ} {StackSym : Type u_1} {State : Type u_2} (M : AuxPDA k Bool StackSym State) (input : List Bool) :
    SurfaceCfg k StackSym State input

    The initial surface configuration of M on input.

    def Turing.AuxPDA.applySurfaceTapes {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (act : Turing.Action k Bool State) (s : SurfaceCfg k StackSym State input) (newTop : Option StackSym) :
    SurfaceCfg k StackSym State input

    Apply the tape and output components of a Turing.Action to a surface configuration, installing newTop as the resulting top stack symbol.

    theorem Turing.AuxPDA.surface_apply_eq_applySurfaceTapes {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (act : Turing.Action k Bool State) (c : Cfg k Bool StackSym State input) (stack' : List StackSym) :
    { tapes := act.apply c.tapes, stack := stack' }.surface = applySurfaceTapes act c.surface stack'.head?

    Elementary surface steps and realizable pairs #

    def Turing.AuxPDA.StayStep {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (M : AuxPDA k Bool StackSym State) (s₁ s₂ : SurfaceCfg k StackSym State input) :

    A single height-preserving surface transition (either a halted self-loop or a .stay step).

    def Turing.AuxPDA.PushStep {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (M : AuxPDA k Bool StackSym State) (s₁ : SurfaceCfg k StackSym State input) (γ : StackSym) (s₂ : SurfaceCfg k StackSym State input) :

    A single .push γ surface transition from s₁ to s₂ (so s₂.topSym = some γ).

    def Turing.AuxPDA.PopStep {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} (M : AuxPDA k Bool StackSym State) (s₁ : SurfaceCfg k StackSym State input) (γ : StackSym) (baseTop : Option StackSym) (s₂ : SurfaceCfg k StackSym State input) :

    A single .pop surface transition from s₁ (whose top is some γ) exposing underlying stack top baseTop in s₂.

    def Turing.AuxPDA.SameHeightRun {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} (p : M.RunPath input) :

    A concrete run path is a same-height non-dipping run when its final stack height equals its initial stack height and no intermediate configuration drops below that height.

    inductive Turing.AuxPDA.Realizable {k : ℕ} {StackSym : Type u_1} {State : Type u_2} (M : AuxPDA k Bool StackSym State) (input : List Bool) :
    SurfaceCfg k StackSym State input → SurfaceCfg k StackSym State input → ℕ → Prop

    Inductive characterization of realizable surface pairs of exact step length d: M.Realizable input s₁ s₂ d holds iff s₁ reaches s₂ in d steps while never dropping below its starting stack height and ending at the same stack height.

    theorem Turing.AuxPDA.Realizable.exists_sameHeightRun {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} {s₁ s₂ : SurfaceCfg k StackSym State input} {d : ℕ} (h : M.Realizable input s₁ s₂ d) {c₁ : Cfg k Bool StackSym State input} (hc₁ : c₁.surface = s₁) :

    Soundness of Realizable: every realizable pair lifts from any matching concrete starting configuration c₁ to a same-height non-dipping run path preserving the stack verbatim.

    theorem Turing.AuxPDA.sameHeightRun_split_ge_two {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} {d' : ℕ} (p : M.RunPath input) (hlen : p.length = d' + 2) (hsame : SameHeightRun p) :

    Structural split of any SameHeightRun of length d' + 2: either it hits the base stack height at an interior index 0 < j < p.length, or it consists of a first push γ, an interior SameHeightRun of length d' one level higher whose configurations all belong to p, and a final pop step.

    theorem Turing.AuxPDA.SameHeightRun.last_stack_eq {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} {p : M.RunPath input} (h : SameHeightRun p) :

    Stack preservation: every concrete same-height non-dipping run preserves the stack verbatim.

    theorem Turing.AuxPDA.realizable_iff_exists_sameHeightRun {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} {s₁ s₂ : SurfaceCfg k StackSym State input} {d : ℕ} {c₁ : Cfg k Bool StackSym State input} (hc₁ : c₁.surface = s₁) :
    M.Realizable input s₁ s₂ d ↔ ∃ (p : M.RunPath input), RelSeries.head p = c₁ ∧ (RelSeries.last p).surface = s₂ ∧ p.length = d ∧ SameHeightRun p

    Soundness and completeness of Realizable: from any concrete configuration c₁ with surface s₁, M.Realizable input s₁ s₂ d holds iff there is a length-d same-height non-dipping run path from c₁ to a configuration with surface s₂.

    theorem Turing.AuxPDA.realizable_decomp {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} {s₁ s₂ : SurfaceCfg k StackSym State input} {d : ℕ} (hd : 2 ≤ d) :
    M.Realizable input s₁ s₂ d ↔ (∃ (γ : StackSym) (s' : SurfaceCfg k StackSym State input) (s'' : SurfaceCfg k StackSym State input), M.PushStep s₁ γ s' ∧ M.Realizable input s' s'' (d - 2) ∧ M.PopStep s'' γ s₁.topSym s₂) ∨ ∃ (s_mid : SurfaceCfg k StackSym State input) (d₁ : ℕ) (d₂ : ℕ), 0 < d₁ ∧ 0 < d₂ ∧ d₁ + d₂ = d ∧ M.Realizable input s₁ s_mid d₁ ∧ M.Realizable input s_mid s₂ d₂

    Surface-pair realizability decomposition (Ruzzo / Venkateswaran): for d ≥ 2, a surface pair (s₁, s₂) is realizable in d steps iff it either splits as a matched push-pop pair wrapping a (d - 2)-step realizable pair, or splits at an intermediate surface configuration s_mid with positive sublengths d₁ + d₂ = d.

    theorem Turing.AuxPDA.accepts_iff_exists_realizable_of_emptyStackHalt {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} (hempty : ∀ (p : M.ComputationPath input), p.last.Halted → p.last.stack = []) :
    M.Accepts input ↔ ∃ (s_acc : SurfaceCfg k StackSym State input) (d : ℕ), s_acc.IsAccepting ∧ s_acc.topSym = none ∧ M.Realizable input (M.initSurface input) s_acc d

    When every halted computation path of M ends with an empty stack, acceptance is equivalent to realizability from initSurface to some empty-stack accepting surface configuration.

    Empty-stack halting normalization #

    def Turing.AuxPDA.withEmptyStackHalt {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {Symbol : Type u_3} (M : AuxPDA k Symbol StackSym State) :
    AuxPDA k Symbol StackSym (Option State)

    Normalize an AuxPDA so every halted computation path ends with an empty stack: add one stack-draining state (none : Option State) entered whenever the original machine would halt, popping until the stack is empty without moving any tape heads or emitting output.

    theorem Turing.AuxPDA.withEmptyStackHalt_halted_stack_nil {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {Symbol : Type u_3} {input : List Symbol} {M : AuxPDA k Symbol StackSym State} (p : M.withEmptyStackHalt.ComputationPath input) (hhalt : p.last.Halted) :

    Every halted computation path of M.withEmptyStackHalt has an empty stack.

    theorem Turing.AuxPDA.withEmptyStackHalt_runsInSpace {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {Symbol : Type u_3} {input : List Symbol} {s : ℕ} {M : AuxPDA k Symbol StackSym State} (h : M.RunsInSpace input s) :

    withEmptyStackHalt preserves work-tape space bounds identically.

    theorem Turing.AuxPDA.withEmptyStackHalt_runsInTime {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {Symbol : Type u_3} {input : List Symbol} {t : ℕ} {M : AuxPDA k Symbol StackSym State} (h : M.RunsInTime input t) :

    withEmptyStackHalt preserves all-branches time bounds with at most 2 * t + 1 steps.

    theorem Turing.AuxPDA.withEmptyStackHalt_accepts_iff {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} {M : AuxPDA k Bool StackSym State} :

    withEmptyStackHalt preserves acceptance exactly.

    Finiteness and polynomial cardinality of surface configurations #

    def Turing.AuxPDA.surfaceCfgBound (StackSym : Type u_3) (State : Type u_4) [Fintype StackSym] [Fintype State] (k n s : ℕ) :

    Upper bound on the number of surface configurations of a k-tape binary AuxPDA on an input of length n whose work-tape storage fits in per-tape windows of total size s.

    theorem Turing.AuxPDA.encard_surfaceCfg_fitsIn_le {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} [Fintype StackSym] [Fintype State] {w : Fin k → ℕ} {s : ℕ} (hsum : ∑ i : Fin k, w i ≤ s) :
    {sc : SurfaceCfg k StackSym State input | sc.storage.FitsIn w}.encard ≤ ↑(surfaceCfgBound StackSym State k input.length s)

    Surface configurations whose storage fits in per-tape windows w with ∑ i, w i ≤ s have cardinality at most surfaceCfgBound StackSym State k input.length s.

    theorem Turing.AuxPDA.encard_reachable_surfaceCfg_le {k : ℕ} {StackSym : Type u_1} {State : Type u_2} {input : List Bool} [Fintype StackSym] [Fintype State] {M : AuxPDA k Bool StackSym State} {s : ℕ} (hs : M.RunsInSpace input s) :
    (Set.range fun (p : M.ComputationPath input) => p.last.surface).encard ≤ ↑(surfaceCfgBound StackSym State k input.length (k * s))

    Under work-tape space bound s, at most surfaceCfgBound StackSym State k n (k * s) surface configurations are reachable from the initial configuration (regardless of stack height).

    theorem Turing.AuxPDA.encard_reachable_surfaceCfg_le_pow {k : ℕ} {StackSym : Type u_1} {State : Type u_2} [Finite StackSym] [Finite State] (M : AuxPDA k Bool StackSym State) :
    ∃ (a : ℕ) (c : ℕ), ∀ (input : List Bool) (s : ℕ), M.RunsInSpace input s → (Set.range fun (p : M.ComputationPath input) => p.last.surface).encard ≤ (↑input.length + 2) * ↑a * 2 ^ (c * s)

    Exponential form: the number of reachable surface configurations under work space s is at most (n + 2) * a * 2 ^ (c * s) with constants a, c depending only on k, StackSym, and State.

    theorem Turing.AuxPDA.surfaceCfgBound_log_polynomiallyBounded {StackSym : Type u_1} {State : Type u_2} [Fintype StackSym] [Fintype State] (k c : ℕ) :
    Cslib.PolynomiallyBounded fun (n : ℕ) => surfaceCfgBound StackSym State k n (k * (c * (n.log2 + 1)))

    Polynomial surface-configuration bound in logarithmic space: for s(n) = c * (log₂ n + 1), the surface-configuration bound surfaceCfgBound StackSym State k n (k * s n) is polynomially bounded in n.