Skip to content

Commit 1f3b5da

Browse files
committed
refactor: unify the two versions of pow_eq_one_iff (leanprover-community#30799)
One version is about torsion-free monoids, the other one about linearly ordered monoids. I argue that all linearly ordered monoids of interest are torsion-free, and therefore the correct lemma to keep is the former. As a byproduct, I must move a few `MonoidHom` lemmas. [Zulip](https://leanprover.zulipchat.com/#narrow/channel/287929-mathlib4/topic/Should.20linear.20ordered.20comm.20monoids.20with.20zero.20be.20torsion-free)
1 parent 2215f28 commit 1f3b5da

12 files changed

Lines changed: 31 additions & 42 deletions

File tree

Mathlib/Algebra/Group/Torsion.lean

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,27 +39,27 @@ lemma pow_left_injective (hn : n ≠ 0) : Injective fun a : M ↦ a ^ n :=
3939
@[to_additive nsmul_right_inj]
4040
lemma pow_left_inj (hn : n ≠ 0) : a ^ n = b ^ n ↔ a = b := (pow_left_injective hn).eq_iff
4141

42-
@[to_additive IsAddTorsionFree.nsmul_eq_zero_iff_right]
43-
lemma IsMulTorsionFree.pow_eq_one_iff_left (hn : n ≠ 0) : a ^ n = 1 ↔ a = 1 := by
42+
@[to_additive nsmul_eq_zero_iff_right]
43+
lemma pow_eq_one_iff_left (hn : n ≠ 0) : a ^ n = 1 ↔ a = 1 := by
4444
rw [← pow_left_inj (a := a) hn, one_pow]
4545

4646
-- We want to use `IsAddTorsion.nsmul_eq_zero_iff` earlier than `smul_eq_zero`.
4747
@[to_additive (attr := simp high)]
48-
lemma IsMulTorsionFree.pow_eq_one_iff : a ^ n = 1 ↔ a = 1 ∨ n = 0 := by
48+
lemma pow_eq_one_iff : a ^ n = 1 ↔ a = 1 ∨ n = 0 := by
4949
obtain rfl | hn := eq_or_ne n 0 <;> simp [pow_eq_one_iff_left, *]
5050

51-
@[to_additive IsAddTorsionFree.nsmul_eq_zero_iff_left]
52-
lemma IsMulTorsionFree.pow_eq_one_iff_right (ha : a ≠ 1) : a ^ n = 1 ↔ n = 0 := by simp [*]
51+
@[to_additive nsmul_eq_zero_iff_left]
52+
lemma pow_eq_one_iff_right (ha : a ≠ 1) : a ^ n = 1 ↔ n = 0 := by simp [*]
5353

5454
@[deprecated (since := "2025-10-19")]
55-
alias IsAddTorsionFree.nsmul_eq_zero_iff' := IsAddTorsionFree.nsmul_eq_zero_iff_left
55+
alias IsAddTorsionFree.nsmul_eq_zero_iff' := nsmul_eq_zero_iff_left
5656

5757
@[deprecated (since := "2025-10-19")]
58-
alias IsMulTorsionFree.pow_eq_one_iff' := IsMulTorsionFree.pow_eq_one_iff_right
58+
alias IsMulTorsionFree.pow_eq_one_iff' := pow_eq_one_iff_right
5959

6060
/-- See `sq_eq_one_iff` for a version that holds in rings. -/
6161
@[to_additive two_nsmul_eq_zero]
62-
lemma sq_eq_one : a ^ 2 = 1 ↔ a = 1 := IsMulTorsionFree.pow_eq_one_iff_left (by lia)
62+
lemma sq_eq_one : a ^ 2 = 1 ↔ a = 1 := pow_eq_one_iff_left (by lia)
6363

6464
end Monoid
6565

Mathlib/Algebra/GroupWithZero/Torsion.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ instance : IsMulTorsionFree M := by
4141
← associated_iff_normalizedFactors_eq_normalizedFactors hx hy] at this
4242
replace hx : IsLeftRegular (x ^ n) := (IsLeftCancelMulZero.mul_left_cancel_of_ne_zero hx).pow n
4343
rw [← hu, mul_pow, eq_comm, IsLeftRegular.mul_left_eq_self_iff hx, ← Units.val_pow_eq_pow_val,
44-
Units.val_eq_one, IsMulTorsionFree.pow_eq_one_iff_left hn] at hxy
44+
Units.val_eq_one, pow_eq_one_iff_left hn] at hxy
4545
rwa [hxy, Units.val_one, mul_one] at hu
4646

4747
end UniqueFactorizationMonoid

Mathlib/Algebra/Order/Monoid/Unbundled/Pow.lean

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,6 @@ theorem one_lt_pow_iff {x : M} {n : ℕ} (hn : n ≠ 0) : 1 < x ^ n ↔ 1 < x :=
222222
theorem pow_lt_one_iff {x : M} {n : ℕ} (hn : n ≠ 0) : x ^ n < 1 ↔ x < 1 :=
223223
lt_iff_lt_of_le_iff_le (one_le_pow_iff hn)
224224

225-
@[to_additive]
226-
theorem pow_eq_one_iff {x : M} {n : ℕ} (hn : n ≠ 0) : x ^ n = 1 ↔ x = 1 := by
227-
simp only [le_antisymm_iff]
228-
rw [pow_le_one_iff hn, one_le_pow_iff hn]
229-
230225
end CovariantLE
231226

232227
section CovariantLT

Mathlib/Algebra/Order/Ring/Basic.lean

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ lemma not_isSquare_of_neg [Semiring R] [LinearOrder R]
3535
{x : R} (h : x < 0) : ¬ IsSquare x :=
3636
(h.not_ge ·.nonneg)
3737

38-
namespace MonoidHom
39-
40-
variable [Ring R] [Monoid M] [LinearOrder M] [MulLeftMono M] (f : R →* M)
41-
42-
theorem map_neg_one : f (-1) = 1 :=
43-
(pow_eq_one_iff (Nat.succ_ne_zero 1)).1 <| by rw [← map_pow, neg_one_sq, map_one]
44-
45-
@[simp]
46-
theorem map_neg (x : R) : f (-x) = f x := by rw [← neg_one_mul, map_mul, map_neg_one, one_mul]
47-
48-
theorem map_sub_swap (x y : R) : f (x - y) = f (y - x) := by rw [← map_neg, neg_sub]
49-
50-
end MonoidHom
51-
5238
section OrderedSemiring
5339

5440
variable [Semiring R] [PartialOrder R] [IsOrderedRing R] {a b x y : R} {n : ℕ}

Mathlib/Algebra/Ring/NonZeroDivisors.lean

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ theorem IsLeftRegular.pow_injective [IsMulTorsionFree R]
3030
intro n m hnm
3131
have main {n m} (h₁ : n ≤ m) (h₂ : r ^ n = r ^ m) : n = m := by
3232
obtain ⟨l, rfl⟩ := Nat.exists_eq_add_of_le h₁
33-
rw [pow_add, eq_comm, IsLeftRegular.mul_left_eq_self_iff (hx.pow n),
34-
IsMulTorsionFree.pow_eq_one_iff_right hx'] at h₂
33+
rw [pow_add, eq_comm, IsLeftRegular.mul_left_eq_self_iff (hx.pow n), pow_eq_one_iff_right hx']
34+
at h₂
3535
rw [h₂, Nat.add_zero]
3636
obtain h | h := Nat.le_or_le n m
3737
· exact main h hnm

Mathlib/Algebra/Ring/Torsion.lean

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ Authors: Kim Morrison
66
module
77

88
public import Mathlib.Algebra.CharZero.Defs
9+
public import Mathlib.Algebra.Group.Torsion
910
public import Mathlib.Algebra.GroupWithZero.Basic
11+
public import Mathlib.Algebra.Ring.Commute
1012
public import Mathlib.Algebra.Ring.Regular
1113

1214
/-!
@@ -28,3 +30,15 @@ scoped instance (R : Type*) [Semiring R] [IsDomain R] [CharZero R] :
2830
grind
2931

3032
end IsDomain
33+
34+
namespace MonoidHom
35+
variable {R M : Type*} [Ring R] [Monoid M] [IsMulTorsionFree M] (f : R →* M)
36+
37+
lemma map_neg_one : f (-1) = 1 :=
38+
(pow_eq_one_iff_left (Nat.succ_ne_zero 1)).1 <| by rw [← map_pow, neg_one_sq, map_one]
39+
40+
@[simp] lemma map_neg (x : R) : f (-x) = f x := by rw [← neg_one_mul, map_mul, map_neg_one, one_mul]
41+
42+
lemma map_sub_swap (x y : R) : f (x - y) = f (y - x) := by rw [← map_neg, neg_sub]
43+
44+
end MonoidHom

Mathlib/Data/Nat/Prime/Pow.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ namespace Nat
2323
theorem pow_minFac {n k : ℕ} (hk : k ≠ 0) : (n ^ k).minFac = n.minFac := by
2424
rcases eq_or_ne n 1 with (rfl | hn)
2525
· simp
26-
have hnk : n ^ k ≠ 1 := fun hk' => hn ((pow_eq_one_iff hk).1 hk')
26+
have hnk : n ^ k ≠ 1 := fun hk' => hn ((pow_eq_one_iff_left hk).1 hk')
2727
apply (minFac_le_of_dvd (minFac_prime hn).two_le ((minFac_dvd n).pow hk)).antisymm
2828
apply
2929
minFac_le_of_dvd (minFac_prime hnk).two_le

Mathlib/FieldTheory/Finite/GaloisField.lean

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,7 @@ def ringEquivOfCardEq (hKK' : Fintype.card K = Fintype.card K') : K ≃+* K' :=
270270
choose n' hp' hK' using FiniteField.card K' p'
271271
have hpp' : p = p' := by
272272
by_contra hne
273-
have h2 := Nat.coprime_pow_primes n n' hp hp' hne
274-
rw [(Eq.congr hK hK').mp hKK', Nat.coprime_self, pow_eq_one_iff (PNat.ne_zero n')] at h2
275-
exact Nat.Prime.ne_one hp' h2
273+
simpa [← hK, hK', hKK', hp'.ne_one] using Nat.coprime_pow_primes n n' hp hp' hne
276274
rw [← hpp'] at _char_p'_K'
277275
haveI := fact_iff.2 hp
278276
letI : Algebra (ZMod p) K := ZMod.algebra _ _

Mathlib/NumberTheory/ArithmeticFunction/Moebius.lean

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,7 @@ theorem moebius_mul_coe_zeta : (μ * ζ : ArithmeticFunction ℤ) = 1 := by
161161
| one => simp
162162
| prime_pow p n hp hn =>
163163
rw [coe_mul_zeta_apply, sum_divisors_prime_pow hp, sum_range_succ']
164-
simp_rw [pow_zero, moebius_apply_one, moebius_apply_prime_pow hp (succ_ne_zero _), succ_inj,
165-
sum_ite_eq', mem_range, if_pos hn, neg_add_cancel]
166-
rw [one_apply_ne]
167-
rw [Ne, pow_eq_one_iff hn.ne']
168-
exact hp.ne_one
164+
simp [moebius_apply_prime_pow, hp.ne_one, hn.ne', hp, hn]
169165
| coprime a b _ha _hb hab ha' hb' =>
170166
rw [IsMultiplicative.map_mul_of_coprime _ hab, ha', hb',
171167
IsMultiplicative.map_mul_of_coprime isMultiplicative_one hab]

Mathlib/RingTheory/Valuation/Basic.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module
88
public import Mathlib.Algebra.GroupWithZero.Range
99
public import Mathlib.Algebra.Order.Hom.Monoid
1010
public import Mathlib.Algebra.Order.Ring.Basic
11+
public import Mathlib.Algebra.Ring.Torsion
1112
public import Mathlib.RingTheory.Ideal.Maps
1213
public import Mathlib.Tactic.TFAE
1314

0 commit comments

Comments
 (0)