OAI/Computability/WLIdentification/BoundedWords.lean
30 declarations, 0 contain sorry, 0 declared as axioms
- inductive
OAI.WLIdentification.BoundedWords.Programline 12Source documentation
Word-register programs with bounded, captured-count loops. No unbounded natural register, whole-input transition or host-language oracle is available.
inductive Program (K : Type) where …
- def
OAI.WLIdentification.BoundedWords.Program.evalline 25 - def
OAI.WLIdentification.BoundedWords.Program.Sizeline 38 - def
OAI.WLIdentification.BoundedWords.Program.Fitsline 42Source documentation
An explicit bound on all data consumed by an execution. Proving this invariant for an algorithm, rather than assuming its runtime, yields a cost.
def Fits : Program K → (K → Word) → ℕ → Prop | .skip, S, B | .clear _, S, B | .push _ _, S, B | .pop _, S, B | .copy _ _, S, B => Size S B | .seq p q, S, B => p.Fits S B ∧ q.Fits (p.eval S) B | .cases k nil zero one, S, B => Size S B ∧ match (S k).getLast? with | none => nil.Fits S B | some false => zero.Fits S B | some true => one.Fits S B | .repeat k p, S, B => Size S B ∧ ∀ i < (S k).length, p.Fits (p.eval^[i] S) BMentions: OAI.WLIdentification.BoundedWords.Program, OAI.WLIdentification.Word, OAI.WLIdentification.BoundedWords.Program.Size
- abbrev
OAI.WLIdentification.BoundedWords.Program.Workline 51 - instance
OAI.WLIdentification.BoundedWords.Program.workFintypeline 58 - instance
OAI.WLIdentification.BoundedWords.Program.workDecidableEqline 60 - def
OAI.WLIdentification.BoundedWords.Program.costline 68 - def
OAI.WLIdentification.BoundedWords.Program.compileline 77 - theorem
OAI.WLIdentification.BoundedWords.Program.cost_polynomialline 97Source documentation
Every syntactic cost is polynomial in the maintained word bound; its constants depend on finite code, not the input or loop counts.
theorem cost_polynomial (p : Program K) : ∃ C d : ℕ, ∀ B, p.cost B ≤ C * (B + 1)^d := by …
- theorem
OAI.WLIdentification.BoundedWords.Program.elim_emptyline 148 - theorem
OAI.WLIdentification.BoundedWords.Program.update_inlline 152 - def
OAI.WLIdentification.BoundedWords.Program.Correctline 159 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_skipline 163 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_clearline 167 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_pushline 173 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_popline 180 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_copyline 187 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_seqline 205 - theorem
OAI.WLIdentification.BoundedWords.Program.correct_casesline 213 - def
OAI.WLIdentification.BoundedWords.Program.counterDataline 284 - def
OAI.WLIdentification.BoundedWords.Program.loopStateline 286 - theorem
OAI.WLIdentification.BoundedWords.Program.loopState_varline 290 - theorem
OAI.WLIdentification.BoundedWords.Program.loopState_counterline 293 - theorem
OAI.WLIdentification.BoundedWords.Program.loopState_templine 296 - theorem
OAI.WLIdentification.BoundedWords.Program.loopState_emptyline 300 - theorem
OAI.WLIdentification.BoundedWords.Program.update_counterline 309 - theorem
OAI.WLIdentification.BoundedWords.Program.drain_repeatline 320Source documentation
The captured counter is consumed one bit per loop, independently of all public registers modified by the body.
theorem drain_repeat {p : Program K} (hp : Correct p) (B : ℕ) (S : K → Word) (w : Word) (hfit : ∀ i < w.length, p.Fits (p.eval^[i] S) B) (s : Option Bool) : ∃ n ≤ (p.cost B + 2) * w.length + 2, Exec (drain (.inr (.inr false)) (p.compile.rename embedLeft)) s (loopState S w) none (loopState (p.eval^[w.length] S) []) n := by …Mentions: OAI.WLIdentification.BoundedWords.Program, OAI.WLIdentification.BoundedWords.Program.Correct, OAI.WLIdentification.Word, OAI.WLIdentification.BoundedWords.Program.loopState
- theorem
OAI.WLIdentification.BoundedWords.Program.correct_repeatline 359 - theorem
OAI.WLIdentification.BoundedWords.Program.correctline 379Source documentation
Fully uniform compilation, with all work stacks again empty at the boundary.
theorem correct (p : Program K) : p.Correct := by …