cfahlgren1's picture
download
raw
9.67 kB
19
def jackpot (x : Grid M) {s : Scene M} (t : Play j M s) :=
body · 1 line
    s.norm*souvenir s.live j ((project t).stream x)
21
def annual (x : Grid M) {s : Scene M} (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
28
lemma fit_ticket {s : Scene M} {t : Play j M s.reset} (h : (Play.ticket s t).Follows J f) :
    Fit s.reset ∧ entry s.reset ∧ (s.live=true → exp (-height j) ≤ s.reset.norm) := by
proof · 4 lines
  obtain ⟨ha,hb,hc,hd,he⟩ := h
  have hh := hb.2.2
  refine ⟨⟨⟨ha.within,ha.positive⟩,hh,?_⟩,rfl, fun H => le_of_not_gt (fun h => hc ⟨H,Or.inr h⟩)⟩
  change s.mass/s.mass ≤ 4; rw [div_self hh.ne']; norm_num
35
lemma annual_valid :
    ∀ᶠ j : ℕ in atTop, ∀ M J : ℕ, J ≤ M → ∀ s : Scene M, ∀ f : Grid M → ℝ,
      ∀ t : Play j M s, t.Follows J f → ∀ u x : Grid M, x∈s.here.block M →
        ‖summons u x t‖ ≤ annual x t := by
proof · 25 lines
  filter_upwards [gala] with j hj M J hh s f t h u x hx
  induction t with
  | rest s => simp [summons,annual]
  | ticket s t ih =>
    rw [summons,annual]
    have HT := 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
    have H := Thread.projected _ he
    exact hj _ _ hh _ f _ _ _ (stream_cast _ H x) (trip_stream _ H HT.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]
    have HE := stream_child (less_self _) hx
    split_ifs with HH
    · exact ir h.2.2.2.2 (HH ▸ HE)
    · rw [show (step s).bit x=false from Bool.eq_false_iff.mpr HH] at HE
      exact il h.2.2.2.1 HE

Prices in true history.

66
def normStamp (s : Scene M) (j : ℕ) :=
body · 1 line
    if s.live then (s.norm/s.mass)*stamp s j else 0
68
def billOf : Event j M → ℝ
body · 3 lines
| .pace s .renew => gateTax s.reset j
| .march s .move _ => normStamp s j
| _ => 0
73
def netGross {s : Scene M} (t : Play j M s) := (trace true t).flatFee billOf
74
def yieldA {s : Scene M} (t : Play j M s) :=
body · 1 line
    (s.here.dice M).Ex (fun x => annual x t)
76
def overdue {s : Scene M} (t : Play j M s) :=
body · 1 line
    if s.live then s.norm*stats (project t) (subtotal (fun b => stamp b.post j)) else 0
79
lemma dueEmpty {s : Scene M} {t : Play j M s} (h : project t=blank s) : overdue t=0 := by
proof · 2 lines
  unfold overdue; rw [h]
  split; simp only [stats_nil,subtotal_nil,mul_zero]; rfl
82
lemma due_restart {s : Scene M} {t : Play j M s} (h : s.norm=0) : overdue t=0 := by simp [overdue,h]
84
lemma cost_jump (s : Scene M) (l : Play j M (s.smaller false)) (r : Play j M (s.smaller true))
    (h : (Play.jump s l r).Follows J f) :
    let a := s.norm*(if s.live then stamp s j else 0)
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 :=
124
lemma cost_attempt (s : Scene M) (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]
  have h₁ : yieldA (Play.attempt s u l r)=yieldA l+yieldA r :=
    Ex_add (s.here.dice M) _ _
  have h₂ : overdue (Play.attempt s u l r)=overdue l := by
    unfold overdue; rw [project]
    cases project l <;> rfl
  rw [h₁,h₂]; ring
136
lemma cost_overall :
    ∀ᶠ j : ℕ in atTop, ∀ M J : ℕ, ∀ f : Grid M → ℝ, ∀ s : Scene M,
      ∀ t : Play j M s, t.Follows J 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 M J 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
    have HE := hj M J v (project t) f (projected _ he) hs.1 hs.2.1 hs.2.2 hf
    have HA : 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)
    let a : ℝ := if v.live then stats (project t) (subtotal (fun b => stamp b.post j)) else 0
    change x ≤ gateTax v j+a at HE
    have Hi := 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]
    have HH := 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]
    have H₁ := 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

    let v : Bool → ℝ := fun b => match b with
      | false => netGross l
      | true => netGross r
    let w : ∀ b, Road j M (s.smaller b) := fun b => match b with
      | false => trace true l
      | true => trace true r
    let P := (step s).probs
    let m := s.mass; let x := s.norm*(if s.live then stamp s j else 0)
    have HV (b : Bool) : (w b).flatFee billOf = v b := by cases b <;> rfl
    have heq : P.Ex (fun b : 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]
    have hM : s.here.lev < M := (Play.first hd).within.2
    have 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]
    have HI : (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; let P := v.probs
    have H := traced t true h
    rw [cost_attempt,netGross,trace,flat_fork _ _ H]
    obtain ⟨ha,hb,hc,hd,he,hx⟩ := h
    let w : ∀ 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]
    have Hi := toss_true u ha.within ha.positive hb.1.2.2
    have HH : (s.lose u).mass = P false*s.mass := toss_mass Hi false
    have HJ : (s.win u).mass = P true*s.mass := toss_mass Hi true
    change _ ≤ s.mass*(P true*netGross r+P false*netGross l)
    have Hi₁ := il he; have Hi₂ := ir hx
    rw [HH] at Hi₁; rw [HJ] at Hi₂; linarith

Xet Storage Details

Size:
9.67 kB
·
Xet hash:
6c1cbc1d333da118fe778f96653a2b0948c5287bd756ff3215b281ed8633b85f

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