Download data/lean/OAI/Combinatorics/MatchingEntropy/Pointwise.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 19.4 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Pointwise.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingEntropy/Pointwise.lean
-
curl -L -o Pointwise.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Pointwise.lean
19.4 kB
| import OAI.Combinatorics.MatchingEntropy.RefinedVariation | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators Topology | |
| open Filter Module Matrix | |
| universe uV uE uI uJ uA uB uC uW uF uD uΞΉ | |
| namespace MatchingEntropyBounds.Refined | |
| variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| open LooplessGraph | |
| theorem pointwise_entropy (G : LooplessGraph V E) (m : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hPM : Nonempty G.Matching) | |
| (x : E β β) (hx : x β G.polytope) : | |
| entropy x - (2 - 2 / (m : β)) * complementEntropy x β€ maxMatchingEntropy G x β§ | |
| maxMatchingEntropy G x β€ entropy x := by | |
| obtain β¨_β© := hPM | |
| exact β¨refined_lower G m hm hV x hx, refined_upper G x hxβ© | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem F_nonneg (G : LooplessGraph V E) {x : E β β} (hx : x β G.polytope) : | |
| 0 β€ entropy x := by | |
| exact Finset.sum_nonneg (fun e _ => Real.negMulLog_nonneg | |
| (G.coordinate_mem_Icc hx e).1 (G.coordinate_mem_Icc hx e).2) | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem B_nonneg (G : LooplessGraph V E) {x : E β β} (hx : x β G.polytope) : | |
| 0 β€ complementEntropy x := by | |
| apply Finset.sum_nonneg | |
| intro e _ | |
| exact Real.negMulLog_nonneg (sub_nonneg.mpr (G.coordinate_mem_Icc hx e).2) | |
| (by linarith [(G.coordinate_mem_Icc hx e).1]) | |
| theorem B_le_order (G : LooplessGraph V E) (m : β) (hV : Fintype.card V = 2 * m) | |
| {x : E β β} (hx : x β G.polytope) : complementEntropy x β€ m := by | |
| rw [β G.marginal_sum hV hx] | |
| apply Finset.sum_le_sum | |
| intro e _ | |
| simpa only [sub_sub_cancel] using | |
| Real.negMulLog_le_one_sub_self (sub_nonneg.mpr (G.coordinate_mem_Icc hx e).2) | |
| theorem entropy_defect (G : LooplessGraph V E) (m : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hPM : Nonempty G.Matching) | |
| (x : E β β) (hx : x β G.polytope) : | |
| 0 β€ entropy x - maxMatchingEntropy G x β§ | |
| entropy x - maxMatchingEntropy G x β€ min (entropy x) (2 * (m : β) - 2) := by | |
| have hb := pointwise_entropy G m hm hV hPM x hx | |
| have hmR : (0 : β) < m := by exact_mod_cast hm | |
| have hm1 : (1 : β) β€ m := by exact_mod_cast hm | |
| have hc : 0 β€ 2 - 2 / (m : β) := by | |
| have hd : 2 / (m : β) β€ 2 := (div_le_iffβ hmR).mpr (by linarith) | |
| linarith | |
| have heq : (2 - 2 / (m : β)) * m = 2 * (m : β) - 2 := by field_simp | |
| have hB := mul_le_mul_of_nonneg_left (B_le_order G m hV hx) hc | |
| rw [heq] at hB | |
| refine β¨sub_nonneg.mpr hb.2, le_min ?_ ?_β© | |
| Β· linarith [maxMatchingEntropy_nonneg G hx] | |
| Β· linarith [hb.1] | |
| section UniformLaw | |
| variable {I : Type uI} [Fintype I] | |
| def uniformLaw (I : Type uI) [Fintype I] : I β β := fun _ => (Fintype.card I : β)β»ΒΉ | |
| theorem uniformLaw_simplex [Nonempty I] : uniformLaw I β probabilitySimplex I := by | |
| have hN : (Fintype.card I : β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| refine β¨fun _ => inv_nonneg.mpr (Nat.cast_nonneg _), ?_β© | |
| simp [uniformLaw, hN] | |
| theorem uniformLaw_entropy [Nonempty I] : entropy (uniformLaw I) = Real.log (Fintype.card I : β) := by | |
| have hN : (Fintype.card I : β) β 0 := by exact_mod_cast Fintype.card_ne_zero | |
| simp only [entropy, uniformLaw, Real.negMulLog, Real.log_inv, neg_mul_neg, | |
| Finset.sum_const, Finset.card_univ, nsmul_eq_mul] | |
| field_simp | |
| end UniformLaw | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem uniformMatching_mean (G : LooplessGraph V E) (hPM : Nonempty G.Matching) : | |
| β z β G.polytope, maxMatchingEntropy G z = Real.log (Fintype.card G.Matching : β) := by | |
| let := hPM | |
| have hp := uniformLaw_simplex (I := G.Matching) | |
| have hz : G.mean (uniformLaw G.Matching) β G.polytope := G.mean_mem_polytope hp | |
| refine β¨_, hz, le_antisymm (maxMatchingEntropy_le_log_card G hz) ?_β© | |
| rw [β uniformLaw_entropy (I := G.Matching)] | |
| exact entropy_le_maxMatchingEntropy G β¨hp, rflβ© | |
| omit [Fintype V] [DecidableEq V] [DecidableEq E] in | |
| theorem continuous_binaryEntropy : Continuous (binaryEntropy (E := E)) := by | |
| exact continuous_entropy.add (continuous_entropy.comp (by fun_prop)) | |
| theorem optimized_entropy (G : LooplessGraph V E) (m : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hPM : Nonempty G.Matching) : | |
| β x β G.polytope, β y β G.polytope, | |
| (β z β G.polytope, entropy z β€ entropy x) β§ | |
| (β z β G.polytope, binaryEntropy z β€ binaryEntropy y) β§ | |
| Real.log (Fintype.card G.Matching : β) β€ entropy x β§ | |
| entropy x β€ Real.log (Fintype.card G.Matching : β) + 2 * (m : β) - 2 β§ | |
| Real.log (Fintype.card G.Matching : β) β€ binaryEntropy y β§ | |
| binaryEntropy y β€ Real.log (Fintype.card G.Matching : β) + 3 * (m : β) - 2 := by | |
| obtain β¨z, hz, heqβ© := uniformMatching_mean G hPM | |
| have hn : G.polytope.Nonempty := β¨z, hzβ© | |
| obtain β¨x, hx, hmaxβ© := UpperSemicontinuousOn.exists_isMaxOn hn G.compact_polytope | |
| continuous_entropy.continuousOn.upperSemicontinuousOn | |
| obtain β¨y, hy, hmaxbβ© := UpperSemicontinuousOn.exists_isMaxOn hn G.compact_polytope | |
| continuous_binaryEntropy.continuousOn.upperSemicontinuousOn | |
| have hxdef := (entropy_defect G m hm hV hPM x hx).2.trans (min_le_right _ _) | |
| have hydef := (entropy_defect G m hm hV hPM y hy).2.trans (min_le_right _ _) | |
| have hxu := maxMatchingEntropy_le_log_card G hx | |
| have hyu := maxMatchingEntropy_le_log_card G hy | |
| have hzu := refined_upper G z hz | |
| have hzB := B_nonneg G hz | |
| have hyB := B_le_order G m hV hy | |
| have hzx : entropy z β€ entropy x := hmax hz | |
| have hzy := hmaxb hz | |
| change entropy z + complementEntropy z β€ entropy y + complementEntropy y at hzy | |
| refine β¨x, hx, y, hy, hmax, hmaxb, ?_, ?_, ?_, ?_β© | |
| Β· linarith | |
| Β· linarith | |
| Β· change _ β€ entropy y + complementEntropy y | |
| linarith | |
| Β· change entropy y + complementEntropy y β€ _ | |
| linarith | |
| def countBound (m k : β) (N : β) : Prop := | |
| (k = 1 β 1 β€ N) β§ | |
| (2 β€ k β (k : β)^m * (1 - 1 / (k : β))^(2 * (m - 1) * (k - 1)) β€ N β§ | |
| Real.exp (-2 * ((m : β) - 1)) * (k : β)^m β€ | |
| (k : β)^m * (1 - 1 / (k : β))^(2 * (m - 1) * (k - 1)) β§ | |
| (Real.exp (-2) * (k : β))^m β€ Real.exp (-2 * ((m : β) - 1)) * (k : β)^m) | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem matching_nonempty_of_mem (G : LooplessGraph V E) {x : E β β} (hx : x β G.polytope) : | |
| Nonempty G.Matching := by | |
| obtain β¨p, hpβ© := (G.mem_polytope_iff x).mp hx | |
| by_contra h | |
| have : IsEmpty G.Matching := not_nonempty_iff.mp h | |
| simpa using hp.1.2 | |
| theorem entropy_uniform (G : LooplessGraph V E) {m k : β} | |
| (hV : Fintype.card V = 2 * m) (hk : 2 β€ k) {x : E β β} (hx : x β G.polytope) | |
| (hu : β e, x e = 0 β¨ x e = 1 / (k : β)) : | |
| entropy x = (m : β) * Real.log (k : β) β§ | |
| complementEntropy x = -(m : β) * ((k : β) - 1) * Real.log (1 - 1 / (k : β)) := by | |
| have hkR : (0 : β) < k := by exact_mod_cast (show 0 < k by omega) | |
| have ha (e : E) : Real.negMulLog (x e) = x e * Real.log (k : β) := by | |
| rcases hu e with he | he | |
| Β· simp [he] | |
| Β· rw [he, one_div, Real.negMulLog, Real.log_inv]; ring | |
| have hb (e : E) : Real.negMulLog (1 - x e) = | |
| -((k : β) - 1) * x e * Real.log (1 - 1 / (k : β)) := by | |
| rcases hu e with he | he | |
| Β· simp [he] | |
| Β· rw [he, Real.negMulLog]; field_simp | |
| constructor | |
| Β· simp_rw [entropy, ha] | |
| rw [β Finset.sum_mul, G.marginal_sum hV hx] | |
| Β· simp_rw [complementEntropy, entropy, hb] | |
| rw [β Finset.sum_mul, β Finset.mul_sum, G.marginal_sum hV hx] | |
| ring | |
| omit [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] in | |
| theorem finiteCount_eq_exp {m k : β} (hm : 0 < m) (hk : 2 β€ k) : | |
| (k : β)^m * (1 - 1 / (k : β))^(2 * (m - 1) * (k - 1)) = | |
| Real.exp ((m : β) * Real.log (k : β) + | |
| 2 * ((m : β) - 1) * ((k : β) - 1) * Real.log (1 - 1 / (k : β))) := by | |
| have hkR : (1 : β) < k := by exact_mod_cast hk | |
| have ht : 0 < 1 - 1 / (k : β) := sub_pos.mpr ((div_lt_one (by linarith)).mpr hkR) | |
| have hc : 2 * ((m : β) - 1) * ((k : β) - 1) = ((2 * (m - 1) * (k - 1) : β) : β) := by | |
| rw [Nat.cast_mul, Nat.cast_mul, Nat.cast_sub (by omega), Nat.cast_sub (by omega)] | |
| norm_num | |
| rw [hc, Real.exp_add, Real.exp_nat_mul, Real.exp_nat_mul, Real.exp_log (by linarith), Real.exp_log ht] | |
| omit [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] in | |
| theorem log_uniform_loss {k : β} (hk : 2 β€ k) : | |
| -1 β€ ((k : β) - 1) * Real.log (1 - 1 / (k : β)) := by | |
| have hkR : (1 : β) < k := by exact_mod_cast hk | |
| have hk0 : (0 : β) < k := by linarith | |
| have ht : 0 < 1 - 1 / (k : β) := sub_pos.mpr ((div_lt_one hk0).mpr hkR) | |
| have hb := Real.log_le_sub_one_of_pos (inv_pos.mpr ht) | |
| rw [Real.log_inv] at hb | |
| have hkm : 0 < (k : β) - 1 := by linarith | |
| have heq : ((1 - 1 / (k : β))β»ΒΉ - 1) * ((k : β) - 1) = 1 := by | |
| field_simp; ring | |
| have hh := mul_le_mul_of_nonneg_right hb (by linarith : 0 β€ (k : β) - 1) | |
| rw [heq] at hh | |
| nlinarith | |
| theorem refined_uniform_count (G : LooplessGraph V E) {m k : β} | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) {x : E β β} (hx : x β G.polytope) | |
| (hu : β e, x e = 0 β¨ x e = 1 / (k : β)) : | |
| countBound m k (Fintype.card G.Matching : β) := by | |
| have hPM := matching_nonempty_of_mem G hx | |
| have hN : (0 : β) < Fintype.card G.Matching := by | |
| exact_mod_cast Fintype.card_pos_iff.mpr hPM | |
| refine β¨fun _ => by exact_mod_cast Fintype.card_pos_iff.mpr hPM, fun hk => ?_β© | |
| have hk0 : (0 : β) < k := by exact_mod_cast (show 0 < k by omega) | |
| have hm0 : (0 : β) < m := by exact_mod_cast hm | |
| have hm1 : (1 : β) β€ m := by exact_mod_cast hm | |
| obtain β¨hF, hBβ© := entropy_uniform G hV hk hx hu | |
| have hl := (pointwise_entropy G m hm hV hPM x hx).1.trans (maxMatchingEntropy_le_log_card G hx) | |
| rw [hF, hB] at hl | |
| have hl' : (m : β) * Real.log (k : β) + | |
| 2 * ((m : β) - 1) * ((k : β) - 1) * Real.log (1 - 1 / (k : β)) β€ | |
| Real.log (Fintype.card G.Matching : β) := by | |
| convert hl using 1 | |
| first | rfl | (field_simp; ring) | |
| refine β¨?_, ?_, ?_β© | |
| Β· rw [finiteCount_eq_exp hm hk] | |
| simpa only [Real.exp_log hN] using Real.exp_le_exp.mpr hl' | |
| Β· rw [finiteCount_eq_exp hm hk] | |
| have heq : Real.exp (-2 * ((m : β) - 1)) * (k : β)^m = | |
| Real.exp (-2 * ((m : β) - 1) + (m : β) * Real.log (k : β)) := by | |
| rw [Real.exp_add, Real.exp_nat_mul, Real.exp_log hk0] | |
| rw [heq] | |
| apply Real.exp_le_exp.mpr | |
| have hh := mul_le_mul_of_nonneg_left (log_uniform_loss hk) (by linarith : 0 β€ 2 * ((m : β) - 1)) | |
| nlinarith | |
| Β· rw [mul_pow, β Real.exp_nat_mul] | |
| apply mul_le_mul_of_nonneg_right _ (pow_nonneg hk0.le _) | |
| apply Real.exp_le_exp.mpr | |
| linarith | |
| theorem structural_count (G : LooplessGraph V E) (m k : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hk : 1 β€ k) | |
| (M : Fin k β G.Matching) | |
| (hd : β i j, i β j β Disjoint (M i).val (M j).val) : | |
| countBound m k (Fintype.card G.Matching : β) := by | |
| obtain β¨x, hx, huβ© := selected_uniform_mean G hk M hd | |
| exact refined_uniform_count G hm hV hx hu | |
| theorem regular_count (G : LooplessGraph V E) (m k : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hk : 1 β€ k) | |
| (hregular : β v, (Finset.univ.filter (G.Incident v)).card = k) | |
| (hodd : β S : Finset V, Odd S.card β k β€ (G.cut S).card) : | |
| countBound m k (Fintype.card G.Matching : β) := by | |
| exact refined_uniform_count G hm hV (regular_uniform_mem G hV hk hregular hodd) (fun _ => Or.inr rfl) | |
| omit [Fintype V] [DecidableEq E] in | |
| theorem degree_cut_count (G : LooplessGraph V E) {k : β} | |
| (hreg : β v, (Finset.univ.filter (G.Incident v)).card = k) (S : Finset V) : | |
| S.card * k = 2 * (Finset.univ.filter (fun e => G.left e β S β§ G.right e β S)).card + | |
| (G.cut S).card := by | |
| classical | |
| have hp (e : E) : ((if G.left e β S then (1 : β) else 0) + | |
| (if G.right e β S then 1 else 0)) = | |
| 2 * (if G.left e β S β§ G.right e β S then 1 else 0) + | |
| (if G.Crosses S e then 1 else 0) := by | |
| by_cases hl : G.left e β S <;> by_cases hr : G.right e β S <;> simp [Crosses, hl, hr] | |
| calc | |
| S.card * k = β v β S, (β e : E, if G.Incident v e then (1 : β) else 0) := by | |
| simp [Finset.sum_boole, hreg, Finset.sum_const] | |
| _ = β e : E, β v β S, if G.Incident v e then (1 : β) else 0 := Finset.sum_comm | |
| _ = _ := by | |
| simp_rw [G.incidence_sum, hp] | |
| rw [Finset.sum_add_distrib, β Finset.mul_sum] | |
| simp [Finset.sum_boole, cut] | |
| omit [DecidableEq E] in | |
| theorem connected_odd_cut (G : LooplessGraph V E) {m k : β} | |
| (hV : Fintype.card V = 2 * m) (hk : 1 β€ k) | |
| (hregular : β v, (Finset.univ.filter (G.Incident v)).card = k) | |
| (hconn : β S : Finset V, S.Nonempty β S β Finset.univ β k - 1 β€ (G.cut S).card) | |
| (S : Finset V) (hS : Odd S.card) : k β€ (G.cut S).card := by | |
| have hsmod := Nat.odd_iff.mp hS | |
| have hn : S.Nonempty := Finset.card_pos.mp (by omega) | |
| have hp : S β Finset.univ := by | |
| intro hh | |
| simp only [hh, Finset.card_univ, hV] at hsmod | |
| omega | |
| have hc := hconn S hn hp | |
| have heq := congrArg (fun a : β => a % 2) (degree_cut_count G hregular S) | |
| rw [Nat.mul_mod S.card k 2, hsmod] at heq | |
| simp only [one_mul, Nat.mod_mod] at heq | |
| omega | |
| theorem connected_regular_count (G : LooplessGraph V E) (m k : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hk : 1 β€ k) | |
| (hregular : β v, (Finset.univ.filter (G.Incident v)).card = k) | |
| (hconn : β S : Finset V, S.Nonempty β S β Finset.univ β k - 1 β€ (G.cut S).card) : | |
| countBound m k (Fintype.card G.Matching : β) := by | |
| exact regular_count G m k hm hV hk hregular (connected_odd_cut G hV hk hregular hconn) | |
| def weightedPartition (G : LooplessGraph V E) (Ξ² : E β β) : β := | |
| β M : G.Matching, (2 : β) ^ (β e, Ξ² e * G.indicator M e) | |
| def weightedObjective (Ξ² x : E β β) : β := entropy x / Real.log 2 + β e, Ξ² e * x e | |
| def gibbsLaw (G : LooplessGraph V E) (Ξ² : E β β) (M : G.Matching) : β := | |
| (2 : β) ^ (β e, Ξ² e * G.indicator M e) / weightedPartition G Ξ² | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem weightedPartition_pos (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) : | |
| 0 < weightedPartition G Ξ² := by | |
| let := hPM | |
| exact Finset.sum_pos (fun M _ => Real.rpow_pos_of_pos (by norm_num) _) Finset.univ_nonempty | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbsLaw_pos (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) (M : G.Matching) : | |
| 0 < gibbsLaw G Ξ² M := | |
| div_pos (Real.rpow_pos_of_pos (by norm_num) _) (weightedPartition_pos G hPM Ξ²) | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbsLaw_simplex (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) : | |
| gibbsLaw G Ξ² β probabilitySimplex G.Matching := by | |
| refine β¨fun M => (gibbsLaw_pos G hPM Ξ² M).le, ?_β© | |
| simp only [gibbsLaw, β Finset.sum_div] | |
| exact div_self (weightedPartition_pos G hPM Ξ²).ne' | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbs_cross_entropy (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) | |
| {p : G.Matching β β} (hp : p β probabilitySimplex G.Matching) : | |
| -(β M, p M * Real.log (gibbsLaw G Ξ² M)) = | |
| Real.log (weightedPartition G Ξ²) - Real.log 2 * (β e, Ξ² e * G.mean p e) := by | |
| have hl (M : G.Matching) : Real.log (gibbsLaw G Ξ² M) = | |
| (β e, Ξ² e * G.indicator M e) * Real.log 2 - Real.log (weightedPartition G Ξ²) := by | |
| rw [gibbsLaw, Real.log_div (ne_of_gt (Real.rpow_pos_of_pos (by norm_num) _)) | |
| (weightedPartition_pos G hPM Ξ²).ne', Real.log_rpow (by norm_num)] | |
| simp_rw [hl, mul_sub, β mul_assoc] | |
| rw [Finset.sum_sub_distrib, β Finset.sum_mul, β Finset.sum_mul, hp.2, one_mul, sum_mean_assoc] | |
| ring | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbs_law_bound (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) | |
| {p : G.Matching β β} (hp : p β probabilitySimplex G.Matching) : | |
| entropy p / Real.log 2 + (β e, Ξ² e * G.mean p e) β€ | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 := by | |
| have h := entropy_le_crossEntropy (gibbsLaw_simplex G hPM Ξ²) hp | |
| (fun M hzero => ((gibbsLaw_pos G hPM Ξ² M).ne' hzero).elim) | |
| rw [gibbs_cross_entropy G hPM Ξ² hp] at h | |
| have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) | |
| apply (le_div_iffβ hlog).mpr | |
| rw [add_mul, div_mul_cancelβ _ hlog.ne'] | |
| nlinarith | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbs_law_equality (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) : | |
| entropy (gibbsLaw G Ξ²) / Real.log 2 + (β e, Ξ² e * G.mean (gibbsLaw G Ξ²) e) = | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 := by | |
| have h := gibbs_cross_entropy G hPM Ξ² (gibbsLaw_simplex G hPM Ξ²) | |
| rw [β entropy_eq] at h | |
| rw [h] | |
| have hlog : Real.log 2 β 0 := (Real.log_pos (by norm_num : (1 : β) < 2)).ne' | |
| field_simp | |
| ring | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem gibbs_variational (G : LooplessGraph V E) (hPM : Nonempty G.Matching) (Ξ² : E β β) : | |
| gibbsLaw G Ξ² β probabilitySimplex G.Matching β§ | |
| maxMatchingEntropy G (G.mean (gibbsLaw G Ξ²)) / Real.log 2 + | |
| (β e, Ξ² e * G.mean (gibbsLaw G Ξ²) e) = Real.log (weightedPartition G Ξ²) / Real.log 2 β§ | |
| β x β G.polytope, maxMatchingEntropy G x / Real.log 2 + (β e, Ξ² e * x e) β€ | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 := by | |
| have hp := gibbsLaw_simplex G hPM Ξ² | |
| have hx := G.mean_mem_polytope hp | |
| have hu : β x β G.polytope, maxMatchingEntropy G x / Real.log 2 + (β e, Ξ² e * x e) β€ | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 := by | |
| intro x hx | |
| obtain β¨p, hp, hoptβ© := maxMatchingEntropy_attained G hx | |
| rw [β hopt, β hp.2] | |
| exact gibbs_law_bound G hPM Ξ² hp.1 | |
| refine β¨hp, le_antisymm (hu _ hx) ?_, huβ© | |
| rw [β gibbs_law_equality G hPM Ξ²] | |
| exact add_le_add (div_le_div_of_nonneg_right (entropy_le_maxMatchingEntropy G β¨hp, rflβ©) | |
| (Real.log_pos (by norm_num)).le) le_rfl | |
| theorem weighted_count (G : LooplessGraph V E) (m : β) | |
| (hm : 0 < m) (hV : Fintype.card V = 2 * m) (hPM : Nonempty G.Matching) | |
| (Ξ² : E β β) : | |
| β x β G.polytope, (β y β G.polytope, weightedObjective Ξ² y β€ weightedObjective Ξ² x) β§ | |
| weightedObjective Ξ² x - (2 * (m : β) - 2) / Real.log 2 β€ | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 β§ | |
| Real.log (weightedPartition G Ξ²) / Real.log 2 β€ weightedObjective Ξ² x := by | |
| obtain β¨hp, heq, huβ© := gibbs_variational G hPM Ξ² | |
| have hz := G.mean_mem_polytope hp | |
| have hcont : Continuous (weightedObjective Ξ²) := by | |
| unfold weightedObjective | |
| exact (continuous_entropy.div_const _).add (by fun_prop) | |
| obtain β¨x, hx, hmaxβ© := UpperSemicontinuousOn.exists_isMaxOn β¨_, hzβ© G.compact_polytope | |
| hcont.continuousOn.upperSemicontinuousOn | |
| have hlog : 0 < Real.log 2 := Real.log_pos (by norm_num) | |
| refine β¨x, hx, hmax, ?_, ?_β© | |
| Β· have hd := (entropy_defect G m hm hV hPM x hx).2.trans (min_le_right _ _) | |
| have hd' := div_le_div_of_nonneg_right hd hlog.le | |
| have huu := hu x hx | |
| dsimp only [weightedObjective] | |
| rw [sub_div] at hd' | |
| linarith | |
| Β· rw [β heq] | |
| apply le_trans _ (hmax hz) | |
| exact add_le_add (div_le_div_of_nonneg_right (refined_upper G _ hz) hlog.le) le_rfl | |
| end MatchingEntropyBounds.Refined | |
| end | |
| end OAI | |