File size: 3,634 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | 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
|