import OAI.Computability.Logspace.EstimatorMachine namespace OAI /-! Finite iteration schedules and the decomposition of estimator increments. From OpenAI, *Exact Derandomization of Logarithmic Space: L = RL = BPL*. -/ set_option autoImplicit true section namespace ExactDerandomization.Rain open Counter Relay Rill Fret Chime Finset Grain Net Hie Est Analysis Stage Glass open Helix Helix.Foil Helix.Age Helix.Moon Helix.Night Helix.Mold Helix.Orbit Scheme open Dome Cone ConeX Buf At SiteX SiteX.MintV noncomputable section /- Enumerate the increments by a pool in which each piece of a telescope, variant of the walk, and multiplicand port have one reserved index. -/ abbrev Crack:= Bool×ℕ abbrev CellQ:= Crack × (ℕ×ℕ) abbrev Fog := (Bool×CellQ) × (Bool×ℕ) abbrev Seed := (ℕ× ℕ×ℕ) × Fog abbrev store0 (_:Word)(x:ℕ):Seed:=dec x namespace Fog abbrev first0 (q:Fog):Bool:=q.1.1 abbrev cell0 (q:Fog):= q.1.2 abbrev sig (q:Fog) := q.cell0.2.2 abbrev event (q:Fog):= q.2.2 abbrev k (q:Fog)(a:ℕ):= if q.cell0.1.1 then a+q.cell0.1.2 else a-q.cell0.1.2 abbrev ray (q:Fog)(a:ℕ):ℕ×ℕ:= (q.k a,q.cell0.2.1) abbrev slackM (q:Fog)(M:ℕ):= M-q.sig-1 abbrev budget (q:Fog)(M:ℕ) := if q.2.1 then q.slackM M+1 else q.slackM M abbrev tick (q:Fog)(v:Wares):=v.ell*q.sig def habitat (q:Fog)(w:Wares)(a m i:ℕ)(forest:Finset Ray):Prop:= let p:=q.ray a let s:Est.Stair:=⟨m,0,⟨a,0,0⟩,w.ell⟩ p∈forest ∧ q.slackM m ∈ s.layers p.1 i ∧ s.slack (q.slackM m)=q.sig ∧ q.cell0.1=(if a ≤ p.1 then (true,p.1-a) else (false,a-p.1)) ∧ q.event simp_all ; omega lemma just (s:Stair)(p:Ray)(m:ℕ):s.layers p.1 m = Est.Stair.layers ⟨s.M,0,⟨s.key.a,0,0⟩,s.lam⟩ p.1 m := by cases m <;> rfl lemma hews {s:Stair} {w:Wares}(hp:s.lam=w.ell) (b:Bool) {p:Ray}{forest:Finset Ray}(he:p∈forest) {i m:ℕ}(hm:m∈s.layers p.1 i)(a:Bool) {j:ℕ}(hj:j dsimp only <;> omega omega end Fog namespace Seed abbrev fog:(Seed)→ Fog:=Prod.snd abbrev x (v:Seed):ℕ:= v.1.2.1 abbrev y (v:Seed):ℕ:=v.1.2.2 def old (b:Bool)(i:ℕ):Seed:=((if b then 0 else 1,i,0),(false,(true,0),0,0),false,0) def along (v:Fog)(i j:ℕ):Seed:= ((2,i,j),v) lemma old_inj {b c i j}: Seed.old b i=Seed.old c j ↔ b=c∧i=j:=by cases b <;> cases c <;> simp [Seed.old] lemma along_inj {q f i j a b}: along q i j=along f a b ↔ q=f∧i=a∧j=b:=by simp [along]; tauto lemma old_not (p i j q v):old p i ≠ along q j v:=by cases p <;> simp [old,along] end Seed abbrev CarryE(p:Wares) :ℕ:= cexpo 2 p.p.K *4 def passport (v:Wares):ℕ:= 50+v.p.M^2+v.p.K+2*v.p.M+4*CarryE v+2*v.ell*lb Print.rad namespace Pass variable (v:Wares) lemma small {p d i j:ℕ}(h:p ≤ i*d)(he:i ≤ j):p ≤ j*d:=le_trans h (Nat.mul_le_mul_right d he) abbrev sized {α} [Wire α] (u:α)(k d:ℕ):= lb (enc u) ≤ k*d lemma pair {α β} [Wire α] [Wire β] {p:α}{q:β}{c d:ℕ}(h:1 ≤ d)(hc:2 ≤ c) (hp:sized p c d)(hq:sized q c d):sized (p,q) (4*c) d:=by have he:lb (enc (p,q)) ≤ 2*lb (enc p)+lb (enc q)+2:=measure_pair .. unfold sized at *; nlinarith lemma little (p d:ℕ)(h:1 ≤ d):sized p (p+1) d:=by change lb p ≤ _; have := lb_le_inc p; nlinarith lemma left {α} [Wire α] (p:α)(k d:ℕ)(h:sized p k d) (c:ℕ)(hp:k ≤ c):sized p c d:=small h hp lemma boo (p:Bool)(k d:ℕ)(he:1 ≤ k)(hp:1 ≤ d):sized p k d:=by unfold sized have h: lb (enc p)=1:=by cases p<;> rfl rw [h]; nlinarith abbrev reserve (v:Wares):=4^7 *passport v lemma lengthC {s:Stair} {i:ℕ}(hp:s.lam=v.ell)(hi:i{q}×ˢ ((s.layers q.1 i).biUnion fun m=>{m}×ˢ calendar s m)) abbrev Arc:= Ray × ℕ × Bool×ℕ lemma pat (p:Finset Ray)(i:ℕ)(x:Arc): x∈tracks s p i ↔ x.1∈p∧ x.2.1∈s.layers x.1.1 i∧ x.2.2.2< Print.rad^h s x.2.1:=by unfold tracks calendar rcases x with ⟨a,b,c,d⟩; cases c <;> simp [and_assoc,and_left_comm,and_comm] def drops (b:Bool)(q:Arc):Fog:= number0 s b q.1 q.2.1 q.2.2.1 q.2.2.2 lemma grange {w:Wares}(ht:s.lam=w.ell)(b:Bool){x:Arc}{p i}(h:x∈tracks s p i): (drops s b x).habitat w s.key.a s.M i p∧ (drops s b x).ray s.key.a=x.1 ∧ (drops s b x).slackM s.M=x.2.1:=by obtain ⟨hl,hA,hQ⟩:= (pat s p i x).mp h obtain ⟨hz,hf⟩:=hews ht b hl hA x.2.2.1 hQ exact ⟨hz,from0 ..,hf⟩ lemma disjoint0 {w:Wares}(ht:s.lam=w.ell) (b p i):Set.InjOn (drops s b) ↑(tracks s p i):= by intro x hx y hy he have h1:=grange s ht b hx; have h2:=grange s ht b hy have ha:x.1=y.1:= h1.2.1.symm.trans ((congrArg (fun x=> ray x s.key.a) he).trans h2.2.1) have hb:x.2.1=y.2.1:= h1.2.2.symm.trans ((congrArg (fun x=> slackM x s.M) he).trans h2.2.2) have hc:x.2.2=y.2.2:=congrArg (fun q:Fog=>q.2) he exact Prod.ext ha (Prod.ext hb hc) lemma total (p:Finset Ray) (i:ℕ) (f:Arc→ℝ): ∑ x∈tracks s p i,f x= ∑ x∈p,∑ m∈s.layers x.1 i,∑ j∈range (Print.rad^(h s m)),∑ b:Bool,f (x,m,b,j):=by unfold tracks rw [sum_biUnion] · apply sum_congr rfl; intro x hx rw [sum_product]; simp only [sum_singleton] rw [sum_biUnion] · apply sum_congr rfl; intro m hm; rw [sum_product] simp only [sum_singleton]; unfold calendar; rw [sum_product,sum_comm] intro i hi j hj ht; apply Finset.disjoint_left.2 intro a ha hc; simp only [mem_product,mem_singleton] at ha hc; grind intro i hi j hj ht; apply Finset.disjoint_left.2 intro a ha hc; simp only [mem_product,mem_singleton] at ha hc; grind def wind (f:Est.Flame n)(d:Axis)(u:Pool n)(x y:ℕ)(r:Arc):ℝ:= let t:= Print.queue (h s r.2.1) r.2.2.2 if Env.live d.u d.a (↑x:ZMod n) (↑y:ZMod n) (w:=0) (d:=0) le_rfl t.1 t.2 u then (if r.2.2.1 then 1 else -1)*Env.weight^(h s r.2.1)* (f.lines r.1).seq (if r.2.2.1 then r.2.1+1 else r.2.1) (go d.u d.a (w:=0) (d:=0) le_rfl t.1 t.2 u) x y else 0 theorem humid (f:Flame n)(d:Axis)(i:ℕ)(u:Pool n)(x y:ℕ) : f.portion s d i u x y=(∑ j∈tracks s f.rays i,wind s f d u x y j)+ if i=0 then f.base x y else 0 :=by rw [total] unfold Flame.portion apply congrArg (fun (p:ℝ)=>p+_) apply sum_congr rfl; intro j hj; unfold Est.Line.waveR apply sum_congr rfl; intro m hm unfold Est.Line.pick Axis.fw Env.sampling rw [← Print.touring] apply sum_congr rfl; intro p hp simp only [Fintype.sum_bool] unfold wind let v:= Print.queue (h s m) p dsimp only unfold Est.Line.shake h split · next hx=> simp only [ite_true,Bool.false_eq_true,ite_false]; ring next hc=>ring end Census end end ExactDerandomization.Rain end end OAI