l3lab/ntp-mathlib huggingface dataset:
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  

Proof state:
case mk.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ Ideal.span {gcd x y} = Ideal.span {d}

Next tactic:
suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
this : Associated d (gcd x y)
⊢ Ideal.span {gcd x y} = Ideal.span {d}

Next tactic:
obtain ⟨D, HD⟩ := this
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    

Proof state:
case intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
D : Rˣ
HD : d * ↑D = gcd x y
⊢ Ideal.span {gcd x y} = Ideal.span {d}

Next tactic:
rw [← HD]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    

Proof state:
case intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
D : Rˣ
HD : d * ↑D = gcd x y
⊢ Ideal.span {d * ↑D} = Ideal.span {d}

Next tactic:
exact span_singleton_mul_right_unit D.isUnit _
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  

Proof state:
case mk.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ Associated d (gcd x y)

Next tactic:
apply associated_of_dvd_dvd
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · 

Proof state:
case mk.intro.hab
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ d ∣ gcd x y

Next tactic:
rw [dvd_gcd_iff]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    

Proof state:
case mk.intro.hab
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ d ∣ x ∧ d ∣ y

Next tactic:
constructor
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> 

Proof state:
case mk.intro.hab.left
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ d ∣ x

Next tactic:
rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> 

Proof state:
case mk.intro.hab.right
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ d ∣ y

Next tactic:
rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · 

Proof state:
case mk.intro.hab.left
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ ∃ a b, a * x + b * y = x

Next tactic:
use 1, 0
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      

Proof state:
case h
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ 1 * x + 0 * y = x

Next tactic:
rw [one_mul, zero_mul, add_zero]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · 

Proof state:
case mk.intro.hab.right
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ ∃ a b, a * x + b * y = y

Next tactic:
use 0, 1
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      

Proof state:
case h
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ 0 * x + 1 * y = y

Next tactic:
rw [one_mul, zero_mul, zero_add]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · 

Proof state:
case mk.intro.hba
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ gcd x y ∣ d

Next tactic:
obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y d : R
hd : Ideal.span {x, y} = Ideal.span {d}
⊢ ∃ r s, r * x + s * y = d

Next tactic:
rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
    

Proof state:
case mk.intro.hba.intro.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y r s : R
hd : Ideal.span {x, y} = Ideal.span {r * x + s * y}
⊢ gcd x y ∣ r * x + s * y

Next tactic:
apply dvd_add
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
    apply dvd_add <;> 

Proof state:
case mk.intro.hba.intro.intro.h₁
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y r s : R
hd : Ideal.span {x, y} = Ideal.span {r * x + s * y}
⊢ gcd x y ∣ r * x

Next tactic:
apply dvd_mul_of_dvd_right
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
    apply dvd_add <;> 

Proof state:
case mk.intro.hba.intro.intro.h₂
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y r s : R
hd : Ideal.span {x, y} = Ideal.span {r * x + s * y}
⊢ gcd x y ∣ s * y

Next tactic:
apply dvd_mul_of_dvd_right
theorem span_gcd (x y : R) : span ({gcd x y} : Set R) = span ({x, y} : Set R) := by
  obtain ⟨d, hd⟩ := IsPrincipalIdealRing.principal (span ({x, y} : Set R))
  rw [submodule_span_eq] at hd
  rw [hd]
  suffices Associated d (gcd x y) by
    obtain ⟨D, HD⟩ := this
    rw [← HD]
    exact span_singleton_mul_right_unit D.isUnit _
  apply associated_of_dvd_dvd
  · rw [dvd_gcd_iff]
    constructor <;> rw [← Ideal.mem_span_singleton, ← hd, Ideal.mem_span_pair]
    · use 1, 0
      rw [one_mul, zero_mul, add_zero]
    · use 0, 1
      rw [one_mul, zero_mul, zero_add]
  · obtain ⟨r, s, rfl⟩ : ∃ r s, r * x + s * y = d := by
      rw [← Ideal.mem_span_pair, hd, Ideal.mem_span_singleton]
    apply dvd_add <;> apply dvd_mul_of_dvd_right
    

Proof state:
case mk.intro.hba.intro.intro.h₁.h
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y r s : R
hd : Ideal.span {x, y} = Ideal.span {r * x + s * y}
⊢ gcd x y ∣ x
case mk.intro.hba.intro.intro.h₂.h
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y r s : R
hd : Ideal.span {x, y} = Ideal.span {r * x + s * y}
⊢ gcd x y ∣ y

Next tactic:
exacts [gcd_dvd_left x y, gcd_dvd_right x y]
theorem gcd_dvd_iff_exists (a b : R) {z} : gcd a b ∣ z ↔ ∃ x y, z = a * x + b * y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
a b z : R
⊢ gcd a b ∣ z ↔ ∃ x y, z = a * x + b * y

Next tactic:
simp_rw [mul_comm a, mul_comm b, @eq_comm _ z, ← Ideal.mem_span_pair, ← span_gcd,
    Ideal.mem_span_singleton]
/-- **Bézout's lemma** -/
theorem exists_gcd_eq_mul_add_mul (a b : R) : ∃ x y, gcd a b = a * x + b * y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
a b : R
⊢ ∃ x y, gcd a b = a * x + b * y

Next tactic:
rw [← gcd_dvd_iff_exists]
theorem gcd_isUnit_iff (x y : R) : IsUnit (gcd x y) ↔ IsCoprime x y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
⊢ IsUnit (gcd x y) ↔ IsCoprime x y

Next tactic:
rw [IsCoprime, ← Ideal.mem_span_pair, ← span_gcd, ← span_singleton_eq_top, eq_top_iff_one]
theorem isCoprime_of_dvd (x y : R) (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y
⊢ IsCoprime x y

Next tactic:
rw [← gcd_isUnit_iff]
theorem isCoprime_of_dvd (x y : R) (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  rw [← gcd_isUnit_iff]
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y
⊢ IsUnit (gcd x y)

Next tactic:
by_contra h
theorem isCoprime_of_dvd (x y : R) (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  rw [← gcd_isUnit_iff]
  by_contra h
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y
h : ¬IsUnit (gcd x y)
⊢ False

Next tactic:
refine' H _ h _ (gcd_dvd_left _ _) (gcd_dvd_right _ _)
theorem isCoprime_of_dvd (x y : R) (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  rw [← gcd_isUnit_iff]
  by_contra h
  refine' H _ h _ (gcd_dvd_left _ _) (gcd_dvd_right _ _)
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y
h : ¬IsUnit (gcd x y)
⊢ gcd x y ≠ 0

Next tactic:
rwa [Ne, gcd_eq_zero_iff]
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
h : Irreducible x
⊢ x ∣ y ∨ IsCoprime x y

Next tactic:
refine' or_iff_not_imp_left.2 fun h' => _
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
h : Irreducible x
h' : ¬x ∣ y
⊢ IsCoprime x y

Next tactic:
apply isCoprime_of_dvd
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  apply isCoprime_of_dvd
  · 

Proof state:
case nonzero
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
h : Irreducible x
h' : ¬x ∣ y
⊢ ¬(x = 0 ∧ y = 0)

Next tactic:
rintro ⟨rfl, rfl⟩
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  apply isCoprime_of_dvd
  · rintro ⟨rfl, rfl⟩
    

Proof state:
case nonzero.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
h : Irreducible 0
h' : ¬0 ∣ 0
⊢ False

Next tactic:
simp at h
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  apply isCoprime_of_dvd
  · rintro ⟨rfl, rfl⟩
    simp at h
  · 

Proof state:
case H
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
h : Irreducible x
h' : ¬x ∣ y
⊢ ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y

Next tactic:
rintro z nu - ⟨w, rfl⟩ dy
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  apply isCoprime_of_dvd
  · rintro ⟨rfl, rfl⟩
    simp at h
  · rintro z nu - ⟨w, rfl⟩ dy
    

Proof state:
case H.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
y z : R
nu : z ∈ nonunits R
w : R
h : Irreducible (z * w)
h' : ¬z * w ∣ y
dy : z ∣ y
⊢ False

Next tactic:
refine' h' (dvd_trans _ dy)
theorem dvd_or_coprime (x y : R) (h : Irreducible x) : x ∣ y ∨ IsCoprime x y := by
  refine' or_iff_not_imp_left.2 fun h' => _
  apply isCoprime_of_dvd
  · rintro ⟨rfl, rfl⟩
    simp at h
  · rintro z nu - ⟨w, rfl⟩ dy
    refine' h' (dvd_trans _ dy)
    

Proof state:
case H.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
y z : R
nu : z ∈ nonunits R
w : R
h : Irreducible (z * w)
h' : ¬z * w ∣ y
dy : z ∣ y
⊢ z * w ∣ z

Next tactic:
simpa using mul_dvd_mul_left z (isUnit_iff_dvd_one.1 <| (of_irreducible_mul h).resolve_left nu)
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
⊢ IsCoprime x y

Next tactic:
apply isCoprime_of_dvd x y nonzero
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  apply isCoprime_of_dvd x y nonzero
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
⊢ ∀ z ∈ nonunits R, z ≠ 0 → z ∣ x → ¬z ∣ y

Next tactic:
intro z znu znz zx zy
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  apply isCoprime_of_dvd x y nonzero
  intro z znu znz zx zy
  

Proof state:
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
z : R
znu : z ∈ nonunits R
znz : z ≠ 0
zx : z ∣ x
zy : z ∣ y
⊢ False

Next tactic:
obtain ⟨i, h1, h2⟩ := WfDvdMonoid.exists_irreducible_factor znu znz
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  apply isCoprime_of_dvd x y nonzero
  intro z znu znz zx zy
  obtain ⟨i, h1, h2⟩ := WfDvdMonoid.exists_irreducible_factor znu znz
  

Proof state:
case intro.intro
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
z : R
znu : z ∈ nonunits R
znz : z ≠ 0
zx : z ∣ x
zy : z ∣ y
i : R
h1 : Irreducible i
h2 : i ∣ z
⊢ False

Next tactic:
apply H i h1
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  apply isCoprime_of_dvd x y nonzero
  intro z znu znz zx zy
  obtain ⟨i, h1, h2⟩ := WfDvdMonoid.exists_irreducible_factor znu znz
  apply H i h1 <;>
    · 

Proof state:
case intro.intro.a
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
z : R
znu : z ∈ nonunits R
znz : z ≠ 0
zx : z ∣ x
zy : z ∣ y
i : R
h1 : Irreducible i
h2 : i ∣ z
⊢ i ∣ x

Next tactic:
apply dvd_trans h2
theorem isCoprime_of_irreducible_dvd {x y : R} (nonzero : ¬(x = 0 ∧ y = 0))
    (H : ∀ z : R, Irreducible z → z ∣ x → ¬z ∣ y) : IsCoprime x y := by
  apply isCoprime_of_dvd x y nonzero
  intro z znu znz zx zy
  obtain ⟨i, h1, h2⟩ := WfDvdMonoid.exists_irreducible_factor znu znz
  apply H i h1 <;>
    · apply dvd_trans h2
      

Proof state:
case intro.intro.a
R : Type u
M : Type v
inst✝³ : CommRing R
inst✝² : IsDomain R
inst✝¹ : IsPrincipalIdealRing R
inst✝ : GCDMonoid R
x y : R
nonzero : ¬(x = 0 ∧ y = 0)
H : ∀ (z : R), Irreducible z → z ∣ x → ¬z ∣ y
z : R
znu : z ∈ nonunits R
znz : z ≠ 0
zx : z ∣ x
zy : z ∣ y
i : R
h1 : Irreducible i
h2 : i ∣ z
⊢ z ∣ x

Next tactic:
assumption