Download data/lean/OAI/Combinatorics/MatchingPSD/MatrixInterpolation.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 6.23 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/MatrixInterpolation.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingPSD/MatrixInterpolation.lean
-
curl -L -o MatrixInterpolation.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/MatrixInterpolation.lean
6.23 kB
| import OAI.Combinatorics.MatchingPSD.PolynomialInterpolation | |
| namespace OAI | |
| universe u_1 u_2 | |
| namespace MatchingInterpolation | |
| open MatchingSmoothing Matrix PerfectMatchingPSD | |
| open scoped BigOperators MatrixOrder | |
| attribute [local instance] Classical.propDecidable | |
| noncomputable def specialPoint : Fin 5 β Point := | |
| ![origin, origin+dirP, origin+dirStar, origin+dirA, origin+dirB] | |
| def specialCoeff : Fin 5 β β := ![1,-2,-1,1,1] | |
| noncomputable def scaledNode {d : β} (L : β) (g : GridIndex d) : Point := | |
| fun a => origin a+L*(g a:β) | |
| noncomputable def weightMass (d : β) (L : β) : β := β g, |weight d L g| | |
| lemma weightMass_nonneg (d : β) (L : β) : 0 β€ weightMass d L := | |
| Finset.sum_nonneg (fun _ _ => abs_nonneg _) | |
| lemma sum_abs_specialCoeff : (β j, |specialCoeff j|) = 6 := by | |
| norm_num [specialCoeff, Fin.sum_univ_succ] | |
| lemma five_interpolation {d : β} (P : Point β β) (hP : P β lowDegree coord d) | |
| {L : β} (hL : L β 0) : | |
| (β j, specialCoeff j * P (specialPoint j)) = β g, weight d L g * P (scaledNode L g) := by | |
| have h := weighted_interpolation d P hP L hL | |
| simp only [specialCoeff, specialPoint, Fin.sum_univ_succ, Matrix.cons_val_zero, | |
| Matrix.cons_val_succ, one_mul, neg_mul, Fin.sum_univ_zero, add_zero] at * | |
| change _ = β g, weight d L g * P (fun a => origin a+L*(g a:β)) | |
| linarith | |
| lemma finite_weighted_error {X : Type u_1} [Fintype X] | |
| (c e : X β β) {Ξ· : β} (he : β x, |e x| β€ Ξ·) : | |
| |β x, c x*e x| β€ (β x, |c x|)*Ξ· := by | |
| calc | |
| _ β€ β x, |c x*e x| := Finset.abs_sum_le_sum_abs _ _ | |
| _ β€ β x, |c x| *Ξ· := by | |
| apply Finset.sum_le_sum | |
| intro x _ | |
| rw [abs_mul] | |
| exact mul_le_mul_of_nonneg_left (he x) (abs_nonneg _) | |
| _ = _ := (Finset.sum_mul _ _ _).symm | |
| lemma interpolation_error {d : β} (F P : Point β β) | |
| (hP : P β lowDegree coord d) {L Ξ· : β} (hL : L β 0) | |
| (hs : β j, |F (specialPoint j)-P (specialPoint j)| β€ Ξ·) | |
| (hg : β g : GridIndex d, |F (scaledNode L g)-P (scaledNode L g)| β€ Ξ·) : | |
| |(β j, specialCoeff j*F (specialPoint j)) - | |
| β g, weight d L g*F (scaledNode L g)| β€ (6+weightMass d L)*Ξ· := by | |
| have hidentity : (β j, specialCoeff j*F (specialPoint j)) - | |
| β g, weight d L g*F (scaledNode L g) = | |
| (β j, specialCoeff j*(F (specialPoint j)-P (specialPoint j))) - | |
| β g, weight d L g*(F (scaledNode L g)-P (scaledNode L g)) := by | |
| simp only [mul_sub, Finset.sum_sub_distrib, five_interpolation P hP hL] | |
| ring | |
| rw [hidentity] | |
| have h1 := finite_weighted_error specialCoeff (fun j => F (specialPoint j)-P (specialPoint j)) hs | |
| have h2 := finite_weighted_error (weight d L) (fun g => F (scaledNode L g)-P (scaledNode L g)) hg | |
| rw [sum_abs_specialCoeff] at h1 | |
| calc | |
| _ β€ |β j, specialCoeff j*(F (specialPoint j)-P (specialPoint j))| + | |
| |β g, weight d L g*(F (scaledNode L g)-P (scaledNode L g))| := abs_sub _ _ | |
| _ β€ 6*Ξ· + weightMass d L*Ξ· := add_le_add h1 h2 | |
| _ = _ := by ring | |
| section Matrices | |
| variable {R : Type u_2} [Fintype R] [DecidableEq R] | |
| lemma interpolation_matrix_domination (d : β) | |
| (B : Point β Matrix R R β) (hB : β x, (B x).PosSemidef) | |
| (P : R β R β Point β β) (hP : β u v, P u v β lowDegree coord d) | |
| {L Ξ· : β} (hL : L β 0) (hΞ· : 0 β€ Ξ·) | |
| (hs : β j u v, |B (specialPoint j) u v-P u v (specialPoint j)| β€ Ξ·) | |
| (hg : β g : GridIndex d, β u v, |B (scaledNode L g) u v-P u v (scaledNode L g)| β€ Ξ·) : | |
| β E : Matrix R R β, E.PosSemidef β§ | |
| B (origin+dirA)+B (origin+dirB) β€ B (origin+dirStar)+(2:β) β’ B (origin+dirP)+E β§ | |
| β (Q : Matrix R R β) (m k : β), Q.trace β€ m β | |
| (β g : GridIndex d, (Q*B (scaledNode L g)).trace β€ k) β | |
| (Q*E).trace β€ weightMass d L*k + | |
| (Fintype.card R : β)*(6+weightMass d L)*Ξ·*m := by | |
| let H := (β j, specialCoeff j β’ B (specialPoint j)) - | |
| β g, weight d L g β’ B (scaledNode L g) | |
| let b := (6+weightMass d L)*Ξ· | |
| let c := (Fintype.card R : β)*b | |
| let W := β g, |weight d L g| β’ B (scaledNode L g) | |
| have hb : 0 β€ b := mul_nonneg (by linarith [weightMass_nonneg d L]) hΞ· | |
| have hc : 0 β€ c := mul_nonneg (Nat.cast_nonneg _) hb | |
| have hH : H.IsHermitian := by | |
| have hh (x : Point) := (hB x).isHermitian.eq | |
| simp only [H, Matrix.IsHermitian, Matrix.conjTranspose_sub, Matrix.conjTranspose_sum, | |
| Matrix.conjTranspose_smul, star_trivial, hh] | |
| have hentry (u v : R) : |H u v| β€ b := by | |
| simpa only [H, Matrix.sub_apply, Matrix.sum_apply, Matrix.smul_apply, smul_eq_mul] using | |
| interpolation_error (fun x => B x u v) (P u v) (hP u v) hL (fun j => hs j u v) (fun g => hg g u v) | |
| have hbound : H β€ c β’ (1 : Matrix R R β) := le_card_entry_bound hH hb hentry | |
| have hW : W.PosSemidef := matrix_sum_psd _ _ (fun g _ => (hB _).smul (abs_nonneg _)) | |
| let E := W+c β’ (1 : Matrix R R β) | |
| have hE : E.PosSemidef := hW.add (Matrix.PosSemidef.one.smul hc) | |
| refine β¨E,hE,?_,?_β© | |
| Β· apply sub_nonneg.mp | |
| apply Matrix.PosSemidef.nonneg | |
| have hdiff : (β g : GridIndex d, (|weight d L g|-weight d L g) β’ B (scaledNode L g)).PosSemidef := | |
| matrix_sum_psd _ _ (fun g _ => (hB _).smul (sub_nonneg.mpr (le_abs_self _))) | |
| convert ((sub_nonneg.mpr hbound).posSemidef.add (hB origin)).add hdiff using 1 | |
| dsimp [E,W,H] | |
| simp only [sub_smul, Finset.sum_sub_distrib, specialPoint, specialCoeff, Fin.sum_univ_succ, | |
| Matrix.cons_val_zero, Matrix.cons_val_succ, one_smul, neg_smul, | |
| Fin.sum_univ_zero, add_zero] | |
| module | |
| Β· intro Q m k hm hk | |
| change (Q*(W+c β’ (1 : Matrix R R β))).trace β€ _ | |
| rw [mul_add, Matrix.trace_add, mul_smul_comm, Matrix.trace_smul, mul_one] | |
| have hWt : (Q*W).trace β€ weightMass d L*k := by | |
| dsimp [W,weightMass] | |
| rw [Finset.mul_sum, Matrix.trace_sum, Finset.sum_mul] | |
| apply Finset.sum_le_sum | |
| intro g _ | |
| rw [mul_smul_comm, Matrix.trace_smul] | |
| exact mul_le_mul_of_nonneg_left (hk g) (abs_nonneg _) | |
| have he := add_le_add hWt (mul_le_mul_of_nonneg_left hm hc) | |
| calc | |
| _ β€ weightMass d L*k + c*m := he | |
| _ = _ := by dsimp [c,b]; ring | |
| end Matrices | |
| end MatchingInterpolation | |
| end OAI | |