OAI/Computability/WLIdentification/WordExpressions.lean
20 declarations, 0 contain sorry, 0 declared as axioms
- inductive
OAI.WLIdentification.WordExpressions.Exprline 11Source documentation
A finite, first-order word language. Loops capture a word length; their body sees both a unary iteration index and the previous accumulator.
inductive Expr : ℕ → Type where …
- def
OAI.WLIdentification.WordExpressions.Expr.stagesline 22 - def
OAI.WLIdentification.WordExpressions.Expr.evalline 26 - def
OAI.WLIdentification.WordExpressions.Expr.Boundedline 38 - theorem
OAI.WLIdentification.WordExpressions.Expr.length_leline 52 - def
OAI.WLIdentification.WordExpressions.Expr.codeline 80Source documentation
The result register is separate from immutable inputs; all temporary register numbers are at least
baseand are cleared before return.def code : {n : ℕ} → Expr n → (Fin n → ℕ) → ℕ → ℕ → StackModel.Command ℕ (Option Bool) | _, .var i, env, out, base => copy (env i) out base | _, .nil, _, out, _ => clear out | _, .snoc e b, env, out, base => .seq (e.code env out base) (.push out (fun _ => b)) | _, .drop e, env, out, base => .seq (e.code env out base) (.pop out (fun _ _ => none)) | _, .cases e p q r, env, out, base => .seq (e.code env base (base+1)) (.seq (StackModel.Command.read base) (.seq (.branch Option.isSome (.branch (fun x => x.getD false) (r.code env out (base+1)) (q.code env out (base+1))) (p.code env out (base+1))) (clear base))) | _, .bind e f, env, out, base => …Mentions: OAI.WLIdentification.WordExpressions.Expr, OAI.WLIdentification.StackModel.Command, OAI.WLIdentification.StackModel.Command.read
- def
OAI.WLIdentification.WordExpressions.Expr.costline 103 - theorem
OAI.WLIdentification.StackModel.Command.drain_indexedline 118Source documentation
General indexed captured-count iteration, preserving an arbitrary counter prefix during each body execution.
theorem drain_indexed (body : Command K (Option Bool)) (counter : K) (X : ℕ → K → Word) (hX : ∀ i, X i counter = []) (cost start : ℕ) (w : Word) (hbody : ∀ i, start ≤ i → i < start+w.length → ∀ v s, ∃ t ≤ cost, Exec body s (Function.update (X i) counter v) none (Function.update (X (i+1)) counter v) t) (s : Option Bool) : ∃ n ≤ (cost+2)*w.length+2, Exec (drain counter body) s (Function.update (X start) counter w) none (X (start+w.length)) n := by …Mentions: OAI.WLIdentification.StackModel.Command, OAI.WLIdentification.Word, OAI.WLIdentification.StackModel.Command.Exec, OAI.WLIdentification.StackModel.Command.drain
- def
OAI.WLIdentification.WordExpressions.Expr.Cleanline 165 - theorem
OAI.WLIdentification.WordExpressions.Expr.Clean.monoline 167 - theorem
OAI.WLIdentification.WordExpressions.Expr.Clean.updateline 170 - theorem
OAI.WLIdentification.WordExpressions.Expr.update_cleanline 175 - def
OAI.WLIdentification.WordExpressions.Expr.Correctline 178 - theorem
OAI.WLIdentification.WordExpressions.Expr.correct_varline 185 - theorem
OAI.WLIdentification.WordExpressions.Expr.correct_nilline 199 - theorem
OAI.WLIdentification.WordExpressions.Expr.correct_snocline 204 - theorem
OAI.WLIdentification.WordExpressions.Expr.correct_dropline 211 - theorem
OAI.WLIdentification.WordExpressions.Expr.env_updateline 219Source documentation
An allocated temporary is invisible to the immutable environment.
theorem env_update {n} (S : ℕ → Word) (env : Fin n → ℕ) (base : ℕ) (w : Word) (h : ∀ i, env i < base) : Function.update S base w ∘ env = S ∘ env := by …Mentions: OAI.WLIdentification.Word
- theorem
OAI.WLIdentification.WordExpressions.Expr.snoc_env_updateline 224 - theorem
OAI.WLIdentification.WordExpressions.Expr.correct_bindline 232