Skip to content

Commit 4c2080a

Browse files
committed
feat(LinearAlgebra/SModEq): add gcongr lemmas (#28008)
1 parent 7a8a234 commit 4c2080a

File tree

1 file changed

+33
-4
lines changed

1 file changed

+33
-4
lines changed

Mathlib/LinearAlgebra/SModEq.lean

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,42 +64,72 @@ instance : IsRefl _ (SModEq U) :=
6464
nonrec theorem symm (hxy : x ≡ y [SMOD U]) : y ≡ x [SMOD U] :=
6565
hxy.symm
6666

67+
theorem comm : x ≡ y [SMOD U] ↔ y ≡ x [SMOD U] := ⟨symm, symm⟩
68+
6769
@[trans]
6870
nonrec theorem trans (hxy : x ≡ y [SMOD U]) (hyz : y ≡ z [SMOD U]) : x ≡ z [SMOD U] :=
6971
hxy.trans hyz
7072

7173
instance instTrans : Trans (SModEq U) (SModEq U) (SModEq U) where
7274
trans := trans
7375

76+
@[gcongr]
7477
theorem add (hxy₁ : x₁ ≡ y₁ [SMOD U]) (hxy₂ : x₂ ≡ y₂ [SMOD U]) : x₁ + x₂ ≡ y₁ + y₂ [SMOD U] := by
7578
rw [SModEq.def] at hxy₁ hxy₂ ⊢
7679
simp_rw [Quotient.mk_add, hxy₁, hxy₂]
7780

81+
@[gcongr]
82+
theorem sum {ι} {s : Finset ι} {x y : ι → M}
83+
(hxy : ∀ i ∈ s, x i ≡ y i [SMOD U]) : ∑ i ∈ s, x i ≡ ∑ i ∈ s, y i [SMOD U] := by
84+
classical
85+
induction s using Finset.cons_induction with
86+
| empty => simp [SModEq.rfl]
87+
| cons i s _ ih =>
88+
grw [Finset.sum_cons, Finset.sum_cons, hxy i (Finset.mem_cons_self i s),
89+
ih (fun j hj ↦ hxy j (Finset.mem_cons_of_mem hj))]
90+
91+
@[gcongr]
7892
theorem smul (hxy : x ≡ y [SMOD U]) (c : R) : c • x ≡ c • y [SMOD U] := by
7993
rw [SModEq.def] at hxy ⊢
8094
simp_rw [Quotient.mk_smul, hxy]
8195

96+
@[gcongr]
8297
lemma nsmul (hxy : x ≡ y [SMOD U]) (n : ℕ) : n • x ≡ n • y [SMOD U] := by
8398
rw [SModEq.def] at hxy ⊢
8499
simp_rw [Quotient.mk_smul, hxy]
85100

101+
@[gcongr]
86102
lemma zsmul (hxy : x ≡ y [SMOD U]) (n : ℤ) : n • x ≡ n • y [SMOD U] := by
87103
rw [SModEq.def] at hxy ⊢
88104
simp_rw [Quotient.mk_smul, hxy]
89105

106+
@[gcongr]
90107
theorem mul {I : Ideal A} {x₁ x₂ y₁ y₂ : A} (hxy₁ : x₁ ≡ y₁ [SMOD I])
91108
(hxy₂ : x₂ ≡ y₂ [SMOD I]) : x₁ * x₂ ≡ y₁ * y₂ [SMOD I] := by
92109
simp only [SModEq.def, Ideal.Quotient.mk_eq_mk, map_mul] at hxy₁ hxy₂ ⊢
93110
rw [hxy₁, hxy₂]
94111

112+
@[gcongr]
113+
theorem prod {I : Ideal A} {ι} {s : Finset ι} {x y : ι → A}
114+
(hxy : ∀ i ∈ s, x i ≡ y i [SMOD I]) : ∏ i ∈ s, x i ≡ ∏ i ∈ s, y i [SMOD I] := by
115+
classical
116+
induction s using Finset.cons_induction with
117+
| empty => simp [SModEq.rfl]
118+
| cons i s _ ih =>
119+
grw [Finset.prod_cons, Finset.prod_cons, hxy i (Finset.mem_cons_self i s),
120+
ih (fun j hj ↦ hxy j (Finset.mem_cons_of_mem hj))]
121+
122+
@[gcongr]
95123
lemma pow {I : Ideal A} {x y : A} (n : ℕ) (hxy : x ≡ y [SMOD I]) :
96124
x ^ n ≡ y ^ n [SMOD I] := by
97125
simp only [SModEq.def, Ideal.Quotient.mk_eq_mk, map_pow] at hxy ⊢
98126
rw [hxy]
99127

128+
@[gcongr]
100129
lemma neg (hxy : x ≡ y [SMOD U]) : - x ≡ - y [SMOD U] := by
101130
simpa only [SModEq.def, Quotient.mk_neg, neg_inj]
102131

132+
@[gcongr]
103133
lemma sub (hxy₁ : x₁ ≡ y₁ [SMOD U]) (hxy₂ : x₂ ≡ y₂ [SMOD U]) : x₁ - x₂ ≡ y₁ - y₂ [SMOD U] := by
104134
rw [SModEq.def] at hxy₁ hxy₂ ⊢
105135
simp_rw [Quotient.mk_sub, hxy₁, hxy₂]
@@ -116,11 +146,10 @@ theorem comap {f : M →ₗ[R] N} (hxy : f x ≡ f y [SMOD V]) : x ≡ y [SMOD V
116146
(Submodule.Quotient.eq _).2 <|
117147
show f (x - y) ∈ V from (f.map_sub x y).symm ▸ (Submodule.Quotient.eq _).1 hxy
118148

149+
@[gcongr]
119150
theorem eval {R : Type*} [CommRing R] {I : Ideal R} {x y : R} (h : x ≡ y [SMOD I]) (f : R[X]) :
120151
f.eval x ≡ f.eval y [SMOD I] := by
121-
rw [SModEq.def] at h ⊢
122-
change Ideal.Quotient.mk I (f.eval x) = Ideal.Quotient.mk I (f.eval y)
123-
replace h : Ideal.Quotient.mk I x = Ideal.Quotient.mk I y := h
124-
rw [← Polynomial.eval₂_at_apply, ← Polynomial.eval₂_at_apply, h]
152+
simp_rw [Polynomial.eval_eq_sum, Polynomial.sum]
153+
gcongr
125154

126155
end SModEq

0 commit comments

Comments
 (0)