openAI-math-dataset / lean /OAI /Combinatorics /IndependentSets /Expansion /PoweringInitializeFrame.lean
Download lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 7.24 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean
-
curl -L -o PoweringInitializeFrame.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Combinatorics/IndependentSets/Expansion/PoweringInitializeFrame.lean
7.24 kB
Lean 4 · 19
declarations statementsfull
def initialExtra (graph : PortTables.Table vertices d) (n : Nat) :
PoweringMachineInitialize.ExtraTape (PoweringMachineRowBody.capacity n) → List Bool := body · 2 lines
fun tape => if tape = .inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n))
then PortTables.tableBits graph else []@[simp] theorem initialExtra_table (graph : PortTables.Table vertices d) (n : Nat) :
initialExtra graph n (.inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n))) =
PortTables.tableBits graph := by simp [initialExtra] theorem initialExtra_other (graph : PortTables.Table vertices d) (n : Nat)
(tape : PoweringMachineInitialize.ExtraTape (PoweringMachineRowBody.capacity n))
(hne : tape ≠ .inl (PoweringMachineTapes.table (PoweringMachineRowBody.capacity n))) :
initialExtra graph n tape = [] := by simp [initialExtra, hne] @[simp] theorem initialExtra_scratch (graph : PortTables.Table vertices d) (n : Nat) :
initialExtra graph n
(.inl (PoweringMachineTapes.scratch (PoweringMachineRowBody.capacity n))) = [] := by proof · 1 line
simp [initialExtra, PoweringMachineTapes.table, PoweringMachineTapes.scratch]def preparedTapes (graph : PortTables.Table vertices d) (n : Nat) :
PoweringMachineGlobal.Tape n → List Bool := body · 3 lines
PoweringMachineInitialize.mergeTapes
(PoweringMachineLoop.finalTapes (PoweringTableLayout.blockSize d n) vertices [])
(initialExtra graph n)theorem prepared_commonRole (graph : PortTables.Table vertices d) (n : Nat)
(j : Fin 11) (hne : j ≠ 1) :
preparedTapes graph n (PoweringMachineGlobal.placement n (.inl j)) =
if j = 0 then PortTables.tableBits graph else [] := by proof · 3 lines
simp [preparedTapes, PoweringMachineGlobal.placement,
PoweringMachineInitialize.commonPlacement, PoweringMachineTapes.start,
PoweringMachineInitialize.mergeTapes, initialExtra, PoweringMachineTapes.table, hne]theorem prepared_ready (graph : PortTables.Table vertices d) (n : Nat) :
PoweringMachineOuterLoop.Ready graph n (PoweringMachineGlobal.placement n)
(preparedTapes graph n) := by proof · 6 lines
constructor
· simpa using prepared_commonRole graph n 0 (by decide)
· simpa using prepared_commonRole graph n 5 (by decide)
· simpa using prepared_commonRole graph n 8 (by decide)
· simpa using prepared_commonRole graph n 9 (by decide)
· simpa using prepared_commonRole graph n 10 (by decide)@[simp] theorem prepared_start (graph : PortTables.Table vertices d) (n : Nat) :
preparedTapes graph n (PoweringMachineGlobal.placement n (.inl 1)) =
encodeWord vertices := by proof · 3 lines
simpa only [preparedTapes, PoweringMachineGlobal.placement, PoweringMachineTapes.start] using
PoweringMachineInitialize.final_counter (PoweringMachineRowBody.capacity n)
(PoweringTableLayout.blockSize d n) vertices (initialExtra graph n)theorem prepared_counter (graph : PortTables.Table vertices d) (n : Nat) :
PoweringMachineOuterLoop.counter (PoweringMachineGlobal.placement n)
(preparedTapes graph n) vertices = preparedTapes graph n := by proof · 3 lines
unfold PoweringMachineOuterLoop.counter MachineUnaryCounter.counterTapes
rw [List.append_nil, ← prepared_start graph n]
simp only [Function.update_eq_self]@[simp] theorem prepared_output (graph : PortTables.Table vertices d) (n : Nat) :
preparedTapes graph n (PoweringMachineGlobal.outputTape n) = [] := by proof · 2 lines
simp [preparedTapes, PoweringMachineGlobal.outputTape, PoweringMachineInitialize.finalOutput,
PoweringMachineInitialize.mergeTapes, initialExtra]@[simp] theorem prepared_vertices (graph : PortTables.Table vertices d) (n : Nat) :
preparedTapes graph n (PoweringMachineGlobal.headerVertices n) = encodeWord vertices := rfl @[simp] theorem prepared_darts (graph : PortTables.Table vertices d) (n : Nat) :
preparedTapes graph n (PoweringMachineGlobal.headerDarts n) =
encodeWord (PoweringTableLayout.blockSize d n * vertices) := rfl @[simp] theorem prepared_source (graph : PortTables.Table vertices d) (n : Nat) :
preparedTapes graph n (.inl PoweringMachineLoop.HeaderTape.source) = [] := rfl def preparedCfg (graph : PortTables.Table vertices d) (n : Nat) :
(PoweringMachineGlobal.machine d n).Cfg := body · 2 lines
⟨some (PoweringMachineGlobal.guardLabel d n),
PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n), preparedTapes graph n⟩theorem initialGlobalTapes_eq (graph : PortTables.Table vertices d) (n : Nat) :
PoweringMachineInitialize.initialGlobalTapes (initialExtra graph n) =
fun tape => if tape = PoweringMachineGlobal.inputTape n
then PortTables.tableBits graph else [] := by proof · 10 lines
funext tape
cases tape with
| inl field =>
simp [PoweringMachineInitialize.initialGlobalTapes, PoweringMachineInitialize.mergeTapes,
PoweringMachineGlobal.inputTape, PoweringMachineGlobal.placement,
PoweringMachineInitialize.commonPlacement_table]
| inr field =>
simp [PoweringMachineInitialize.initialGlobalTapes, PoweringMachineInitialize.mergeTapes,
PoweringMachineGlobal.inputTape, PoweringMachineGlobal.placement,
PoweringMachineInitialize.commonPlacement_table, initialExtra]private theorem machine_initialStacks (d n : Nat) (input : List Bool) :
(initList (PoweringMachineGlobal.machine d n) input).stk =
fun tape => if tape = PoweringMachineGlobal.inputTape n then input else [] := rfl theorem initList_eq (graph : PortTables.Table vertices d) (n : Nat) :
initList (PoweringMachineGlobal.machine d n) (PortTables.tableBits graph) =
⟨some (PoweringMachineGlobal.main d n),
PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n),
PoweringMachineInitialize.initialGlobalTapes (initialExtra graph n)⟩ := by proof · 3 lines
have ht := (machine_initialStacks d n (PortTables.tableBits graph)).trans
(initialGlobalTapes_eq graph n).symm
exact congrArg (TM2.Cfg.mk _ _) httheorem tableBits_head (graph : PortTables.Table vertices d) :
PortTables.tableBits graph = encodeWord vertices ++
encodeWords (PortTables.tableWords graph).tail := rfl def initializeInTime (graph : PortTables.Table vertices d) (n : Nat) :
StateTransition.EvalsToInTime (PoweringMachineGlobal.machine d n).step
(initList (PoweringMachineGlobal.machine d n) (PortTables.tableBits graph))
(some (preparedCfg graph n)) (3 * vertices + 5) := by body · 9 lines
rw [initList_eq]
exact PoweringMachineInitialize.initializeAtInTime
(PoweringMachineRowBody.capacity n) (PoweringMachineRowBody.bufferSize d n)
(PoweringTableLayout.blockSize d n) vertices
(PoweringMachineGlobal.initLabels d n) (some (PoweringMachineGlobal.guardLabel d n))
(PoweringMachineGlobal.program d n) (PoweringMachineGlobal.atInit d n)
(initialExtra graph n) (encodeWords (PortTables.tableWords graph).tail)
(by rw [initialExtra_table, tableBits_head]) (initialExtra_scratch graph n)
(PoweringMasterState.clean (PoweringMachineRowBody.bufferSize d n))Outline
- def
initialExtra12 - theorem
initialExtra_table17 - theorem
initialExtra_other21 - theorem
initialExtra_scratch26 - def
preparedTapes31 - theorem
prepared_commonRole37 - theorem
prepared_ready45 - theorem
prepared_start55 - theorem
prepared_counter62 - theorem
prepared_output69 - theorem
prepared_vertices74 - theorem
prepared_darts77 - theorem
prepared_source81 - def
preparedCfg84 - theorem
initialGlobalTapes_eq89 - theorem
machine_initialStacks104 - theorem
initList_eq108 - theorem
tableBits_head117 - def
initializeInTime121