Download data/lean/OAI/Combinatorics/MatchingEntropy/MatchingCovariance.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.74 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/MatchingCovariance.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingEntropy/MatchingCovariance.lean
-
curl -L -o MatchingCovariance.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingEntropy/MatchingCovariance.lean
6.74 kB
| import OAI.Combinatorics.MatchingEntropy.Continuity | |
| namespace OAI | |
| noncomputable section | |
| open scoped BigOperators Topology | |
| open Filter Matrix | |
| 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] | |
| def matchingNormalized (G : LooplessGraph V E) (x : E β β) : | |
| G.Matching β {e // 0 < x e} β β := | |
| normalizedCentered (fun M e => G.indicator M e.val) (fun e => x e.val) | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem matchingNormalized_average (G : LooplessGraph V E) {x y : E β β} | |
| {q : G.Matching β β} (hq : q β G.feasibleLaws y) (e : {e // 0 < x e}) : | |
| (β M, q M*matchingNormalized G x M e)=(y e.val-x e.val)/Real.sqrt (x e.val) := by | |
| simp only [matchingNormalized,normalizedCentered,β mul_div_assoc,mul_sub, | |
| β Finset.sum_div,Finset.sum_sub_distrib,β Finset.sum_mul,hq.1.2,one_mul] | |
| rw [show (β M, q M*G.indicator M e.val)=y e.val from congrFun hq.2 e.val] | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem midpoint_law_support (G : LooplessGraph V E) {x v : E β β} {a : β} | |
| {p q r : G.Matching β β} (hp : p β G.feasibleLaws x) | |
| (hopt : entropy p=maxMatchingEntropy G x) | |
| (hq : q β G.feasibleLaws (x+a β’ v)) | |
| (hr : r β G.feasibleLaws (x+(-a) β’ v)) : | |
| β M, 0 < q M β 0 < p M := by | |
| let w : G.Matching β β := (1/2:β) β’ q+(1/2:β) β’ r | |
| have hw : w β G.feasibleLaws x := by | |
| refine β¨convex_probabilitySimplex _ hq.1 hr.1 (by norm_num) (by norm_num) (by norm_num),?_β© | |
| change G.meanLinear ((1/2:β) β’ q+(1/2:β) β’ r) = _ | |
| rw [map_add,map_smul,map_smul] | |
| change (1/2:β) β’ G.mean q+(1/2:β) β’ G.mean r = _ | |
| rw [hq.2,hr.2] | |
| ext e | |
| simp only [Pi.add_apply,Pi.smul_apply,smul_eq_mul] | |
| ring | |
| intro M hM | |
| apply matching_optimizer_support G hp hw hopt | |
| change 0 < (1/2:β)*q M+(1/2:β)*r M | |
| have hh := hr.1.1 M | |
| linarith | |
| theorem normalized_face_mem (G : LooplessGraph V E) {x : E β β} | |
| (heven : Even (Fintype.card V)) {p : G.Matching β β} | |
| (hp : p β G.feasibleLaws x) (hopt : entropy p=maxMatchingEntropy G x) | |
| {u : {e // 0 < x e} β β} (hu : u β G.faceSpace x) : | |
| (fun e => u e/Real.sqrt (x e.val)) β weightedDirectionSpace p (matchingNormalized G x) := by | |
| have hx : x β G.polytope := (G.mem_polytope_iff x).mpr β¨p,hpβ© | |
| have hev := G.faceSpace_eventually_line (G.polytope_subset_constraintPolytope hx) hu | |
| have hneg : βαΆ t : β in π 0, x+(-t) β’ LooplessGraph.positiveExtension x u β G.constraintPolytope := by | |
| have hc : Tendsto (fun t : β => -t) (π 0) (π 0) := by simpa using continuous_neg.tendsto (0:β) | |
| exact hc.eventually hev | |
| have hh : βαΆ t : β in π[>] 0, | |
| (x+t β’ LooplessGraph.positiveExtension x u β G.constraintPolytope β§ | |
| x+(-t) β’ LooplessGraph.positiveExtension x u β G.constraintPolytope) β§ 0 < t := | |
| ((hev.and hneg).filter_mono nhdsWithin_le_nhds).and eventually_mem_nhdsWithin | |
| obtain β¨a,β¨ha,hnaβ©,ha0β© := hh.exists | |
| rw [β G.polytope_eq_constraints heven] at ha hna | |
| obtain β¨q,hqβ© := (G.mem_polytope_iff _).mp ha | |
| obtain β¨r,hrβ© := (G.mem_polytope_iff _).mp hna | |
| have hsupp := midpoint_law_support G hp hopt hq hr | |
| have hsum : (β M, q M β’ matchingNormalized G x M) β | |
| weightedDirectionSpace p (matchingNormalized G x) := by | |
| apply Submodule.sum_mem | |
| intro M _ | |
| by_cases hM : 0 < p M | |
| Β· exact Submodule.smul_mem _ _ (Submodule.subset_span β¨β¨M,hMβ©,rflβ©) | |
| Β· have hq0 : q M=0 := le_antisymm (le_of_not_gt fun hqM => hM (hsupp M hqM)) (hq.1.1 M) | |
| simp only [hq0,zero_smul] | |
| exact Submodule.zero_mem _ | |
| have hin := Submodule.smul_mem _ aβ»ΒΉ hsum | |
| have he : aβ»ΒΉ β’ (β M, q M β’ matchingNormalized G x M) = | |
| (fun e => u e/Real.sqrt (x e.val)) := by | |
| ext e | |
| simp only [Pi.smul_apply,Finset.sum_apply,smul_eq_mul] | |
| rw [matchingNormalized_average G hq] | |
| simp only [Pi.add_apply,Pi.smul_apply,smul_eq_mul,LooplessGraph.positiveExtension_pos] | |
| field_simp | |
| ring | |
| rwa [he] at hin | |
| def normalizeLinear (x : E β β) : | |
| ({e // 0 < x e} β β) ββ[β] ({e // 0 < x e} β β) where | |
| toFun := fun u e => u e/Real.sqrt (x e.val) | |
| map_add' := by intro u v; ext e; exact add_div _ _ _ | |
| map_smul' := by intro a u; ext e; exact mul_div_assoc _ _ _ | |
| omit [DecidableEq E] in | |
| theorem sum_positive_support (x f : E β β) (hf : β e, Β¬ 0 < x e β f e=0) : | |
| (β e, f e) = β e : {e // 0 < x e}, f e.val := by | |
| classical | |
| have hz : (β e : {e // Β¬ 0 < x e}, f e.val)=0 := | |
| Finset.sum_eq_zero fun e _ => hf e.val e.property | |
| have hh := Fintype.sum_subtype_add_sum_subtype (fun e => 0 < x e) f | |
| rw [hz,add_zero] at hh | |
| exact hh.symm | |
| def matchingScoreWeights (x : E β β) (u : {e // 0 < x e} β β) : E β β := | |
| LooplessGraph.positiveExtension x (fun e => u e/Real.sqrt (x e.val)) | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem matchingNormalized_score (G : LooplessGraph V E) (x : E β β) | |
| (u : {e // 0 < x e} β β) (M : G.Matching) : | |
| linearScore G (matchingScoreWeights x u) (β e, matchingScoreWeights x u e*x e) M = | |
| matchingNormalized G x M β¬α΅₯ u := by | |
| classical | |
| unfold linearScore | |
| rw [β Finset.sum_sub_distrib] | |
| rw [sum_positive_support x _ (fun e he => by simp [matchingScoreWeights,LooplessGraph.positiveExtension,he])] | |
| rw [dotProduct] | |
| apply Finset.sum_congr rfl | |
| intro e _ | |
| simp only [matchingScoreWeights,LooplessGraph.positiveExtension_pos,matchingNormalized,normalizedCentered] | |
| ring | |
| omit [Fintype V] [DecidableEq V] in | |
| theorem matchingNormalized_mulVec (G : LooplessGraph V E) {x : E β β} | |
| {p : G.Matching β β} (hp : p β G.feasibleLaws x) | |
| (u : {e // 0 < x e} β β) (e : {e // 0 < x e}) : | |
| (covariance p (matchingNormalized G x) *α΅₯ u) e = | |
| G.mean (fun M => p M * linearScore G (matchingScoreWeights x u) | |
| (β e, matchingScoreWeights x u e*x e) M) e.val / Real.sqrt (x e.val) := by | |
| let a := linearScore G (matchingScoreWeights x u) (β e, matchingScoreWeights x u e*x e) | |
| have hcenter : β M, p M*a M=0 := by | |
| dsimp only [a] | |
| rw [linearScore_expectation,hp.2,hp.1.2,mul_one,sub_self] | |
| calc | |
| _ = β M, (p M*a M*G.indicator M e.val-x e.val*(p M*a M))/Real.sqrt (x e.val) := by | |
| rw [covariance_mulVec hp.1.1] | |
| apply Finset.sum_congr rfl | |
| intro M _ | |
| rw [β matchingNormalized_score G x u M] | |
| change p M*((G.indicator M e.val-x e.val)/Real.sqrt (x e.val))*a M = _ | |
| ring | |
| _ = _ := by | |
| rw [β Finset.sum_div,Finset.sum_sub_distrib,β Finset.mul_sum,hcenter,mul_zero,sub_zero] | |
| rfl | |
| end MatchingEntropyBounds | |
| end | |
| end OAI | |