Skip to content

Commit 2d46f7b

Browse files
committed
feat port: RingTheory.Coprime.Basic (#899)
a95b16cbade0f938fc24abd05412bde1e84bab9b Turns out there are actually some more imports needed to port this file which were imported via `tactic.ring` in Lean3. Co-authored-by: Chris Hughes <33847686+ChrisHughes24@users.noreply.github.com>
1 parent 18fa17a commit 2d46f7b

File tree

2 files changed

+392
-0
lines changed

2 files changed

+392
-0
lines changed

Mathlib.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ import Mathlib.Order.SymmDiff
313313
import Mathlib.Order.Synonym
314314
import Mathlib.Order.WellFounded
315315
import Mathlib.Order.WithBot
316+
import Mathlib.RingTheory.Coprime.Basic
316317
import Mathlib.Tactic.Abel
317318
import Mathlib.Tactic.Alias
318319
import Mathlib.Tactic.ApplyFun

Mathlib/RingTheory/Coprime/Basic.lean

Lines changed: 391 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,391 @@
1+
/-
2+
Copyright (c) 2020 Kenny Lau. All rights reserved.
3+
Released under Apache 2.0 license as described in the file LICENSE.
4+
Authors: Kenny Lau, Ken Lee, Chris Hughes
5+
-/
6+
import Mathlib.Tactic.Ring
7+
import Mathlib.GroupTheory.GroupAction.Units
8+
import Mathlib.Algebra.Ring.Divisibility
9+
import Mathlib.Algebra.Hom.Ring
10+
import Mathlib.Algebra.GroupPower.Ring
11+
12+
/-!
13+
# Coprime elements of a ring
14+
15+
## Main definitions
16+
17+
* `IsCoprime x y`: that `x` and `y` are coprime, defined to be the existence of `a` and `b` such
18+
that `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,
19+
e.g., the multivariate polynomials `x₁` and `x₂` are not coprime.
20+
21+
See also `RingTheory.Coprime.Lemmas` for further development of coprime elements.
22+
-/
23+
24+
25+
open Classical
26+
27+
universe u v
28+
29+
section CommSemiring
30+
31+
variable {R : Type u} [CommSemiring R] (x y z : R)
32+
33+
/-- The proposition that `x` and `y` are coprime, defined to be the existence of `a` and `b` such
34+
that `a * x + b * y = 1`. Note that elements with no common divisors are not necessarily coprime,
35+
e.g., the multivariate polynomials `x₁` and `x₂` are not coprime. -/
36+
@[simp]
37+
def IsCoprime : Prop :=
38+
∃ a b, a * x + b * y = 1
39+
#align is_coprime IsCoprime
40+
41+
variable {x y z}
42+
43+
theorem IsCoprime.symm (H : IsCoprime x y) : IsCoprime y x :=
44+
let ⟨a, b, H⟩ := H
45+
⟨b, a, by rw [add_comm, H]⟩
46+
#align is_coprime.symm IsCoprime.symm
47+
48+
theorem isCoprime_comm : IsCoprime x y ↔ IsCoprime y x :=
49+
⟨IsCoprime.symm, IsCoprime.symm⟩
50+
#align is_coprime_comm isCoprime_comm
51+
52+
theorem isCoprime_self : IsCoprime x x ↔ IsUnit x :=
53+
fun ⟨a, b, h⟩ => isUnit_of_mul_eq_one x (a + b) <| by rwa [mul_comm, add_mul], fun h =>
54+
let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 h
55+
⟨b, 0, by rwa [zero_mul, add_zero]⟩⟩
56+
#align is_coprime_self isCoprime_self
57+
58+
theorem isCoprime_zero_left : IsCoprime 0 x ↔ IsUnit x :=
59+
fun ⟨a, b, H⟩ => isUnit_of_mul_eq_one x b <| by rwa [mul_zero, zero_add, mul_comm] at H, fun H =>
60+
let ⟨b, hb⟩ := isUnit_iff_exists_inv'.1 H
61+
1, b, by rwa [one_mul, zero_add]⟩⟩
62+
#align is_coprime_zero_left isCoprime_zero_left
63+
64+
theorem isCoprime_zero_right : IsCoprime x 0 ↔ IsUnit x :=
65+
isCoprime_comm.trans isCoprime_zero_left
66+
#align is_coprime_zero_right isCoprime_zero_right
67+
68+
theorem not_isCoprime_zero_zero [Nontrivial R] : ¬IsCoprime (0 : R) 0 :=
69+
mt isCoprime_zero_right.mp not_isUnit_zero
70+
#align not_coprime_zero_zero not_isCoprime_zero_zero
71+
72+
/-- If a 2-vector `p` satisfies `is_coprime (p 0) (p 1)`, then `p ≠ 0`. -/
73+
theorem IsCoprime.ne_zero [Nontrivial R] {p : Fin 2 → R} (h : IsCoprime (p 0) (p 1)) : p ≠ 0 := by
74+
rintro rfl
75+
exact not_isCoprime_zero_zero h
76+
#align is_coprime.ne_zero IsCoprime.ne_zero
77+
78+
theorem isCoprime_one_left : IsCoprime 1 x :=
79+
1, 0, by rw [one_mul, zero_mul, add_zero]⟩
80+
#align is_coprime_one_left isCoprime_one_left
81+
82+
theorem isCoprime_one_right : IsCoprime x 1 :=
83+
0, 1, by rw [one_mul, zero_mul, zero_add]⟩
84+
#align is_coprime_one_right isCoprime_one_right
85+
86+
theorem IsCoprime.dvd_of_dvd_mul_right (H1 : IsCoprime x z) (H2 : x ∣ y * z) : x ∣ y := by
87+
let ⟨a, b, H⟩ := H1
88+
rw [← mul_one y, ← H, mul_add, ← mul_assoc, mul_left_comm]
89+
exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)
90+
#align is_coprime.dvd_of_dvd_mul_right IsCoprime.dvd_of_dvd_mul_right
91+
92+
theorem IsCoprime.dvd_of_dvd_mul_left (H1 : IsCoprime x y) (H2 : x ∣ y * z) : x ∣ z := by
93+
let ⟨a, b, H⟩ := H1
94+
rw [← one_mul z, ← H, add_mul, mul_right_comm, mul_assoc b]
95+
exact dvd_add (dvd_mul_left _ _) (H2.mul_left _)
96+
#align is_coprime.dvd_of_dvd_mul_left IsCoprime.dvd_of_dvd_mul_left
97+
98+
theorem IsCoprime.mul_left (H1 : IsCoprime x z) (H2 : IsCoprime y z) : IsCoprime (x * y) z :=
99+
let ⟨a, b, h1⟩ := H1
100+
let ⟨c, d, h2⟩ := H2
101+
⟨a * c, a * x * d + b * c * y + b * d * z,
102+
calc
103+
a * c * (x * y) + (a * x * d + b * c * y + b * d * z) * z =
104+
(a * x + b * z) * (c * y + d * z) :=
105+
by ring
106+
_ = 1 := by rw [h1, h2, mul_one]
107+
108+
#align is_coprime.mul_left IsCoprime.mul_left
109+
110+
theorem IsCoprime.mul_right (H1 : IsCoprime x y) (H2 : IsCoprime x z) : IsCoprime x (y * z) := by
111+
rw [isCoprime_comm] at H1 H2⊢
112+
exact H1.mul_left H2
113+
#align is_coprime.mul_right IsCoprime.mul_right
114+
115+
theorem IsCoprime.mul_dvd (H : IsCoprime x y) (H1 : x ∣ z) (H2 : y ∣ z) : x * y ∣ z := by
116+
obtain ⟨a, b, h⟩ := H
117+
rw [← mul_one z, ← h, mul_add]
118+
apply dvd_add
119+
· rw [mul_comm z, mul_assoc]
120+
exact (mul_dvd_mul_left _ H2).mul_left _
121+
· rw [mul_comm b, ← mul_assoc]
122+
exact (mul_dvd_mul_right H1 _).mul_right _
123+
#align is_coprime.mul_dvd IsCoprime.mul_dvd
124+
125+
theorem IsCoprime.of_mul_left_left (H : IsCoprime (x * y) z) : IsCoprime x z :=
126+
let ⟨a, b, h⟩ := H
127+
⟨a * y, b, by rwa [mul_right_comm, mul_assoc]⟩
128+
#align is_coprime.of_mul_left_left IsCoprime.of_mul_left_left
129+
130+
theorem IsCoprime.of_mul_left_right (H : IsCoprime (x * y) z) : IsCoprime y z := by
131+
rw [mul_comm] at H
132+
exact H.of_mul_left_left
133+
#align is_coprime.of_mul_left_right IsCoprime.of_mul_left_right
134+
135+
theorem IsCoprime.of_mul_right_left (H : IsCoprime x (y * z)) : IsCoprime x y := by
136+
rw [isCoprime_comm] at H⊢
137+
exact H.of_mul_left_left
138+
#align is_coprime.of_mul_right_left IsCoprime.of_mul_right_left
139+
140+
theorem IsCoprime.of_mul_right_right (H : IsCoprime x (y * z)) : IsCoprime x z := by
141+
rw [mul_comm] at H
142+
exact H.of_mul_right_left
143+
#align is_coprime.of_mul_right_right IsCoprime.of_mul_right_right
144+
145+
theorem IsCoprime.mul_left_iff : IsCoprime (x * y) z ↔ IsCoprime x z ∧ IsCoprime y z :=
146+
fun H => ⟨H.of_mul_left_left, H.of_mul_left_right⟩, fun ⟨H1, H2⟩ => H1.mul_left H2⟩
147+
#align is_coprime.mul_left_iff IsCoprime.mul_left_iff
148+
149+
theorem IsCoprime.mul_right_iff : IsCoprime x (y * z) ↔ IsCoprime x y ∧ IsCoprime x z := by
150+
rw [isCoprime_comm, IsCoprime.mul_left_iff, isCoprime_comm, @isCoprime_comm _ _ z]
151+
#align is_coprime.mul_right_iff IsCoprime.mul_right_iff
152+
153+
theorem IsCoprime.of_isCoprime_of_dvd_left (h : IsCoprime y z) (hdvd : x ∣ y) : IsCoprime x z := by
154+
obtain ⟨d, rfl⟩ := hdvd
155+
exact IsCoprime.of_mul_left_left h
156+
#align is_coprime.of_coprime_of_dvd_left IsCoprime.of_isCoprime_of_dvd_left
157+
158+
theorem IsCoprime.of_isCoprime_of_dvd_right (h : IsCoprime z y) (hdvd : x ∣ y) : IsCoprime z x :=
159+
(h.symm.of_isCoprime_of_dvd_left hdvd).symm
160+
#align is_coprime.of_coprime_of_dvd_right IsCoprime.of_isCoprime_of_dvd_right
161+
162+
theorem IsCoprime.is_unit_of_dvd (H : IsCoprime x y) (d : x ∣ y) : IsUnit x :=
163+
let ⟨k, hk⟩ := d
164+
isCoprime_self.1 <| IsCoprime.of_mul_right_left <| show IsCoprime x (x * k) from hk ▸ H
165+
#align is_coprime.is_unit_of_dvd IsCoprime.is_unit_of_dvd
166+
167+
theorem IsCoprime.is_unit_of_dvd' {a b x : R} (h : IsCoprime a b) (ha : x ∣ a) (hb : x ∣ b) :
168+
IsUnit x :=
169+
(h.of_isCoprime_of_dvd_left ha).is_unit_of_dvd hb
170+
#align is_coprime.is_unit_of_dvd' IsCoprime.is_unit_of_dvd'
171+
172+
theorem IsCoprime.map (H : IsCoprime x y) {S : Type v} [CommSemiring S] (f : R →+* S) :
173+
IsCoprime (f x) (f y) :=
174+
let ⟨a, b, h⟩ := H
175+
⟨f a, f b, by rw [← f.map_mul, ← f.map_mul, ← f.map_add, h, f.map_one]⟩
176+
#align is_coprime.map IsCoprime.map
177+
178+
theorem IsCoprime.of_add_mul_left_left (h : IsCoprime (x + y * z) y) : IsCoprime x y :=
179+
let ⟨a, b, H⟩ := h
180+
⟨a, a * z + b, by
181+
simpa only [add_mul, mul_add, add_assoc, add_comm, add_left_comm, mul_assoc, mul_comm,
182+
mul_left_comm] using H⟩
183+
#align is_coprime.of_add_mul_left_left IsCoprime.of_add_mul_left_left
184+
185+
theorem IsCoprime.of_add_mul_right_left (h : IsCoprime (x + z * y) y) : IsCoprime x y := by
186+
rw [mul_comm] at h
187+
exact h.of_add_mul_left_left
188+
#align is_coprime.of_add_mul_right_left IsCoprime.of_add_mul_right_left
189+
190+
theorem IsCoprime.of_add_mul_left_right (h : IsCoprime x (y + x * z)) : IsCoprime x y := by
191+
rw [isCoprime_comm] at h⊢
192+
exact h.of_add_mul_left_left
193+
#align is_coprime.of_add_mul_left_right IsCoprime.of_add_mul_left_right
194+
195+
theorem IsCoprime.of_add_mul_right_right (h : IsCoprime x (y + z * x)) : IsCoprime x y := by
196+
rw [mul_comm] at h
197+
exact h.of_add_mul_left_right
198+
#align is_coprime.of_add_mul_right_right IsCoprime.of_add_mul_right_right
199+
200+
theorem IsCoprime.of_mul_add_left_left (h : IsCoprime (y * z + x) y) : IsCoprime x y := by
201+
rw [add_comm] at h
202+
exact h.of_add_mul_left_left
203+
#align is_coprime.of_mul_add_left_left IsCoprime.of_mul_add_left_left
204+
205+
theorem IsCoprime.of_mul_add_right_left (h : IsCoprime (z * y + x) y) : IsCoprime x y := by
206+
rw [add_comm] at h
207+
exact h.of_add_mul_right_left
208+
#align is_coprime.of_mul_add_right_left IsCoprime.of_mul_add_right_left
209+
210+
theorem IsCoprime.of_mul_add_left_right (h : IsCoprime x (x * z + y)) : IsCoprime x y := by
211+
rw [add_comm] at h
212+
exact h.of_add_mul_left_right
213+
#align is_coprime.of_mul_add_left_right IsCoprime.of_mul_add_left_right
214+
215+
theorem IsCoprime.of_mul_add_right_right (h : IsCoprime x (z * x + y)) : IsCoprime x y := by
216+
rw [add_comm] at h
217+
exact h.of_add_mul_right_right
218+
#align is_coprime.of_mul_add_right_right IsCoprime.of_mul_add_right_right
219+
220+
end CommSemiring
221+
222+
section ScalarTower
223+
224+
variable {R G : Type _} [CommSemiring R] [Group G] [MulAction G R] [SMulCommClass G R R]
225+
[IsScalarTower G R R] (x : G) (y z : R)
226+
227+
theorem isCoprime_group_smul_left : IsCoprime (x • y) z ↔ IsCoprime y z :=
228+
fun ⟨a, b, h⟩ => ⟨x • a, b, by rwa [smul_mul_assoc, ← mul_smul_comm]⟩, fun ⟨a, b, h⟩ =>
229+
⟨x⁻¹ • a, b, by rwa [smul_mul_smul, inv_mul_self, one_smul]⟩⟩
230+
#align is_coprime_group_smul_left isCoprime_group_smul_left
231+
232+
theorem isCoprime_group_smul_right : IsCoprime y (x • z) ↔ IsCoprime y z :=
233+
isCoprime_comm.trans <| (isCoprime_group_smul_left x z y).trans isCoprime_comm
234+
#align is_coprime_group_smul_right isCoprime_group_smul_right
235+
236+
theorem isCoprime_group_smul : IsCoprime (x • y) (x • z) ↔ IsCoprime y z :=
237+
(isCoprime_group_smul_left x y (x • z)).trans (isCoprime_group_smul_right x y z)
238+
#align is_coprime_group_smul isCoprime_group_smul
239+
240+
end ScalarTower
241+
242+
section CommSemiringUnit
243+
244+
variable {R : Type _} [CommSemiring R] {x : R} (hu : IsUnit x) (y z : R)
245+
246+
theorem isCoprime_mul_unit_left_left : IsCoprime (x * y) z ↔ IsCoprime y z :=
247+
let ⟨u, hu⟩ := hu
248+
hu ▸ isCoprime_group_smul_left u y z
249+
#align is_coprime_mul_unit_left_left isCoprime_mul_unit_left_left
250+
251+
theorem isCoprime_mul_unit_left_right : IsCoprime y (x * z) ↔ IsCoprime y z :=
252+
let ⟨u, hu⟩ := hu
253+
hu ▸ isCoprime_group_smul_right u y z
254+
#align is_coprime_mul_unit_left_right isCoprime_mul_unit_left_right
255+
256+
theorem isCoprime_mul_unit_left : IsCoprime (x * y) (x * z) ↔ IsCoprime y z :=
257+
(isCoprime_mul_unit_left_left hu y (x * z)).trans (isCoprime_mul_unit_left_right hu y z)
258+
#align is_coprime_mul_unit_left isCoprime_mul_unit_left
259+
260+
theorem isCoprime_mul_unit_right_left : IsCoprime (y * x) z ↔ IsCoprime y z :=
261+
mul_comm x y ▸ isCoprime_mul_unit_left_left hu y z
262+
#align is_coprime_mul_unit_right_left isCoprime_mul_unit_right_left
263+
264+
theorem isCoprime_mul_unit_right_right : IsCoprime y (z * x) ↔ IsCoprime y z :=
265+
mul_comm x z ▸ isCoprime_mul_unit_left_right hu y z
266+
#align is_coprime_mul_unit_right_right isCoprime_mul_unit_right_right
267+
268+
theorem isCoprime_mul_unit_right : IsCoprime (y * x) (z * x) ↔ IsCoprime y z :=
269+
(isCoprime_mul_unit_right_left hu y (z * x)).trans (isCoprime_mul_unit_right_right hu y z)
270+
#align is_coprime_mul_unit_right isCoprime_mul_unit_right
271+
272+
end CommSemiringUnit
273+
274+
namespace IsCoprime
275+
276+
section CommRing
277+
278+
variable {R : Type u} [CommRing R]
279+
280+
theorem add_mul_left_left {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime (x + y * z) y :=
281+
@of_add_mul_left_left R _ _ _ (-z) <| by simpa only [mul_neg, add_neg_cancel_right] using h
282+
#align is_coprime.add_mul_left_left IsCoprime.add_mul_left_left
283+
284+
theorem add_mul_right_left {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime (x + z * y) y := by
285+
rw [mul_comm]
286+
exact h.add_mul_left_left z
287+
#align is_coprime.add_mul_right_left IsCoprime.add_mul_right_left
288+
289+
theorem add_mul_left_right {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime x (y + x * z) := by
290+
rw [isCoprime_comm]
291+
exact h.symm.add_mul_left_left z
292+
#align is_coprime.add_mul_left_right IsCoprime.add_mul_left_right
293+
294+
theorem add_mul_right_right {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime x (y + z * x) := by
295+
rw [isCoprime_comm]
296+
exact h.symm.add_mul_right_left z
297+
#align is_coprime.add_mul_right_right IsCoprime.add_mul_right_right
298+
299+
theorem mul_add_left_left {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime (y * z + x) y := by
300+
rw [add_comm]
301+
exact h.add_mul_left_left z
302+
#align is_coprime.mul_add_left_left IsCoprime.mul_add_left_left
303+
304+
theorem mul_add_right_left {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime (z * y + x) y := by
305+
rw [add_comm]
306+
exact h.add_mul_right_left z
307+
#align is_coprime.mul_add_right_left IsCoprime.mul_add_right_left
308+
309+
theorem mul_add_left_right {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime x (x * z + y) := by
310+
rw [add_comm]
311+
exact h.add_mul_left_right z
312+
#align is_coprime.mul_add_left_right IsCoprime.mul_add_left_right
313+
314+
theorem mul_add_right_right {x y : R} (h : IsCoprime x y) (z : R) : IsCoprime x (z * x + y) := by
315+
rw [add_comm]
316+
exact h.add_mul_right_right z
317+
#align is_coprime.mul_add_right_right IsCoprime.mul_add_right_right
318+
319+
theorem add_mul_left_left_iff {x y z : R} : IsCoprime (x + y * z) y ↔ IsCoprime x y :=
320+
⟨of_add_mul_left_left, fun h => h.add_mul_left_left z⟩
321+
#align is_coprime.add_mul_left_left_iff IsCoprime.add_mul_left_left_iff
322+
323+
theorem add_mul_right_left_iff {x y z : R} : IsCoprime (x + z * y) y ↔ IsCoprime x y :=
324+
⟨of_add_mul_right_left, fun h => h.add_mul_right_left z⟩
325+
#align is_coprime.add_mul_right_left_iff IsCoprime.add_mul_right_left_iff
326+
327+
theorem add_mul_left_right_iff {x y z : R} : IsCoprime x (y + x * z) ↔ IsCoprime x y :=
328+
⟨of_add_mul_left_right, fun h => h.add_mul_left_right z⟩
329+
#align is_coprime.add_mul_left_right_iff IsCoprime.add_mul_left_right_iff
330+
331+
theorem add_mul_right_right_iff {x y z : R} : IsCoprime x (y + z * x) ↔ IsCoprime x y :=
332+
⟨of_add_mul_right_right, fun h => h.add_mul_right_right z⟩
333+
#align is_coprime.add_mul_right_right_iff IsCoprime.add_mul_right_right_iff
334+
335+
theorem mul_add_left_left_iff {x y z : R} : IsCoprime (y * z + x) y ↔ IsCoprime x y :=
336+
⟨of_mul_add_left_left, fun h => h.mul_add_left_left z⟩
337+
#align is_coprime.mul_add_left_left_iff IsCoprime.mul_add_left_left_iff
338+
339+
theorem mul_add_right_left_iff {x y z : R} : IsCoprime (z * y + x) y ↔ IsCoprime x y :=
340+
⟨of_mul_add_right_left, fun h => h.mul_add_right_left z⟩
341+
#align is_coprime.mul_add_right_left_iff IsCoprime.mul_add_right_left_iff
342+
343+
theorem mul_add_left_right_iff {x y z : R} : IsCoprime x (x * z + y) ↔ IsCoprime x y :=
344+
⟨of_mul_add_left_right, fun h => h.mul_add_left_right z⟩
345+
#align is_coprime.mul_add_left_right_iff IsCoprime.mul_add_left_right_iff
346+
347+
theorem mul_add_right_right_iff {x y z : R} : IsCoprime x (z * x + y) ↔ IsCoprime x y :=
348+
⟨of_mul_add_right_right, fun h => h.mul_add_right_right z⟩
349+
#align is_coprime.mul_add_right_right_iff IsCoprime.mul_add_right_right_iff
350+
351+
theorem neg_left {x y : R} (h : IsCoprime x y) : IsCoprime (-x) y := by
352+
obtain ⟨a, b, h⟩ := h
353+
use -a, b
354+
rwa [neg_mul_neg]
355+
#align is_coprime.neg_left IsCoprime.neg_left
356+
357+
theorem neg_left_iff (x y : R) : IsCoprime (-x) y ↔ IsCoprime x y :=
358+
fun h => neg_neg x ▸ h.neg_left, neg_left⟩
359+
#align is_coprime.neg_left_iff IsCoprime.neg_left_iff
360+
361+
theorem neg_right {x y : R} (h : IsCoprime x y) : IsCoprime x (-y) :=
362+
h.symm.neg_left.symm
363+
#align is_coprime.neg_right IsCoprime.neg_right
364+
365+
theorem neg_right_iff (x y : R) : IsCoprime x (-y) ↔ IsCoprime x y :=
366+
fun h => neg_neg y ▸ h.neg_right, neg_right⟩
367+
#align is_coprime.neg_right_iff IsCoprime.neg_right_iff
368+
369+
theorem neg_neg {x y : R} (h : IsCoprime x y) : IsCoprime (-x) (-y) :=
370+
h.neg_left.neg_right
371+
#align is_coprime.neg_neg IsCoprime.neg_neg
372+
373+
theorem neg_neg_iff (x y : R) : IsCoprime (-x) (-y) ↔ IsCoprime x y :=
374+
(neg_left_iff _ _).trans (neg_right_iff _ _)
375+
#align is_coprime.neg_neg_iff IsCoprime.neg_neg_iff
376+
377+
end CommRing
378+
379+
theorem sq_add_sq_ne_zero {R : Type _} [LinearOrderedCommRing R] {a b : R} (h : IsCoprime a b) :
380+
a ^ 2 + b ^ 20 := by
381+
intro h'
382+
obtain ⟨ha, hb⟩ := (add_eq_zero_iff'
383+
--Porting TODO: replace with sq_nonneg when that file is ported
384+
(by rw [pow_two]; exact mul_self_nonneg _)
385+
(by rw [pow_two]; exact mul_self_nonneg _)).mp h'
386+
obtain rfl := pow_eq_zero ha
387+
obtain rfl := pow_eq_zero hb
388+
exact not_isCoprime_zero_zero h
389+
#align is_coprime.sq_add_sq_ne_zero IsCoprime.sq_add_sq_ne_zero
390+
391+
end IsCoprime

0 commit comments

Comments
 (0)