Download data/lean/OAI/Probability/CriticalPercolation/Entropy/BinaryDescriptor.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.23 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Entropy/BinaryDescriptor.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Probability/CriticalPercolation/Entropy/BinaryDescriptor.lean
-
curl -L -o BinaryDescriptor.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Probability/CriticalPercolation/Entropy/BinaryDescriptor.lean
7.23 kB
| import Mathlib | |
| import OAI.Probability.CriticalPercolation.Exploration.PrefixScoreNonneg | |
| import OAI.Probability.CriticalPercolation.Entropy.BinaryWords | |
| import OAI.Probability.CriticalPercolation.Entropy.BinaryMarks | |
| namespace OAI | |
| section | |
| section | |
| namespace CriticalPercolation.BinaryLaw | |
| open scoped Classical | |
| open FiniteProduct BondGraph BinaryInterpolation InterpolationForest FiniteEntropy ExactExposure | |
| variable {V E : Type*} | |
| abbrev FixedDescriptor (n : β) := Fin n β Bool Γ Bool Γ Bool | |
| lemma fixedDescriptor_card (n : β) : Fintype.card (FixedDescriptor n) = 8^n := by | |
| simp only [FixedDescriptor,Fintype.card_fun,Fintype.card_prod,Fintype.card_bool,Fintype.card_fin] | |
| noncomputable def descriptor (G : BondGraph V E) (d : β) (x : β β V) | |
| (n : β) (h : History E n) (Ο : Set E) : FixedDescriptor n := fun i => | |
| (sides n h i, decide (marks n h i β none), decide (i.val+2 β activeNodes G d x n h Ο)) | |
| lemma descriptor_sides (G : BondGraph V E) (d : β) (x : β β V) | |
| (n : β) (h : History E n) (Ο : Set E) (D : FixedDescriptor n) | |
| (hD : descriptor G d x n h Ο = D) : sides n h = fun i => (D i).1 := by | |
| funext i | |
| exact congrArg (fun D : FixedDescriptor n => (D i).1) hD | |
| lemma sum_history_words [Fintype E] (n : β) (f : History E n β β) : | |
| (β h, f h) = β b : Fin n β Bool, β m : Fin n β Option E, f (fromWords n b m) := by | |
| rw [β (wordsEquiv (E := E) n).symm.sum_comp f,Fintype.sum_prod_type] | |
| rfl | |
| section Finite | |
| variable [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| variable (G : BondGraph V E) (order : List (LazyDFS.Dart V E)) (d : β) (x : β β V) | |
| variable (p : β) (w : E β Prop β β) (s n : β) | |
| noncomputable def jointMass (z : (E β Bool) Γ History E n) : β := | |
| FiniteProduct.density (QueryTree.bitWeight p) z.1 * | |
| density G order d x p w (seed G w (x 0) (x d) s) n z.2 (configuration z.1) | |
| lemma jointMass_nonneg (hp : p β Set.Ioo 0 1) (h0 : β e, w e False = 1-p) | |
| (h1 : β e, w e True = p) (hΞ΄ : 0 < prob w (endpointEvent G (x 0) (x d) s)) | |
| (z : (E β Bool) Γ History E n) : 0 β€ jointMass G order d x p w s n z := by | |
| exact mul_nonneg (FiniteProduct.density_nonneg (fun e b => (QueryTree.bitWeight_pos hp e b).le) _) | |
| (density_nonneg G order d x p w _ hp h0 h1 (seed_nonneg G w _ _ s hΞ΄) n z.2 _) | |
| lemma jointMass_normalized (ho : LazyDFS.Exhaustive G order) (hd : 2 β€ d) | |
| (hp : p β Set.Ioo 0 1) (h0 : β e, w e False = 1-p) (h1 : β e, w e True = p) | |
| {c : β} (hc : 0<c) | |
| (hconn : β j k, j<k β kβ€d β k-j<d β | |
| c β€ prob w (fun Ο => (G.openGraph Ο).Reachable (x j) (x k))) | |
| (hΞ΄ : 0 < prob w (endpointEvent G (x 0) (x d) s)) : | |
| β z, jointMass G order d x p w s n z = 1 := by | |
| have hw : QueryTree.bitWeight p = fun e (b : Bool) => w e (b = true) := by | |
| funext e b | |
| cases b <;> simp [QueryTree.bitWeight,h0,h1] | |
| rw [Fintype.sum_prod_type,Finset.sum_comm] | |
| simp only [jointMass] | |
| have ht := endpoint_density_normalized G order ho hd x hp w h0 h1 hc hconn s hΞ΄ n | |
| rw [β ht] | |
| apply Finset.sum_congr rfl | |
| intro h _ | |
| have he := expect_configuration w | |
| (fun Ξ· : Set E => density G order d x p w (seed G w (x 0) (x d) s) n h Ξ·) | |
| rw [β hw] at he | |
| refine Eq.trans ?_ he | |
| unfold expect | |
| apply Finset.sum_congr | |
| Β· ext f; simp only [Finset.mem_univ] | |
| Β· intro f _; rfl | |
| noncomputable def descriptorMass (D : FixedDescriptor n) : β := | |
| pushMass (fun z : (E β Bool) Γ History E n => descriptor G d x n z.2 (configuration z.1)) | |
| (jointMass G order d x p w s n) D | |
| lemma descriptorMass_sum : | |
| (β D, descriptorMass G order d x p w s n D) = β z, jointMass G order d x p w s n z := | |
| pushMass_sum _ _ | |
| theorem exists_descriptor (hZ : β z, jointMass G order d x p w s n z = 1) : | |
| β D : FixedDescriptor n, (8:β)^(- (n:β€)) β€ descriptorMass G order d x p w s n D := by | |
| obtain β¨D,hD,hmaxβ© := Finset.exists_max_image (Finset.univ : Finset (FixedDescriptor n)) | |
| (descriptorMass G order d x p w s n) Finset.univ_nonempty | |
| have hs : 1 β€ (8:β)^n * descriptorMass G order d x p w s n D := by | |
| calc | |
| 1 = β D', descriptorMass G order d x p w s n D' := (descriptorMass_sum G order d x p w s n).trans hZ |>.symm | |
| _ β€ β _D' : FixedDescriptor n, descriptorMass G order d x p w s n D := | |
| Finset.sum_le_sum (fun D' hD' => hmax D' hD') | |
| _ = _ := by simp only [Finset.sum_const,Finset.card_univ,fixedDescriptor_card,nsmul_eq_mul,Nat.cast_pow,Nat.cast_ofNat] | |
| refine β¨D,?_β© | |
| rw [zpow_neg, zpow_natCast] | |
| rw [β one_div] | |
| exact (div_le_iffβ (pow_pos (by norm_num : (0:β)<8) n)).mpr (by simpa only [mul_comm] using hs) | |
| noncomputable def fixedMass (D : FixedDescriptor n) (z : (E β Bool) Γ (Fin n β Option E)) : β := | |
| let h := fromWords n (fun i => (D i).1) z.2 | |
| if descriptor G d x n h (configuration z.1) = D then | |
| jointMass G order d x p w s n (z.1,h) else 0 | |
| lemma fixedMass_sum (D : FixedDescriptor n) : | |
| (β z, fixedMass G order d x p w s n D z) = descriptorMass G order d x p w s n D := by | |
| unfold descriptorMass pushMass | |
| conv_rhs => rw [Fintype.sum_prod_type] | |
| simp_rw [sum_history_words] | |
| rw [Fintype.sum_prod_type] | |
| apply Finset.sum_congr rfl | |
| intro Ο _ | |
| symm | |
| apply (Finset.sum_eq_single (fun i => (D i).1) ?_ ?_).trans | |
| Β· apply Finset.sum_congr rfl | |
| intro m _ | |
| unfold fixedMass | |
| dsimp only | |
| split_ifs <;> rfl | |
| Β· intro b _ hb | |
| apply Finset.sum_eq_zero | |
| intro m _ | |
| have hne : descriptor G d x n (fromWords n b m) (configuration Ο) β D := by | |
| intro he | |
| have hs := descriptor_sides G d x n _ _ D he | |
| rw [sides_fromWords] at hs | |
| exact hb hs | |
| rw [ite_eq_right hne] | |
| Β· simp | |
| noncomputable def conditionedMass (D : FixedDescriptor n) | |
| (z : (E β Bool) Γ (Fin n β Option E)) : β := | |
| fixedMass G order d x p w s n D z / descriptorMass G order d x p w s n D | |
| lemma conditionedMass_normalized (D : FixedDescriptor n) | |
| (hD : 0 < descriptorMass G order d x p w s n D) : | |
| β z, conditionedMass G order d x p w s n D z = 1 := by | |
| simp only [conditionedMass,β Finset.sum_div,fixedMass_sum,div_self hD.ne'] | |
| lemma conditionedMass_nonneg (hp : p β Set.Ioo 0 1) (h0 : β e, w e False = 1-p) | |
| (h1 : β e, w e True = p) (hΞ΄ : 0 < prob w (endpointEvent G (x 0) (x d) s)) | |
| (D : FixedDescriptor n) (hD : 0 < descriptorMass G order d x p w s n D) | |
| (z : (E β Bool) Γ (Fin n β Option E)) : 0 β€ conditionedMass G order d x p w s n D z := by | |
| apply div_nonneg _ hD.le | |
| unfold fixedMass | |
| dsimp only | |
| split_ifs | |
| Β· exact jointMass_nonneg G order d x p w s n hp h0 h1 hΞ΄ _ | |
| Β· rfl | |
| lemma conditionedMass_support (D : FixedDescriptor n) | |
| (z : (E β Bool) Γ (Fin n β Option E)) | |
| (hz : conditionedMass G order d x p w s n D z β 0) : | |
| let h := fromWords n (fun i => (D i).1) z.2 | |
| descriptor G d x n h (configuration z.1) = D β§ | |
| density G order d x p w (seed G w (x 0) (x d) s) n h (configuration z.1) β 0 := by | |
| have hf := (div_ne_zero_iff.mp hz).1 | |
| unfold fixedMass at hf | |
| dsimp only at hf β’ | |
| split_ifs at hf with ht | |
| Β· exact β¨ht,(mul_ne_zero_iff.mp hf).2β© | |
| Β· exact (hf rfl).elim | |
| end Finite | |
| end CriticalPercolation.BinaryLaw | |
| end | |
| end | |
| end OAI | |