-
Notifications
You must be signed in to change notification settings - Fork 298
feat(linear_algebra/bilinear_form, linear_algebra/quadratic_form): bilinear, quadratic forms on finsupp #6606
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
(p + q).sum (λ i x, r.sum (λ j y, A i j y x)) | ||
= p.sum (λ i x, r.sum (λ j y, A i j y x)) + q.sum (λ i x, r.sum (λ j y, A i j y x)) := |
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 wonder if a finsupp.sum₂
definition would be useful here - It could be used here too:
and maybe would share some lemmas
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.
Now that we have a better big operator library, I would rather get rid of sum
entirely:
instance : has_mul (monoid_algebra k G) :=
⟨λ f g, ∑ i in f.support, ∑ j in g.support, single (i * j) (f i * g j)⟩
maybe would share some lemmas
This is the reason why I'd rather have one definition, and a third of the lemmas.
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 agree that finsupp.sum
could be profitably replaced with finset.sum
, or even finsum
. Let's stick to finsupp.sum
in this PR, since the linear algebra library uses it consistently throughout (for now).
{ bilin := λ p q, p.sum (λ i x, q.sum (λ j y, A i j x y)), | ||
bilin_add_left := bilin_add_left' (λ i j x, ((A i j).left x).to_add_monoid_hom), | ||
bilin_smul_left := bilin_smul_left' (λ i j x, (A i j).left x), | ||
bilin_add_right := bilin_add_right' (λ i j x, ((A i j).right x).to_add_monoid_hom), | ||
bilin_smul_right := bilin_smul_right' (λ i j x, (A i j).right x) } |
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.
You might get the add
proofs for free if instead of sum
you used lift_add_hom
, something like:
{ bilin := λ p q, p.sum (λ i x, q.sum (λ j y, A i j x y)), | |
bilin_add_left := bilin_add_left' (λ i j x, ((A i j).left x).to_add_monoid_hom), | |
bilin_smul_left := bilin_smul_left' (λ i j x, (A i j).left x), | |
bilin_add_right := bilin_add_right' (λ i j x, ((A i j).right x).to_add_monoid_hom), | |
bilin_smul_right := bilin_smul_right' (λ i j x, (A i j).right x) } | |
{ bilin := λ p q, p.lift_add_hom (λ i, q.lift_add_hom (λ j, (A i j : M →+ M →+ R)), | |
bilin_add_left := sorry, | |
bilin_smul_left := bilin_smul_left' (λ i j x, (A i j).left x), | |
bilin_add_right := sorry, | |
bilin_smul_right := bilin_smul_right' (λ i j x, (A i j).right x) } |
where A i j : M →+ M →+ R
is some missing definition that is really just a weaker version of (A i j).to_lin
.
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
variables {M' : Type*} [add_comm_monoid M'] | ||
variables {N : Type*} [has_zero N] | ||
|
||
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
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.
The name of this lemma seems a bit weird, since there's no mention of linearity at all in the statement or proof. Since this is just an auxiliary lemma to build bilin_form_of
, can you mark it private
, so that the name doesn't matter?
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 agree: I would go with either:
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : | |
private lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
or
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : | |
lemma bilin_form_of_add_left_aux (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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.
bors d+
variables {M' : Type*} [add_comm_monoid M'] | ||
variables {N : Type*} [has_zero N] | ||
|
||
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
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 agree: I would go with either:
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : | |
private lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
or
lemma bilin_add_left' (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : | |
lemma bilin_form_of_add_left_aux (A : α → β → N → (M' →+ R)) (p q : α →₀ M') (r : β →₀ N) : |
lemma bilin_add_right' (A : α → β → N → (M' →+ R)) (p : α →₀ N) (q r : β →₀ M') : | ||
p.sum (λ i x, (q + r).sum (λ j y, A i j x y)) | ||
= p.sum (λ i x, q.sum (λ j y, A i j x y)) + p.sum (λ i x, r.sum (λ j y, A i j x y)) := |
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 bilin_add_right' (A : α → β → N → (M' →+ R)) (p : α →₀ N) (q r : β →₀ M') : | |
p.sum (λ i x, (q + r).sum (λ j y, A i j x y)) | |
= p.sum (λ i x, q.sum (λ j y, A i j x y)) + p.sum (λ i x, r.sum (λ j y, A i j x y)) := | |
private lemma bilin_add_right' (A : α → β → N → (M' →+ R)) (p : α →₀ N) (q r : β →₀ M') : | |
p.sum (λ i x, (q + r).sum (λ j y, A i j x y)) | |
= p.sum (λ i x, q.sum (λ j y, A i j x y)) + p.sum (λ i x, r.sum (λ j y, A i j x y)) := |
{ simp [mul_add] } | ||
end | ||
|
||
lemma bilin_smul_left' (A : α → β → N → (M →ₗ[R] R)) (a : 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.
lemma bilin_smul_left' (A : α → β → N → (M →ₗ[R] R)) (a : R) | |
private lemma bilin_smul_left' (A : α → β → N → (M →ₗ[R] R)) (a : R) |
simp [h] }, | ||
end | ||
|
||
lemma bilin_smul_right' (A : α → β → N → (M →ₗ[R] R)) (a : 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.
lemma bilin_smul_right' (A : α → β → N → (M →ₗ[R] R)) (a : R) | |
private lemma bilin_smul_right' (A : α → β → N → (M →ₗ[R] R)) (a : R) |
/-- A bilinear form on `finsupp` from an "infinite matrix" is symmetric, if the coefficients | ||
satisfy a symmetry condition. -/ | ||
-- TODO the same for matrices | ||
lemma finsupp.is_sym_to_bilinear_form {α : Type*} (A : α → α → (bilin_form R M)) |
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 finsupp.is_sym_to_bilinear_form {α : Type*} (A : α → α → (bilin_form R M)) | |
lemma finsupp.is_sym_bilin_form_of {α : Type*} (A : α → α → (bilin_form R M)) |
simp [bit0, add_smul] | ||
end | ||
|
||
@[simp] lemma to_quadratic_form_polar_apply (A : α → α → (bilin_form R M)) |
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.
@[simp] lemma to_quadratic_form_polar_apply (A : α → α → (bilin_form R M)) | |
@[simp] lemma quadratic_form_of_polar_apply (A : α → α → (bilin_form R M)) |
(p + q).sum (λ i x, r.sum (λ j y, A i j y x)) | ||
= p.sum (λ i x, r.sum (λ j y, A i j y x)) + q.sum (λ i x, r.sum (λ j y, A i j y x)) := |
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 agree that finsupp.sum
could be profitably replaced with finset.sum
, or even finsum
. Let's stick to finsupp.sum
in this PR, since the linear algebra library uses it consistently throughout (for now).
(λ i j, if i = j then bilin_form.lin_mul_lin linear_map.id linear_map.id else 0) | ||
|
||
@[simp] lemma norm_sq_apply [decidable_eq α] (p : α →₀ R₁) : norm_sq p = p.sum (λ i x, x ^ 2) := | ||
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.
I would have expected this proof to be shorter, but can't find an easy way to golf it. So we can keep it as is.
✌️ hrmacbeth can now approve this pull request. To approve and merge a pull request, simply reply with |
@hrmacbeth Do you have plans to return to this at some point? |
A "matrix" of bilinear forms on
M
on a typeα
(possibly infinite) induces a bilinear form onα →₀ M
, and thence (viabilin_form.to_quadratic_form
a quadratic form. In particular, define the "Euclidean" (sum-of-squares) quadratic form onα →₀ M
.Zulip