Skip to content

Commit 50b8949

Browse files
committed
feat: lemmas about Matrix.single and diagonal and submatrix (leanprover-community#33547)
This also moves some very basic API lemmas higher up the file.
1 parent 70e9ecf commit 50b8949

1 file changed

Lines changed: 40 additions & 21 deletions

File tree

Mathlib/Data/Matrix/Basis.lean

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,26 @@ and zeroes elsewhere.
3434
def single (i : m) (j : n) (a : α) : Matrix m n α :=
3535
of <| fun i' j' => if i = i' ∧ j = j' then a else 0
3636

37+
section
38+
variable (i : m) (j : n) (c : α) (i' : m) (j' : n)
39+
40+
@[simp]
41+
theorem single_apply_same : single i j c i j = c :=
42+
if_pos (And.intro rfl rfl)
43+
44+
@[simp]
45+
theorem single_apply_of_ne (h : ¬(i = i' ∧ j = j')) : single i j c i' j' = 0 := by
46+
simp only [single, and_imp, ite_eq_right_iff, of_apply]
47+
tauto
48+
49+
theorem single_apply_of_row_ne {i i' : m} (hi : i ≠ i') (j j' : n) (a : α) :
50+
single i j a i' j' = 0 := by simp [hi]
51+
52+
theorem single_apply_of_col_ne (i i' : m) {j j' : n} (hj : j ≠ j') (a : α) :
53+
single i j a i' j' = 0 := by simp [hj]
54+
55+
end
56+
3757
/-- See also `single_eq_updateRow_zero` and `single_eq_updateCol_zero`. -/
3858
theorem single_eq_of_single_single (i : m) (j : n) (a : α) :
3959
single i j a = Matrix.of (Pi.single i (Pi.single j a)) := by
@@ -76,6 +96,26 @@ theorem single_mem_matrix {S : Set α} (hS : 0 ∈ S) {i : m} {j : n} {a : α} :
7696
conv_lhs => intro _ _; rw [ite_mem]
7797
simp [hS]
7898

99+
theorem diagonal_single (i : m) (r : α) :
100+
diagonal (Pi.single i r) = single i i r := by
101+
ext j k
102+
dsimp [diagonal, single]
103+
grind
104+
105+
@[simp]
106+
theorem submatrix_single_equiv
107+
(f : l ≃ n) (g : m ≃ o) (i : n) (j : o) (r : α) :
108+
(single i j r).submatrix f g = single (f.symm i) (g.symm j) r := by
109+
ext i' j'
110+
dsimp
111+
obtain hi | rfl := ne_or_eq (f.symm i) i'
112+
· rw [single_apply_of_row_ne hi, single_apply_of_row_ne]
113+
exact f.symm_apply_eq.not.1 hi
114+
obtain hj | rfl := ne_or_eq (g.symm j) j'
115+
· rw [single_apply_of_col_ne _ _ hj, single_apply_of_col_ne]
116+
exact g.symm_apply_eq.not.1 hj
117+
simp
118+
79119
end Zero
80120

81121
theorem single_add [AddZeroClass α] (i : m) (j : n) (a b : α) :
@@ -211,27 +251,6 @@ end liftLinear
211251

212252
end ext
213253

214-
section
215-
216-
variable [Zero α] (i : m) (j : n) (c : α) (i' : m) (j' : n)
217-
218-
@[simp]
219-
theorem single_apply_same : single i j c i j = c :=
220-
if_pos (And.intro rfl rfl)
221-
222-
@[simp]
223-
theorem single_apply_of_ne (h : ¬(i = i' ∧ j = j')) : single i j c i' j' = 0 := by
224-
simp only [single, and_imp, ite_eq_right_iff, of_apply]
225-
tauto
226-
227-
theorem single_apply_of_row_ne {i i' : m} (hi : i ≠ i') (j j' : n) (a : α) :
228-
single i j a i' j' = 0 := by simp [hi]
229-
230-
theorem single_apply_of_col_ne (i i' : m) {j j' : n} (hj : j ≠ j') (a : α) :
231-
single i j a i' j' = 0 := by simp [hj]
232-
233-
end
234-
235254
section
236255
variable [Zero α] (i j : n) (c : α)
237256

0 commit comments

Comments
 (0)