-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exact Inverse Relations: Equations 146, 150 ,156 through 160 with Support Lemmas #3
base: master
Are you sure you want to change the base?
Exact Inverse Relations: Equations 146, 150 ,156 through 160 with Support Lemmas #3
Conversation
src/matrix_cookbook/mat_inv_lib.lean
Outdated
lemma is_unit_of_pos_def {A : matrix m m ℂ} (hA: matrix.pos_def A): | ||
is_unit A.det := | ||
begin | ||
rw is_unit_iff_ne_zero, | ||
apply ne.symm, | ||
cases hA with hAH hpos, | ||
rw is_hermitian.det_eq_prod_eigenvalues hAH, | ||
norm_cast, | ||
rw ← ne.def, | ||
apply ne_of_lt, | ||
apply finset.prod_pos, | ||
intros i _, | ||
rw hAH.eigenvalues_eq, | ||
apply hpos _ (λ h, _), | ||
have h_det : (hAH.eigenvector_matrix)ᵀ.det = 0, | ||
from matrix.det_eq_zero_of_row_eq_zero i (λ j, congr_fun h j), | ||
simpa only [h_det, not_is_unit_zero] using | ||
is_unit_det_of_invertible hAH.eigenvector_matrixᵀ, | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is a complex version of matrix.pos_def.det_pos
? Can you make a PR to mathlib that generalizes that lemma to is_R_or_C 𝕜
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems this one is a problem. We know because the matrix is positive definite that its determinant is a real number. But the way det is defined means for a
I think that is why the person who wrote matrix.pos_def.det_pos
avoided it anyway. just to avoid the headache?
So I guess the question is given a matrix that is is_R_or_C
how do you tell lean hey lean I know this determinant is going to be real number deal with it as such?
src/matrix_cookbook/mat_inv_lib.lean
Outdated
open_locale matrix big_operators | ||
|
||
|
||
lemma is_unit_of_pos_def {A : matrix m m ℂ} (hA: matrix.pos_def A): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lemma is_unit_of_pos_def {A : matrix m m ℂ} (hA: matrix.pos_def A): | |
lemma matrix.pos_def.complex_is_unit_det {A : matrix m m ℂ} (hA : matrix.pos_def A) : |
src/matrix_cookbook/mat_inv_lib.lean
Outdated
noncomputable lemma invertible_of_pos_def {A : matrix m m ℂ} {hA: matrix.pos_def A}: | ||
invertible A := | ||
begin | ||
apply invertible_of_is_unit_det, | ||
apply is_unit_of_pos_def, | ||
exact hA, | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this one is worth having, if you need it you can use invertible_of_is_unit_det hA.complex_is_unit_det
src/matrix_cookbook/mat_inv_lib.lean
Outdated
(P : matrix m m ℂ) (R : matrix n n ℂ) (B : matrix n m ℂ) | ||
-- [invertible P] [invertible R] | ||
(hP: matrix.pos_def P) (hR: matrix.pos_def R) : | ||
matrix.pos_def (B⬝P⬝Bᴴ + R) := |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are two separate lemmas hiding here I think:
pos_def.add (hP: matrix.pos_def A) (hR: matrix.pos_def B) : matrix.pos_def (A + B)
pos_def.hermitian_conj (hP: matrix.pos_def P) : matrix.pos_def (B⬝P⬝Bᴴ)
lemma pos_def.add_semidef {A: matrix m m R} {B: matrix m m R} | ||
(hA: matrix.pos_def A) (hB: matrix.pos_semidef B) : matrix.pos_def (A + B) := | ||
begin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is now in leanprover-community/mathlib4#13750
lemma eq_158_hermitianized (P : matrix m m ℂ) (R : matrix n n ℂ) (B : matrix n m ℂ) | ||
[invertible P] [invertible R] | ||
{hP: matrix.pos_def P} {hR: matrix.pos_def R} : | ||
(P⁻¹ + Bᴴ⬝R⁻¹⬝B)⁻¹⬝Bᴴ⬝R⁻¹ = P⬝Bᴴ⬝(B⬝P⬝Bᴴ + R)⁻¹ := | ||
begin | ||
-- This is equation 80: | ||
-- http://www.stat.columbia.edu/~liam/teaching/neurostat-spr12/papers/hmm/KF-welling-notes.pdf | ||
|
||
have hP_unit := is_unit_iff_ne_zero.2 (pos_def.det_ne_zero hP), | ||
have hR_unit := is_unit_iff_ne_zero.2 (pos_def.det_ne_zero hR), | ||
have hP_inv_unit := is_unit_nonsing_inv_det P hP_unit, | ||
have hR_inv_unit := is_unit_nonsing_inv_det R hR_unit, | ||
have hComb_unit: is_unit (R + B ⬝ P ⬝ Bᴴ).det, | ||
{ apply is_unit_iff_ne_zero.2, | ||
apply pos_def.det_ne_zero, | ||
apply pos_def.add_semidef hR, | ||
exact pos_def.hermitian_conj_is_semidef hP, }, | ||
have : is_unit (R⁻¹⁻¹ + Bᴴᴴ ⬝ P⁻¹⁻¹ ⬝ Bᴴ).det, | ||
{ simp only [inv_inv_of_invertible, conj_transpose_conj_transpose], | ||
apply hComb_unit, }, | ||
|
||
rw add_comm _ R, | ||
nth_rewrite 1 ← conj_transpose_conj_transpose B, | ||
rw eq_156_hermitianized P⁻¹ R⁻¹ Bᴴ, | ||
simp only [inv_inv_of_invertible, conj_transpose_conj_transpose], | ||
rw [matrix.sub_mul, matrix.sub_mul, sub_eq_iff_eq_add], | ||
apply_fun (matrix.mul P⁻¹), | ||
rw matrix.mul_add, | ||
repeat {rw ← matrix.mul_assoc P⁻¹ _ _}, | ||
apply_fun (λ x, x⬝R), | ||
dsimp, | ||
rw matrix.add_mul, | ||
simp only [inv_mul_of_invertible, matrix.one_mul, | ||
inv_mul_cancel_right_of_invertible], | ||
repeat {rw matrix.mul_assoc (Bᴴ⬝(R + B ⬝ P ⬝ Bᴴ)⁻¹)}, | ||
rw ← matrix.mul_add (Bᴴ⬝(R + B ⬝ P ⬝ Bᴴ)⁻¹), | ||
rw nonsing_inv_mul_cancel_right, | ||
|
||
assumption', | ||
|
||
apply right_mul_inj_of_invertible, | ||
apply left_mul_inj_of_invertible, | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I ported this one as #16, using the mathlib-ed versions of many of your theorems; thanks for the proof outline, even though it took over a year to get merged!
Adapted from #3, using new results that have since been upstreamed to mathlib Co-authored-by: MohanadAhmed <[email protected]>
Exact Inverse Relations: Eq 146, 150, 156 through Eq 160
This Pull Request adds proofs for equations 156 through 160. In addition equations 156 and 158 have "Hermitianized" versions, where the Hermitian operator is used instead of the transpose. These might be more appropriate (or what the reader understands when thinking of comlelx matrices).
The file
mat_inv_lib.lean
contains support identities. These are:is_unit_of_pos_def
: a positive definite matrix is also a unit determinant matrix (basically fancy way of saying determinant is nonzero).invertible_of_pos_def
: a positive definite matrix is invertible.A_add_B_P_Bt_pos_if_A_pos_B_pos
: Givenright_mul_inj_of_invertible
: multiplication from the right by invertible matrices is injective.left_mul_inj_of_invertible
: multiplication from the the left by invertible matrices is injective.unit_matrix_sandwich
: amatrix unit unit R
i.e. a matrix with one element interposed in an outerproduct can be removed to the left to be scalar multiplication by that one element.With$\cdot{}$ , meaning matrix multiplication and $[A]_{ab}$ meaning element a,b from matrix $A$ :
row_mul_mat_mul_col
: a weighted inner product of row and vector columns with a weight matrix in the middle can be regraded as scalar or one element matrix.one_add_row_mul_mat_col_inv