Theorem: Int.gcd_eq_one_iff_coprime
File: Mathlib/RingTheory/Int/Basic.lean

tactic: constructor
state_before: a b : ℤ
⊢ a.gcd b = 1 ↔ IsCoprime a b
state_after: case mp
a b : ℤ
⊢ a.gcd b = 1 → IsCoprime a b

case mpr
a b : ℤ
⊢ IsCoprime a b → a.gcd b = 1

tactic: intro hg
state_before: case mp
a b : ℤ
⊢ a.gcd b = 1 → IsCoprime a b
state_after: case mp
a b : ℤ
hg : a.gcd b = 1
⊢ IsCoprime a b

tactic: obtain ⟨ua, -, ha⟩ := exists_unit_of_abs a
state_before: case mp
a b : ℤ
hg : a.gcd b = 1
⊢ IsCoprime a b
state_after: case mp.intro.intro
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
⊢ IsCoprime a b

tactic: obtain ⟨ub, -, hb⟩ := exists_unit_of_abs b
state_before: case mp.intro.intro
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
⊢ IsCoprime a b
state_after: case mp.intro.intro.intro.intro
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
ub : ℤ
hb : ↑b.natAbs = ub * b
⊢ IsCoprime a b

tactic: use Nat.gcdA (Int.natAbs a) (Int.natAbs b) * ua, Nat.gcdB (Int.natAbs a) (Int.natAbs b) * ub
state_before: case mp.intro.intro.intro.intro
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
ub : ℤ
hb : ↑b.natAbs = ub * b
⊢ IsCoprime a b
state_after: case h
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
ub : ℤ
hb : ↑b.natAbs = ub * b
⊢ a.natAbs.gcdA b.natAbs * ua * a + a.natAbs.gcdB b.natAbs * ub * b = 1

tactic: rw [mul_assoc, ← ha, mul_assoc, ← hb, mul_comm, mul_comm _ (Int.natAbs b : ℤ), ←
  Nat.gcd_eq_gcd_ab, ← gcd_eq_natAbs, hg, Int.ofNat_one]
state_before: case h
a b : ℤ
hg : a.gcd b = 1
ua : ℤ
ha : ↑a.natAbs = ua * a
ub : ℤ
hb : ↑b.natAbs = ub * b
⊢ a.natAbs.gcdA b.natAbs * ua * a + a.natAbs.gcdB b.natAbs * ub * b = 1
state_after: no goals

tactic: rintro ⟨r, s, h⟩
state_before: case mpr
a b : ℤ
⊢ IsCoprime a b → a.gcd b = 1
state_after: case mpr.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
⊢ a.gcd b = 1

tactic: by_contra hg
state_before: case mpr.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
⊢ a.gcd b = 1
state_after: case mpr.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
⊢ False

tactic: obtain ⟨p, ⟨hp, ha, hb⟩⟩ := Nat.Prime.not_coprime_iff_dvd.mp hg
state_before: case mpr.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
⊢ False
state_after: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ False

tactic: apply Nat.Prime.not_dvd_one hp
state_before: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ False
state_after: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ p ∣ 1

tactic: rw [← natCast_dvd_natCast, Int.ofNat_one, ← h]
state_before: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ p ∣ 1
state_after: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ ↑p ∣ r * a + s * b

tactic: exact dvd_add ((natCast_dvd.mpr ha).mul_left _) ((natCast_dvd.mpr hb).mul_left _)
state_before: case mpr.intro.intro.intro.intro.intro
a b r s : ℤ
h : r * a + s * b = 1
hg : ¬a.gcd b = 1
p : ℕ
hp : Nat.Prime p
ha : p ∣ a.natAbs
hb : p ∣ b.natAbs
⊢ ↑p ∣ r * a + s * b
state_after: no goals