File size: 5,722 Bytes
4a56cd6 | 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 | import Mathlib
import OAI.Probability.CriticalPercolation.Entropy.RecursiveLikelihood
import OAI.Probability.CriticalPercolation.Entropy.BinaryLikelihood
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 refLikelihoodFinDec (n : β) : DecidableEq (Fin n) := Classical.decEq _
noncomputable def recorded (n : β) (D : FixedDescriptor n) (z : (E β Bool) Γ (Fin n β Option E)) :
(E β Bool) Γ (Fin n β Option E) Γ (Fin n β Option E) :=
(stage n D z.1 z.2 n,masked (activeSteps n D) z.2,masked (activeSteps n D)αΆ z.2)
variable (G : BondGraph V E) (order : List (LazyDFS.Dart V E)) (d : β) (x : β β V)
variable (p : β) (w : E β Prop β β) (n : β) (D : FixedDescriptor n)
def inverseLog (Ο : E β Bool) (m : Fin n β Option E) : β :=
2*(β i β activeSteps n D, Real.log (1+selectedCost G order d x p w n D i Ο (m i))) +
logContactMass (scheduleWeight G order d x p w n (fun j => (D j).1)) (configuration Ο)
lemma inversePenalty_product (hp : p β Set.Ioo 0 1)
(h0 : β e, w e False = 1-p) (h1 : β e, w e True = p)
(Ο : E β Bool) (m : Fin n β Option E) :
(β i, inversePenalty G order d x p w n D i Ο (m i)) =
Real.exp (inverseLog G order d x p w n D Ο m) := by
have hc (i : Fin n) : 0 < 1+selectedCost G order d x p w n D i Ο (m i) := by
have hn := (selected_nonneg G order d x p w n D hp h0 h1 i Ο (m i)).2
linarith
have he (i : Fin n) : (if i β activeSteps n D then
(1+selectedCost G order d x p w n D i Ο (m i))^2 else 1) =
Real.exp (if i β activeSteps n D then
2*Real.log (1+selectedCost G order d x p w n D i Ο (m i)) else 0) := by
split_ifs
Β· rw [two_mul,Real.exp_add,Real.exp_log (hc i),pow_two]
Β· exact Real.exp_zero.symm
simp only [inversePenalty,Finset.prod_mul_distrib,he,β Real.exp_sum]
change _ * (β i, max 1 (β a, scheduleWeight G order d x p w n
(fun j => (D j).1) i (configuration Ο) a)) = _
rw [β exp_logContactMass (scheduleWeight G order d x p w n (fun j => (D j).1))
(configuration Ο),β Real.exp_add]
congr 1
simp only [inverseLog,logContactMass]
rw [β Finset.sum_filter,β Finset.mul_sum]
simp only [Finset.filter_mem_eq_inter,Finset.univ_inter]
lemma supported_reference_dominance (s : β) (hp : p β Set.Ioo 0 1)
(h0 : β e, w e False = 1-p) (h1 : β e, w e True = p)
(Ο : E β Bool) (m : Fin n β Option E)
(hz : conditionedMass G order d x p w s n D (Ο,m) β 0) :
FiniteProduct.density (QueryTree.bitWeight p) Ο *
(β i, scheduleWeight G order d x p w n (fun j => (D j).1) i (configuration Ο) (m i)) β€
inverseReference G order d x p w n D (recorded n D (Ο,m)) *
Real.exp (inverseLog G order d x p w n D Ο m) := by
let m' : β β Option E := fun j => if hj : j<n then masked (activeSteps n D) m β¨j,hjβ© else none
have hm : (fun i : Fin n => m' i.val) = masked (activeSteps n D) m := by
funext i
simp only [m',dite_eq_left i.isLt]
have hu : β j<n, inverseUpdate (E := E) n D j (stage n D Ο m (j+1)) (m' j) = stage n D Ο m j := by
intro j hj
simpa only [m',dite_eq_left hj] using supported_inverse_update G order d x p w s n D Ο m hz β¨j,hjβ©
have hh := ReverseReference.joint_trajectory_dominance
(FiniteProduct.density (QueryTree.bitWeight p) : (E β Bool) β β)
(inverseKernel G order d x p w n D) (inverseUpdate (E := E) n D) n
(inactiveKernel G order d x p w n D) (stage n D Ο m) m' (masked (activeSteps n D)αΆ m)
(fun i => scheduleWeight G order d x p w n (fun j => (D j).1) i (configuration Ο) (m i))
(fun i => inversePenalty G order d x p w n D i Ο (m i)) hu
(fun i => scheduleWeight_nonneg G order d x p w hp h0 h1 n _ i _ _)
(fun i => mul_nonneg (mul_nonneg
(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 _ _ _))
(inversePenalty_nonneg G order d x p w n D _ _ _))
(fun i => by
simpa only [stage_zero,m',dite_eq_left i.isLt] using
supported_step_likelihood G order d x p w n D s hp h0 h1 Ο m hz i)
rw [hm,stage_zero,inversePenalty_product G order d x p w n D hp h0 h1 Ο m] at hh
exact hh
lemma conditioned_reference_density_le (s : β) (hd : 0<d) (hp : p β Set.Ioo 0 1)
(h0 : β e, w e False = 1-p) (h1 : β e, w e True = p)
{c : β} (hc : 0<c) (hc1 : cβ€1)
(hconn : β j, 0<j β j<d β c β€ prob w (fun Ο => (G.openGraph Ο).Reachable (x 0) (x j)))
(hΞ΄ : 0 < prob w (endpointEvent G (x 0) (x d) s))
(hD : 0 < descriptorMass G order d x p w s n D)
(z : (E β Bool) Γ (Fin n β Option E)) :
conditionedMass G order d x p w s n D z β€
inverseReference G order d x p w n D (recorded n D z) *
Real.exp (constructionCost G order d x p w c s n D + inverseLog G order d x p w n D z.1 z.2) := by
by_cases hz : conditionedMass G order d x p w s n D z = 0
Β· rw [hz]
exact mul_nonneg (inverseReference_nonneg G order d x p w n D hp h0 h1 _) (Real.exp_pos _).le
Β· have hh := mul_le_mul_of_nonneg_left
(supported_reference_dominance G order d x p w n D s hp h0 h1 z.1 z.2 hz)
(Real.exp_pos (constructionCost G order d x p w c s n D)).le
calc
_ β€ _ := conditionedMass_density_le G order d x p w hd hp h0 h1 hc hc1 hconn s n D hΞ΄ hD z
_ β€ _ := by simpa only [Real.exp_add,mul_assoc,mul_left_comm,mul_comm] using hh
end CriticalPercolation.BinaryLaw
end
end
end
end OAI
|