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

Commit 22eba86

Browse files
committed
feat(*): add some missing coe_* lemmas (#6697)
* add `submonoid.coe_pow`, `submonoid.coe_list_prod`, `submonoid.coe_multiset_prod`, `submonoid.coe_finset_prod`, `subring.coe_pow`, `subring.coe_nat_cast`, `subring.coe_int_cast`; * add `rat.num_div_denom`; * add `inv_of_pow`.
1 parent 57de126 commit 22eba86

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

src/algebra/group_power/lemmas.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ instance invertible_pow (m : M) [invertible m] (n : ℕ) : invertible (m ^ n) :=
5555
inv_of_mul_self := by rw [← (commute_inv_of m).symm.mul_pow, inv_of_mul_self, one_pow],
5656
mul_inv_of_self := by rw [← (commute_inv_of m).mul_pow, mul_inv_of_self, one_pow] }
5757

58+
lemma inv_of_pow (m : M) [invertible m] (n : ℕ) [invertible (m ^ n)] :
59+
⅟(m ^ n) = ⅟m ^ n :=
60+
@invertible_unique M _ (m ^ n) (m ^ n) rfl ‹_› (invertible_pow m n)
61+
5862
lemma is_unit.pow {m : M} (n : ℕ) : is_unit m → is_unit (m ^ n) :=
5963
λ ⟨u, hu⟩, ⟨u ^ n, by simp *⟩
6064

src/data/rat/basic.lean

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,9 @@ begin
609609
simp [division_def, coe_int_eq_mk, mul_def one_ne_zero d0]
610610
end
611611

612+
theorem num_div_denom (r : ℚ) : (r.num / r.denom : ℚ) = r :=
613+
by rw [← int.cast_coe_nat, ← mk_eq_div, num_denom]
614+
612615
lemma exists_eq_mul_div_num_and_eq_mul_div_denom {n d : ℤ} (n_ne_zero : n ≠ 0)
613616
(d_ne_zero : d ≠ 0) :
614617
∃ (c : ℤ), n = c * ((n : ℚ) / d).num ∧ (d : ℤ) = c * ((n : ℚ) / d).denom :=

src/group_theory/submonoid/membership.lean

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ namespace submonoid
3939

4040
variables (S : submonoid M)
4141

42+
@[simp, norm_cast] theorem coe_pow (x : S) (n : ℕ) : ↑(x ^ n) = (x ^ n : M) :=
43+
S.subtype.map_pow x n
44+
45+
@[simp, norm_cast] theorem coe_list_prod (l : list S) : (l.prod : M) = (l.map coe).prod :=
46+
S.subtype.map_list_prod l
47+
48+
@[simp, norm_cast] theorem coe_multiset_prod {M} [comm_monoid M] (S : submonoid M)
49+
(m : multiset S) : (m.prod : M) = (m.map coe).prod :=
50+
S.subtype.map_multiset_prod m
51+
52+
@[simp, norm_cast] theorem coe_finset_prod {ι M} [comm_monoid M] (S : submonoid M)
53+
(f : ι → S) (s : finset ι) :
54+
↑(∏ i in s, f i) = (∏ i in s, f i : M) :=
55+
S.subtype.map_prod f s
56+
4257
/-- Product of a list of elements in a submonoid is in the submonoid. -/
4358
@[to_additive "Sum of a list of elements in an `add_submonoid` is in the `add_submonoid`."]
4459
lemma list_prod_mem : ∀ {l : list M}, (∀x ∈ l, x ∈ S) → l.prod ∈ S
@@ -68,9 +83,8 @@ lemma prod_mem {M : Type*} [comm_monoid M] (S : submonoid M)
6883
∏ c in t, f c ∈ S :=
6984
S.multiset_prod_mem (t.1.map f) $ λ x hx, let ⟨i, hi, hix⟩ := multiset.mem_map.1 hx in hix ▸ h i hi
7085

71-
lemma pow_mem {x : M} (hx : x ∈ S) : ∀ n:ℕ, x^n ∈ S
72-
| 0 := S.one_mem
73-
| (n+1) := S.mul_mem hx (pow_mem n)
86+
lemma pow_mem {x : M} (hx : x ∈ S) (n : ℕ) : x ^ n ∈ S :=
87+
by simpa only [coe_pow] using ((⟨x, hx⟩ : S) ^ n).coe_prop
7488

7589
open set
7690

src/ring_theory/subring.lean

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ instance to_ring : ring s :=
233233
@[simp, norm_cast] lemma coe_mul (x y : s) : (↑(x * y) : R) = ↑x * ↑y := rfl
234234
@[simp, norm_cast] lemma coe_zero : ((0 : s) : R) = 0 := rfl
235235
@[simp, norm_cast] lemma coe_one : ((1 : s) : R) = 1 := rfl
236+
@[simp, norm_cast] lemma coe_pow (x : s) (n : ℕ) : (↑(x ^ n) : R) = x ^ n :=
237+
s.to_submonoid.coe_pow x n
236238

237239
@[simp] lemma coe_eq_zero_iff {x : s} : (x : R) = 0 ↔ x = 0 :=
238240
⟨λ h, subtype.ext (trans h s.coe_zero.symm),
@@ -281,6 +283,10 @@ def subtype (s : subring R) : s →+* R :=
281283
.. s.to_submonoid.subtype, .. s.to_add_subgroup.subtype }
282284

283285
@[simp] theorem coe_subtype : ⇑s.subtype = coe := rfl
286+
@[simp, norm_cast] lemma coe_nat_cast (n : ℕ) : ((n : s) : R) = n :=
287+
s.subtype.map_nat_cast n
288+
@[simp, norm_cast] lemma coe_int_cast (n : ℤ) : ((n : s) : R) = n :=
289+
s.subtype.map_int_cast n
284290

285291
/-! # Partial order -/
286292

0 commit comments

Comments
 (0)