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

Commit 03fda91

Browse files
committed
refactor(algebra/group_power/lemmas): assume n ≠ 0 instead of 0 < n (#17323)
Also rename `is_unit_pos_pow_iff` to `is_unit_pow_iff`.
1 parent 688effb commit 03fda91

File tree

8 files changed

+19
-20
lines changed

8 files changed

+19
-20
lines changed

src/algebra/associated.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ begin
177177
intro h,
178178
obtain ⟨k, rfl⟩ := nat.exists_eq_add_of_lt hn,
179179
rw [pow_succ, add_comm] at h,
180-
exact (or_iff_left_of_imp ((is_unit_pos_pow_iff (nat.succ_pos _)).mp)).mp (of_irreducible_mul h)
180+
exact (or_iff_left_of_imp is_unit_pow_succ_iff.mp).mp (of_irreducible_mul h)
181181
end
182182

183183
theorem irreducible_or_factor {α} [monoid α] (x : α) (h : ¬ is_unit x) :

src/algebra/group_power/lemmas.lean

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,9 @@ begin
5656
exact and.left
5757
end
5858

59-
lemma is_unit_pos_pow_iff {m : M} :
60-
∀ {n : ℕ} (h : 0 < n), is_unit (m ^ n) ↔ is_unit m
59+
lemma is_unit_pow_iff {m : M} :
60+
∀ {n : ℕ} (h : n ≠ 0), is_unit (m ^ n) ↔ is_unit m
61+
| 0 h := (h rfl).elim
6162
| (n + 1) _ := is_unit_pow_succ_iff
6263

6364
/-- If `x ^ n.succ = 1` then `x` has an inverse, `x^n`. -/
@@ -66,15 +67,15 @@ def invertible_of_pow_succ_eq_one (x : M) (n : ℕ) (hx : x ^ n.succ = 1) :
6667
⟨x ^ n, (pow_succ' x n).symm.trans hx, (pow_succ x n).symm.trans hx⟩
6768

6869
/-- If `x ^ n = 1` then `x` has an inverse, `x^(n - 1)`. -/
69-
def invertible_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : 0 < n) :
70+
def invertible_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : n ≠ 0) :
7071
invertible x :=
7172
begin
7273
apply invertible_of_pow_succ_eq_one x (n - 1),
7374
convert hx,
74-
exact tsub_add_cancel_of_le (nat.succ_le_of_lt hn),
75+
exact nat.succ_pred_eq_of_pos (pos_iff_ne_zero.2 hn),
7576
end
7677

77-
lemma is_unit_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : 0 < n) :
78+
lemma is_unit_of_pow_eq_one (x : M) (n : ℕ) (hx : x ^ n = 1) (hn : n ≠ 0) :
7879
is_unit x :=
7980
begin
8081
haveI := invertible_of_pow_eq_one x n hx hn,

src/algebra/is_prime_pow.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ lemma not_is_prime_pow_one : ¬ is_prime_pow (1 : R) :=
4343
begin
4444
simp only [is_prime_pow_def, not_exists, not_and', and_imp],
4545
intros x n hn hx ht,
46-
exact ht.not_unit (is_unit_of_pow_eq_one x n hx hn),
46+
exact ht.not_unit (is_unit_of_pow_eq_one x n hx hn.ne'),
4747
end
4848

4949
lemma prime.is_prime_pow {p : R} (hp : prime p) : is_prime_pow p :=

src/data/int/gcd.lean

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ lemma pow_gcd_eq_one {M : Type*} [monoid M] (x : M) {m n : ℕ} (hm : x ^ m = 1)
384384
x ^ m.gcd n = 1 :=
385385
begin
386386
cases m, { simp only [hn, nat.gcd_zero_left] },
387-
obtain ⟨x, rfl⟩ : is_unit x,
388-
{ apply is_unit_of_pow_eq_one _ _ hm m.succ_pos },
387+
lift x to Mˣ using is_unit_of_pow_eq_one _ _ hm m.succ_ne_zero,
389388
simp only [← units.coe_pow] at *,
390389
rw [← units.coe_one, ← zpow_coe_nat, ← units.ext_iff] at *,
391390
simp only [nat.gcd_eq_gcd_ab, zpow_add, zpow_mul, hm, hn, one_zpow, one_mul]

src/data/polynomial/unit_trinomial.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ begin
190190
{ have key : ∀ k ∈ p.support, (p.coeff k) ^ 2 = 1 :=
191191
λ k hk, int.sq_eq_one_of_sq_le_three ((single_le_sum
192192
(λ k hk, sq_nonneg (p.coeff k)) hk).trans hp.le) (mem_support_iff.mp hk),
193-
refine is_unit_trinomial_iff.mpr ⟨_, λ k hk, is_unit_of_pow_eq_one _ 2 (key k hk) zero_lt_two⟩,
193+
refine is_unit_trinomial_iff.mpr ⟨_, λ k hk, is_unit_of_pow_eq_one _ 2 (key k hk) two_ne_zero⟩,
194194
rw [sum_def, sum_congr rfl key, sum_const, nat.smul_one_eq_coe] at hp,
195195
exact nat.cast_injective hp },
196196
end

src/field_theory/abel_ruffini.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ begin
107107
have key : ∀ σ : (X ^ n - 1 : F[X]).gal, ∃ m : ℕ, σ a = a ^ m,
108108
{ intro σ,
109109
obtain ⟨m, hm⟩ := map_root_of_unity_eq_pow_self σ.to_alg_hom
110-
⟨is_unit.unit (is_unit_of_pow_eq_one a n ha hn'),
110+
⟨is_unit.unit (is_unit_of_pow_eq_one a n ha hn),
111111
by { ext, rwa [units.coe_pow, is_unit.unit_spec, subtype.coe_mk n hn'] }⟩,
112112
use m,
113113
convert hm },

src/linear_algebra/matrix/zpow.lean

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@ lemma is_unit_det_zpow_iff {A : M} {z : ℤ} :
123123
begin
124124
induction z using int.induction_on with z IH z IH,
125125
{ simp },
126-
{ rw [←int.coe_nat_succ, zpow_coe_nat, det_pow, is_unit_pos_pow_iff (z.zero_lt_succ),
127-
←int.coe_nat_zero, int.coe_nat_eq_coe_nat_iff],
128-
simp },
129-
{ rw [←neg_add', ←int.coe_nat_succ, zpow_neg_coe_nat, is_unit_nonsing_inv_det_iff,
130-
det_pow, is_unit_pos_pow_iff (z.zero_lt_succ), neg_eq_zero, ←int.coe_nat_zero,
126+
{ rw [←int.coe_nat_succ, zpow_coe_nat, det_pow, is_unit_pow_succ_iff, ←int.coe_nat_zero,
131127
int.coe_nat_eq_coe_nat_iff],
128+
simp },
129+
{ rw [←neg_add', ←int.coe_nat_succ, zpow_neg_coe_nat, is_unit_nonsing_inv_det_iff, det_pow,
130+
is_unit_pow_succ_iff, neg_eq_zero, ←int.coe_nat_zero, int.coe_nat_eq_coe_nat_iff],
132131
simp }
133132
end
134133

src/ring_theory/roots_of_unity.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ let h : ∀ ξ : roots_of_unity n R, (σ ξ) ^ (n : ℕ) = 1 := λ ξ, by
134134
{ change (σ (ξ : Rˣ)) ^ (n : ℕ) = 1,
135135
rw [←map_pow, ←units.coe_pow, show ((ξ : Rˣ) ^ (n : ℕ) = 1), from ξ.2,
136136
units.coe_one, map_one σ] } in
137-
{ to_fun := λ ξ, ⟨@unit_of_invertible _ _ _ (invertible_of_pow_eq_one _ _ (h ξ) n.2),
137+
{ to_fun := λ ξ, ⟨@unit_of_invertible _ _ _ (invertible_of_pow_eq_one _ _ (h ξ) n.ne_zero),
138138
by { ext, rw units.coe_pow, exact h ξ }⟩,
139139
map_one' := by { ext, exact map_one σ },
140140
map_mul' := λ ξ₁ ξ₂, by { ext, rw [subgroup.coe_mul, units.coe_mul], exact map_mul σ _ _ } }
@@ -710,9 +710,9 @@ lemma eq_pow_of_pow_eq_one {k : ℕ} {ζ ξ : R}
710710
(h : is_primitive_root ζ k) (hξ : ξ ^ k = 1) (h0 : 0 < k) :
711711
∃ i < k, ζ ^ i = ξ :=
712712
begin
713-
obtain ⟨ζ, rfl⟩ := h.is_unit h0,
714-
obtain ⟨ξ, rfl⟩ := is_unit_of_pow_eq_one ξ k hξ h0,
715-
obtain ⟨k, rfl⟩ : ∃ k' : ℕ+, k = k' := ⟨⟨k, h0⟩, rfl⟩,
713+
lift ζ to Rˣ using h.is_unit h0,
714+
lift ξ to Rˣ using is_unit_of_pow_eq_one ξ k hξ h0.ne',
715+
lift k to ℕ+ using h0,
716716
simp only [← units.coe_pow, ← units.ext_iff],
717717
rw coe_units_iff at h,
718718
apply h.eq_pow_of_mem_roots_of_unity,

0 commit comments

Comments
 (0)