Download data/lean/OAI/Combinatorics/MatchingPSD/MatrixBounds.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 3.63 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/MatrixBounds.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Combinatorics/MatchingPSD/MatrixBounds.lean
-
curl -L -o MatrixBounds.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Combinatorics/MatchingPSD/MatrixBounds.lean
3.63 kB
| import OAI.Combinatorics.MatchingPSD.BitTests | |
| namespace OAI | |
| universe u_1 u_2 | |
| namespace PerfectMatchingPSD | |
| open Matrix | |
| open scoped MatrixOrder | |
| variable {R : Type u_1} [Fintype R] [DecidableEq R] | |
| lemma entry_product_bound {a x y b : β} (hb : 0 β€ b) (ha : |a| β€ b) : | |
| x*a*y β€ b*(x^2+y^2)/2 := by | |
| have hxy : 2 * |x| * |y| β€ x^2+y^2 := by | |
| nlinarith [sq_nonneg (|x|-|y|), sq_abs x, sq_abs y] | |
| have he : x*a*y β€ b*(|x| * |y|) := by | |
| calc | |
| _ β€ |x*a*y| := le_abs_self _ | |
| _ = |a| *(|x| * |y|) := by rw [abs_mul, abs_mul]; ring | |
| _ β€ _ := mul_le_mul_of_nonneg_right ha (mul_nonneg (abs_nonneg _) (abs_nonneg _)) | |
| nlinarith [mul_le_mul_of_nonneg_left hxy hb] | |
| lemma le_card_entry_bound {E : Matrix R R β} (hE : E.IsHermitian) | |
| {b : β} (hb : 0 β€ b) (hbound : β i j, |E i j| β€ b) : | |
| E β€ ((Fintype.card R : β)*b) β’ (1 : Matrix R R β) := by | |
| apply sub_nonneg.mp | |
| apply Matrix.PosSemidef.nonneg | |
| apply Matrix.PosSemidef.of_dotProduct_mulVec_nonneg | |
| Β· exact (isHermitian_one.smul (.of_nonneg (mul_nonneg (Nat.cast_nonneg _) hb))).sub hE | |
| Β· intro x | |
| have hsum : (β i, β j, x i*E i j*x j) β€ | |
| (Fintype.card R : β)*b*(β i, (x i)^2) := by | |
| calc | |
| _ β€ β i, β j, (b/2*(x i)^2 + b/2*(x j)^2) := by | |
| apply Finset.sum_le_sum | |
| intro i _ | |
| apply Finset.sum_le_sum | |
| intro j _ | |
| have he := entry_product_bound (x := x i) (y := x j) hb (hbound i j) | |
| linarith | |
| _ = _ := by | |
| simp only [Finset.sum_add_distrib, Finset.sum_const, Finset.card_univ, | |
| nsmul_eq_mul, β Finset.mul_sum] | |
| ring | |
| simp only [Matrix.sub_mulVec, Matrix.smul_mulVec, Matrix.one_mulVec, | |
| dotProduct_sub, dotProduct_smul, star_trivial] | |
| rw [sub_nonneg] | |
| simpa only [dotProduct, Matrix.mulVec, Finset.mul_sum, pow_two, smul_eq_mul, mul_assoc] using hsum | |
| lemma posSemidef_entry_abs_le_trace {A : Matrix R R β} (hA : A.PosSemidef) (i j : R) : | |
| |A i j| β€ A.trace := by | |
| have hi : 0 β€ A i i := by | |
| have he := hA.dotProduct_mulVec_nonneg (Pi.single i 1) | |
| simpa using he | |
| have hj : 0 β€ A j j := by | |
| have he := hA.dotProduct_mulVec_nonneg (Pi.single j 1) | |
| simpa using he | |
| have hsym : A j i = A i j := by | |
| simpa using congrArg (fun M : Matrix R R β => M i j) hA.isHermitian.eq | |
| have hplus : -(A i i + A j j)/2 β€ A i j := by | |
| have he := hA.dotProduct_mulVec_nonneg (Pi.single i 1 + Pi.single j 1) | |
| simp only [star_trivial, Matrix.mulVec_add, dotProduct_add, | |
| add_dotProduct, Matrix.mulVec_single_one, single_dotProduct, one_mul, Matrix.col_apply] at he | |
| rw [hsym] at he | |
| linarith | |
| have hminus : A i j β€ (A i i + A j j)/2 := by | |
| have he := hA.dotProduct_mulVec_nonneg (Pi.single i 1 - Pi.single j 1) | |
| simp only [star_trivial, Matrix.mulVec_sub, dotProduct_sub, | |
| sub_dotProduct, Matrix.mulVec_single_one, single_dotProduct, one_mul, Matrix.col_apply] at he | |
| rw [hsym] at he | |
| linarith | |
| have hdiag (k : R) : A k k β€ A.trace := by | |
| change A k k β€ β l, A l l | |
| apply Finset.single_le_sum (f := fun l => A l l) | |
| Β· intro l _ | |
| have he := hA.dotProduct_mulVec_nonneg (Pi.single l 1) | |
| simpa using he | |
| Β· exact Finset.mem_univ k | |
| exact (abs_le.mpr β¨by linarith, hminusβ©).trans (by linarith [hdiag i, hdiag j]) | |
| omit [Fintype R] [DecidableEq R] in | |
| lemma matrix_sum_psd {X : Type u_2} (s : Finset X) (f : X β Matrix R R β) | |
| (hf : β x β s, (f x).PosSemidef) : (β x β s, f x).PosSemidef := | |
| (Finset.sum_nonneg (fun x hx => (hf x hx).nonneg)).posSemidef | |
| end PerfectMatchingPSD | |
| end OAI | |