math / data /lean /OAI /Probability /FirstPassage /BKExponentialQuantiles.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
4.79 kB
import OAI.Probability.FirstPassage.BKQuantization
import OAI.Probability.FirstPassage.FiniteEdgeEvents
import Mathlib.MeasureTheory.Function.Floor
namespace OAI
namespace PlanarFPP
open MeasureTheory ProbabilityTheory Set
variable {Ξ© : Type*} [MeasurableSpace Ξ©] {P : Measure Ξ©} {Ο„ : Edge β†’ Ξ© β†’ ℝ}
lemma ExponentialEnvironment.edge_tail_real (h : ExponentialEnvironment P Ο„)
(e : Edge) (r : ℝ) (hr : 0 ≀ r) : P.real {Ο‰ | r < Ο„ e Ο‰} = Real.exp (-r) := by
let _ := h.probability
have hm : P {Ο‰ | Ο„ e Ο‰ ≀ r} = expMeasure 1 (Iic r) := by
rw [← h.marginal e,Measure.map_apply (h.measurable e) measurableSet_Iic]
rfl
have hc : P.real {Ο‰ | Ο„ e Ο‰ ≀ r} = 1-Real.exp (-r) := by
change (P {Ο‰ | Ο„ e Ο‰ ≀ r}).toReal = _
rw [hm,← measureReal_def,← cdf_eq_real,cdf_expMeasure_eq (by norm_num)]
simp [hr]
have he : {Ο‰ | r < Ο„ e Ο‰} = {Ο‰ | Ο„ e Ο‰ ≀ r}ᢜ := by ext Ο‰; simp
rw [he,measureReal_compl (measurableSet_le (h.measurable e) measurable_const),hc]
simp
theorem ExponentialEnvironment.survival_lt_real (h : ExponentialEnvironment P Ο„)
(e : Edge) (u : ℝ) (hu : 0 ≀ u) (hu1 : u ≀ 1) :
P.real {Ο‰ | Real.exp (-Ο„ e Ο‰) < u} = u := by
by_cases hz : u=0
Β· subst u
have he : {Ο‰ | Real.exp (-Ο„ e Ο‰) < 0} = βˆ… := by
ext Ο‰; simp [not_lt.mpr (Real.exp_pos (-Ο„ e Ο‰)).le]
rw [he]; simp
Β· have hup : 0 < u := lt_of_le_of_ne hu (Ne.symm hz)
have he : {Ο‰ | Real.exp (-Ο„ e Ο‰) < u} = {Ο‰ | -Real.log u < Ο„ e Ο‰} := by
ext Ο‰
rw [mem_ofPred_eq,mem_ofPred_eq,← Real.exp_log hup,Real.exp_lt_exp]
simp only [Real.log_exp]
constructor <;> intro hh <;> linarith
rw [he,h.edge_tail_real e (-Real.log u) (neg_nonneg.mpr (Real.log_nonpos hu hu1))]
simp [Real.exp_log hup]
theorem ExponentialEnvironment.survival_bin_real (h : ExponentialEnvironment P Ο„)
(e : Edge) (a b : ℝ) (ha : 0 ≀ a) (hab : a ≀ b) (hb : b ≀ 1) :
P.real {Ο‰ | a ≀ Real.exp (-Ο„ e Ο‰) ∧ Real.exp (-Ο„ e Ο‰) < b} = b-a := by
let _ := h.probability
let A : Set Ξ© := {Ο‰ | Real.exp (-Ο„ e Ο‰) < a}
let B : Set Ξ© := {Ο‰ | Real.exp (-Ο„ e Ο‰) < b}
have hA : MeasurableSet A := measurableSet_lt (Real.measurable_exp.comp (h.measurable e).neg) measurable_const
have hAB : A βŠ† B := fun Ο‰ hΟ‰ => lt_of_lt_of_le hΟ‰ hab
have he : {Ο‰ | a ≀ Real.exp (-Ο„ e Ο‰) ∧ Real.exp (-Ο„ e Ο‰) < b} = B \ A := by
ext Ο‰
simp only [mem_ofPred_eq,mem_sdiff,A,B,not_lt]
tauto
rw [he,measureReal_sdiff hAB hA]
exact congrArgβ‚‚ (Β·-Β·) (h.survival_lt_real e b (ha.trans hab) hb)
(h.survival_lt_real e a ha (hab.trans hb))
theorem ExponentialEnvironment.survival_rank_real (h : ExponentialEnvironment P Ο„)
(e : Edge) (m i : β„•) (hm : 0 < m) (hi : i < m) :
P.real {Ο‰ | ⌊(m:ℝ)*Real.exp (-Ο„ e Ο‰)βŒ‹β‚Š = i} = 1/(m:ℝ) := by
have hm' : (0:ℝ) < m := by exact_mod_cast hm
have he : {Ο‰ | ⌊(m:ℝ)*Real.exp (-Ο„ e Ο‰)βŒ‹β‚Š = i} =
{Ο‰ | (i:ℝ)/m ≀ Real.exp (-Ο„ e Ο‰) ∧ Real.exp (-Ο„ e Ο‰) < ((i:ℝ)+1)/m} := by
ext Ο‰
rw [mem_ofPred_eq,mem_ofPred_eq,Nat.floor_eq_iff (by positivity)]
rw [div_le_iffβ‚€ hm',lt_div_iffβ‚€ hm']
simp only [mul_comm]
have hu : ((i:ℝ)+1)/m ≀ 1 := by
rw [div_le_iffβ‚€ hm']
have hi' : (i:ℝ)+1 ≀ m := by exact_mod_cast (show i+1 ≀ m by omega)
simpa using hi'
rw [he,h.survival_bin_real e ((i:ℝ)/m) (((i:ℝ)+1)/m) (by positivity)
(div_le_div_of_nonneg_right (by linarith) hm'.le) hu]
ring
theorem ExponentialEnvironment.survival_ranks_joint_real (h : ExponentialEnvironment P Ο„)
(S : Finset Edge) (m : β„•) (hm : 0 < m) (i : Edge β†’ β„•) (hi : βˆ€ e ∈ S, i e < m) :
P.real {Ο‰ | βˆ€ e ∈ S, ⌊(m:ℝ)*Real.exp (-Ο„ e Ο‰)βŒ‹β‚Š = i e} = (1/(m:ℝ))^S.card := by
let A : Edge β†’ Set (Edge β†’ ℝ) := fun e => {w | ⌊(m:ℝ)*Real.exp (-w e)βŒ‹β‚Š = i e}
have hA : βˆ€ e ∈ S, MeasurableSet (A e) := by
intro e _
apply measurableSet_eq_fun _ measurable_const
fun_prop
have hAS : βˆ€ e ∈ S, DependsOnEdges (A e) {e} := by
intro e _ w w' hw
have he := hw e (Finset.mem_singleton_self e)
simp only [A,mem_ofPred_eq,he]
have hd : Set.Pairwise (↑S : Set Edge) (fun e f => Disjoint ({e} : Finset Edge) {f}) := by
intro e _ f _ hef
simpa using hef
have hj := disjoint_edge_events_inter_probability h S A (fun e => {e}) hA hAS hd
have hr := congrArg ENNReal.toReal hj
simp only [ENNReal.toReal_prod] at hr
change P.real _ = ∏ e ∈ S, P.real _ at hr
dsimp [A] at hr
rw [hr]
calc
_ = ∏ _e ∈ S, (1/(m:ℝ)) := by
apply Finset.prod_congr rfl
intro e he
exact h.survival_rank_real e m (i e) hm (hi e he)
_ = _ := by simp
end PlanarFPP
end OAI