File size: 6,147 Bytes
d4317d7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | import OAI.MeasureTheory.Falconer.Recursion.BranchCounts
import OAI.MeasureTheory.Falconer.Recursion.BranchValidity
namespace OAI
namespace PlanarFalconer
noncomputable def branchCost (A : ℕ → ℝ) (s : BranchState) : BranchLabel → BranchState → ℝ
| .suffix, u => A u.finish-intervalMin A u.finish s.finish
| .high, u | .direct, u => height A s.start u.start
| _, _ => 0
theorem BranchStep.cost_nonneg {A : ℕ → ℝ} {N q : ℕ} {sig : ℝ}
{s u : BranchState} {label : BranchLabel} (h : BranchStep A N q sig s label u)
(hq : 0 < q) (hv : s.Valid N sig) : 0 ≤ branchCost A s label u := by
have hn := h.nested hq hv
cases h <;> simp only [branchCost]
· exact sub_nonneg.mpr (intervalMin_le A le_rfl hn.2)
· exact le_rfl
· exact height_nonneg A hn.1
· exact le_rfl
· exact le_rfl
· exact height_nonneg A hn.1
theorem BranchStep.paid_width {A : ℕ → ℝ} {N q : ℕ} {sig : ℝ}
{s u : BranchState} {label : BranchLabel} (h : BranchStep A N q sig s label u)
(hq : 0 < q) (hv : s.Valid N sig) (hslack : sig*(N:ℝ) ≤ q)
(hc : label = .suffix ∨ label = .high ∨ label = .direct) : u.start+10*q ≤ u.finish := by
cases h with
| suffix hw hs => exact (actual_suffix_policy_payment A hq hv.2 hw hs).1
| high hw hs hm hg =>
have hm := Finset.mem_Ioc.mp hm
exact (actual_prefix_policy_payment A hq hv.2 hw hs hm.2 (high_depth_gap hm.2 hg hslack)).1
| direct _ he => exact he.width
| _ => simp at hc
theorem BranchStep.potential_payment {A : ℕ → ℝ} {N q : ℕ} {sig : ℝ}
{s u : BranchState} {label : BranchLabel} (h : BranchStep A N q sig s label u)
(hq : 0 < q) (hv : s.Valid N sig) (hslack : sig*(N:ℝ) ≤ q)
(hu : u.start+10*q ≤ u.finish) :
potential A s.start s.finish (10*q)+branchCost A s label u ≤
potential A u.start u.finish (10*q) := by
have hn := h.nested hq hv
have hm := potential_mono A (by omega : 0 < 10*q) hu hn.1 hn.2
cases h with
| suffix hw hs => exact (actual_suffix_policy_payment A hq hv.2 hw hs).2
| high hw hs hmem hg =>
have hmem := Finset.mem_Ioc.mp hmem
exact (actual_prefix_policy_payment A hq hv.2 hw hs hmem.2 (high_depth_gap hmem.2 hg hslack)).2
| direct _ he => exact he.payment
| _ => simpa only [branchCost,add_zero] using hm
theorem BranchStep.short_cost_zero {A : ℕ → ℝ} {N q : ℕ} {sig : ℝ}
{s u : BranchState} {label : BranchLabel} (h : BranchStep A N q sig s label u)
(hq : 0 < q) (hv : s.Valid N sig) (hslack : sig*(N:ℝ) ≤ q)
(hu : u.finish < u.start+10*q) : branchCost A s label u = 0 := by
have hc : ¬ (label = .suffix ∨ label = .high ∨ label = .direct) := by
intro hl
exact (not_le_of_gt hu) (h.paid_width hq hv hslack hl)
cases label <;> simp_all [branchCost]
def DiscreteProfileLipschitz (A : ℕ → ℝ) (N : ℕ) : Prop :=
∀ i ≤ N, ∀ j ≤ N, |A i-A j| ≤ |(i:ℝ)-j|/(N:ℝ)
theorem potential_le_final_start {A : ℕ → ℝ} {N a t f Q : ℕ}
(hN : 0 < N) (hA : DiscreteProfileLipschitz A N)
(hQ : 0 < Q) (hw : a+Q ≤ t) (ht : t ≤ N) (haf : a ≤ f) (hft : f ≤ t) :
potential A a t Q ≤ 2*A f+2*(Q:ℝ)/N := by
have hNR : (0:ℝ) < N := Nat.cast_pos.mpr hN
have hb := potential_near_final A hQ hw haf hft (e := (Q:ℝ)/N) ?_
· simpa only [mul_div_assoc] using hb
intro j _ hjt hjf hfj
have hd : |(j:ℝ)-f| ≤ (Q:ℝ) := by
have hjR : (j:ℝ) ≤ (f:ℝ)+Q := by exact_mod_cast hjf
have hfR : (f:ℝ) ≤ (j:ℝ)+Q := by exact_mod_cast hfj
exact abs_le.mpr ⟨by linarith,by linarith⟩
have hh := (hA j (hjt.trans ht) f (hft.trans ht)).trans (div_le_div_of_nonneg_right hd hNR.le)
have hh' := (le_abs_self (A j-A f)).trans hh
linarith
namespace PolicyBranch
variable {A : ℕ → ℝ} {N q n : ℕ} {sig : ℝ}
theorem costs_le_potential (b : PolicyBranch A N q sig n) (hq : 0 < q)
(hslack : sig*(N:ℝ) ≤ q) (hfinal : (b.state n).start+10*q ≤ (b.state n).finish) :
∑ j ∈ Finset.range n, branchCost A (b.state j) (b.label j) (b.state (j+1)) ≤
potential A (b.state n).start (b.state n).finish (10*q)-
potential A (b.state 0).start (b.state 0).finish (10*q) := by
apply branch_cost_bound (fun j => potential A (b.state j).start (b.state j).finish (10*q))
(fun j => branchCost A (b.state j) (b.label j) (b.state (j+1))) n
intro j hj
apply (b.step j hj).potential_payment hq (b.valid j hj.le) hslack
by_cases he : j+1 = n
· simpa only [he] using hfinal
· have hw := (b.step (j+1) (by omega)).nonterminal
omega
theorem costs_le_final_start (b : PolicyBranch A N q sig n) (hN : 0 < N) (hq : 0 < q)
(hslack : sig*(N:ℝ) ≤ q) (hA : DiscreteProfileLipschitz A N)
(hinit : (b.state 0).start+10*q ≤ (b.state 0).finish) :
∑ j ∈ Finset.range n, branchCost A (b.state j) (b.label j) (b.state (j+1)) ≤
2*A (b.state n).start+20*(q:ℝ)/N-potential A (b.state 0).start (b.state 0).finish (10*q) := by
have hQ : 0 < 10*q := by omega
have hfinal := BranchState.valid_depths (b.valid n le_rfl)
by_cases hw : (b.state n).start+10*q ≤ (b.state n).finish
· have hc := b.costs_le_potential hq hslack hw
have hf := potential_le_final_start hN hA hQ hw hfinal.2 (le_refl _) hfinal.1
norm_num only [Nat.cast_mul,Nat.cast_ofNat] at hf
linear_combination hc+hf
· cases n with
| zero => exact (hw hinit).elim
| succ n =>
have hs := b.step n (by omega)
have hn := hs.nested hq (b.valid n (by omega))
have hp := hs.nonterminal
have hpwide : (b.state n).start+10*q ≤ (b.state n).finish := by omega
have hd := BranchState.valid_depths (b.valid n (by omega))
have hc := (b.initialSegment n (by omega)).costs_le_potential hq hslack hpwide
dsimp only [initialSegment] at hc
have hz := hs.short_cost_zero hq (b.valid n (by omega)) hslack (by omega)
have hf := potential_le_final_start hN hA hQ hpwide hd.2 hn.1 (hfinal.1.trans hn.2)
norm_num only [Nat.cast_mul,Nat.cast_ofNat] at hf
rw [Finset.sum_range_succ,hz,add_zero]
linear_combination hc+hf
end PolicyBranch
end PlanarFalconer
end OAI
|