Download lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.72 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean
-
curl -L -o MachineDrain.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Machines/MachineDrain.lean
2.72 kB
Lean 4 · 4
declarations statementsfull
abbrev Alphabet (_ : K) := Bool def drain (source : K) (again : Λ) (exit : Option Λ) :
TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) := body · 4 lines
.pop source (fun state head => (state.1, head))
(.branch (fun state => state.2.isSome)
(.goto fun _ => again)
(.load (fun state => (state.1, none)) (Reduction.MachineTransfer.exitAt source exit)))theorem drainTrace (source : K) (again : Λ) (exit : Option Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atDrain : program again = drain source again exit)
(base : K → List Bool) (word : List Bool) (ambient : σ) (register : Option Bool) :
(MachineComposition.advance (TM2.step program))^[word.length + 1]
(some ⟨some again, (ambient, register), Function.update base source word⟩) =
some ⟨exit, (ambient, none), Function.update base source []⟩ := by proof · 13 lines
induction word generalizing register with
| nil =>
change some (TM2.stepAux (program again) (ambient, register)
(Function.update base source [])) = _
rw [atDrain]
cases exit <;> simp [drain, TM2.stepAux, Reduction.MachineTransfer.exitAt]
| cons symbol word ih =>
rw [List.length_cons, Function.iterate_succ_apply]
change (MachineComposition.advance (TM2.step program))^[word.length + 1]
(some (TM2.stepAux (program again) (ambient, register)
(Function.update base source (symbol :: word)))) = _
rw [atDrain]
simpa [drain, TM2.stepAux] using ih (some symbol)def drainInTime (source : K) (again : Λ) (exit : Option Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atDrain : program again = drain source again exit)
(base : K → List Bool) (ambient : σ) (register : Option Bool) :
StateTransition.EvalsToInTime (TM2.step program)
⟨some again, (ambient, register), base⟩
(some ⟨exit, (ambient, none), Function.update base source []⟩)
((base source).length + 1) where body · 7 lines
steps := (base source).length + 1
evals_in_steps := by
change (MachineComposition.advance (TM2.step program))^[(base source).length + 1]
(some ⟨some again, (ambient, register), base⟩) = _
simpa only [Function.update_eq_self] using
drainTrace source again exit program atDrain base (base source) ambient register
steps_le_m := Nat.le_refl _Outline