OAI/Computability/Superstring/Instructions.lean
33 declarations, 0 contain sorry, 0 declared as axioms
- abbrev
OAI.Superstring.BitCode.Storeline 7 - inductive
OAI.Superstring.BitCode.Instrline 11Source documentation
A finite-control bit-stack instruction. There is no unbounded internal state and no operation on an entire stack other than one push/pop/peek.
inductive Instr (K L : Type) | push (k : K) (b : Bool) (next : L) | pop (k : K) (next : L) | branch (k : K) (empty low high : L) | jump (next : L) namespace Instr
- def
OAI.Superstring.BitCode.Instr.mapline 19 - def
OAI.Superstring.BitCode.Instr.runline 25 - theorem
OAI.Superstring.BitCode.Instr.run_mapline 34 - def
OAI.Superstring.BitCode.Instr.emitline 43 - theorem
OAI.Superstring.BitCode.Instr.finish_stepline 56 - theorem
OAI.Superstring.BitCode.Instr.emit_stepline 61 - inductive
OAI.Superstring.BitCode.Blockline 77Source documentation
Structured bit-stack code. Loops are ordinary operational loops, not unbounded-cost primitives. Their iteration count is charged in
Exec.inductive Block (K : Type) | push (k : K) (b : Bool) | pop (k : K) | skip | branch (k : K) (empty low high : Block K) | seq (first second : Block K) | loop (k : K) (body : Block K) namespace Block
- def
OAI.Superstring.BitCode.Block.Labelline 87 - instance
OAI.Superstring.BitCode.Block.labelFintypeline 93 - instance
OAI.Superstring.BitCode.Block.labelDecidableEqline 108 - def
OAI.Superstring.BitCode.Block.startline 123 - def
OAI.Superstring.BitCode.Block.codeline 129 - inductive
OAI.Superstring.BitCode.Stepsline 157Source documentation
Exact execution in the finite-control graph, stopping before a halt label is stepped. This is a finite trace, not an oracle for a computation.
inductive Steps {L : Type} (code : L → Instr K (Option L)) : (Option L × Store K) → ℕ → (Option L × Store K) → Prop | refl (c) : Steps code c 0 c | step (l : L) (s : Store K) {n d} (h : Steps code ((code l).run s) n d) : Steps code (some l, s) (n + 1) d namespace Steps variable {L M : Type} {code : L → Instr K (Option L)}Mentions: OAI.Superstring.BitCode.Instr, OAI.Superstring.BitCode.Store
- theorem
OAI.Superstring.BitCode.Steps.transline 167 - theorem
OAI.Superstring.BitCode.Steps.mapline 173 - inductive
OAI.Superstring.BitCode.Block.Execline 191Source documentation
Big-step semantics with the exact number of primitive bit instructions.
inductive Exec : Block K → Store K → Store K → ℕ → Prop | push (k b s) : Exec (.push k b) s (Function.update s k (b :: s k)) 1 | pop (k s) : Exec (.pop k) s (Function.update s k (s k).tail) 1 | skip (s) : Exec .skip s s 1 | branch_none {k a b c s t n} (h : (s k).head? = none) (run : Exec a s t n) : Exec (.branch k a b c) s t (n + 1) | branch_false {k a b c s t n} (h : (s k).head? = some false) (run : Exec b s t n) : Exec (.branch k a b c) s t (n + 1) | branch_true {k a b c s t n} (h : (s k).head? = some true) (run : Exec c s t n) : Exec (.branch k a b c) s t (n + 1) | seq {a b s t u m n} (first : Exec a s t m) (second : Exec b t u n) : Exec (.seq a b) s u (m + n) …Mentions: OAI.Superstring.BitCode.Block, OAI.Superstring.BitCode.Store
- theorem
OAI.Superstring.BitCode.Block.exec_stepsline 207 - def
OAI.Superstring.BitCode.Block.machineline 251 - def
OAI.Superstring.BitCode.Block.packline 262 - theorem
OAI.Superstring.BitCode.Block.steps_iterateline 265 - def
OAI.Superstring.BitCode.Block.exec_machineline 275 - def
OAI.Superstring.BitCode.singleline 290Source documentation
A single populated stack: the exact Mathlib initial/final convention.
def single (k : K) (w : List Bool) : Store K := fun j => if j = k then w else [] …
Mentions: OAI.Superstring.BitCode.Store
- theorem
OAI.Superstring.BitCode.Block.init_eqline 294 - theorem
OAI.Superstring.BitCode.Block.halt_eqline 304 - def
OAI.Superstring.BitCode.Block.certificateline 315Source documentation
Execution with a polynomial clock gives a polynomial-time TM2 certificate.
noncomputable def certificate [Fintype K] {α β : Type} (ea : α → List Bool) (eb : β → List Bool) (f : α → β) (b : Block K) (i o : K) (P : Polynomial ℕ) (correct : ∀ a, ∃ n, n ≤ P.eval (ea a).length ∧ b.Exec (single i (ea a)) (single o (eb (f a))) n) : Turing.TM2ComputableInPolyTime ea eb f where …Mentions: OAI.Superstring.BitCode.Block, OAI.Superstring.BitCode.single
- theorem
OAI.Superstring.BitCode.Block.certificate_finiteline 339 - def
OAI.Superstring.BitCode.sizeline 352 - theorem
OAI.Superstring.BitCode.size_updateline 354 - theorem
OAI.Superstring.BitCode.size_pushline 369 - theorem
OAI.Superstring.BitCode.size_popline 375 - theorem
OAI.Superstring.BitCode.Block.Exec.size_leline 383Source documentation
Every actually executed primitive bit instruction increases total stored length by at most one; branch tests and iterations do not hide bulk operations.
theorem Block.Exec.size_le {b : Block K} {s t : Store K} {n : ℕ} (h : b.Exec s t n) : size t ≤ size s + n := by …Mentions: OAI.Superstring.BitCode.Block, OAI.Superstring.BitCode.Store, OAI.Superstring.BitCode.size