import Mathlib import OAI.Probability.CriticalPercolation.ProductMeasure.ContinuousExpectWeights import OAI.Probability.CriticalPercolation.GraphGeometry.HitEvent namespace OAI section section open scoped BigOperators open scoped Classical ENNReal open Set open scoped Classical Topology open Set MeasureTheory ProbabilityTheory open scoped Classical open Filter Topology open Set MeasureTheory ProbabilityTheory Filter open scoped Topology Classical namespace CriticalPercolation.BernoulliProduct variable {E : Type*} lemma continuous_bitWeight (b : Prop) : Continuous (fun p : unitInterval => bitWeight p b) := by by_cases hb : b · simpa [bitWeight, hb] using (continuous_subtype_val : Continuous (fun p : unitInterval => (p : ℝ))) · simp only [bitWeight, ite_eq_right hb] fun_prop lemma continuous_real_law_finite [Fintype E] (A : Set (Set E)) : Continuous (fun p : unitInterval => (law (fun _ : E => p)).real A) := by have h (p : unitInterval) : (law (fun _ : E => p)).real A = FiniteProduct.expect (fun _ : E => bitWeight p) (fun ω : E → Prop => A.indicator (fun _ => (1 : ℝ)) {e | ω e}) := by rw [← integral_law_eq_expect] exact (integral_indicator_one (.of_discrete) : (∫ ω, A.indicator (1 : Set E → ℝ) ω ∂law (fun _ : E => p)) = _).symm simp_rw [h] apply (FiniteProduct.continuous_expect_weights _).comp exact continuous_pi fun _ => continuous_pi fun b => continuous_bitWeight b lemma real_law_restrict (p : unitInterval) (s : Set E) (hs : s.Finite) (A : Set (Set E)) : (law (fun _ : E => p)).real {ω | s ∩ ω ∈ A} = (law (fun _ : s => p)).real {ω | Subtype.val '' ω ∈ A} := by let := hs.fintype have hi (ω : Set E) : Subtype.val '' (Subtype.val ⁻¹' ω : Set s) = s ∩ ω := by ext e simp rw [← law_map_restrict (fun _ : E => p) s] have hf : Measurable (fun ω : Set E => (Subtype.val ⁻¹' ω : Set s)) := Measurable.of_eval (fun edge => measurable_set_mem edge.val) simp only [Measure.real] rw [Measure.map_apply hf (.of_discrete)] simp only [Set.preimage_ofPred_eq, hi] lemma continuous_real_law_restrict (s : Set E) (hs : s.Finite) (A : Set (Set E)) : Continuous (fun p : unitInterval => (law (fun _ : E => p)).real {ω | s ∩ ω ∈ A}) := by let := hs.fintype simp_rw [real_law_restrict _ s hs A] exact continuous_real_law_finite _ def HasFiniteOpenWitness (A : Set (Set E)) : Prop := ∀ ω ∈ A, ∃ s : Set E, s.Finite ∧ s ⊆ ω ∧ s ∈ A lemma finiteWitness_exhaustion (A : Set (Set E)) (hmono : IsUpperSet A) (hw : HasFiniteOpenWitness A) (K : Set.FiniteExhaustion (Set.univ : Set E)) : (⋃ n, {ω | K n ∩ ω ∈ A}) = A := by ext ω constructor · intro h obtain ⟨n, hn⟩ := Set.mem_iUnion.mp h exact hmono Set.inter_subset_right hn · intro h obtain ⟨s, hs, hsω, hsA⟩ := hw ω h obtain ⟨n, hn⟩ := BondGraph.finite_subset_exhaustion K hs (Set.subset_univ _) exact Set.mem_iUnion.mpr ⟨n, hmono (Set.subset_inter hn hsω) hsA⟩ lemma finiteWitness_exhaustion_mono (A : Set (Set E)) (hmono : IsUpperSet A) (K : Set.FiniteExhaustion (Set.univ : Set E)) : Monotone (fun n => {ω | K n ∩ ω ∈ A}) := by intro m n h ω hω exact hmono (Set.inter_subset_inter_left _ (K.mono h)) hω lemma tendsto_real_finiteWitness (p : unitInterval) (A : Set (Set E)) (hmono : IsUpperSet A) (hw : HasFiniteOpenWitness A) (K : Set.FiniteExhaustion (Set.univ : Set E)) : Tendsto (fun n => (law (fun _ : E => p)).real {ω | K n ∩ ω ∈ A}) atTop (𝓝 ((law (fun _ : E => p)).real A)) := by have h := tendsto_measure_iUnion_atTop (μ := law (fun _ : E => p)) (finiteWitness_exhaustion_mono A hmono K) rw [finiteWitness_exhaustion A hmono hw K] at h exact (ENNReal.tendsto_toReal (measure_ne_top _ _)).comp h lemma lowerSemicontinuous_real_finiteWitness [Countable E] (A : Set (Set E)) (hmono : IsUpperSet A) (hw : HasFiniteOpenWitness A) : LowerSemicontinuous (fun p : unitInterval => (law (fun _ : E => p)).real A) := by let K := (Set.to_countable (Set.univ : Set E)).finiteExhaustion intro p a ha have ht := (tendsto_real_finiteWitness p A hmono hw K).eventually (lt_mem_nhds ha) obtain ⟨n, hn⟩ := ht.exists have hc := (continuous_real_law_restrict (K n) (K.finite n) A).continuousAt (x := p) filter_upwards [hc.eventually (lt_mem_nhds hn)] with q hq exact lt_of_lt_of_le hq (measureReal_mono (fun ω hω => hmono Set.inter_subset_right hω)) lemma exists_lower_parameter [Countable E] {I : Type*} [Finite I] (A : I → Set (Set E)) (hmono : ∀ i, IsUpperSet (A i)) (hw : ∀ i, HasFiniteOpenWitness (A i)) (p : unitInterval) (hp : 0 < p) (a : I → ℝ) (ha : ∀ i, a i < (law (fun _ : E => p)).real (A i)) : ∃ q : unitInterval, (p : ℝ) / 2 ≤ q ∧ q < p ∧ ∀ i, a i < (law (fun _ : E => q)).real (A i) := by have hall : ∀ᶠ q in 𝓝 p, ∀ i, a i < (law (fun _ : E => q)).real (A i) := Filter.eventually_all.mpr fun i => lowerSemicontinuous_real_finiteWitness (A i) (hmono i) (hw i) p (a i) (ha i) have hp' : (0 : ℝ) < p := hp have hhalf : ∀ᶠ q : unitInterval in 𝓝 p, (p : ℝ) / 2 < q := continuous_subtype_val.continuousAt.eventually (lt_mem_nhds (by linarith : (p : ℝ) / 2 < p)) have : NeBot (𝓝[<] p) := nhdsLT_neBot_of_exists_lt ⟨0, hp⟩ obtain ⟨q, hq, hqp, hqA⟩ := ((hhalf.filter_mono nhdsWithin_le_nhds).and ((show ∀ᶠ q in 𝓝[<] p, q < p from self_mem_nhdsWithin).and (hall.filter_mono nhdsWithin_le_nhds))).exists exact ⟨q, le_of_lt hq, hqp, hqA⟩ end CriticalPercolation.BernoulliProduct end end end OAI