Theorem: extract_gcd
File: Mathlib/Algebra/GCDMonoid/Basic.lean

tactic: by_cases h : gcd x y = 0
state_before: α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')
state_after: case pos
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : gcd x y = 0
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')

case neg
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')

tactic: obtain ⟨x', ex⟩ := gcd_dvd_left x y
state_before: case neg
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')
state_after: case neg.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
x' : α
ex : x = gcd x y * x'
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')

tactic: obtain ⟨y', ey⟩ := gcd_dvd_right x y
state_before: case neg.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
x' : α
ex : x = gcd x y * x'
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')
state_after: case neg.intro.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
x' : α
ex : x = gcd x y * x'
y' : α
ey : y = gcd x y * y'
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')

tactic: exact ⟨x', y', ex, ey, isUnit_gcd_of_eq_mul_gcd ex ey h⟩
state_before: case neg.intro.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : ¬gcd x y = 0
x' : α
ex : x = gcd x y * x'
y' : α
ey : y = gcd x y * y'
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')
state_after: no goals

tactic: obtain ⟨rfl, rfl⟩ := (gcd_eq_zero_iff x y).1 h
state_before: case pos
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
x y : α
h : gcd x y = 0
⊢ ∃ x' y', x = gcd x y * x' ∧ y = gcd x y * y' ∧ IsUnit (gcd x' y')
state_after: case pos.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
h : gcd 0 0 = 0
⊢ ∃ x' y', 0 = gcd 0 0 * x' ∧ 0 = gcd 0 0 * y' ∧ IsUnit (gcd x' y')

tactic: simp_rw [← associated_one_iff_isUnit]
state_before: case pos.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
h : gcd 0 0 = 0
⊢ ∃ x' y', 0 = gcd 0 0 * x' ∧ 0 = gcd 0 0 * y' ∧ IsUnit (gcd x' y')
state_after: case pos.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
h : gcd 0 0 = 0
⊢ ∃ x' y', 0 = gcd 0 0 * x' ∧ 0 = gcd 0 0 * y' ∧ Associated (gcd x' y') 1

tactic: exact ⟨1, 1, by rw [h, zero_mul], by rw [h, zero_mul], gcd_one_left' 1⟩
state_before: case pos.intro
α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
h : gcd 0 0 = 0
⊢ ∃ x' y', 0 = gcd 0 0 * x' ∧ 0 = gcd 0 0 * y' ∧ Associated (gcd x' y') 1
state_after: no goals

tactic: rw [h, zero_mul]
state_before: α✝ : Type u_1
inst✝² : CancelCommMonoidWithZero α✝
α : Type u_2
inst✝¹ : CancelCommMonoidWithZero α
inst✝ : GCDMonoid α
h : gcd 0 0 = 0
⊢ 0 = gcd 0 0 * 1
state_after: no goals