Buckets:
| import OAI.Computability.UniqueGames.Machines.MachineCopy | |
| import OAI.Computability.UniqueGames.PCP.InputLemmas | |
| import OAI.Computability.UniqueGames.PCP.SourceMachine | |
| namespace OAI | |
| namespace UniqueGamesTheorem.Foundations.PCP.AlphabetTable.Setup | |
| open Turing | |
| open UniqueGamesTheorem.Foundations.Complexity | |
| open UniqueGamesTheorem.Foundations.Hastad | |
| variable {K Λ σ : Type} [DecidableEq K] | |
| abbrev Alphabet (_ : K) := Bool | |
| abbrev Ports (K : Type) := Fin 7 → K | |
| inductive Label | |
| | copyFirst | copySecond | verticesStart | verticesLoop | |
| | dartsStart | dartsLoop | counterFirst | counterSecond | initialize | |
| deriving DecidableEq | |
| protected abbrev Label.enumList : List Label := [.copyFirst, .copySecond, .verticesStart, | |
| .verticesLoop, .dartsStart, .dartsLoop, .counterFirst, .counterSecond, .initialize] | |
| protected theorem Label.enumList_getElem?_ctorIdx_eq (x : Label) : | |
| Label.enumList[x.ctorIdx]? = some x := by | |
| cases x <;> rfl | |
| protected theorem Label.enumList_nodup : Label.enumList.Nodup := by decide | |
| instance : Fintype Label where | |
| elems := ⟨Label.enumList, Label.enumList_nodup⟩ | |
| complete x := by cases x <;> decide | |
| def statement (ports : Ports K) (labels : Label → Λ) (exit : Option Λ) : | |
| Label → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool) | |
| | .copyFirst => Reduction.MachineTransfer.loopAt (ports 0) (ports 5) id false | |
| (labels .copyFirst) (some (labels .copySecond)) | |
| | .copySecond => MachineCopy.forkLoop (ports 5) (ports 0) (ports 1) false | |
| (labels .copySecond) (some (labels .verticesStart)) | |
| | .verticesStart => SourceMachine.fieldStart (ports 2) (labels .verticesLoop) | |
| | .verticesLoop => SourceMachine.fieldLoop (ports 1) (ports 2) | |
| (labels .verticesLoop) (some (labels .dartsStart)) | |
| | .dartsStart => SourceMachine.fieldStart (ports 3) (labels .dartsLoop) | |
| | .dartsLoop => SourceMachine.fieldLoop (ports 1) (ports 3) | |
| (labels .dartsLoop) (some (labels .counterFirst)) | |
| | .counterFirst => Reduction.MachineTransfer.loopAt (ports 3) (ports 5) id false | |
| (labels .counterFirst) (some (labels .counterSecond)) | |
| | .counterSecond => MachineCopy.forkLoop (ports 5) (ports 3) (ports 4) false | |
| (labels .counterSecond) (some (labels .initialize)) | |
| | .initialize => .push (ports 6) (fun _ => false) | |
| (.load (fun state => (state.1, none)) (Reduction.MachineTransfer.exitAt (ports 6) exit)) | |
| def resultTapes (ports : Ports K) (base : K → List Bool) | |
| (n m : Nat) (rows : List Bool) : K → List Bool := | |
| Function.update | |
| (Function.update | |
| (Function.update | |
| (Function.update (Function.update base (ports 1) rows) | |
| (ports 2) (encodeWord n)) (ports 3) (encodeWord m)) | |
| (ports 4) (encodeWord m)) (ports 6) (encodeWord 0) | |
| theorem resultTapes_other (ports : Ports K) (base : K → List Bool) | |
| (n m : Nat) (rows : List Bool) (tape : K) | |
| (h : ∀ i : Fin 7, i ≠ 0 → i ≠ 5 → tape ≠ ports i) : | |
| resultTapes ports base n m rows tape = base tape := by | |
| simp [resultTapes, h] | |
| /-- Actual program placement is the only execution premise. Header values and | |
| unread row bits specify the input, and every auxiliary role starts empty. -/ | |
| def setupInTime (ports : Ports K) (distinct : Function.Injective ports) | |
| (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) | |
| (atLabels : ∀ label, program (labels label) = statement ports labels exit label) | |
| (base : K → List Bool) (n m : Nat) (rows : List Bool) | |
| (initial : ∀ i : Fin 7, base (ports i) = | |
| if i = 0 then encodeWord n ++ (encodeWord m ++ rows) else []) | |
| (ambient : σ) (register : Option Bool) : | |
| StateTransition.EvalsToInTime (TM2.step program) | |
| ⟨some (labels .copyFirst), (ambient, register), base⟩ | |
| (some ⟨exit, (ambient, none), resultTapes ports base n m rows⟩) | |
| (2 * (encodeWord n ++ (encodeWord m ++ rows)).length + n + 3 * m + 11) := by | |
| let input := encodeWord n ++ (encodeWord m ++ rows) | |
| let t₀ := Function.update base (ports 1) input | |
| let t₁ := SourceMachine.afterField (ports 1) (ports 2) t₀ n (encodeWord m ++ rows) | |
| let t₂ := SourceMachine.afterField (ports 1) (ports 3) t₁ m rows | |
| let t₃ := Function.update t₂ (ports 4) (encodeWord m) | |
| have hne {i j : Fin 7} (h : i ≠ j) : ports i ≠ ports j := fun e => h (distinct e) | |
| have run₀ := MachineCopy.copyInTime (ports 0) (ports 1) (ports 5) | |
| (hne (by decide)) (hne (by decide)) (hne (by decide)) false | |
| (labels .copyFirst) (labels .copySecond) (some (labels .verticesStart)) | |
| program (atLabels .copyFirst) (atLabels .copySecond) base | |
| (by simp [initial]) ambient register | |
| have hb0 : base (ports 0) = input := by simpa [input] using initial 0 | |
| have hb1 : base (ports 1) = [] := by simpa using initial 1 | |
| rw [hb0, hb1, List.append_nil] at run₀ | |
| change StateTransition.EvalsToInTime (TM2.step program) | |
| ⟨some (labels .copyFirst), (ambient, register), base⟩ | |
| (some ⟨some (labels .verticesStart), (ambient, none), t₀⟩) | |
| (2 * (input.length + 1)) at run₀ | |
| have run₁ := SourceMachine.fieldInTime (ports 1) (ports 2) (hne (by decide)) | |
| (labels .verticesStart) (labels .verticesLoop) (some (labels .dartsStart)) | |
| program (atLabels .verticesStart) (atLabels .verticesLoop) | |
| t₀ n (encodeWord m ++ rows) (by simp [t₀, input]) ambient none | |
| have run₂ := SourceMachine.fieldInTime (ports 1) (ports 3) (hne (by decide)) | |
| (labels .dartsStart) (labels .dartsLoop) (some (labels .counterFirst)) | |
| program (atLabels .dartsStart) (atLabels .dartsLoop) | |
| t₁ m rows (by simp [t₁, SourceMachine.afterField, distinct.eq_iff]) ambient none | |
| have h₂m : t₂ (ports 3) = encodeWord m := by | |
| simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, | |
| distinct.eq_iff, initial] | |
| have h₂c : t₂ (ports 4) = [] := by | |
| simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, | |
| distinct.eq_iff, initial] | |
| have h₂s : t₂ (ports 5) = [] := by | |
| simp [t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, | |
| distinct.eq_iff, initial] | |
| have run₃ := MachineCopy.copyInTime (ports 3) (ports 4) (ports 5) | |
| (hne (by decide)) (hne (by decide)) (hne (by decide)) false | |
| (labels .counterFirst) (labels .counterSecond) (some (labels .initialize)) | |
| program (atLabels .counterFirst) (atLabels .counterSecond) t₂ h₂s ambient none | |
| rw [h₂m, h₂c, List.append_nil, encodeWord_length] at run₃ | |
| have h₃e : t₃ (ports 6) = [] := by | |
| simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, | |
| distinct.eq_iff, initial] | |
| have hresult : Function.update t₃ (ports 6) [false] = | |
| resultTapes ports base n m rows := by | |
| funext tape | |
| by_cases h1 : tape = ports 1 | |
| · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, | |
| SourceMachine.fieldTapes, resultTapes, distinct.eq_iff] | |
| · by_cases h2 : tape = ports 2 | |
| · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, | |
| SourceMachine.fieldTapes, resultTapes, distinct.eq_iff, initial] | |
| · by_cases h3 : tape = ports 3 | |
| · subst tape; simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, | |
| SourceMachine.fieldTapes, resultTapes, distinct.eq_iff, initial] | |
| · simp [t₃, t₂, t₁, t₀, SourceMachine.afterField, SourceMachine.fieldTapes, | |
| resultTapes, Function.update_apply, h1, h2, h3, encodeWord] | |
| have run₄ : StateTransition.EvalsToInTime (TM2.step program) | |
| ⟨some (labels .initialize), (ambient, none), t₃⟩ | |
| (some ⟨exit, (ambient, none), resultTapes ports base n m rows⟩) 1 := { | |
| steps := 1 | |
| evals_in_steps := by | |
| change some (TM2.stepAux (program (labels .initialize)) (ambient, none) t₃) = _ | |
| rw [atLabels] | |
| cases exit <;> simp [statement, TM2.stepAux, Reduction.MachineTransfer.exitAt, | |
| h₃e, hresult] | |
| steps_le_m := Nat.le_refl _ } | |
| let r₀₁ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ run₀ run₁ | |
| let r₀₁₂ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁ run₂ | |
| let r₀₁₂₃ := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁₂ run₃ | |
| let run := StateTransition.EvalsToInTime.trans _ _ _ _ _ _ r₀₁₂₃ run₄ | |
| exact { | |
| toEvalsTo := run.toEvalsTo | |
| steps_le_m := by | |
| have h := run.steps_le_m | |
| dsimp [input] at h | |
| omega } | |
| /-- Specialization to the checked graph-table codec. The bound follows from | |
| the actual copy and delimiter-scan traces above. -/ | |
| def tableSetupInTime {q : Nat} (ports : Ports K) (distinct : Function.Injective ports) | |
| (labels : Label → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool)) | |
| (atLabels : ∀ label, program (labels label) = statement ports labels exit label) | |
| (base : K → List Bool) (table : GenericGraphTables.Table q) | |
| (initial : ∀ i : Fin 7, base (ports i) = | |
| if i = 0 then GenericGraphTables.tableBits table else []) | |
| (ambient : σ) (register : Option Bool) : | |
| StateTransition.EvalsToInTime (TM2.step program) | |
| ⟨some (labels .copyFirst), (ambient, register), base⟩ | |
| (some ⟨exit, (ambient, none), resultTapes ports base table.vertices table.darts | |
| (encodeWords ((GenericGraphTables.rowList table).flatMap GenericGraphTables.rowWords))⟩) | |
| (6 * (GenericGraphTables.tableBits table).length + 11) := by | |
| have hb := Input.tableBits_header table | |
| let run := setupInTime ports distinct labels exit program atLabels base | |
| table.vertices table.darts | |
| (encodeWords ((GenericGraphTables.rowList table).flatMap GenericGraphTables.rowWords)) | |
| (by intro i; rw [initial i, hb]) ambient register | |
| have hn := GenericGraphTables.vertices_le_tableBits_length table | |
| have hm := GenericGraphTables.darts_le_tableBits_length table | |
| exact { | |
| toEvalsTo := run.toEvalsTo | |
| steps_le_m := by | |
| have h := run.steps_le_m | |
| have hlen := congrArg List.length hb | |
| omega } | |
| def program (ports : Ports K) : Label → TM2.Stmt (Alphabet (K := K)) Label (σ × Option Bool) := | |
| statement ports id none | |
| /-- This stage itself has only seven tapes and nine control labels. -/ | |
| def machine : FinTM2 where | |
| K := Fin 7 | |
| k₀ := 0 | |
| k₁ := 1 | |
| Γ _ := Bool | |
| Λ := Label | |
| main := .copyFirst | |
| σ := Unit × Option Bool | |
| initialState := ((), none) | |
| m := program id | |
| end UniqueGamesTheorem.Foundations.PCP.AlphabetTable.Setup | |
| end OAI | |
Xet Storage Details
- Size:
- 10.5 kB
- Xet hash:
- 3ba06f5e77ce265488ac1d626ca27a3695c45f96f461afd323615a05bf786727
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.