cfahlgren1/math / lean /OAI /Combinatorics /IndependentSets /Machines /MachineLookupDiscard.lean
cfahlgren1's picture
download
raw
5.71 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Machines.MachineLookupCore
namespace OAI
namespace IndependentSetsGames.Foundations.Complexity.MachineLookup
open Turing
variable {K Λ σ : Type} [DecidableEq K]
private theorem discard_update_twice (source : K) (base : K → List Bool)
(input replacement : List Bool) :
Function.update (Function.update base source input) source replacement =
Function.update base source replacement := by
funext p
by_cases hp : p = source
· subst p; simp
· simp [hp]
theorem discardStep_delimiter (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (suffix : List Bool) (ambient : σ)
(register : Option Bool) :
TM2.step program
⟨some loopLabel, (ambient, register), Function.update base source (false :: suffix)⟩ =
some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by
change some (TM2.stepAux (program loopLabel) (ambient, register)
(Function.update base source (false :: suffix))) = _
rw [atLoop]
simp [discard, TM2.stepAux]
theorem discardStep_true (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (input : List Bool) (ambient : σ)
(register : Option Bool) :
TM2.step program
⟨some loopLabel, (ambient, register), Function.update base source (true :: input)⟩ =
some ⟨some loopLabel, (ambient, some true), Function.update base source input⟩ := by
change some (TM2.stepAux (program loopLabel) (ambient, register)
(Function.update base source (true :: input))) = _
rw [atLoop]
simp [discard, TM2.stepAux]
theorem discard_empty_step (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (hinput : base source = [])
(ambient : σ) (register : Option Bool) :
TM2.step program ⟨some loopLabel, (ambient, register), base⟩ =
some ⟨some returnLabel, (ambient, none), base⟩ := by
have hupdate : Function.update base source [] = base := by
funext p
by_cases hp : p = source
· subst p; simp [hinput]
· simp [hp]
change some (TM2.stepAux (program loopLabel) (ambient, register) base) = _
rw [atLoop]
simp [discard, TM2.stepAux, hinput, hupdate]
theorem discardTrace_update (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (n : Nat) (suffix : List Bool)
(ambient : σ) (register : Option Bool) :
(MachineComposition.advance (TM2.step program))^[n + 1]
(some ⟨some loopLabel, (ambient, register),
Function.update base source (encodeWord n ++ suffix)⟩) =
some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by
induction n generalizing register with
| zero =>
simpa only [Nat.zero_add, Function.iterate_one, MachineComposition.advance_some,
encodeWord, List.replicate_zero, List.nil_append, List.singleton_append] using
discardStep_delimiter source loopLabel returnLabel program atLoop
base suffix ambient register
| succ n ih =>
rw [Function.iterate_succ_apply]
simp only [encodeWord, List.replicate_succ, List.cons_append]
change (MachineComposition.advance (TM2.step program))^[n + 1]
(TM2.step program ⟨some loopLabel, (ambient, register),
Function.update base source (true :: (encodeWord n ++ suffix))⟩) = _
rw [discardStep_true source loopLabel returnLabel program atLoop, ih]
theorem discardTrace (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (n : Nat) (suffix : List Bool)
(hinput : base source = encodeWord n ++ suffix)
(ambient : σ) (register : Option Bool) :
(MachineComposition.advance (TM2.step program))^[n + 1]
(some ⟨some loopLabel, (ambient, register), base⟩) =
some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩ := by
have hbase : Function.update base source (encodeWord n ++ suffix) = base := by
funext p
by_cases hp : p = source
· subst p; simp [hinput]
· simp [hp]
have h := discardTrace_update source loopLabel returnLabel program atLoop
base n suffix ambient register
rw [hbase] at h
exact h
def discardInTime (source : K) (loopLabel returnLabel : Λ)
(program : Λ → TM2.Stmt (Alphabet (K := K)) Λ (σ × Option Bool))
(atLoop : program loopLabel = discard source loopLabel returnLabel)
(base : K → List Bool) (n : Nat) (suffix : List Bool)
(hinput : base source = encodeWord n ++ suffix)
(ambient : σ) (register : Option Bool) :
StateTransition.EvalsToInTime (TM2.step program)
⟨some loopLabel, (ambient, register), base⟩
(some ⟨some returnLabel, (ambient, none), Function.update base source suffix⟩)
(n + 1) where
steps := n + 1
evals_in_steps := discardTrace source loopLabel returnLabel program atLoop
base n suffix hinput ambient register
steps_le_m := Nat.le_refl _
end IndependentSetsGames.Foundations.Complexity.MachineLookup
end OAI

Xet Storage Details

Size:
5.71 kB
·
Xet hash:
b9e34d020837de272e0bcdf001d42b4aba9704554264852cb3d0c9b3a758a961

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.