Raw projection of the canonical pair frame
InductiveStacks of the raw pair-frame splitter#✓fully proved
The original input becomes the second field; left holds the first.
inductive K | input | left | scratch
deriving DecidableEq
Used by 35
InductiveControl labels of the raw pair-frame splitter#✓fully proved
Read one frame, restore its order, then report success or failure.
inductive Lab | read | copy | good | bad
deriving DecidableEq
Used by 32
DefinitionProgram of the raw pair-frame splitter#✓fully proved
Pair framing is split using the existing delimiter and move kernels.
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
inductive Lab | read | copy | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:40
inductive K | input | left | scratch
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:32
def read (a b : K) (d : Γ a → Option Bool) (g : Bool → Γ b)
(self good bad : Λ) : TM2.Stmt Γ Λ Bool :=
.peek a (fun _ o => isBit d o) <| .branch id
(.pop a (fun _ o => bitOf d o) <| .branch id
(.peek a (fun _ o => isBit d o) <| .branch id
(.pop a (fun _ o => bitOf d o) <| .push b g <|
.goto fun _ => self)
(.goto fun _ => bad))
(.goto fun _ => good))
(.goto fun _ => bad)
CSLibExt/Computability/Complexity/FramedCNF/Block.lean:32
def moveB (a b : K) (d : Γ a → Option Bool) (g : Bool → Γ b) (self next : Λ) :
TM2.Stmt Γ Λ σ :=
.peek a (fun _ o => Flag.tag (isBit d o))
(.branch Flag.untag
(.pop a (fun _ o => Flag.tag (bitOf d o))
(.branch Flag.untag
(.push b (fun _ => g true) (.goto fun _ => self))
(.push b (fun _ => g false) (.goto fun _ => self))))
(.goto fun _ => next))
MathlibExt/Computability/TuringMachine/BitOps.lean:86
Uses 5 · Used by 13
DefinitionStack layout of the raw pair-frame splitter#✓fully proved
Explicit stack layout of the projection invariant.
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
inductive K | input | left | scratch
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:32
Uses 1 · Used by 10
TheoremPair-frame splitter extracts both raw fields#✓fully proved
Extract both raw fields, restore first-field order, and clear scratch in exactly two steps per first-field bit plus two.
theorem run_delimit (p r out : List Bool) (v : Bool) :
∃ v', Run prog (2 * p.length + 2)
⟨some .read, v, st (delimit p ++ r) out []⟩
⟨some .good, v', st r (p ++ out) []⟩
def Run (n : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
(flip bind (TM2.step M))^[n] (some c) = some d
MathlibExt/Computability/TuringMachine/Program.lean:84
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
def delimit : List Bool → List Bool
| [] => [false]
| b :: l => true :: b :: delimit l
MathlibExt/Computability/Complexity.lean:68
Uses 9 · Used by 4
TheoremPair-frame splitter projects every well-framed input in linear time#✓fully proved
Every successful raw pair frame is projected within input length plus one; its two payloads are left unnormalized.
theorem run_some {x p r : List Bool}
(h : undelimit x = some (p, r)) (out : List Bool) (v : Bool) :
∃ v', RunLe prog (x.length + 1)
⟨some .read, v, st x out []⟩
⟨some .good, v', st r (p ++ out) []⟩
def undelimit : List Bool → Option (List Bool × List Bool)
| false :: rest => some ([], rest)
| true :: b :: input => (undelimit input).map fun p => (b :: p.1, p.2)
| _ => none
MathlibExt/Computability/Complexity.lean:74
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
Uses 10 · Used by 2
TheoremPair-frame splitter fails on malformed first-field framing#✓fully proved
Malformed first-field framing reaches the actual failure label. Scratch may contain a partial field and must be cleared before reuse.
theorem run_none {x : List Bool} (h : undelimit x = none)
(out : List Bool) (v : Bool) :
∃ v' S, RunLe prog (x.length + 1)
⟨some .read, v, st x out []⟩ ⟨some .bad, v', S⟩
def undelimit : List Bool → Option (List Bool × List Bool)
| false :: rest => some ([], rest)
| true :: b :: input => (undelimit input).map fun p => (b :: p.1, p.2)
| _ => none
MathlibExt/Computability/Complexity.lean:74
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
AbbreviationRaw pair-frame splitter as a host component#✓fully proved
The finite component interface used by fixed nested-codec callers.
abbrev component : Host.Comp where
K := K
Γ := fun _ => Bool
L := Lab
prog := prog
ks := [.input, .left, .scratch]
ks_nodup := by decide
mem_ks k := by cases k <;> decide
structure Comp where
/-- Stack indices. -/
K : Type
/-- Decidable equality of stack indices. -/
[decK : DecidableEq K]
/-- Finitely many stacks. -/
[finK : Fintype K]
/-- Stack alphabets. -/
Γ : K → Type
/-- Finite alphabets. -/
[finΓ : ∀ k, Fintype (Γ k)]
/-- Labels. -/
⋯
CSLibExt/Computability/Complexity/Host.lean:53
inductive K | input | left | scratch
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:32
inductive Lab | read | copy | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:40
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
TheoremRaw field projection agrees with the pair decoder#✓fully proved
Raw field projection agrees with the existing pair decoder. This is not a runtime assumption or implementation of either element codec.
theorem run_decoded {α β : Type}
[MetaMathlibExt.BitstringEncoding α] [MetaMathlibExt.BitstringEncoding β]
{x : List Bool} {a : α} {b : β} (h : bitDecode x = some (a, b))
(v : Bool) :
∃ p r v', RunLe prog (x.length + 1)
⟨some .read, v, st x [] []⟩ ⟨some .good, v', st r p []⟩ ∧
bitDecode p = some a ∧ bitDecode r = some b
class BitstringEncoding α extends Computability.Encoding α Bool
MathlibExt/Computability/Complexity.lean:48
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
Uses 14
TheoremPair-frame splitter reaches the framing outcome#✓fully proved
Total framing outcome, without prematurely accepting either field as a value of its eventual element type.
theorem run (x : List Bool) (v : Bool) :
∃ v' S, RunLe prog (x.length + 1)
⟨some .read, v, st x [] []⟩
⟨some (if (undelimit x).isSome then .good else .bad), v', S⟩ ∧
∀ p r, undelimit x = some (p, r) → S = st r p []
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
def undelimit : List Bool → Option (List Bool × List Bool)
| false :: rest => some ([], rest)
| true :: b :: input => (undelimit input).map fun p => (b :: p.1, p.2)
| _ => none
MathlibExt/Computability/Complexity.lean:74
Uses 8 · Used by 1
TheoremEmbedded pair-frame splitter preserves caller stacks#✓fully proved
Embedded projection preserves all caller stacks outside the three-stack workspace, even when framing fails.
theorem run_embedded {J L : Type} [DecidableEq J] {Γ : J → Type}
(E : MetaMathlibExt.TM2Embedding.SEmb (fun _ : K => Bool) Γ)
(φ : Lab → L) {M : L → TM2.Stmt Γ L Bool}
(hm : MetaMathlibExt.TM2Embedding.Embeds E φ prog M)
(x : List Bool) (v : Bool) (S : ∀ j, List (Γ j))
(hs : MetaMathlibExt.TM2Embedding.Agree E (st x [] []) S) :
∃ v' T, RunLe M (x.length + 1)
⟨some (φ .read), v, S⟩
⟨some (φ (if (undelimit x).isSome then .good else .bad)), v', T⟩ ∧
MetaMathlibExt.TM2Embedding.Frame E S T ∧
∀ p r, undelimit x = some (p, r) →
MetaMathlibExt.TM2Embedding.Agree E (st r p []) T
structure SEmb {K K' : Type} (Γ : K → Type) (Γ' : K' → Type) where
/-- The stack renaming. -/
e : K → K'
/-- Distinct sub-machine stacks go to distinct host stacks. -/
inj : Injective e
/-- The alphabet of each sub-machine stack, identified with its host stack's. -/
ι : ∀ k, Γ k ≃ Γ' (e k)
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:51
inductive K | input | left | scratch
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:32
inductive Lab | read | copy | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:40
def Embeds (M : Λ → TM2.Stmt Γ Λ σ) (M' : Λ' → TM2.Stmt Γ' Λ' σ) : Prop :=
∀ l, M' (φ l) = mapS E φ (M l) ∨ M l = .halt
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:76
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .read => Block.read .input .scratch some id .read .copy .bad
| .copy => moveB .scratch .left some id .copy .good
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:48
def Agree (S : ∀ k, List (Γ k)) (S' : ∀ k', List (Γ' k')) : Prop :=
∀ k, S' (E.e k) = (S k).map (E.ι k)
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:80
def st (input left scratch : List Bool) : K → List Bool
| .input => input
| .left => left
| .scratch => scratch
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:54
def RunLe (M : Λ → TM2.Stmt Γ Λ σ) (B : ℕ) (c d : TM2.Cfg Γ Λ σ) : Prop :=
∃ n, n ≤ B ∧ Run M n c d
MathlibExt/Computability/TuringMachine/Program.lean:901
def undelimit : List Bool → Option (List Bool × List Bool)
| false :: rest => some ([], rest)
| true :: b :: input => (undelimit input).map fun p => (b :: p.1, p.2)
| _ => none
MathlibExt/Computability/Complexity.lean:74
def Frame (S' S'' : ∀ k', List (Γ' k')) : Prop :=
∀ k', (∀ k, E.e k ≠ k') → S'' k' = S' k'
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:84
Uses 12
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.