Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

feat(linear_algebra/bilinear_form, linear_algebra/quadratic_form): bilinear, quadratic forms on finsupp #6606

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

hrmacbeth
Copy link
Member

@hrmacbeth hrmacbeth commented Mar 9, 2021

A "matrix" of bilinear forms on M on a type α (possibly infinite) induces a bilinear form on α →₀ M, and thence (via bilin_form.to_quadratic_form a quadratic form. In particular, define the "Euclidean" (sum-of-squares) quadratic form on α →₀ M.

Zulip


@hrmacbeth hrmacbeth added the awaiting-review The author would like community review of the PR label Mar 9, 2021
@github-actions github-actions bot added the blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. label Mar 9, 2021
Comment on lines +742 to +743
(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)) :=
Copy link
Member

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:

https://github.com/leanprover-community/mathlib/blob/07fc9821f41bd369d930fa9ff8e83e56935e7594/src/algebra/monoid_algebra.lean#L72-L73

and maybe would share some lemmas

Copy link
Member

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.

Copy link
Collaborator

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).

Comment on lines 790 to 794
{ 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) }
Copy link
Member

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:

Suggested change
{ 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.

@hrmacbeth hrmacbeth changed the title feat(linear_algebra/bilinear_form): bilinear form on finsupp feat(linear_algebra/bilinear_form, linear_algebra/quadratic_form): bilinear, quadratic forms on finsupp Mar 11, 2021
@github-actions github-actions bot added merge-conflict Please `git merge origin/master` then a bot will remove this label. and removed blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. labels Mar 11, 2021
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Mar 11, 2021
hrmacbeth and others added 3 commits March 14, 2021 15:18
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
src/linear_algebra/bilinear_form.lean Outdated Show resolved Hide resolved
src/linear_algebra/bilinear_form.lean Outdated Show resolved Hide resolved
src/linear_algebra/bilinear_form.lean Outdated Show resolved Hide resolved
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) :
Copy link
Member

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?

Copy link
Collaborator

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:

Suggested change
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

Suggested change
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) :

src/linear_algebra/bilinear_form.lean Show resolved Hide resolved
src/linear_algebra/bilinear_form.lean Show resolved Hide resolved
@bryangingechen bryangingechen added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Mar 21, 2021
@github-actions github-actions bot added blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. merge-conflict Please `git merge origin/master` then a bot will remove this label. and removed blocked-by-other-PR This PR depends on another PR which is still in the queue. A bot manages this label via PR comment. labels Mar 22, 2021
@github-actions github-actions bot removed the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Mar 27, 2021
@eric-wieser eric-wieser added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Apr 5, 2021
@Vierkantor Vierkantor self-requested a review April 14, 2021 08:31
Copy link
Collaborator

@Vierkantor Vierkantor left a 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) :
Copy link
Collaborator

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:

Suggested change
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

Suggested change
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) :

Comment on lines +902 to +904
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)) :=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@[simp] lemma to_quadratic_form_polar_apply (A : α → α → (bilin_form R M))
@[simp] lemma quadratic_form_of_polar_apply (A : α → α → (bilin_form R M))

Comment on lines +742 to +743
(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)) :=
Copy link
Collaborator

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
Copy link
Collaborator

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.

@bors
Copy link

bors bot commented Apr 14, 2021

✌️ hrmacbeth can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@Vierkantor Vierkantor added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Apr 14, 2021
@tb65536
Copy link
Collaborator

tb65536 commented May 10, 2021

@hrmacbeth Do you have plans to return to this at some point?

@jcommelin
Copy link
Member

@hrmacbeth 🏓

@github-actions github-actions bot added the merge-conflict Please `git merge origin/master` then a bot will remove this label. label Oct 18, 2021
@semorrison semorrison added the too-late This PR was ready too late for inclusion in mathlib3 label Jul 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
delegated The PR author may merge after reviewing final suggestions. merge-conflict Please `git merge origin/master` then a bot will remove this label. too-late This PR was ready too late for inclusion in mathlib3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants