Theorem: Nat.factorization_gcd
File: Mathlib/Data/Nat/Factorization/Basic.lean

tactic: let dfac := a.factorization ⊓ b.factorization
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization

tactic: have dfac_prime : ∀ p : ℕ, p ∈ dfac.support → Prime p := by
  intro p hp
  have : p ∈ a.factors ∧ p ∈ b.factors := by simpa [dfac] using hp
  exact prime_of_mem_factors this.1
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization

tactic: have h1 : d.factorization = dfac := prod_pow_factorization_eq_self dfac_prime
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization

tactic: have hd_pos : d ≠ 0 := (factorizationEquiv.invFun ⟨dfac, dfac_prime⟩).2.ne'
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization

tactic: suffices d = gcd a b by rwa [← this]
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d = a.gcd b

tactic: apply gcd_greatest
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d = a.gcd b
state_after: case hda
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d ∣ a

case hdb
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d ∣ b

case hd
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ ∀ (e : ℕ), e ∣ a → e ∣ b → e ∣ d

tactic: intro p hp
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
⊢ ∀ p ∈ dfac.support, Prime p
state_after: a✝ b✝ m n p✝ a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
p : ℕ
hp : p ∈ dfac.support
⊢ Prime p

tactic: have : p ∈ a.factors ∧ p ∈ b.factors := by simpa [dfac] using hp
state_before: a✝ b✝ m n p✝ a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
p : ℕ
hp : p ∈ dfac.support
⊢ Prime p
state_after: a✝ b✝ m n p✝ a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
p : ℕ
hp : p ∈ dfac.support
this : p ∈ a.factors ∧ p ∈ b.factors
⊢ Prime p

tactic: exact prime_of_mem_factors this.1
state_before: a✝ b✝ m n p✝ a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
p : ℕ
hp : p ∈ dfac.support
this : p ∈ a.factors ∧ p ∈ b.factors
⊢ Prime p
state_after: no goals

tactic: simpa [dfac] using hp
state_before: a✝ b✝ m n p✝ a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
p : ℕ
hp : p ∈ dfac.support
⊢ p ∈ a.factors ∧ p ∈ b.factors
state_after: no goals

tactic: rwa [← this]
state_before: a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
this : d = a.gcd b
⊢ (a.gcd b).factorization = a.factorization ⊓ b.factorization
state_after: no goals

tactic: rw [← factorization_le_iff_dvd hd_pos ha_pos, h1]
state_before: case hda
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d ∣ a
state_after: case hda
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ dfac ≤ a.factorization

tactic: exact inf_le_left
state_before: case hda
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ dfac ≤ a.factorization
state_after: no goals

tactic: rw [← factorization_le_iff_dvd hd_pos hb_pos, h1]
state_before: case hdb
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ d ∣ b
state_after: case hdb
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ dfac ≤ b.factorization

tactic: exact inf_le_right
state_before: case hdb
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ dfac ≤ b.factorization
state_after: no goals

tactic: intro e hea heb
state_before: case hd
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
⊢ ∀ (e : ℕ), e ∣ a → e ∣ b → e ∣ d
state_after: case hd
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
⊢ e ∣ d

tactic: rcases Decidable.eq_or_ne e 0 with (rfl | he_pos)
state_before: case hd
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
⊢ e ∣ d
state_after: case hd.inl
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
hea : 0 ∣ a
heb : 0 ∣ b
⊢ 0 ∣ d

case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
⊢ e ∣ d

tactic: have hea' := (factorization_le_iff_dvd he_pos ha_pos).mpr hea
state_before: case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
⊢ e ∣ d
state_after: case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
hea' : e.factorization ≤ a.factorization
⊢ e ∣ d

tactic: have heb' := (factorization_le_iff_dvd he_pos hb_pos).mpr heb
state_before: case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
hea' : e.factorization ≤ a.factorization
⊢ e ∣ d
state_after: case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
hea' : e.factorization ≤ a.factorization
heb' : e.factorization ≤ b.factorization
⊢ e ∣ d

tactic: simp [dfac, ← factorization_le_iff_dvd he_pos hd_pos, h1, hea', heb']
state_before: case hd.inr
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
e : ℕ
hea : e ∣ a
heb : e ∣ b
he_pos : e ≠ 0
hea' : e.factorization ≤ a.factorization
heb' : e.factorization ≤ b.factorization
⊢ e ∣ d
state_after: no goals

tactic: simp only [zero_dvd_iff] at hea
state_before: case hd.inl
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
hea : 0 ∣ a
heb : 0 ∣ b
⊢ 0 ∣ d
state_after: case hd.inl
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
heb : 0 ∣ b
hea : a = 0
⊢ 0 ∣ d

tactic: contradiction
state_before: case hd.inl
a✝ b✝ m n p a b : ℕ
ha_pos : a ≠ 0
hb_pos : b ≠ 0
dfac : ℕ →₀ ℕ := a.factorization ⊓ b.factorization
d : ℕ := dfac.prod fun x x_1 => x ^ x_1
dfac_prime : ∀ p ∈ dfac.support, Prime p
h1 : d.factorization = dfac
hd_pos : d ≠ 0
heb : 0 ∣ b
hea : a = 0
⊢ 0 ∣ d
state_after: no goals