Buckets:
| import Mathlib | |
| import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalRow | |
| namespace OAI | |
| namespace IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow | |
| open Turing MachineComposition | |
| open PCP PCP.GraphTables PCP.PreprocessingRegularTables | |
| section Execution | |
| variable {Λ σ : Type} | |
| theorem join_trace {A : Type*} {f : A → A} {m n : Nat} {a b c : A} | |
| (first : f^[m] a = b) (second : f^[n] b = c) : f^[m + n] a = c := by | |
| rw [Nat.add_comm m n, Function.iterate_add_apply, first, second] | |
| theorem lookupTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt Alphabet Λ (State σ)) | |
| (code : ∀ l, program (labels l) = instruction q labels exit l) | |
| (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) | |
| (ambient : σ) (register : Option Bool) : | |
| (advance (TM2.step program))^[MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 3] | |
| (some ⟨some (labels (.lookup .seed)), ((ambient, zeroBuffer), register), base⟩) = | |
| some ⟨some (labels .copyRelation), ((ambient, zeroBuffer), none), looked t e base⟩ := by | |
| exact MachineAffineLookup.affineLookupTrace 0 lookupTape lookupTape_injective source_outside | |
| 4098 3 (fun l => labels (.lookup l)) (some (labels .copyRelation)) program | |
| (fun l => code (.lookup l)) base (GraphTables.tableWords t) input.tableWord input.scratchEmpty | |
| e.val [] (by simpa only [List.append_nil] using input.indexWord) | |
| t.rows[e].reverseIndex.val (selected_reverse t e) (ambient, zeroBuffer) register | |
| theorem copyTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt Alphabet Λ (State σ)) | |
| (code : ∀ l, program (labels l) = instruction q labels exit l) | |
| (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (ambient : σ) : | |
| (advance (TM2.step program))^[1] | |
| (some ⟨some (labels .copyRelation), ((ambient, zeroBuffer), none), looked t e base⟩) = | |
| some ⟨some (labels .reverseSeed), ((ambient, zeroBuffer), none), copied t e base⟩ := by | |
| simp only [Function.iterate_one, advance_some] | |
| have run := relationCopy_step (3 : Tape) 7 (by decide) (labels .copyRelation) | |
| (some (labels .reverseSeed)) program (code .copyRelation) t.rows[e].relation | |
| (encodeWords (suffixWords t e) ++ base 3) (looked t e base) (looked_relation t e base) | |
| ambient zeroBuffer none | |
| rw [looked_other t e base 7 (by decide) (by decide) (by decide)] at run | |
| exact run | |
| theorem affineTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt Alphabet Λ (State σ)) | |
| (code : ∀ l, program (labels l) = instruction q labels exit l) | |
| (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) | |
| (ambient : σ) : | |
| (advance (TM2.step program))^[2 * (t.rows[e].reverseIndex.val + 1) + 1] | |
| (some ⟨some (labels .reverseSeed), ((ambient, zeroBuffer), none), copied t e base⟩) = | |
| some ⟨some (labels (.emit .relationRead)), ((ambient, zeroBuffer), none), | |
| affined q t e base⟩ := by | |
| have hsource : copied t e base 4 = encodeWord t.rows[e].reverseIndex.val ++ [] := by | |
| rw [copied_reverse, input.reverseEmpty] | |
| have hscratch : copied t e base 5 = [] := by | |
| rw [copied_other t e base 5 (by decide) (by decide) (by decide) (by decide), input.scratchEmpty] | |
| have run := MachineUnaryAffineAt.seededAffineTrace (4 : Tape) 5 6 (by decide) (by decide) | |
| (by decide) (q + 1) q (labels .reverseSeed) (labels .reverseScan) (labels .reverseRestore) | |
| (some (labels (.emit .relationRead))) program (code .reverseSeed) (code .reverseScan) | |
| (code .reverseRestore) (copied t e base) t.rows[e].reverseIndex.val [] hsource hscratch | |
| (ambient, zeroBuffer) none | |
| rw [copied_other t e base 6 (by decide) (by decide) (by decide) (by decide)] at run | |
| exact run | |
| theorem emitTrace (q : Nat) (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt Alphabet Λ (State σ)) | |
| (code : ∀ l, program (labels l) = instruction q labels exit l) | |
| (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) | |
| (ambient : σ) : | |
| (advance (TM2.step program))^[rowSteps q t e base] | |
| (some ⟨some (labels (.emit .relationRead)), ((ambient, zeroBuffer), none), affined q t e base⟩) = | |
| some ⟨exit, ((ambient, zeroBuffer), none), finalTapes q t e base⟩ := by | |
| have hrow : affined q t e base 8 = [] := by | |
| rw [affined_other q t e base 8 (by decide) (by decide) (by decide) (by decide) (by decide), input.rowEmpty] | |
| have hscratch : affined q t e base 5 = [] := by | |
| rw [affined_other q t e base 5 (by decide) (by decide) (by decide) (by decide) (by decide), input.scratchEmpty] | |
| have hout := affined_other q t e base 9 (by decide) (by decide) (by decide) | |
| (by decide) (by decide) | |
| have hfields := affined_fields q t e base input | |
| have hsize : MachineTableRows.fieldSize fields (affined q t e base) = | |
| (encodeWords (emittedWords q t e)).length := by | |
| rw [← MachineTableRows.fieldBits_length, hfields] | |
| have run := MachineTableRows.appendTrace fields (8 : Tape) 9 5 fields_separate | |
| (by decide) (by decide) (by decide) (fun l => labels (.emit l)) exit program | |
| (fun l => code (.emit l)) (affined q t e base) hrow hscratch (ambient, zeroBuffer) none | |
| rw [hsize, hout, hfields] at run | |
| exact run | |
| theorem traceAt (q : Nat) (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt Alphabet Λ (State σ)) | |
| (code : ∀ l, program (labels l) = instruction q labels exit l) | |
| (t : Table) (e : Fin t.darts) (base : Tape → List Bool) (input : Input t e base) | |
| (ambient : σ) (register : Option Bool) : | |
| (advance (TM2.step program))^[steps q t e base] | |
| (some ⟨some (labels (.lookup .seed)), ((ambient, zeroBuffer), register), base⟩) = | |
| some ⟨exit, ((ambient, zeroBuffer), none), finalTapes q t e base⟩ := by | |
| have hlookup := lookupTrace q labels exit program code t e base input ambient register | |
| have hcopy := copyTrace q labels exit program code t e base ambient | |
| have haffine := affineTrace q labels exit program code t e base input ambient | |
| have hemit := emitTrace q labels exit program code t e base input ambient | |
| exact join_trace (join_trace (join_trace hlookup hcopy) haffine) hemit | |
| end Execution | |
| def timeBound (q inputLength outputLength : Nat) : Nat := | |
| (4 * q + 17) * inputLength + 2 * outputLength + 4 * q + 32795 | |
| theorem steps_le (q : Nat) (t : Table) (e : Fin t.darts) (base : Tape → List Bool) : | |
| steps q t e base ≤ timeBound q (tableBits t).length (base 9).length := by | |
| have hl := MachineAffineLookup.steps_le (GraphTables.tableWords t) e.val 4098 3 | |
| t.rows[e].reverseIndex.val (selected_reverse t e) | |
| have htable := tableWords_length_le_bits t | |
| have he : e.val ≤ (tableBits t).length := by have he := e.isLt; omega | |
| have hr : t.rows[e].reverseIndex.val ≤ (tableBits t).length := by | |
| have hrlt := t.rows[e].reverseIndex.isLt | |
| omega | |
| have hrel := relationBits_length_le t.rows[e].relation | |
| have hmul := Nat.mul_le_mul_left (4 * (q + 1) + 2) hr | |
| change MachineAffineLookup.steps (GraphTables.tableWords t) e.val 4098 3 ≤ | |
| 2 * e.val + 5 * (tableBits t).length + 6 at hl | |
| unfold steps rowSteps timeBound emittedWords | |
| simp only [encodeWords, List.length_append, encodeWord_length] | |
| nlinarith | |
| def machineInTime (H : BaseTable) (t : Table) (e : Fin t.darts) | |
| (base : Tape → List Bool) (input : Input t e base) (register : Option Bool) : | |
| StateTransition.EvalsToInTime (machine internalDegree).step | |
| ⟨some (.lookup .seed), (((), zeroBuffer), register), base⟩ | |
| (some ⟨none, (((), zeroBuffer), none), | |
| Function.update (affined internalDegree t e base) (9 : Tape) | |
| (base (9 : Tape) ++ encodeWords (rowWords (inheritedRow H t e)))⟩) | |
| (timeBound internalDegree (tableBits t).length (base (9 : Tape)).length) where | |
| steps := steps internalDegree t e base | |
| evals_in_steps := by | |
| change (advance (TM2.step (instruction internalDegree id none)))^[_] _ = _ | |
| rw [inheritedRow_words] | |
| exact traceAt internalDegree id none (instruction internalDegree id none) | |
| (fun _ => rfl) t e base input () register | |
| steps_le_m := steps_le internalDegree t e base | |
| end IndependentSetsGames.Foundations.Complexity.MachineRegularOriginalRow | |
| end OAI | |
Xet Storage Details
- Size:
- 8.38 kB
- Xet hash:
- 2c815523ccfc99d3dfa9eebbc4dda308dbfc7d7b5c9215d1210eaa5f136d416d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.