import OAI.Computability.Logspace.EstimatorMachine import OAI.Computability.Logspace.IterationSchedule namespace OAI /-! Choice of simultaneous resource and error parameters for the estimator. From OpenAI, *Exact Derandomization of Logarithmic Space: L = RL = BPL*. -/ set_option autoImplicit true section namespace ExactDerandomization.Terrain open Analysis Hie Counter Relay Rill Fret Grain Net Est At Buf Stage Finset open Chime Scheme Dome Cone.ConeX _root_.OAI.ExactDerandomization.Sub Swirl open Helix Helix.Age Helix.Mold Helix.Orbit Helix.Foil Helix.Moon open SiteX SiteX.Line open Rain noncomputable section open scoped Classical variable {q w h:ℕ} {r:Rock q w h} namespace Bank /- Monetary knobs separated from the syntactic program. Overspending c for canonical tapes scheduled LAST. Width e is small label sizing, independent of c. -/ def bootC (r:Rock q w h):ℕ:= 50+ Was.Kpre r +clim r.w.p+2*r.w.p.M abbrev hi (_:MintV)(r:Rock q w h):ℕ:=bootC r+10 abbrev hu (p:MintV)(r:Rock q w h):ℕ:=10*(hi p r+p.vol) abbrev hx (p:MintV)(r:Rock q w h):ℕ:= 10*(hu p r+p.vol) structure Green (r:Rock q w h)(p:MintV) :Prop where money : ∃ t:r.w.Proof, t.T.size^4 ≤ massB p.coin 1∧ t.T.R ≤ massB p.sealR 1 minutes: (massB p.low 1)⁻¹ ≤ delta / 1000 power : 4+Pass.reserve r.w ≤ p.vol honest: 16+p.tokenH ≤ p.sealR lemma greenUp {r:Rock q w h} (e:r.w.Proof):∃ p:MintV,Green r p:=by have he (c:ℝ):∃ p:ℕ,c ≤ massB p 1 := by obtain ⟨p,h⟩:= exists_nat_gt c exact ⟨p,h.le.trans (swellB (by omega)).le⟩ obtain ⟨k,hk⟩:=he (e.T.size^4) obtain ⟨c,hc⟩:=he e.T.R obtain ⟨w,hw⟩:=he (1000/delta) let v:=4+Pass.reserve r.w let p:MintV:=⟨k,v,c+16+v+20+2*k,w⟩ refine ⟨p,⟨e,hk,le_trans hc (mass_mono (by dsimp only [p]; omega) _)⟩,?_,le_rfl,?_⟩ · apply le_trans (inv_anti₀ (div_pos (by norm_num) dp) hw) exact le_of_eq (by simp) change 16+(v+(20+2*k)) ≤ _ dsimp only [p]; omega structure Turf (p:MintV) (r:Rock q w h) (v:Tags) :Prop where saving : Green r p cost0 : hx p r ≤ v.e coinbook : bootC r ≤ v.bonus namespace Green variable {p:MintV} (h0:Green r p) include h0 lemma tested : p.fine:=by unfold MintV.fine; have hh:=h0.honest; omega lemma rooms:50+CarryE r.w+r.w.p.K ≤ p.vol:=by have hh:=h0.power; unfold Pass.reserve passport at hh; omega lemma boxesK {d i:ℕ}(hp:1 ≤ d)(he:i grind structure Rector (v:Fabric u)(p:MintV):Prop where book:Bank.Turf p u.r u.v chart:u.Chart good:v.Good namespace Rector variable {v:Fabric u}{p:MintV}(h0:Rector v p) include h0 lemma tickets(_ v':ℕ)(hp: v'.succ ≤ Bank.hx p u.r):(lb v') ≤ u.eye.e := (lb_le_inc v').trans (hp.trans h0.book.cost0) lemma wide0 (a i:ℕ):u.smallQ (v.c a i) 0:=by change lb 0 ≤ u.eye.e * u.D.D (v.c a i) rw [lb_zero]; have hx : 1 ≤ u.D.D (v.c a i):=by rw [D]; exact (pace ..).1 have hf : 1 ≤ u.eye.e:=by have h:=h0.book.cost0; change _ ≤ u.eye.e at h; unfold Bank.hx hu hi at h; omega nlinarith lemma aft {a i j:ℕ}(hx:lb j ≤ p.vol*u.D.D (v.c a i)):u.smallQ (v.c a i) j:=by exact le_trans hx (Nat.mul_le_mul_right _ (le_trans (show p.vol ≤ Bank.hx p u.r by unfold Bank.hx;omega) h0.book.cost0)) lemma endUnits (a:ℕ) (hj:a=14∨a=15∨(a=12 ∧ delta0 (bitR v.t))∨(a=16∧redV (bitR v.t))): u.D.Suite (v.c a 0):=by apply Fabric.Good.booked h0.chart h0.good · rw [Age.Period,ite_eq_right (by unfold Brole; omega)]; omega exact ⟨rightR _,Or.inr (by grind)⟩ variable (hc:v.activeR) lemma midUnits (hc:v.activeR) (a i:ℕ)(hj:(1 ≤ a∧a ≤ 4∧i< Age.L v.m)∨i=0∧((9 ≤ a∧a ≤ 11)∨(a=13∧delta0 (bitR v.t)))): u.D.Suite (v.c a i):=by apply Fabric.Good.booked h0.chart h0.good ?_ ⟨rightR _,Or.inl ⟨by grind,(v.workR).1 hc⟩⟩ unfold Age.Period Brole; rcases hj with h|h <;> grind lemma provision {a b i o m:ℕ}(hi:b=2∨b=4∨b=10∨b=11∨b=15) (he: b=11 ∧ a=9 ∧ o=3 ∨ (a+1=b ∧b≠11∧o=0)) (hs:u.D.Suite (v.c a i))(ht:u.D.Suite (v.c b i)) (hh:∀ j:ℕ,j < m → lb j ≤ p.vol*u.D.D (v.c b i)): (CageQ.mk (v.c a i) (v.c b i) o m).Front u:=by have ha: (1 ≤ a∧ a ≤ 17)∧(Age.Brole a↔Age.Brole b):=by unfold Age.Brole;omega have hx:u.D.D (v.c a i)=u.D.D (v.c b i):=by rw [D,D]; simp [slackT,ha.2] refine ⟨hs.stage,ht.stage,?_,?_,hx,fun i hi=> h0.aft (hh i hi), (alive v (i:=i) hi he 0).1,fun j=>(alive v (i:=i) hi he j).2,?_⟩ · have h:= h0.book.cost0; change _ ≤ u.eye.e at h; unfold Bank.hx hu Bank.hi at h; omega · rw [W,W,D]; apply Age.sooner _ (by omega) (by omega) rwa [D,D] at hx intro j hk apply spokenC u hs.stage (Age.cpos _) o j 0 · change lb j ≤ u.eye.e *u.D.D (v.c a i) rw [hx]; exact hk rw [roleR] unfold taps omegaQ colorQ; omega lemma frontI (hc:v.activeR) (i)(he:i < Age.L v.m): (v.α p i).Front u := by apply h0.provision (by decide) (by decide) (h0.midUnits hc 1 i (Or.inl ⟨by decide,by decide,he⟩)) (h0.midUnits hc 2 i (Or.inl ⟨by decide,by decide,he⟩)) intro j hj; rw [D]; exact h0.book.saving.ray_size (gap_pos _ i) hj lemma frontP (hc:v.activeR) (i)(he:i < Age.L v.m): (v.β i).Front u := by apply h0.provision (by decide) (by decide) (h0.midUnits hc 3 i (Or.inl ⟨by decide,by decide,he⟩)) (h0.midUnits hc 4 i (Or.inl ⟨by decide,by decide,he⟩)) intro j hj; rw [D]; exact h0.book.saving.trunks he hj lemma frontT (hc:v.activeR) (b): (v.terminal b).Front u:=by cases b · apply h0.provision (by decide) (by decide) (h0.midUnits hc 9 0 (Or.inr ⟨rfl,Or.inl (by decide)⟩)) (h0.midUnits hc 10 0 (Or.inr ⟨rfl,Or.inl (by decide)⟩)) intro j hj; rw [D]; exact h0.book.saving.boxesK ((pace ..).1) hj apply h0.provision (by decide) (by decide) (h0.midUnits hc 9 0 (Or.inr ⟨rfl,Or.inl (by decide)⟩)) (h0.midUnits hc 11 0 (Or.inr ⟨rfl,Or.inl (by decide)⟩)) intro j hj; rw [D]; exact h0.book.saving.boxesK ((pace ..).1) hj lemma frontE : v.leaveE.Front u:=by apply h0.provision (by decide) (by decide) (h0.endUnits _ (Or.inl rfl)) (h0.endUnits _ (Or.inr (Or.inl rfl))) intro j hj; rw [D]; exact h0.book.saving.boxesK ((pace ..).1) hj end Rector end Stone end end ExactDerandomization.Terrain end end OAI