Zulip Chat Archive
Stream: Is there code for X?
Topic: Is there a theorem `pow_eq_pow_iff_of_coprime` for Nat?
Lingwei Peng (彭灵伟) (May 18 2025 at 15:08):
Hi all,
I’m looking for a theorem on natural numbers that states:
If m and n are coprime, then
a^m = b^n if and only if there exists some c such that a = c^n and b = c^m.
I was trying to state it as:
import Mathlib
theorem pow_eq_pow_iff_of_coprime' {a b m n : ℕ} (h1 : m.Coprime n) : a^m = b^n ↔ ∃ c, a = c^n ∧ b = c^m := by
sorry
Riccardo Brasca (May 18 2025 at 15:30):
You can probably get there via docs#pow_eq_pow_iff_of_coprime, that is close (but it doesn't work for ℕ). Let me see.
Lingwei Peng (彭灵伟) (May 18 2025 at 15:33):
Yes, I found that it doesn’t work for Nat too.
Riccardo Brasca (May 18 2025 at 15:42):
I don't have time right now, but here is a start
import Mathlib
theorem pow_eq_pow_iff_of_coprime' {a b m n : ℕ} (h1 : m.Coprime n) : a^m = b^n ↔ ∃ c, a = c^n ∧ b = c^m := by
refine ⟨fun h ↦ ?_, fun h ↦ ?_⟩
· replace h : (a : ℚ) ^ m = b ^ n := by norm_cast
obtain ⟨c, hca, hcb⟩ := (pow_eq_pow_iff_of_coprime h1).mp h
sorry
· obtain ⟨c, rfl, rfl⟩ := h
ring
Riccardo Brasca (May 18 2025 at 15:43):
I would finish showing that c is the coercion of a natural number. This follows from something like docs#irrational_nrt_of_notint_nrt, but for rational numbers.
Riccardo Brasca (May 18 2025 at 15:52):
This holds for example since Z is integrally closed, but it is more elementary.
Riccardo Brasca (May 18 2025 at 17:43):
This
import Mathlib
open Polynomial FaithfulSMul
variable {R : Type*} [CommRing R] [IsIntegrallyClosed R] [IsDomain R]
theorem IsIntegrallyClosed.pow_eq_pow_iff_of_coprime (a b : R) {m n : ℕ} (hnm : m.Coprime n) :
a ^ m = b ^ n ↔ ∃ c, a = c ^ n ∧ b = c ^ m := by
let K := FractionRing R
refine ⟨fun h ↦ ?_, fun ⟨c, hac, hbc⟩ ↦ by simp [hac, hbc, ← pow_mul, mul_comm]⟩
by_cases hn : n = 0
· simp_all
apply_fun (algebraMap R K) at h
obtain ⟨c, hca, hcb⟩ := (_root_.pow_eq_pow_iff_of_coprime hnm).mp (by simpa [map_pow] using h)
rsuffices ⟨d, rfl⟩ : ∃ d, algebraMap R K d = c
· exact ⟨d, algebraMap_injective R K (by simp [hca]), algebraMap_injective R K (by simp [hcb])⟩
exact algebraMap_eq_of_integral ⟨X ^ n - C a, monic_X_pow_sub_C a hn, by simp [hca]⟩
works for ℤ. It shouldn't be too hard to get to the Nat version.
Ruben Van de Velde (May 18 2025 at 17:58):
That seems very heavy handed. Does the approach with Nat.gcdA/B not work directly?
Riccardo Brasca (May 18 2025 at 18:13):
I've not tried, but as I said the result for ℕ and ℤ is actually completely elementary.
Jz Pan (May 18 2025 at 19:01):
Why IsIntegrallyClosed is coming? Does it have counterexamples for ?
Riccardo Brasca (May 18 2025 at 19:11):
I don't have any specific counterexample, but what is possible is that, for a domain R with field of fraction K, there is an element x in K but not in R such that x^n is in R.
Riccardo Brasca (May 18 2025 at 19:12):
What happens in the proof is pretty clear, you want to use Bezout on the exponents, so you need to take negative powers, in particular you need to work in the field of fractions. I haven't thought if this is really necessary.
Andrew Yang (May 18 2025 at 19:23):
In , is both a square and a cube but not a 6-th power of anything.
Riccardo Brasca (May 18 2025 at 19:44):
Anyway we surely want the above version. Feel free to PR it.
Lingwei Peng (彭灵伟) (May 19 2025 at 15:23):
Thanks,I got the Nat version based on your answer.
Last updated: Dec 20 2025 at 21:32 UTC