Download data/lean/OAI/Combinatorics/MatchingEntropy/Counting.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 7.84 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Counting.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingEntropy/Counting.lean
-
curl -L -o Counting.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/Counting.lean
7.84 kB
| import OAI.Combinatorics.MatchingEntropy.EntropyUpper | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators Topology | |
| open Filter | |
| universe uV uE uI uJ uA uB uC uW uF uD uΞΉ | |
| namespace MatchingEntropyBounds | |
| variable {V : Type uV} {E : Type uE} [Fintype V] [Fintype E] [DecidableEq V] [DecidableEq E] | |
| theorem separable_entropy_main (G : LooplessGraph V E) | |
| (_hn : 2 β€ Fintype.card V) (hPM : Nonempty G.Matching) | |
| (x : E β β) (hx : x β G.polytope) : | |
| separableLower x β€ maxMatchingEntropy G x β§ | |
| maxMatchingEntropy G x β€ binaryEntropy x := | |
| β¨separable_lower G hPM x hx, maxMatchingEntropy_le_binary G x hxβ© | |
| omit [Fintype V] [Fintype E] [DecidableEq V] in | |
| theorem selected_uniform_mean (G : LooplessGraph V E) {k : β} (hk : 1 β€ k) | |
| (M : Fin k β G.Matching) | |
| (hdisjoint : β i j, i β j β Disjoint (M i).val (M j).val) : | |
| β x β G.polytope, β e, x e=0 β¨ x e=1/(k:β) := by | |
| classical | |
| have hkR : (0:β)<k := by exact_mod_cast (show 0<k by omega) | |
| have hsum : (β i : Fin k, (1/(k:β)))=1 := by | |
| simp only [Finset.sum_const,Finset.card_univ,Fintype.card_fin,nsmul_eq_mul] | |
| field_simp | |
| let x := β i : Fin k, (1/(k:β)) β’ G.indicator (M i) | |
| refine β¨x,?_,?_β© | |
| Β· exact (convex_convexHull β (Set.range G.indicator)).sum_mem | |
| (fun (i : Fin k) _ => (one_div_pos.mpr hkR).le) hsum | |
| (fun i _ => subset_convexHull β _ (Set.mem_range_self (M i))) | |
| Β· intro e | |
| dsimp only [x] | |
| simp only [Finset.sum_apply,Pi.smul_apply,smul_eq_mul] | |
| by_cases he : β i, e β (M i).val | |
| Β· obtain β¨i,hiβ© := he | |
| right | |
| rw [Finset.sum_eq_single i] | |
| Β· simp [LooplessGraph.indicator,hi] | |
| Β· intro j _ hji | |
| have hj : e β (M j).val := fun h => | |
| Finset.disjoint_left.mp (hdisjoint j i hji) h hi | |
| simp [LooplessGraph.indicator,hj] | |
| Β· simp | |
| Β· left | |
| apply Finset.sum_eq_zero | |
| intro i _ | |
| have hi : e β (M i).val := fun h => he β¨i,hβ© | |
| simp [LooplessGraph.indicator,hi] | |
| theorem separableLower_uniform (G : LooplessGraph V E) {r k : β} | |
| (hV : Fintype.card V=2*r) (hk : 2 β€ k) {x : E β β} (hx : x β G.polytope) | |
| (huniform : β e, x e=0 β¨ x e=1/(k:β)) : | |
| separableLower x = (r:β)*(Real.log (k:β)+ | |
| (3*((k-1:β):β))*Real.log (1-1/(k:β))) := by | |
| have hkR : (0:β)<k := by exact_mod_cast (show 0<k by omega) | |
| have hkcast : ((k-1:β):β)=(k:β)-1 := by rw [Nat.cast_sub (by omega)]; norm_num | |
| have ha (e : E) : Real.negMulLog (x e)=x e*Real.log (k:β) := by | |
| rcases huniform 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 huniform e with he | he | |
| Β· simp [he] | |
| Β· rw [he,Real.negMulLog] | |
| field_simp | |
| unfold separableLower entropy | |
| simp_rw [ha,hb] | |
| rw [β Finset.sum_mul,β Finset.sum_mul,β Finset.mul_sum,G.marginal_sum hV hx,hkcast] | |
| ring | |
| theorem structuralBase_eq_exp {k : β} (hk : 2 β€ k) : | |
| structuralBase k = Real.exp (Real.log (k:β)+ | |
| (3*((k-1:β):β))*Real.log (1-1/(k:β))) := by | |
| have hkR : (1:β)<k := by exact_mod_cast (show 1<k by omega) | |
| have ht : 0<1-1/(k:β) := by | |
| have hh := (div_lt_one (by linarith : (0:β)<k)).mpr hkR | |
| linarith | |
| rw [structuralBase,ite_eq_right (by omega),Real.exp_add,Real.exp_log (by linarith)] | |
| have hc : (3*((k-1:β):β)) = ((3*(k-1):β):β) := by push_cast; ring | |
| rw [hc,Real.exp_nat_mul,Real.exp_log ht] | |
| theorem structuralBase_lower {k : β} (hk : 1 β€ k) : | |
| Real.exp (-3)*(k:β) β€ structuralBase k := by | |
| by_cases hk1 : k=1 | |
| Β· subst k | |
| simp only [structuralBase,ite_true,Nat.cast_one,mul_one] | |
| exact Real.exp_le_one_iff.mpr (by norm_num) | |
| Β· have hk2 : 2 β€ k := by omega | |
| have hkR : (1:β)<k := by exact_mod_cast (show 1<k by omega) | |
| 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 hkm.le | |
| rw [heq] at hh | |
| have hlog : -1 β€ ((k:β)-1)*Real.log (1-1/(k:β)) := by nlinarith | |
| rw [structuralBase_eq_exp hk2] | |
| have hkcast : ((k-1:β):β)=(k:β)-1 := by rw [Nat.cast_sub (by omega)]; norm_num | |
| have hbase : Real.exp (-3)*(k:β)=Real.exp (-3+Real.log (k:β)) := by | |
| rw [Real.exp_add,Real.exp_log hk0] | |
| rw [hbase] | |
| apply Real.exp_le_exp.mpr | |
| rw [hkcast] | |
| nlinarith | |
| theorem uniform_support_count (G : LooplessGraph V E) {r k : β} | |
| (hV : Fintype.card V=2*r) (hk : 1 β€ k) {x : E β β} (hx : x β G.polytope) | |
| (huniform : β e, x e=0 β¨ x e=1/(k:β)) : | |
| structuralBase k ^ r β€ (Fintype.card G.Matching : β) β§ | |
| (Real.exp (-3)*(k:β)) ^ r β€ structuralBase k ^ r := by | |
| have hPM : 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 | |
| have hN : (0:β)<Fintype.card G.Matching := by | |
| exact_mod_cast Fintype.card_pos_iff.mpr hPM | |
| constructor | |
| Β· by_cases hk1 : k=1 | |
| Β· subst k | |
| simp only [structuralBase,ite_true,one_pow] | |
| exact_mod_cast (Fintype.card_pos_iff.mpr hPM) | |
| Β· have hk2 : 2 β€ k := by omega | |
| have hlog := (separable_lower G hPM x hx).trans (maxMatchingEntropy_le_log_card G hx) | |
| rw [separableLower_uniform G hV hk2 hx huniform] at hlog | |
| have he := Real.exp_le_exp.mpr hlog | |
| rw [Real.exp_log hN,Real.exp_nat_mul,β structuralBase_eq_exp hk2] at he | |
| exact he | |
| Β· exact pow_le_pow_leftβ (mul_nonneg (Real.exp_pos _).le (Nat.cast_nonneg _)) | |
| (structuralBase_lower hk) r | |
| theorem structural_count_main (G : LooplessGraph V E) (r k : β) | |
| (_hr : 0<r) (hV : Fintype.card V=2*r) (hk : 1 β€ k) | |
| (M : Fin k β G.Matching) | |
| (hdisjoint : β i j, iβ j β Disjoint (M i).val (M j).val) : | |
| structuralBase k ^ r β€ (Fintype.card G.Matching : β) β§ | |
| (Real.exp (-3)*(k:β)) ^ r β€ structuralBase k ^ r := by | |
| obtain β¨x,hx,huβ© := selected_uniform_mean G hk M hdisjoint | |
| exact uniform_support_count G hV hk hx hu | |
| theorem regular_uniform_mem (G : LooplessGraph V E) {r k : β} | |
| (hV : Fintype.card V=2*r) (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) : | |
| (fun _ : E => 1/(k:β)) β G.polytope := by | |
| have hkR : (0:β)<k := by exact_mod_cast (show 0<k by omega) | |
| rw [G.polytope_eq_constraints (by rw [hV]; exact even_two_mul r)] | |
| refine β¨fun _ => (one_div_pos.mpr hkR).le,?_,?_β© | |
| Β· intro v | |
| unfold LooplessGraph.degree | |
| rw [β Finset.sum_filter] | |
| simp only [Finset.sum_const,nsmul_eq_mul,hregular] | |
| field_simp | |
| Β· intro S hS | |
| unfold LooplessGraph.cutMass | |
| simp only [Finset.sum_const,nsmul_eq_mul] | |
| have hc : (k:β) β€ (G.cut S).card := by exact_mod_cast hodd S hS | |
| calc | |
| 1 = (k:β)*(1/(k:β)) := by field_simp | |
| _ β€ _ := mul_le_mul_of_nonneg_right hc (one_div_pos.mpr hkR).le | |
| theorem regular_count_main (G : LooplessGraph V E) (r k : β) | |
| (_hr : 0<r) (hV : Fintype.card V=2*r) (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) : | |
| structuralBase k ^ r β€ (Fintype.card G.Matching : β) β§ | |
| (Real.exp (-3)*(k:β)) ^ r β€ structuralBase k ^ r := by | |
| exact uniform_support_count G hV hk (regular_uniform_mem G hV hk hregular hodd) | |
| (fun _ => Or.inr rfl) | |
| end MatchingEntropyBounds | |
| end | |
| end OAI | |