math / data /lean /OAI /Probability /CriticalPercolation /Entropy /BinaryReverseKernels.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
6.28 kB
import Mathlib
import OAI.Probability.CriticalPercolation.Entropy.BinaryTranscript
import OAI.Probability.CriticalPercolation.Criticality.ReverseReference
import OAI.Probability.CriticalPercolation.Entropy.MarkedBits
namespace OAI
section
section
noncomputable section
namespace CriticalPercolation.BinaryLaw
open scoped Classical
open FiniteProduct BondGraph BinaryInterpolation ExactExposure FiniteEntropy MarkedBits SearchTree
variable {V E : Type*} [Fintype V] [Fintype E]
local instance kernelsFinDec (n : β„•) : DecidableEq (Fin n) := Classical.decEq _
variable (G : BondGraph V E) (order : List (LazyDFS.Dart V E)) (d : β„•) (x : β„• β†’ V)
variable (p : ℝ) (w : E β†’ Prop β†’ ℝ) (n : β„•) (D : FixedDescriptor n)
noncomputable def pivotGuess (i : Fin n) (Ο‰ : E β†’ Bool) (e : E) : ℝ :=
(LazyDFS.search G order (stepLeft (E := E) d x n D i) (stepTargets (E := E) d x n D i)).reverseGuess
p (fun Οƒ => βˆƒ b ∈ stepTargets (E := E) d x n D i,
(G.openGraph Οƒ).Reachable (stepLeft (E := E) d x n D i) b) w (configuration Ο‰) 0 e
lemma pivotGuess_subprobability (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p) (i : Fin n) (Ο‰ : E β†’ Bool) :
(βˆ€ e, 0 ≀ pivotGuess G order d x p w n D i Ο‰ e) ∧
(βˆ‘ e, pivotGuess G order d x p w n D i Ο‰ e) ≀ 1 := by
apply SearchTree.reverseGuess_subprobability _ βˆ… (LazyDFS.compile_valid G order _ _ _ _) hp
· rintro a b hab ⟨v,hv,hr⟩
exact ⟨v,hv,hr.mono (G.openGraph_mono hab)⟩
Β· exact homogeneous_normalized w p h0 h1
Β· exact fun e b => (homogeneous_positive w hp h0 h1 e b).le
· exact fun e _ => ⟨h0 e,h1 e⟩
noncomputable def inverseKernel (j : β„•) (Ο‰ : E β†’ Bool) (m : Option E) : ℝ :=
if hj : j < n then
if (⟨j,hj⟩ : Fin n) ∈ activeSteps n D then
match m with | none => 0 | some e => pivotGuess G order d x p w n D ⟨j,hj⟩ Ο‰ e
else if m = none then 1 else 0
else if m = none then 1 else 0
noncomputable def inverseUpdate (j : β„•) (Ο‰ : E β†’ Bool) (m : Option E) : E β†’ Bool :=
if hj : j < n then
if (⟨j,hj⟩ : Fin n) ∈ activeSteps n D then
match m with | none => Ο‰ | some e => Function.update Ο‰ e false
else Ο‰
else Ο‰
lemma inverseKernel_nonneg (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p)
(j : β„•) (Ο‰ : E β†’ Bool) (m : Option E) : 0 ≀ inverseKernel G order d x p w n D j Ο‰ m := by
unfold inverseKernel
split_ifs with hj hi hm hm
Β· cases m with
| none => exact le_rfl
| some e => exact (pivotGuess_subprobability G order d x p w n D hp h0 h1 _ Ο‰).1 e
Β· exact zero_le_one
Β· exact le_rfl
Β· exact zero_le_one
Β· exact le_rfl
lemma inverseKernel_sum (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p)
(j : β„•) (Ο‰ : E β†’ Bool) : (βˆ‘ m, inverseKernel G order d x p w n D j Ο‰ m) ≀ 1 := by
unfold inverseKernel
split_ifs with hj hi
Β· rw [Fintype.sum_option]
simp only [zero_add]
exact (pivotGuess_subprobability G order d x p w n D hp h0 h1 _ Ο‰).2
Β· simp
Β· simp
noncomputable def contactTotal (i : Fin n) (Ο‰ : E β†’ Bool) : ℝ :=
βˆ‘ m, scheduleWeight G order d x p w n (fun j => (D j).1) i (configuration Ο‰) m
noncomputable def inactiveKernel (i : Fin n) (Ο‰ : E β†’ Bool) (m : Option E) : ℝ :=
if i ∈ activeSteps n D then if m=none then 1 else 0
else if contactTotal G order d x p w n D i Ο‰ = 0 then if m=none then 1 else 0
else scheduleWeight G order d x p w n (fun j => (D j).1) i (configuration Ο‰) m /
contactTotal G order d x p w n D i Ο‰
lemma contactTotal_nonneg (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p) (i : Fin n) (Ο‰ : E β†’ Bool) :
0 ≀ contactTotal G order d x p w n D i Ο‰ :=
Finset.sum_nonneg fun m _ => scheduleWeight_nonneg G order d x p w hp h0 h1 n _ i _ m
lemma inactiveKernel_nonneg (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p)
(i : Fin n) (Ο‰ : E β†’ Bool) (m : Option E) : 0 ≀ inactiveKernel G order d x p w n D i Ο‰ m := by
unfold inactiveKernel
split_ifs
Β· exact zero_le_one
Β· exact le_rfl
Β· exact zero_le_one
Β· exact le_rfl
Β· exact div_nonneg (scheduleWeight_nonneg G order d x p w hp h0 h1 n _ i _ m)
(contactTotal_nonneg G order d x p w n D hp h0 h1 i Ο‰)
lemma inactiveKernel_sum (i : Fin n) (Ο‰ : E β†’ Bool) :
(βˆ‘ m, inactiveKernel G order d x p w n D i Ο‰ m) = 1 := by
unfold inactiveKernel
split_ifs with hi ht
Β· simp
Β· simp
Β· rw [← Finset.sum_div]
exact div_self ht
noncomputable def inverseReference : ((E β†’ Bool) Γ— (Fin n β†’ Option E) Γ— (Fin n β†’ Option E)) β†’ ℝ :=
ReverseReference.joint (FiniteProduct.density (QueryTree.bitWeight p))
(inverseKernel G order d x p w n D) (inverseUpdate (E := E) n D)
(inactiveKernel G order d x p w n D) n
lemma inverseReference_nonneg (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p) (z) :
0 ≀ inverseReference G order d x p w n D z :=
ReverseReference.joint_nonneg _ (FiniteProduct.density_nonneg (QueryTree.bitWeight_nonneg ⟨hp.1.le,hp.2.le⟩))
_ _ (inverseKernel_nonneg G order d x p w n D hp h0 h1)
_ (inactiveKernel_nonneg G order d x p w n D hp h0 h1) n z
lemma inverseReference_marginal (hp : p ∈ Set.Ioo 0 1)
(h0 : βˆ€ e, w e False = 1-p) (h1 : βˆ€ e, w e True = p) (Ο‰ : E β†’ Bool) :
pushMass Prod.fst (inverseReference G order d x p w n D) Ο‰ ≀
FiniteProduct.density (QueryTree.bitWeight p) Ο‰ := by
have he := ReverseReference.joint_marginal_le
(FiniteProduct.density (QueryTree.bitWeight p) : (E β†’ Bool) β†’ ℝ)
(FiniteProduct.density_nonneg (QueryTree.bitWeight_nonneg ⟨hp.1.le,hp.2.le⟩))
(inverseKernel G order d x p w n D) (inverseUpdate (E := E) n D)
(inverseKernel_nonneg G order d x p w n D hp h0 h1)
(inverseKernel_sum G order d x p w n D hp h0 h1)
(inactiveKernel G order d x p w n D) (inactiveKernel_sum G order d x p w n D) n Ο‰
refine Eq.trans_le ?_ he
unfold pushMass
apply Finset.sum_congr
Β· ext z
simp only [Finset.mem_univ]
Β· intro z _
rfl
end CriticalPercolation.BinaryLaw
end
end
end
end OAI