Skip to content
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

[Merged by Bors] - feat(data/matrix/basic): miscellaneous defs and lemmas #8289

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6c65a6e
miscellaneous defs and lemmas
l534zhan Jul 13, 2021
3ca697c
fixed typos
l534zhan Jul 13, 2021
5f58636
fixed typos
l534zhan Jul 13, 2021
7e7684a
fixed things
l534zhan Jul 13, 2021
75a4d4a
Merge branch 'master' into matrix_lz
eric-wieser Jul 13, 2021
5594f80
change
l534zhan Jul 14, 2021
a9910be
Merge branch 'matrix_lz' of https://github.com/leanprover-community/m…
l534zhan Jul 14, 2021
5392017
change
l534zhan Jul 14, 2021
0d40ddc
change
l534zhan Jul 14, 2021
a1afb10
typo
l534zhan Jul 14, 2021
accea2e
l534zhan Jul 14, 2021
afccd56
change
l534zhan Jul 15, 2021
1c07552
Merge branch 'master' into matrix_lz
eric-wieser Jul 16, 2021
1b2ef30
change
l534zhan Jul 27, 2021
7b18a57
change
l534zhan Jul 27, 2021
63623fe
change
l534zhan Aug 6, 2021
bc2b7bb
Merge branch 'master' of https://github.com/leanprover-community/math…
l534zhan Aug 6, 2021
8ec73c9
change
l534zhan Aug 6, 2021
5f6ad37
change
l534zhan Aug 6, 2021
20618f9
change
l534zhan Aug 6, 2021
5d8e753
change
l534zhan Aug 6, 2021
824a8ee
change
l534zhan Aug 6, 2021
9bf4a80
Update src/data/matrix/basic.lean
l534zhan Aug 9, 2021
5e32307
Update src/data/matrix/block.lean
l534zhan Aug 9, 2021
33ca458
Update src/data/matrix/basic.lean
l534zhan Aug 9, 2021
0b80e3a
Update src/data/matrix/block.lean
l534zhan Aug 9, 2021
d1a7194
Update src/data/matrix/basic.lean
l534zhan Aug 9, 2021
a62a6a7
Merge remote-tracking branch 'origin/master' into matrix_lz
YaelDillies Apr 20, 2023
2ac46f6
reduce diff
YaelDillies Apr 20, 2023
01f8479
fix one_dot_product_one
YaelDillies Apr 20, 2023
a5a1888
fix mul_vec_one
YaelDillies Apr 20, 2023
758e25e
fix data.matrix.block
YaelDillies Apr 20, 2023
239f5ab
use `⬝ᵥ` notation
YaelDillies Apr 20, 2023
ef549bd
fix lint
YaelDillies Apr 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 29 additions & 3 deletions src/data/matrix/basic.lean
@@ -1,4 +1,4 @@
/-

Check warning on line 1 in src/data/matrix/basic.lean

View workflow job for this annotation

GitHub Actions / Check for modifications to ported files

Changes to this file will need to be ported to mathlib 4! Please consider retracting the changes to this file unless you are willing to immediately forward-port them.
Copyright (c) 2018 Ellen Arlt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin, Lu-Ming Zhang
Expand Down Expand Up @@ -472,6 +472,14 @@
v ⬝ᵥ w = v ⟨⟩ * w ⟨⟩ :=
by simp [dot_product]

section mul_one_class
variables [mul_one_class α] [add_comm_monoid α]

lemma dot_product_one (v : n → α) : v ⬝ᵥ 1 = ∑ i, v i := by simp [(⬝ᵥ)]
lemma one_dot_product (v : n → α) : 1 ⬝ᵥ v = ∑ i, v i := by simp [(⬝ᵥ)]

end mul_one_class

section non_unital_non_assoc_semiring
variables [non_unital_non_assoc_semiring α] (u v w : m → α) (x y : n → α)

Expand Down Expand Up @@ -533,6 +541,14 @@

end non_unital_non_assoc_semiring_decidable

section non_assoc_semiring
variables [non_assoc_semiring α]

@[simp] lemma one_dot_product_one : (1 : n → α) ⬝ᵥ 1 = fintype.card n :=
by simp [dot_product, fintype.card]

end non_assoc_semiring

section non_unital_non_assoc_ring
variables [non_unital_non_assoc_ring α] (u v w : m → α)

Expand Down Expand Up @@ -1305,7 +1321,15 @@
end non_unital_semiring

section non_assoc_semiring
variables [fintype m] [decidable_eq m] [non_assoc_semiring α]
variables [non_assoc_semiring α]

lemma mul_vec_one [fintype n] (A : matrix m n α) : mul_vec A 1 = λ i, ∑ j, A i j :=
by ext; simp [mul_vec, dot_product]

lemma vec_one_mul [fintype m] (A : matrix m n α) : vec_mul 1 A = λ j, ∑ i, A i j :=
by ext; simp [vec_mul, dot_product]

variables [fintype m] [fintype n] [decidable_eq m]

@[simp] lemma one_mul_vec (v : m → α) : mul_vec 1 v = v :=
by { ext, rw [←diagonal_one, mul_vec_diagonal, one_mul] }
Expand Down Expand Up @@ -1816,10 +1840,11 @@
vec_mul v (M.submatrix e₁ e₂) = vec_mul (v ∘ e₁.symm) M ∘ e₂ :=
funext $ λ i, eq.symm (comp_equiv_symm_dot_product _ _ _)

lemma mul_submatrix_one [fintype n] [fintype o] [non_assoc_semiring α] [decidable_eq o] (e₁ : n ≃ o)
lemma mul_submatrix_one [fintype n] [finite o] [non_assoc_semiring α] [decidable_eq o] (e₁ : n ≃ o)
(e₂ : l → o) (M : matrix m n α) :
M ⬝ (1 : matrix o o α).submatrix e₁ e₂ = submatrix M id (e₁.symm ∘ e₂) :=
begin
casesI nonempty_fintype o,
let A := M.submatrix id e₁.symm,
have : M = A.submatrix id e₁,
{ simp only [submatrix_submatrix, function.comp.right_id, submatrix_id_id,
Expand All @@ -1829,10 +1854,11 @@
equiv.symm_comp_self],
end

lemma one_submatrix_mul [fintype m] [fintype o] [non_assoc_semiring α] [decidable_eq o] (e₁ : l → o)
lemma one_submatrix_mul [fintype m] [finite o] [non_assoc_semiring α] [decidable_eq o] (e₁ : l → o)
(e₂ : m ≃ o) (M : matrix m n α) :
((1 : matrix o o α).submatrix e₁ e₂).mul M = submatrix M (e₂.symm ∘ e₁) id :=
begin
casesI nonempty_fintype o,
let A := M.submatrix e₂.symm id,
have : M = A.submatrix e₂ id,
{ simp only [submatrix_submatrix, function.comp.right_id, submatrix_id_id,
Expand Down
6 changes: 5 additions & 1 deletion src/data/matrix/block.lean
@@ -1,4 +1,4 @@
/-

Check warning on line 1 in src/data/matrix/block.lean

View workflow job for this annotation

GitHub Actions / Check for modifications to ported files

Changes to this file will need to be ported to mathlib 4! Please consider retracting the changes to this file unless you are willing to immediately forward-port them.
Copyright (c) 2018 Ellen Arlt. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Ellen Arlt, Blair Shi, Sean Leather, Mario Carneiro, Johan Commelin
Expand Down Expand Up @@ -27,10 +27,14 @@
variables {l m n o p q : Type*} {m' n' p' : o → Type*}
variables {R : Type*} {S : Type*} {α : Type*} {β : Type*}

open_locale matrix
open_locale big_operators matrix

namespace matrix

lemma dot_product_block [fintype m] [fintype n] [has_mul α] [add_comm_monoid α] (v w : m ⊕ n → α) :
v ⬝ᵥ w = v ∘ sum.inl ⬝ᵥ w ∘ sum.inl + v ∘ sum.inr ⬝ᵥ w ∘ sum.inr :=
fintype.sum_sum_type _

section block_matrices

/-- We can form a single large matrix by flattening smaller 'block' matrices of compatible
Expand Down