Buckets:
| import OAI.Computability.DepthThree.TapeArray | |
| import OAI.Computability.DepthThree.TapeArithmetic | |
| namespace OAI | |
| universe uDepth1 uDepth2 uDepth3 uDepth4 | |
| namespace DepthThreeLowerBound | |
| namespace TapeProductTerm | |
| open TapeMultiProgram TapeCopy TapeRouting TapeArithmetic TapeUnary | |
| theorem onPair_eq_self {src dst : TapeRegister} {T : TapeTapes} | |
| {S D : Turing.Tape TapeSymbol} (hS : T src = S) (hD : T dst = D) : | |
| onPair src dst T S D = T := by | |
| funext r | |
| by_cases hs : r = src | |
| · subst r | |
| simpa only [onPair_src] using hS.symm | |
| · by_cases hd : r = dst | |
| · subst r | |
| simp only [onPair, hs, ite_false, ite_true] | |
| exact hD.symm | |
| · simp [onPair, hs, hd] | |
| theorem read_at {index array : TapeRegister} (hne : index ≠ array) | |
| (T : TapeTapes) («prefix» suffix : List Bool) (b : Bool) | |
| (hi : T index = counterTape «prefix».length) | |
| (ha : T array = wordTape («prefix» ++ b :: suffix)) : | |
| RunsIn (TapeArray.code index array id).step | |
| (cfg TapeArray.State.start T) (cfg (TapeArray.State.done b) T) | |
| (2 * «prefix».length + 4) := by | |
| have h := TapeArray.runs_read hne T «prefix» suffix b | |
| have hframe := onPair_eq_self hi ha | |
| dsimp only [counterTape] at hframe | |
| simpa only [counterTape, hframe] using h | |
| theorem modify_at {index array : TapeRegister} (hne : index ≠ array) | |
| (f : Bool → Bool) (T : TapeTapes) («prefix» suffix : List Bool) (b : Bool) | |
| (hi : T index = counterTape «prefix».length) | |
| (ha : T array = wordTape («prefix» ++ b :: suffix)) : | |
| RunsIn (TapeArray.code index array f).step | |
| (cfg TapeArray.State.start T) | |
| (cfg (TapeArray.State.done b) | |
| (Function.update T array (wordTape («prefix» ++ f b :: suffix)))) | |
| (2 * «prefix».length + 4) := by | |
| have h := TapeArray.runs_modify hne f T «prefix» suffix b | |
| have hframe := onPair_eq_self hi ha | |
| have hout : onPair index array T (counterTape «prefix».length) | |
| (wordTape («prefix» ++ f b :: suffix)) = | |
| Function.update T array (wordTape («prefix» ++ f b :: suffix)) := by | |
| rw [← update_onPair_dst hne T (counterTape «prefix».length) | |
| (wordTape («prefix» ++ b :: suffix)), hframe] | |
| dsimp only [counterTape] at hframe hout | |
| simpa only [counterTape, hframe, hout] using h | |
| def carryCode {F : Type uDepth1} {Q : Type uDepth2} (P : F → TapeMultiProgram Q) : TapeMultiProgram (F × Q) | |
| | (flag, q), h => (P flag q h).map fun out => ((flag, out.1), out.2) | |
| theorem carry_runs {F : Type uDepth3} {Q : Type uDepth4} (P : F → TapeMultiProgram Q) (flag : F) | |
| {q q' : Q} {T U : TapeTapes} {n : ℕ} | |
| (h : RunsIn (P flag).step (cfg q T) (cfg q' U) n) : | |
| RunsIn (carryCode P).step (cfg (flag, q) T) (cfg (flag, q') U) n := | |
| runs_map (P flag) (carryCode P) (fun q => (flag, q)) (by | |
| intro a heads a' writes moves he | |
| simp only [carryCode, he, Option.map_some]) h | |
| def readFlag : TapeArray.State → Bool | |
| | .done b => b | |
| | _ => false | |
| abbrev ReadState := TapeArray.State ⊕ (Bool × TapeArray.State) | |
| abbrev State := ReadState ⊕ ((Bool × Bool) × TapeArray.State) | |
| def readProgram (i a j b : TapeRegister) : TapeMultiProgram ReadState := | |
| joinCode (TapeArray.code i a id) | |
| (carryCode (fun _ : Bool => TapeArray.code j b id)) | |
| (fun q => (readFlag q, TapeArray.State.start)) | |
| def termFlags : ReadState → (Bool × Bool) | |
| | .inr (a, q) => (a, readFlag q) | |
| | .inl _ => (false, false) | |
| def updateProgram (k c : TapeRegister) : TapeMultiProgram ((Bool × Bool) × TapeArray.State) := | |
| carryCode fun ab => TapeArray.code k c (fun old => Bool.xor old (ab.1 && ab.2)) | |
| def program (i a j b k c : TapeRegister) : TapeMultiProgram State := | |
| joinCode (readProgram i a j b) (updateProgram k c) | |
| (fun q => (termFlags q, TapeArray.State.start)) | |
| def start : State := .inl (.inl TapeArray.State.start) | |
| def done (a b old : Bool) : State := .inr ((a, b), TapeArray.State.done old) | |
| theorem runs_product_term (i a j b k c : TapeRegister) | |
| (hia : i ≠ a) (hjb : j ≠ b) (hkc : k ≠ c) | |
| (T : TapeTapes) (pa sa pb sb pc sc : List Bool) (va vb old : Bool) | |
| (hi : T i = counterTape pa.length) (ha : T a = wordTape (pa ++ va :: sa)) | |
| (hj : T j = counterTape pb.length) (hb : T b = wordTape (pb ++ vb :: sb)) | |
| (hk : T k = counterTape pc.length) (hc : T c = wordTape (pc ++ old :: sc)) : | |
| RunsIn (program i a j b k c).step (cfg start T) | |
| (cfg (done va vb old) | |
| (Function.update T c (wordTape (pc ++ Bool.xor old (va && vb) :: sc)))) | |
| (2 * (pa.length + pb.length + pc.length) + 14) := by | |
| have hra := read_at hia T pa sa va hi ha | |
| have hrb := read_at hjb T pb sb vb hj hb | |
| have hrb' := carry_runs (fun _ : Bool => TapeArray.code j b id) va hrb | |
| have hread := join_runs (TapeArray.code i a id) | |
| (carryCode (fun _ : Bool => TapeArray.code j b id)) | |
| (fun q => (readFlag q, TapeArray.State.start)) hra rfl hrb' | |
| have hupdate := modify_at hkc (fun old => Bool.xor old (va && vb)) T pc sc old hk hc | |
| have hupdate' := carry_runs | |
| (fun ab : Bool × Bool => TapeArray.code k c (fun old => Bool.xor old (ab.1 && ab.2))) | |
| (va, vb) hupdate | |
| have hreadhalt : readProgram i a j b (.inr (va, TapeArray.State.done vb)) (heads T) = none := rfl | |
| have hall := join_runs (readProgram i a j b) (updateProgram k c) | |
| (fun q => (termFlags q, TapeArray.State.start)) hread hreadhalt hupdate' | |
| have htime : (2 * pa.length + 4 + 1 + (2 * pb.length + 4)) + 1 + | |
| (2 * pc.length + 4) = 2 * (pa.length + pb.length + pc.length) + 14 := by omega | |
| simpa only [program, start, done, htime] using hall | |
| @[simp] theorem program_done (i a j b k c : TapeRegister) (va vb old : Bool) (h : TapeHeads) : | |
| program i a j b k c (done va vb old) h = none := rfl | |
| end TapeProductTerm | |
| end DepthThreeLowerBound | |
| end OAI | |
Xet Storage Details
- Size:
- 5.74 kB
- Xet hash:
- 15ee34d3eb88a659cc011d2877eb2a17bc9aabbef591b64754663c13e4022db3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.