defannual (x : GridM) {s : SceneM} (t : Play j M s) : ℝ:=match t with
body · 5
lines
| .rest _ =>0
| .ticket _ t => jackpot x t+annual x t
| .freeze _ t => annual x t
| .attempt _ _ l r => annual x l+annual x r
| .jump s l r =>if (step s).bit x then annual x r else annual x l
lemmaannual_valid :
∀ᶠ j : ℕin atTop, ∀MJ : ℕ, J≤M→∀s : SceneM, ∀f : GridM→ℝ,
∀t : Play j M s, t.FollowsJ f →∀u x : GridM, x∈s.here.block M→
‖summons u x t‖ ≤ annual x t :=by
proof · 25
lines
filter_upwards [gala] with j hj MJ hh s f t h u x hx
induction t with
| rest s => simp [summons,annual]
| ticket s t ih =>
rw [summons,annual]
haveHT:= fit_ticket h
obtain ⟨ha,hb,hc,hd,he⟩ := h
apply le_trans (norm_add_le _ _)
apply add_le_add _ (ih he hx)
let q := t
unfold ordinary jackpot; rw [norm_scaleC,abs_of_nonneg HT.1.pos.le]
apply mul_le_mul_of_nonneg_left _ HT.1.pos.le
haveH:=Thread.projected _ he
exact hj _ _ hh _ f _ _ _ (stream_cast _ H x) (trip_stream _ HHT.1 hx)
| freeze s t ih => exact ih h.2.2.2 hx
| attempt s v l r il ir =>
rw [summons,annual]
exact (norm_add_le _ _).trans (add_le_add (il h.2.2.2.2.1 hx) (ir h.2.2.2.2.2 hx))
| jump s l r il ir =>
rw [summons,annual]
haveHE:= stream_child (less_self _) hx
split_ifs withHH
· exact ir h.2.2.2.2 (HH ▸ HE)
· rw [show (step s).bit x=falsefromBool.eq_false_iff.mpr HH] at HE
exact il h.2.2.2.1HE
lemmacost_jump (s : SceneM) (l : Play j M (s.smaller false)) (r : Play j M (s.smaller true))
(h : (Play.jump s l r).FollowsJ f) :
let a := s.norm*(if s.live then stamp s j else0)
proof · 2
lines
yieldA (Play.jump s l r) + overdue (Play.jump s l r) =
((yieldA l+overdue l)+(yieldA r+overdue r))/2+a :=
lemmacost_attempt (s : SceneM) (u : Update j M s.here)
(l : Play j M (s.lose u)) (r : Play j M (s.win u)) :
yieldA (Play.attempt s u l r)+overdue (Play.attempt s u l r) =
yieldA l+overdue l+(yieldA r+overdue r) :=by
proof · 7
lines
rw [due_restart (s:=s.win u) rfl]
haveh₁ : yieldA (Play.attempt s u l r)=yieldA l+yieldA r :=Ex_add (s.here.dice M) _ _
haveh₂ : overdue (Play.attempt s u l r)=overdue l :=by
unfold overdue; rw [project]
cases project l <;> rfl
rw [h₁,h₂]; ring
lemmacost_overall :
∀ᶠ j : ℕin atTop, ∀MJ : ℕ, ∀f : GridM→ℝ, ∀s : SceneM,
∀t : Play j M s, t.FollowsJ f → (∀ x, f x ≤ exp (height j)) →
yieldA t+overdue t ≤ s.mass*netGross t :=by
proof · 79
lines
filter_upwards [receipt_paid] with j hj MJ f s t h hf
induction t with
| rest s =>
rw [netGross,trace,flat_finish,dueEmpty rfl]
simp_rw [yieldA,annual,Ex_const]; simp
| ticket s t ih =>let v := s.reset
have hs := fit_ticket h
obtain ⟨ha,hb,hc,hd,he⟩ := h
haveHE:= hj MJ v (project t) f (projected _ he) hs.1 hs.2.1 hs.2.2 hf
haveHA : yieldA (Play.ticket s t)=
v.norm*stats (project t) (souvenir v.live j)+yieldA t :=by
unfold yieldA
simp_rw [annual,jackpot]; rw [Ex_add,Ex_lmul]
rfl
rw [HA, netGross, trace, flat_push,dueEmpty rfl,add_zero]
let x := stats (project t) (souvenir v.live j)
change v.norm*x+_ ≤ s.mass*(gateTax s.reset j+netGross t)
leta : ℝ:=if v.live then stats (project t) (subtotal (fun b => stamp b.post j)) else0
change x ≤ gateTax v j+a at HEhaveHi:= ih he
rw [show overdue t = s.mass*a by unfold overdue a v; split <;> first|rfl|simp] at Hi
change yieldA t+s.mass*a ≤ s.mass*_ at Hi
change s.mass*x+_ ≤ s.mass*(gateTax v j+_)
nlinarith [hb.2.2]
| freeze s t ih =>
rw [dueEmpty rfl,netGross,trace]
rw [ite_eq_left rfl,flat_push]
haveHH:= ih h.2.2.2
rw [due_restart (s:=s.out) rfl] at HH
change yieldA t+0≤ s.mass*(0+netGross t)
rw [zero_add]; exact HH
| jump s l r il ir =>let t :=Play.jump s l r
rw [cost_jump _ _ _ h]
haveH₁:= traced t true h
unfold netGross; rw [trace,flat_fork _ _ H₁]
obtain ⟨ha,hb,hc,hd,he⟩ := h
let g (b : Bool) :=if b then netGross r else netGross l
letv : Bool→ℝ:=fun b =>match b with
| false=> netGross l
| true=> netGross r
letw : ∀ b, Road j M (s.smaller b) :=fun b =>match b with
| false=> trace true l
| true=> trace true r
letP:= (step s).probs
let m := s.mass; let x := s.norm*(if s.live then stamp s j else0)
haveHV (b : Bool) : (w b).flatFee billOf = v b :=by cases b <;> rfl
haveheq : P.Ex (funb : Bool=> normStamp s j+(w b).flatFee billOf) = normStamp s j+P.Ex v :=by
simp_rw [HV,Ex_add _ (f:=fun _ => _),Ex_const]
change _ + x ≤ s.mass*P.Ex (fun b => normStamp s j+(w b).flatFee billOf)
rw [heq,mul_add]
havehM : s.here.lev < M:= (Play.first hd).within.2have hi := output_split s ha.within.1 hM ha.positive hb.1.2.2 v
have hm := hb.1.2.2
rw [show s.mass*normStamp s j=x by unfold x normStamp; split; field_simp; simp]
change s.mass*P.Ex v=_ at hi
rw [hi,fair_av]
haveHI : (fun b => (s.smaller b).mass*v b) false = (s.smaller false).mass*netGross l := rfl
change _/2+x ≤ x+ ((s.smaller false).mass*netGross l+(s.smaller true).mass*netGross r)/2
linarith [il hd,ir he]
| attempt s u l r il ir =>let t :=Play.attempt s u l r
let v := toss s u; letP:= v.probs
haveH:= traced t true h
rw [cost_attempt,netGross,trace,flat_fork _ _ H]
obtain ⟨ha,hb,hc,hd,he,hx⟩ := h
letw : ∀ b, Road j M (v.dst b) :=fun b =>match b with
| false=> trace true l
| true=> trace true r
change _ ≤ s.mass*P.Ex (fun b =>0+(w b).flatFee billOf)
simp only [zero_add,Ex,Fintype.sum_bool]
haveHi:= toss_true u ha.within ha.positive hb.1.2.2haveHH : (s.lose u).mass = Pfalse*s.mass := toss_mass HifalsehaveHJ : (s.win u).mass = Ptrue*s.mass := toss_mass Hitrue
change _ ≤ s.mass*(Ptrue*netGross r+Pfalse*netGross l)
haveHi₁:= il he; haveHi₂:= ir hx
rw [HH] at Hi₁; rw [HJ] at Hi₂; linarith