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] - chore: Matrix.mulVec and Matrix.vecMul get infix notation #10297

Closed
wants to merge 15 commits into from
2 changes: 1 addition & 1 deletion Archive/Wiedijk100Theorems/FriendshipGraphs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ theorem isRegularOf_not_existsPolitician (hG' : ¬ExistsPolitician G) :
This essentially means that the graph has `d ^ 2 - d + 1` vertices. -/
theorem card_of_regular (hd : G.IsRegularOfDegree d) : d + (Fintype.card V - 1) = d * d := by
have v := Classical.arbitrary V
trans (G.adjMatrix ℕ ^ 2).mulVec (fun _ => 1) v
trans ((G.adjMatrix ℕ ^ 2) *ᵥ (fun _ => 1)) v
· rw [adjMatrix_sq_of_regular hG hd, mulVec, dotProduct, ← insert_erase (mem_univ v)]
simp only [sum_insert, mul_one, if_true, Nat.cast_id, eq_self_iff_true, mem_erase, not_true,
Ne.def, not_false_iff, add_right_inj, false_and_iff, of_apply]
Expand Down
6 changes: 3 additions & 3 deletions Mathlib/Analysis/Matrix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -380,16 +380,16 @@ theorem linfty_opNorm_mul (A : Matrix l m α) (B : Matrix m n α) : ‖A * B‖
alias linfty_op_norm_mul :=
linfty_opNorm_mul -- deprecated on 2024-02-02

theorem linfty_opNNNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A.mulVec v‖₊ ≤ ‖A‖₊ * ‖v‖₊ := by
rw [← linfty_opNNNorm_col (A.mulVec v), ← linfty_opNNNorm_col v]
theorem linfty_opNNNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖₊ ≤ ‖A‖₊ * ‖v‖₊ := by
rw [← linfty_opNNNorm_col (A *ᵥ v), ← linfty_opNNNorm_col v]
exact linfty_opNNNorm_mul A (col v)
#align matrix.linfty_op_nnnorm_mul_vec Matrix.linfty_opNNNorm_mulVec

@[deprecated linfty_opNNNorm_mulVec]
alias linfty_op_nnnorm_mulVec :=
linfty_opNNNorm_mulVec -- deprecated on 2024-02-02

theorem linfty_opNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖Matrix.mulVec A v‖ ≤ ‖A‖ * ‖v‖ :=
theorem linfty_opNorm_mulVec (A : Matrix l m α) (v : m → α) : ‖A *ᵥ v‖ ≤ ‖A‖ * ‖v‖ :=
linfty_opNNNorm_mulVec _ _
#align matrix.linfty_op_norm_mul_vec Matrix.linfty_opNorm_mulVec

Expand Down
4 changes: 2 additions & 2 deletions Mathlib/Analysis/NormedSpace/Star/Matrix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,15 @@ alias l2_op_nnnorm_conjTranspose_mul_self :=

-- note: with only a type ascription in the left-hand side, Lean picks the wrong norm.
lemma l2_opNorm_mulVec (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
‖(EuclideanSpace.equiv m 𝕜).symm <| A.mulVec x‖ ≤ ‖A‖ * ‖x‖ :=
‖(EuclideanSpace.equiv m 𝕜).symm <| A *ᵥ x‖ ≤ ‖A‖ * ‖x‖ :=
toEuclideanLin (n := n) (m := m) (𝕜 := 𝕜) |>.trans toContinuousLinearMap A |>.le_opNorm x

@[deprecated l2_opNorm_mulVec]
alias l2_op_norm_mulVec :=
l2_opNorm_mulVec -- deprecated on 2024-02-02

lemma l2_opNNNorm_mulVec (A : Matrix m n 𝕜) (x : EuclideanSpace 𝕜 n) :
‖(EuclideanSpace.equiv m 𝕜).symm <| A.mulVec x‖₊ ≤ ‖A‖₊ * ‖x‖₊ :=
‖(EuclideanSpace.equiv m 𝕜).symm <| A *ᵥ x‖₊ ≤ ‖A‖₊ * ‖x‖₊ :=
A.l2_opNorm_mulVec x

@[deprecated l2_opNNNorm_mulVec]
Expand Down
8 changes: 4 additions & 4 deletions Mathlib/Combinatorics/SimpleGraph/AdjMatrix.lean
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ theorem dotProduct_adjMatrix [NonAssocSemiring α] (v : V) (vec : V → α) :

@[simp]
theorem adjMatrix_mulVec_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).mulVec vec) v = ∑ u in G.neighborFinset v, vec u := by
(G.adjMatrix α *ᵥ vec) v = ∑ u in G.neighborFinset v, vec u := by
rw [mulVec, adjMatrix_dotProduct]
#align simple_graph.adj_matrix_mul_vec_apply SimpleGraph.adjMatrix_mulVec_apply

@[simp]
theorem adjMatrix_vecMul_apply [NonAssocSemiring α] (v : V) (vec : V → α) :
((G.adjMatrix α).vecMul vec) v = ∑ u in G.neighborFinset v, vec u := by
(vec ᵥ* G.adjMatrix α) v = ∑ u in G.neighborFinset v, vec u := by
simp only [← dotProduct_adjMatrix, vecMul]
refine' congr rfl _; ext x
rw [← transpose_apply (adjMatrix α G) x v, transpose_adjMatrix]
Expand Down Expand Up @@ -250,11 +250,11 @@ variable {G}

-- @[simp] -- Porting note: simp can prove this
theorem adjMatrix_mulVec_const_apply [Semiring α] {a : α} {v : V} :
(G.adjMatrix α).mulVec (Function.const _ a) v = G.degree v * a := by simp
(G.adjMatrix α *ᵥ Function.const _ a) v = G.degree v * a := by simp
#align simple_graph.adj_matrix_mul_vec_const_apply SimpleGraph.adjMatrix_mulVec_const_apply

theorem adjMatrix_mulVec_const_apply_of_regular [Semiring α] {d : ℕ} {a : α}
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α).mulVec (Function.const _ a) v = d * a :=
(hd : G.IsRegularOfDegree d) {v : V} : (G.adjMatrix α *ᵥ Function.const _ a) v = d * a :=
by simp [hd v]
#align simple_graph.adj_matrix_mul_vec_const_apply_of_regular SimpleGraph.adjMatrix_mulVec_const_apply_of_regular

Expand Down
Loading
Loading