Buckets:
| import Mathlib | |
| import OAI.Combinatorics.IndependentSets.Machines.MachineRegularOriginalRow | |
| import OAI.Combinatorics.IndependentSets.Machines.MachinePortReindex | |
| import OAI.Combinatorics.IndependentSets.Expansion.PreprocessingLazyWords | |
| namespace OAI | |
| namespace IndependentSetsGames.Foundations.Complexity.MachineLazyRows | |
| open Turing MachineComposition PCP.GraphTables | |
| open PCP.PreprocessingLazyWords (reverseMap moveRow moveRow_words) | |
| variable {K Λ A : Type} [DecidableEq K] | |
| abbrev Label (d : Nat) := MachinePortReindex.Label d ⊕ MachineTableRows.Label | |
| abbrev State (A : Type) (d : Nat) := MachinePortReindex.State A d | |
| def addressIndex : Fin 5 → Fin 9 := ![1, 3, 4, 5, 6] | |
| theorem addressIndex_injective : Function.Injective addressIndex := by | |
| intro i j h | |
| fin_cases i <;> fin_cases j <;> simp_all [addressIndex] | |
| def fields (tape : Fin 9 → K) : Fin 3 → K := ![tape 0, tape 6, tape 2] | |
| def reindexInstruction (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 9 → K) | |
| (labels : Label d → Λ) (exit : Option Λ) : | |
| Label d → TM2.Stmt (fun _ : K => Bool) Λ (State A d) | |
| | .inl stage => MachinePortReindex.instruction d positive c b | |
| (tape ∘ addressIndex) (fun stage => labels (.inl stage)) | |
| (some (labels (.inr .relationRead))) stage | |
| | .inr stage => MachineTableRows.routine (fields tape) (tape 8) (tape 7) (tape 3) | |
| (fun stage => labels (.inr stage)) exit stage | |
| def instruction (d : Nat) (positive : 0 < d) (tape : Fin 9 → K) | |
| (labels : Label d → Λ) (exit : Option Λ) : | |
| Label d → TM2.Stmt (fun _ : K => Bool) Λ (State A d) := | |
| reindexInstruction d positive (2 * d) d tape labels exit | |
| def reindexRowBits (d c b v j : Nat) (relation : RelationTable) : List Bool := | |
| encodeWord v ++ encodeWord (MachinePortReindex.value d c b j) ++ | |
| encodeWords (relationWords relation) | |
| def reindexMappedTapes (d c b j : Nat) (tape : Fin 9 → K) | |
| (base : K → List Bool) : K → List Bool := | |
| Function.update base (tape 6) (encodeWord (MachinePortReindex.value d c b j)) | |
| def reindexResultTapes (d c b v j : Nat) (relation : RelationTable) | |
| (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := | |
| Function.update (reindexMappedTapes d c b j tape base) (tape 7) | |
| (base (tape 7) ++ reindexRowBits d c b v j relation) | |
| def reindexSteps (d c b v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := | |
| MachinePortReindex.steps d j + 4 * (reindexRowBits d c b v j relation).length + | |
| 2 * output.length + 9 | |
| def rowBits (d v j : Nat) (relation : RelationTable) : List Bool := | |
| encodeWord v ++ encodeWord (reverseMap d j) ++ encodeWords (relationWords relation) | |
| def mappedTapes (d j : Nat) (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := | |
| Function.update base (tape 6) (encodeWord (reverseMap d j)) | |
| def resultTapes (d v j : Nat) (relation : RelationTable) | |
| (tape : Fin 9 → K) (base : K → List Bool) : K → List Bool := | |
| Function.update (mappedTapes d j tape base) (tape 7) | |
| (base (tape 7) ++ rowBits d v j relation) | |
| def steps (d v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := | |
| MachinePortReindex.steps d j + 4 * (rowBits d v j relation).length + 2 * output.length + 9 | |
| theorem reindexRowTrace (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 9 → K) | |
| (distinct : Function.Injective tape) (labels : Label d → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A d)) | |
| (atLabels : ∀ l, program (labels l) = reindexInstruction d positive c b tape labels exit l) | |
| (base : K → List Bool) (v j : Nat) (relation : RelationTable) | |
| (tailWord : base (tape 0) = encodeWord v) | |
| (reverseWord : base (tape 1) = encodeWord j) | |
| (relationWord : base (tape 2) = encodeWords (relationWords relation)) | |
| (scratchEmpty : base (tape 3) = []) (workEmpty : base (tape 4) = []) | |
| (quotientEmpty : base (tape 5) = []) (newReverseEmpty : base (tape 6) = []) | |
| (rowEmpty : base (tape 8) = []) (ambient : A) : | |
| (advance (TM2.step program))^[reindexSteps d c b v j relation (base (tape 7))] | |
| (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = | |
| some ⟨exit, MachinePortReindex.clean d positive ambient, | |
| reindexResultTapes d c b v j relation tape base⟩ := by | |
| have hd (i k : Fin 9) (h : i ≠ k) : tape i ≠ tape k := fun e => h (distinct e) | |
| have ha0 : addressIndex 0 = 1 := rfl | |
| have ha4 : addressIndex 4 = 6 := rfl | |
| have mapRun := MachinePortReindex.reindexTrace d positive c b | |
| (tape ∘ addressIndex) (distinct.comp addressIndex_injective) | |
| (fun stage => labels (.inl stage)) (some (labels (.inr .relationRead))) | |
| program (fun stage => atLabels (.inl stage)) base j [] | |
| (by simpa only [Function.comp_apply, ha0, List.append_nil] using reverseWord) | |
| scratchEmpty workEmpty quotientEmpty ambient | |
| simp only [Function.comp_apply, ha4, newReverseEmpty, | |
| List.append_nil] at mapRun | |
| change (advance (TM2.step program))^[MachinePortReindex.steps d j] | |
| (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = | |
| some ⟨some (labels (.inr .relationRead)), MachinePortReindex.clean d positive ambient, | |
| reindexMappedTapes d c b j tape base⟩ at mapRun | |
| have hfields (i : Fin 3) : fields tape i ≠ tape 8 ∧ fields tape i ≠ tape 3 := by | |
| fin_cases i | |
| · exact ⟨hd 0 8 (by decide), hd 0 3 (by decide)⟩ | |
| · exact ⟨hd 6 8 (by decide), hd 6 3 (by decide)⟩ | |
| · exact ⟨hd 2 8 (by decide), hd 2 3 (by decide)⟩ | |
| have hbits : MachineTableRows.fieldBits (fields tape) (reindexMappedTapes d c b j tape base) = | |
| reindexRowBits d c b v j relation := by | |
| simp [MachineTableRows.fieldBits, fields, reindexMappedTapes, hd 0 6 (by decide), | |
| hd 2 6 (by decide), tailWord, relationWord, reindexRowBits] | |
| have hsize : MachineTableRows.fieldSize (fields tape) (reindexMappedTapes d c b j tape base) = | |
| (reindexRowBits d c b v j relation).length := by | |
| rw [← MachineTableRows.fieldBits_length, hbits] | |
| have hout : reindexMappedTapes d c b j tape base (tape 7) = base (tape 7) := by | |
| simp [reindexMappedTapes, hd 7 6 (by decide)] | |
| have appendRun := MachineTableRows.appendTrace (fields tape) (tape 8) (tape 7) (tape 3) | |
| hfields (hd 8 7 (by decide)) (hd 8 3 (by decide)) (hd 7 3 (by decide)) | |
| (fun stage => labels (.inr stage)) exit program | |
| (fun stage => atLabels (.inr stage)) (reindexMappedTapes d c b j tape base) | |
| (by simp [reindexMappedTapes, hd 8 6 (by decide), rowEmpty]) | |
| (by simp [reindexMappedTapes, hd 3 6 (by decide), scratchEmpty]) | |
| (ambient, MachineFixedDivMod.residue d positive 0) none | |
| rw [hsize, hout, hbits] at appendRun | |
| change (advance (TM2.step program))^[4 * (reindexRowBits d c b v j relation).length + | |
| 2 * (base (tape 7)).length + 9] | |
| (some ⟨some (labels (.inr .relationRead)), MachinePortReindex.clean d positive ambient, | |
| reindexMappedTapes d c b j tape base⟩) = | |
| some ⟨exit, MachinePortReindex.clean d positive ambient, | |
| reindexResultTapes d c b v j relation tape base⟩ at appendRun | |
| rw [show reindexSteps d c b v j relation (base (tape 7)) = | |
| (4 * (reindexRowBits d c b v j relation).length + 2 * (base (tape 7)).length + 9) + | |
| MachinePortReindex.steps d j by unfold reindexSteps; omega, | |
| Function.iterate_add_apply, mapRun, appendRun] | |
| theorem rowTrace (d : Nat) (positive : 0 < d) (tape : Fin 9 → K) | |
| (distinct : Function.Injective tape) (labels : Label d → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (State A d)) | |
| (atLabels : ∀ l, program (labels l) = instruction d positive tape labels exit l) | |
| (base : K → List Bool) (v j : Nat) (relation : RelationTable) | |
| (tailWord : base (tape 0) = encodeWord v) | |
| (reverseWord : base (tape 1) = encodeWord j) | |
| (relationWord : base (tape 2) = encodeWords (relationWords relation)) | |
| (scratchEmpty : base (tape 3) = []) (workEmpty : base (tape 4) = []) | |
| (quotientEmpty : base (tape 5) = []) (newReverseEmpty : base (tape 6) = []) | |
| (rowEmpty : base (tape 8) = []) (ambient : A) : | |
| (advance (TM2.step program))^[steps d v j relation (base (tape 7))] | |
| (some ⟨some (labels (.inl .copySeed)), MachinePortReindex.clean d positive ambient, base⟩) = | |
| some ⟨exit, MachinePortReindex.clean d positive ambient, | |
| resultTapes d v j relation tape base⟩ := by | |
| simpa only [reindexSteps, reindexResultTapes, reindexMappedTapes, reindexRowBits, | |
| MachinePortReindex.lazy_value, reverseMap, steps, resultTapes, mappedTapes, rowBits] using | |
| reindexRowTrace d positive (2 * d) d tape distinct labels exit program atLabels | |
| base v j relation tailWord reverseWord relationWord scratchEmpty workEmpty | |
| quotientEmpty newReverseEmpty rowEmpty ambient | |
| theorem rowBits_eq_moveRow {n d : Nat} (table : PCP.PortTables.Table n d) | |
| (v : Fin n) (p : Fin d) : | |
| rowBits d v.val (PCP.PreprocessingLazyWords.row table v p).reverseIndex.val | |
| (PCP.PreprocessingLazyWords.row table v p).relation = | |
| encodeWords (rowWords (moveRow table v p)) := by | |
| rw [moveRow_words] | |
| simp [rowBits, encodeWords] | |
| def machine (d : Nat) (positive : 0 < d) : FinTM2 where | |
| K := Fin 9 | |
| k₀ := 1 | |
| k₁ := 7 | |
| Γ _ := Bool | |
| Λ := Label d | |
| main := .inl .copySeed | |
| σ := State Unit d | |
| initialState := MachinePortReindex.clean d positive () | |
| m := instruction d positive id id none | |
| abbrev Buffer := MachineRegularOriginalRow.Buffer | |
| abbrev StreamState (A : Type) (d : Nat) := State (A × Buffer) d | |
| def streamClean (d : Nat) (positive : 0 < d) (ambient : A) : StreamState A d := | |
| MachinePortReindex.clean d positive (ambient, MachineRegularOriginalRow.zeroBuffer) | |
| def relationStateEquiv (A : Type) (d : Nat) : | |
| MachineRegularOriginalRow.State (A × Fin d) ≃ StreamState A d where | |
| toFun s := (((s.1.1.1, s.1.2), s.1.1.2), s.2) | |
| invFun s := (((s.1.1.1, s.1.2), s.1.1.2), s.2) | |
| left_inv _ := rfl | |
| right_inv _ := rfl | |
| def streamRelationCopy (d : Nat) (source destination : K) (exit : Option Λ) : | |
| TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d) := | |
| MachineStateEquiv.statement (relationStateEquiv A d) | |
| (MachineRegularOriginalRow.relationCopyAt source destination exit) | |
| theorem streamRelationCopy_step (d : Nat) (positive : 0 < d) | |
| (source destination : K) (different : source ≠ destination) | |
| (label : Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) | |
| (code : program label = streamRelationCopy d source destination exit) | |
| (relation : RelationTable) (suffix : List Bool) (base : K → List Bool) | |
| (input : base source = encodeWords (relationWords relation) ++ suffix) (ambient : A) : | |
| TM2.step program ⟨some label, streamClean d positive ambient, base⟩ = | |
| some ⟨exit, streamClean d positive ambient, | |
| Function.update (Function.update base source suffix) destination | |
| (encodeWords (relationWords relation) ++ base destination)⟩ := by | |
| have hraw := MachineRegularOriginalRow.relationCopy_step source destination different label exit | |
| (fun _ => MachineRegularOriginalRow.relationCopyAt source destination exit) rfl | |
| relation suffix base input (ambient, MachineFixedDivMod.residue d positive 0) | |
| MachineRegularOriginalRow.zeroBuffer none | |
| have haux := Option.some.inj hraw | |
| change some (TM2.stepAux (program label) (streamClean d positive ambient) base) = _ | |
| rw [code, streamRelationCopy, MachineStateEquiv.stepAux_transport_symm] | |
| change some (MachineStateEquiv.configuration (relationStateEquiv A d) | |
| (TM2.stepAux (MachineRegularOriginalRow.relationCopyAt source destination exit) | |
| (((ambient, MachineFixedDivMod.residue d positive 0), | |
| MachineRegularOriginalRow.zeroBuffer), none) base)) = _ | |
| rw [haux] | |
| rfl | |
| def bodyIndex (i : Fin 9) : Fin 10 := i.castSucc | |
| theorem bodyIndex_injective : Function.Injective bodyIndex := by | |
| intro i j h | |
| apply Fin.ext | |
| exact congrArg (fun k : Fin 10 => k.val) h | |
| inductive StreamLabel (d : Nat) | |
| | tailStart | tailRead | reverseStart | reverseRead | copyRelation | |
| | row (stage : Label d) | |
| | clearTail | clearOld | clearRelation | clearNew | |
| deriving DecidableEq, Fintype | |
| def streamInstruction (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 10 → K) | |
| (labels : StreamLabel d → Λ) (exit : Option Λ) : | |
| StreamLabel d → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d) | |
| | .tailStart => Hastad.SourceMachine.fieldStart (tape 0) (labels .tailRead) | |
| | .tailRead => Hastad.SourceMachine.fieldLoop (tape 9) (tape 0) (labels .tailRead) | |
| (some (labels .reverseStart)) | |
| | .reverseStart => Hastad.SourceMachine.fieldStart (tape 1) (labels .reverseRead) | |
| | .reverseRead => Hastad.SourceMachine.fieldLoop (tape 9) (tape 1) (labels .reverseRead) | |
| (some (labels .copyRelation)) | |
| | .copyRelation => streamRelationCopy d (tape 9) (tape 2) | |
| (some (labels (.row (.inl .copySeed)))) | |
| | .row stage => reindexInstruction d positive c b (tape ∘ bodyIndex) | |
| (fun stage => labels (.row stage)) (some (labels .clearTail)) stage | |
| | .clearTail => MachineDrain.drain (tape 0) (labels .clearTail) (some (labels .clearOld)) | |
| | .clearOld => MachineDrain.drain (tape 1) (labels .clearOld) (some (labels .clearRelation)) | |
| | .clearRelation => MachineDrain.drain (tape 2) (labels .clearRelation) (some (labels .clearNew)) | |
| | .clearNew => MachineDrain.drain (tape 6) (labels .clearNew) exit | |
| def inputRowBits (v j : Nat) (relation : RelationTable) : List Bool := | |
| encodeWord v ++ encodeWord j ++ encodeWords (relationWords relation) | |
| def streamRowSteps (d c b v j : Nat) (relation : RelationTable) (output : List Bool) : Nat := | |
| (v + 2) + (j + 2) + 1 + reindexSteps d c b v j relation output + | |
| (v + 2) + (j + 2) + ((encodeWords (relationWords relation)).length + 1) + | |
| (MachinePortReindex.value d c b j + 2) | |
| def streamResultTapes (d c b v j : Nat) (relation : RelationTable) | |
| (tape : Fin 10 → K) (base : K → List Bool) (suffix : List Bool) : K → List Bool := | |
| Function.update (Function.update base (tape 9) suffix) (tape 7) | |
| (base (tape 7) ++ reindexRowBits d c b v j relation) | |
| theorem joinTrace {X : Type*} {f : X → X} {a b c : X} {n m : Nat} | |
| (first : f^[n] a = b) (second : f^[m] b = c) : f^[n + m] a = c := by | |
| rw [Nat.add_comm, Function.iterate_add_apply, first, second] | |
| theorem streamRowTrace (d : Nat) (positive : 0 < d) (c b : Nat) (tape : Fin 10 → K) | |
| (distinct : Function.Injective tape) (labels : StreamLabel d → Λ) (exit : Option Λ) | |
| (program : Λ → TM2.Stmt (fun _ : K => Bool) Λ (StreamState A d)) | |
| (atLabels : ∀ l, program (labels l) = streamInstruction d positive c b tape labels exit l) | |
| (base : K → List Bool) (v j : Nat) (relation : RelationTable) (suffix : List Bool) | |
| (input : base (tape 9) = inputRowBits v j relation ++ suffix) | |
| (empty : ∀ i : Fin 10, i ≠ 7 → i ≠ 9 → base (tape i) = []) (ambient : A) : | |
| (advance (TM2.step program))^[streamRowSteps d c b v j relation (base (tape 7))] | |
| (some ⟨some (labels .tailStart), streamClean d positive ambient, base⟩) = | |
| some ⟨exit, streamClean d positive ambient, | |
| streamResultTapes d c b v j relation tape base suffix⟩ := by | |
| have hd (i k : Fin 10) (h : i ≠ k) : tape i ≠ tape k := fun x => h (distinct x) | |
| have hb6 : bodyIndex 6 = 6 := rfl | |
| have hb7 : bodyIndex 7 = 7 := rfl | |
| have h₀ := empty 0 (by decide) (by decide) | |
| have h₁ := empty 1 (by decide) (by decide) | |
| have h₂ := empty 2 (by decide) (by decide) | |
| have h₃ := empty 3 (by decide) (by decide) | |
| have h₄ := empty 4 (by decide) (by decide) | |
| have h₅ := empty 5 (by decide) (by decide) | |
| have h₆ := empty 6 (by decide) (by decide) | |
| have h₈ := empty 8 (by decide) (by decide) | |
| let relationBits := encodeWords (relationWords relation) | |
| let tailLoaded := Function.update (Function.update base (tape 9) | |
| (encodeWord j ++ (relationBits ++ suffix))) (tape 0) (encodeWord v) | |
| let reverseLoaded := Function.update (Function.update tailLoaded (tape 9) | |
| (relationBits ++ suffix)) (tape 1) (encodeWord j) | |
| let loaded := Function.update (Function.update reverseLoaded (tape 9) suffix) (tape 2) relationBits | |
| let rowed := reindexResultTapes d c b v j relation (tape ∘ bodyIndex) loaded | |
| let tailCleared := Function.update rowed (tape 0) [] | |
| let oldCleared := Function.update tailCleared (tape 1) [] | |
| let relationCleared := Function.update oldCleared (tape 2) [] | |
| have tailRun : (advance (TM2.step program))^[v + 2] | |
| (some ⟨some (labels .tailStart), streamClean d positive ambient, base⟩) = | |
| some ⟨some (labels .reverseStart), streamClean d positive ambient, tailLoaded⟩ := by | |
| have h := (Hastad.SourceMachine.fieldInTime (tape 9) (tape 0) (hd 9 0 (by decide)) | |
| (labels .tailStart) (labels .tailRead) (some (labels .reverseStart)) program | |
| (atLabels .tailStart) (atLabels .tailRead) base v | |
| (encodeWord j ++ (relationBits ++ suffix)) | |
| (by simpa only [inputRowBits, List.append_assoc] using input) | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| simp only [Hastad.SourceMachine.fieldInTime, Hastad.SourceMachine.fieldTapes, | |
| h₀, List.append_nil] at h | |
| convert h using 1 <;> rfl | |
| have reverseRun : (advance (TM2.step program))^[j + 2] | |
| (some ⟨some (labels .reverseStart), streamClean d positive ambient, tailLoaded⟩) = | |
| some ⟨some (labels .copyRelation), streamClean d positive ambient, reverseLoaded⟩ := by | |
| have hstart : tailLoaded (tape 1) = [] := by | |
| simp [tailLoaded, hd 1 0 (by decide), hd 1 9 (by decide), h₁] | |
| have h := (Hastad.SourceMachine.fieldInTime (tape 9) (tape 1) (hd 9 1 (by decide)) | |
| (labels .reverseStart) (labels .reverseRead) (some (labels .copyRelation)) program | |
| (atLabels .reverseStart) (atLabels .reverseRead) tailLoaded j (relationBits ++ suffix) | |
| (by simp [tailLoaded, hd 9 0 (by decide)]) | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| simp only [Hastad.SourceMachine.fieldInTime, Hastad.SourceMachine.fieldTapes, | |
| hstart, List.append_nil] at h | |
| convert h using 1 <;> rfl | |
| have copyRun : (advance (TM2.step program))^[1] | |
| (some ⟨some (labels .copyRelation), streamClean d positive ambient, reverseLoaded⟩) = | |
| some ⟨some (labels (.row (.inl .copySeed))), streamClean d positive ambient, loaded⟩ := by | |
| have hempty : reverseLoaded (tape 2) = [] := by | |
| simp [reverseLoaded, tailLoaded, hd 2 1 (by decide), hd 2 9 (by decide), | |
| hd 2 0 (by decide), h₂] | |
| have h := streamRelationCopy_step d positive (tape 9) (tape 2) (hd 9 2 (by decide)) | |
| (labels .copyRelation) (some (labels (.row (.inl .copySeed)))) program | |
| (atLabels .copyRelation) relation suffix reverseLoaded | |
| (by simp [reverseLoaded, relationBits, hd 9 1 (by decide)]) ambient | |
| simpa only [Function.iterate_one, advance_some, hempty, List.append_nil, loaded] using h | |
| have hs (i : Fin 10) (hi : i ≠ 0) (hi' : i ≠ 1) (hi'' : i ≠ 2) (hi''' : i ≠ 9) : | |
| loaded (tape i) = base (tape i) := by | |
| simp [loaded, reverseLoaded, tailLoaded, hd i 0 hi, hd i 1 hi', | |
| hd i 2 hi'', hd i 9 hi'''] | |
| have loadedTail : loaded (tape 0) = encodeWord v := by | |
| simp [loaded, reverseLoaded, tailLoaded, hd 0 2 (by decide), hd 0 9 (by decide), | |
| hd 0 1 (by decide)] | |
| have loadedReverse : loaded (tape 1) = encodeWord j := by | |
| simp [loaded, reverseLoaded, hd 1 2 (by decide), hd 1 9 (by decide)] | |
| have loadedRelation : loaded (tape 2) = relationBits := by simp [loaded] | |
| have bodyRun := reindexRowTrace d positive c b (tape ∘ bodyIndex) | |
| (distinct.comp bodyIndex_injective) (fun stage => labels (.row stage)) | |
| (some (labels .clearTail)) program (fun stage => atLabels (.row stage)) loaded v j relation | |
| loadedTail loadedReverse loadedRelation | |
| ((hs 3 (by decide) (by decide) (by decide) (by decide)).trans h₃) | |
| ((hs 4 (by decide) (by decide) (by decide) (by decide)).trans h₄) | |
| ((hs 5 (by decide) (by decide) (by decide) (by decide)).trans h₅) | |
| ((hs 6 (by decide) (by decide) (by decide) (by decide)).trans h₆) | |
| ((hs 8 (by decide) (by decide) (by decide) (by decide)).trans h₈) | |
| (ambient, MachineRegularOriginalRow.zeroBuffer) | |
| have hout : loaded ((tape ∘ bodyIndex) 7) = base (tape 7) := | |
| hs 7 (by decide) (by decide) (by decide) (by decide) | |
| rw [hout] at bodyRun | |
| change (advance (TM2.step program))^[reindexSteps d c b v j relation (base (tape 7))] | |
| (some ⟨some (labels (.row (.inl .copySeed))), streamClean d positive ambient, loaded⟩) = | |
| some ⟨some (labels .clearTail), streamClean d positive ambient, rowed⟩ at bodyRun | |
| have rowedTail : rowed (tape 0) = encodeWord v := by | |
| simp only [rowed, reindexResultTapes, reindexMappedTapes, Function.comp_apply, hb6, hb7] | |
| simpa only [Function.update_of_ne (hd 0 7 (by decide)), | |
| Function.update_of_ne (hd 0 6 (by decide))] using loadedTail | |
| have rowedOld : tailCleared (tape 1) = encodeWord j := by | |
| simp only [tailCleared, rowed, reindexResultTapes, reindexMappedTapes, | |
| Function.comp_apply, hb6, hb7] | |
| simpa only [Function.update_of_ne (hd 1 0 (by decide)), | |
| Function.update_of_ne (hd 1 7 (by decide)), Function.update_of_ne (hd 1 6 (by decide))] | |
| using loadedReverse | |
| have rowedRelation : oldCleared (tape 2) = relationBits := by | |
| simp only [oldCleared, tailCleared, rowed, reindexResultTapes, reindexMappedTapes, | |
| Function.comp_apply, hb6, hb7] | |
| simpa only [Function.update_of_ne (hd 2 1 (by decide)), | |
| Function.update_of_ne (hd 2 0 (by decide)), Function.update_of_ne (hd 2 7 (by decide)), | |
| Function.update_of_ne (hd 2 6 (by decide))] using loadedRelation | |
| have rowedNew : relationCleared (tape 6) = encodeWord (MachinePortReindex.value d c b j) := by | |
| simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, | |
| reindexMappedTapes, Function.comp_apply, bodyIndex, hd 6 2 (by decide), | |
| hd 6 1 (by decide), hd 6 0 (by decide), hd 6 7 (by decide)] | |
| have clearTail := (MachineDrain.drainInTime (tape 0) (labels .clearTail) | |
| (some (labels .clearOld)) program (atLabels .clearTail) rowed | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| change (advance (TM2.step program))^[(rowed (tape 0)).length + 1] | |
| (some ⟨some (labels .clearTail), streamClean d positive ambient, rowed⟩) = | |
| some ⟨some (labels .clearOld), streamClean d positive ambient, tailCleared⟩ at clearTail | |
| rw [rowedTail, encodeWord_length] at clearTail | |
| have clearOld := (MachineDrain.drainInTime (tape 1) (labels .clearOld) | |
| (some (labels .clearRelation)) program (atLabels .clearOld) tailCleared | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| change (advance (TM2.step program))^[(tailCleared (tape 1)).length + 1] | |
| (some ⟨some (labels .clearOld), streamClean d positive ambient, tailCleared⟩) = | |
| some ⟨some (labels .clearRelation), streamClean d positive ambient, oldCleared⟩ at clearOld | |
| rw [rowedOld, encodeWord_length] at clearOld | |
| have clearRelation := (MachineDrain.drainInTime (tape 2) (labels .clearRelation) | |
| (some (labels .clearNew)) program (atLabels .clearRelation) oldCleared | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| change (advance (TM2.step program))^[(oldCleared (tape 2)).length + 1] | |
| (some ⟨some (labels .clearRelation), streamClean d positive ambient, oldCleared⟩) = | |
| some ⟨some (labels .clearNew), streamClean d positive ambient, relationCleared⟩ at clearRelation | |
| rw [rowedRelation] at clearRelation | |
| have clearNew := (MachineDrain.drainInTime (tape 6) (labels .clearNew) | |
| exit program (atLabels .clearNew) relationCleared | |
| ((ambient, MachineRegularOriginalRow.zeroBuffer), | |
| MachineFixedDivMod.residue d positive 0) none).evals_in_steps | |
| change (advance (TM2.step program))^[(relationCleared (tape 6)).length + 1] | |
| (some ⟨some (labels .clearNew), streamClean d positive ambient, relationCleared⟩) = | |
| some ⟨exit, streamClean d positive ambient, | |
| Function.update relationCleared (tape 6) []⟩ at clearNew | |
| rw [rowedNew, encodeWord_length] at clearNew | |
| have finalFrame : Function.update relationCleared (tape 6) [] = | |
| streamResultTapes d c b v j relation tape base suffix := by | |
| funext k | |
| by_cases h6 : k = tape 6 | |
| · subst k | |
| simp [streamResultTapes, hd 6 7 (by decide), hd 6 9 (by decide), h₆] | |
| · by_cases h2 : k = tape 2 | |
| · subst k | |
| simp [relationCleared, streamResultTapes, hd 2 6 (by decide), | |
| hd 2 7 (by decide), hd 2 9 (by decide), h₂] | |
| · by_cases h1 : k = tape 1 | |
| · subst k | |
| simp [relationCleared, oldCleared, streamResultTapes, | |
| hd 1 6 (by decide), hd 1 2 (by decide), hd 1 7 (by decide), | |
| hd 1 9 (by decide), h₁] | |
| · by_cases h0 : k = tape 0 | |
| · subst k | |
| simp [relationCleared, oldCleared, tailCleared, streamResultTapes, | |
| hd 0 6 (by decide), hd 0 2 (by decide), hd 0 1 (by decide), | |
| hd 0 7 (by decide), hd 0 9 (by decide), h₀] | |
| · by_cases h7 : k = tape 7 | |
| · subst k | |
| simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, | |
| reindexMappedTapes, Function.comp_apply, bodyIndex, streamResultTapes, | |
| loaded, reverseLoaded, tailLoaded, hd 7 6 (by decide), hd 7 2 (by decide), | |
| hd 7 1 (by decide), hd 7 0 (by decide), hd 7 9 (by decide)] | |
| · by_cases h9 : k = tape 9 | |
| · subst k | |
| simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, | |
| reindexMappedTapes, Function.comp_apply, bodyIndex, loaded, reverseLoaded, | |
| tailLoaded, streamResultTapes, hd 9 6 (by decide), hd 9 2 (by decide), | |
| hd 9 1 (by decide), hd 9 0 (by decide), hd 9 7 (by decide)] | |
| · simp [relationCleared, oldCleared, tailCleared, rowed, reindexResultTapes, | |
| reindexMappedTapes, Function.comp_apply, bodyIndex, loaded, reverseLoaded, | |
| tailLoaded, streamResultTapes, h6, h2, h1, h0, h7, h9] | |
| rw [finalFrame] at clearNew | |
| exact joinTrace (joinTrace (joinTrace (joinTrace (joinTrace (joinTrace | |
| (joinTrace tailRun reverseRun) copyRun) bodyRun) clearTail) clearOld) clearRelation) clearNew | |
| end IndependentSetsGames.Foundations.Complexity.MachineLazyRows | |
| end OAI | |
Xet Storage Details
- Size:
- 26.8 kB
- Xet hash:
- c0be478690f0356b2c1a78e9d282316e04cd5b1aaf7d571a813acd077ea2ed3d
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.