Four canonical outputs from a Nat-pair list and a Nat pair
InductiveStacks of the four-output pair-list decoder#✓fully proved
Two disjoint existing workspaces; the pair buffer also serves the initial outer-frame split and is cleared before normalization starts.
inductive K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
inductive K | input | acc (right : Bool) | output (right : Bool)
| pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:71
inductive K | pair (k : PairSplit.K) | buffer | left | right
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:29
Uses 2 · Used by 10
InductiveControl labels of the four-output pair-list decoder#✓fully proved
The existing split, list projector, and final pair normalizer.
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
inductive Lab | read | copy | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:40
inductive Lab | loop | block | back | pair (l : NatPair.Lab)
| emit (right : Bool) | finish (right : Bool) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:85
inductive Lab | pair (l : PairSplit.Lab)
| norm (second : Bool) (l : NormalizeMachine.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:40
Uses 3 · Used by 9
DefinitionOuter-splitter stack embedding in the four-output decoder#✓fully proved
The outer splitter reuses the final pair's input and empty buffer.
def splitEmb : SEmb (fun _ : PairSplit.K => Bool) (fun _ : K => Bool) where
e
| .input => .pair (.pair .input)
| .left => .items .input
| .scratch => .pair .buffer
inj a b h := by cases a <;> cases b <;> simp_all
ι _ := Equiv.refl Bool
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 K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
e : K → K'
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:53
inj : Injective e
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:55
Uses 5 · Used by 3
DefinitionList-projector stack embedding in the four-output decoder#✓fully proved
The list projector has its own disjoint workspace.
def itemsEmb : SEmb (fun _ : ListNatPair.K => Bool) (fun _ : K => Bool) where
e := K.items
inj _ _ h := K.items.inj h
ι _ := Equiv.refl Bool
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 | acc (right : Bool) | output (right : Bool)
| pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:71
inductive K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
inj : Injective e
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:55
ι : ∀ k, Γ k ≃ Γ' (e k)
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:57
Uses 4 · Used by 3
DefinitionFinal pair-projector stack embedding in the four-output decoder#✓fully proved
The final pair projector has its own disjoint workspace.
def pairEmb : SEmb (fun _ : NatPair.K => Bool) (fun _ : K => Bool) where
e := K.pair
inj _ _ h := K.pair.inj h
ι _ := Equiv.refl Bool
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 | pair (k : PairSplit.K) | buffer | left | right
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:29
inductive K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
inj : Injective e
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:55
ι : ∀ k, Γ k ≃ Γ' (e k)
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:57
Uses 4 · Used by 3
DefinitionLabel map from the outer splitter to the list projector#✓fully proved
Successful outer framing enters the item-list projector.
def splitLabel : PairSplit.Lab → Lab
| .good => .items .loop
| .bad => .bad
| l => .split l
inductive Lab | read | copy | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/PairSplit.lean:40
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
Uses 3 · Used by 3
DefinitionLabel map from the list projector to the final pair decoder#✓fully proved
Successful item projection enters the final pair decoder.
def itemsLabel : ListNatPair.Lab → Lab
| .good => .pair (.pair .read)
| .bad => .bad
| l => .items l
inductive Lab | loop | block | back | pair (l : NatPair.Lab)
| emit (right : Bool) | finish (right : Bool) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:85
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
DefinitionLabel map from final pair halts to the decoder outcomes#✓fully proved
The final pair's actual halts are the whole decoder's outcomes.
def pairLabel : NatPair.Lab → Lab
| .good => .good
| .bad => .bad
| l => .pair l
inductive Lab | pair (l : PairSplit.Lab)
| norm (second : Bool) (l : NormalizeMachine.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:40
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
DefinitionProgram of the four-output pair-list decoder#✓fully proved
The whole finite program is a composition of existing components.
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
inductive K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
def mapS : TM2.Stmt Γ Λ σ → TM2.Stmt Γ' Λ' σ
| .push k f q => .push (E.e k) (fun s => E.ι k (f s)) (mapS q)
| .peek k f q => .peek (E.e k) (fun s o => f s (o.map (E.ι k).symm)) (mapS q)
| .pop k f q => .pop (E.e k) (fun s o => f s (o.map (E.ι k).symm)) (mapS q)
| .load a q => .load a (mapS q)
| .branch f q₁ q₂ => .branch f (mapS q₁) (mapS q₂)
| .goto f => .goto fun s => φ (f s)
| .halt => .halt
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:65
def splitEmb : SEmb (fun _ : PairSplit.K => Bool) (fun _ : K => Bool) where
e
| .input => .pair (.pair .input)
| .left => .items .input
| .scratch => .pair .buffer
inj a b h := by cases a <;> cases b <;> simp_all
ι _ := Equiv.refl Bool
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:49
def splitLabel : PairSplit.Lab → Lab
| .good => .items .loop
| .bad => .bad
| l => .split l
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:70
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 itemsEmb : SEmb (fun _ : ListNatPair.K => Bool) (fun _ : K => Bool) where
e := K.items
inj _ _ h := K.items.inj h
ι _ := Equiv.refl Bool
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:58
def itemsLabel : ListNatPair.Lab → Lab
| .good => .pair (.pair .read)
| .bad => .bad
| l => .items l
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:76
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .loop => .peek .input (fun _ o => o.isSome) <| .branch id
(.goto fun _ => .block) (.goto fun _ => .finish false)
| .block => FramedCNF.Block.read .input (.pair (.pair .scratch))
some id .block .back .bad
| .back => moveB (.pair (.pair .scratch)) (.pair (.pair .input))
some id .back (.pair (.pair .read))
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .emit right => emitFrame
(if right then .pair .right else .pair .left) (.acc right)
some id (.emit right) (if right then .loop else .emit true)
| .finish right => moveB (.acc right) (.output right) some id
⋯
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:111
def pairEmb : SEmb (fun _ : NatPair.K => Bool) (fun _ : K => Bool) where
e := K.pair
inj _ _ h := K.pair.inj h
ι _ := Equiv.refl Bool
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:64
def pairLabel : NatPair.Lab → Lab
| .good => .good
| .bad => .bad
| l => .pair l
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:82
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .pair l => mapS pairEmb pairLabel (PairSplit.prog l)
| .norm s l => mapS (normEmb s) (normLabel s) (NormalizeMachine.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:84
Uses 18 · Used by 5
DefinitionStack invariant of the four-output pair-list decoder#✓fully proved
Exact raw-field and four-output invariant, with empty private scratch.
At entry the item field is empty and the entire raw input is pairRaw.
def st (itemsRaw pairRaw weights values capacity threshold : List Bool) :
K → List Bool
| .items k => ListNatPair.st itemsRaw [] [] weights values
(NatPair.st [] [] [] [] [] []) k
| .pair k => NatPair.st pairRaw [] [] [] capacity threshold k
inductive K | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
def st (input aw av ow ov : List Bool) (P : NatPair.K → List Bool) :
K → List Bool
| .input => input
| .acc right => if right then av else aw
| .output right => if right then ov else ow
| .pair k => P k
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:127
def st (input first scratch buffer left right : List Bool) : K → List Bool
| .pair .input => input
| .pair .left => first
| .pair .scratch => scratch
| .buffer => buffer
| .left => left
| .right => right
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:90
TheoremFour-output decoder emits four canonical outputs on success#✓fully proved
The entire raw decoder emits four canonical outputs, preserving caller suffixes and emptying all input and private scratch on success.
theorem run_some {x : List Bool} {as : List (Nat × Nat)} {c t : Nat}
(h : bitDecode x = some (as, (c, t)))
(weights values capacity threshold : List Bool) (v : Bool) :
∃ w, RunLe prog (9 * x.length + 2)
⟨some (.split .read), v, st [] x weights values capacity threshold⟩
⟨some .good, w,
st [] [] (bitEncode (as.map Prod.fst) ++ weights)
(bitEncode (as.map Prod.snd) ++ values)
(Computability.encodeNat c ++ capacity)
(Computability.encodeNat t ++ threshold)⟩
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
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:88
def st (itemsRaw pairRaw weights values capacity threshold : List Bool) :
K → List Bool
| .items k => ListNatPair.st itemsRaw [] [] weights values
(NatPair.st [] [] [] [] [] []) k
| .pair k => NatPair.st pairRaw [] [] [] capacity threshold k
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:96
def bitEncode [BitstringEncoding α] (a : α) : List Bool := toEncoding.encode a
MathlibExt/Computability/Complexity.lean:55
Uses 44 · Used by 1
TheoremFour-output decoder output is at most twice the input length#✓fully proved
The combined newly emitted output size is at most twice raw input length, independently of decoded magnitudes and caller output suffixes.
theorem output_length_le {x : List Bool} {as : List (Nat × Nat)} {c t : Nat}
(h : bitDecode x = some (as, (c, t))) :
(bitEncode (as.map Prod.fst)).length +
(bitEncode (as.map Prod.snd)).length +
(Computability.encodeNat c).length +
(Computability.encodeNat t).length ≤ 2 * x.length
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
def bitEncode [BitstringEncoding α] (a : α) : List Bool := toEncoding.encode a
MathlibExt/Computability/Complexity.lean:55
Uses 11
TheoremFour-output decoder fails on malformed input#✓fully proved
Every failed raw decode reaches bad within the same whole-input
bound. Failed owned workspace can be partial and must be discarded
or cleared.
theorem run_none {x : List Bool}
(h : bitDecode (α := List (Nat × Nat) × (Nat × Nat)) x = none)
(weights values capacity threshold : List Bool) (v : Bool) :
∃ w S, RunLe prog (9 * x.length + 2)
⟨some (.split .read), v, st [] x weights values capacity threshold⟩
⟨some .bad, w, S⟩
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
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:88
def st (itemsRaw pairRaw weights values capacity threshold : List Bool) :
K → List Bool
| .items k => ListNatPair.st itemsRaw [] [] weights values
(NatPair.st [] [] [] [] [] []) k
| .pair k => NatPair.st pairRaw [] [] [] capacity threshold k
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:96
Uses 46 · Used by 1
AbbreviationFour-output pair-list decoder as a host component#✓fully proved
The fixed seventeen-stack decoder in the existing Host interface.
Cslib.Complexity.PolynomialEncoding.ListNatPairPair.component · 15 lines
abbrev component : Host.Comp where
K := K
Γ := fun _ => Bool
L := Lab
prog := prog
ks := ListNatPair.component.ks.map K.items ++ NatPair.component.ks.map K.pair
ks_nodup := by decide
mem_ks k := by
simp only [List.mem_append]
cases k with
| items k =>
exact Or.inl (List.mem_map.mpr
⟨k, ListNatPair.component.mem_ks k, rfl⟩)
| pair k =>
exact Or.inr (List.mem_map.mpr ⟨k, NatPair.component.mem_ks k, rfl⟩)
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 | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
def prog : Lab → TM2.Stmt (fun _ : K => Bool) Lab Bool
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:88
abbrev component : Host.Comp where
K := K
Γ := fun _ => Bool
L := Lab
prog := prog
ks := [.input, .acc false, .acc true, .output false, .output true,
.pair (.pair .input), .pair (.pair .left), .pair (.pair .scratch),
.pair .buffer, .pair .left, .pair .right]
ks_nodup := by decide
mem_ks k := by
cases k with
| input => decide
⋯
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPair.lean:469
abbrev component : Host.Comp where
K := K
Γ := fun _ => Bool
L := Lab
prog := prog
ks := [.pair .input, .pair .left, .pair .scratch, .buffer, .left, .right]
ks_nodup := by decide
mem_ks k := by
rcases k with k | _ | _ | _ <;> try decide
cases k <;> decide
CSLibExt/Computability/Complexity/PolynomialEncoding/NatPair.lean:233
Uses 13
TheoremFour-output decoder reaches exactly the canonical decoding outcome#✓fully proved
Total raw decoder contract with four output suffixes. Exactly the canonical decoder's success/failure label is reached, with empty scratch on success.
theorem run (x weights values capacity threshold : List Bool) (v : Bool) :
∃ w S, RunLe prog (9 * x.length + 2)
⟨some (.split .read), v, st [] x weights values capacity threshold⟩
⟨some (if (bitDecode (α := List (Nat × Nat) × (Nat × Nat)) x).isSome
then .good else .bad), w, S⟩ ∧
∀ (as : List (Nat × Nat)) (c t : Nat),
bitDecode x = some (as, (c, t)) →
S = st [] [] (bitEncode (as.map Prod.fst) ++ weights)
(bitEncode (as.map Prod.snd) ++ values)
(Computability.encodeNat c ++ capacity)
(Computability.encodeNat t ++ threshold)
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
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:88
def st (itemsRaw pairRaw weights values capacity threshold : List Bool) :
K → List Bool
| .items k => ListNatPair.st itemsRaw [] [] weights values
(NatPair.st [] [] [] [] [] []) k
| .pair k => NatPair.st pairRaw [] [] [] capacity threshold k
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:96
def bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
def bitEncode [BitstringEncoding α] (a : α) : List Bool := toEncoding.encode a
MathlibExt/Computability/Complexity.lean:55
Uses 19 · Used by 1
TheoremEmbedded four-output decoder preserves outside stacks#✓fully proved
Embedded execution preserves every outside stack on both outcomes. Successful output suffixes survive and private scratch is empty. Failed workspace may be partial. Callers establish continuation-label separation.
Cslib.Complexity.PolynomialEncoding.ListNatPairPair.run_embedded · 16 lines
theorem run_embedded {J L : Type} [DecidableEq J] {Γ : J → Type}
(E : SEmb (fun _ : K => Bool) Γ) (φ : Lab → L)
{M : L → TM2.Stmt Γ L Bool} (hm : Embeds E φ prog M)
(x weights values capacity threshold : List Bool) (v : Bool)
(S : ∀ j, List (Γ j))
(hs : Agree E (st [] x weights values capacity threshold) S) :
∃ w T, RunLe M (9 * x.length + 2)
⟨some (φ (.split .read)), v, S⟩
⟨some (φ (if (bitDecode (α := List (Nat × Nat) × (Nat × Nat)) x).isSome
then .good else .bad)), w, T⟩ ∧ Frame E S T ∧
∀ (as : List (Nat × Nat)) (c t : Nat),
bitDecode x = some (as, (c, t)) →
Agree E (st [] [] (bitEncode (as.map Prod.fst) ++ weights)
(bitEncode (as.map Prod.snd) ++ values)
(Computability.encodeNat c ++ capacity)
(Computability.encodeNat t ++ threshold)) 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 | items (k : ListNatPair.K) | pair (k : NatPair.K)
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:31
inductive Lab | split (l : PairSplit.Lab) | items (l : ListNatPair.Lab)
| pair (l : NatPair.Lab) | good | bad
deriving DecidableEq
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:39
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
| .split l => mapS splitEmb splitLabel (PairSplit.prog l)
| .items l => mapS itemsEmb itemsLabel (ListNatPair.prog l)
| .pair l => mapS pairEmb pairLabel (NatPair.prog l)
| .good | .bad => .halt
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:88
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 (itemsRaw pairRaw weights values capacity threshold : List Bool) :
K → List Bool
| .items k => ListNatPair.st itemsRaw [] [] weights values
(NatPair.st [] [] [] [] [] []) k
| .pair k => NatPair.st pairRaw [] [] [] capacity threshold k
CSLibExt/Computability/Complexity/PolynomialEncoding/ListNatPairPair.lean:96
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 bitDecode [BitstringEncoding α] (l : List Bool) : Option α := toEncoding.decode l
MathlibExt/Computability/Complexity.lean:58
def Frame (S' S'' : ∀ k', List (Γ' k')) : Prop :=
∀ k', (∀ k, E.e k ≠ k') → S'' k' = S' k'
MathlibExt/Computability/TuringMachine/StackEmbedding.lean:84
def bitEncode [BitstringEncoding α] (a : α) : List Bool := toEncoding.encode a
MathlibExt/Computability/Complexity.lean:55
Uses 23
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.