Theorem: Polynomial.isUnitTrinomial_iff
File: Mathlib/Data/Polynomial/UnitTrinomial.lean

tactic: refine' ⟨fun hp => ⟨hp.card_support_eq_three, fun k => hp.coeff_isUnit⟩, fun hp => _⟩
state_before: p q : ℤ[X]
⊢ IsUnitTrinomial p ↔ card (support p) = 3 ∧ ∀ (k : ℕ), k ∈ support p → IsUnit (coeff p k)

tactic: obtain ⟨k, m, n, hkm, hmn, x, y, z, hx, hy, hz, rfl⟩ := card_support_eq_three.mp hp.1
state_before: p q : ℤ[X]
hp : card (support p) = 3 ∧ ∀ (k : ℕ), k ∈ support p → IsUnit (coeff p k)
⊢ IsUnitTrinomial p

tactic: rw [support_trinomial hkm hmn hx hy hz] at hp
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hx : x ≠ 0
hy : y ≠ 0
hz : z ≠ 0
hp :
  card (support (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)) = 3 ∧
    ∀ (k_1 : ℕ),
      k_1 ∈ support (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) →
        IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: replace hx := hp.2 k (mem_insert_self k {m, n})
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hx : x ≠ 0
hy : y ≠ 0
hz : z ≠ 0
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: replace hy := hp.2 m (mem_insert_of_mem (mem_insert_self m {n}))
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hy : y ≠ 0
hz : z ≠ 0
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: replace hz := hp.2 n (mem_insert_of_mem (mem_insert_of_mem (mem_singleton_self n)))
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hz : z ≠ 0
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k)
hy : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) m)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: simp_rw [coeff_add, coeff_C_mul, coeff_X_pow_self, mul_one, coeff_X_pow] at hx hy hz
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k)
hy : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) m)
hz : IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) n)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: rw [if_neg hkm.ne, if_neg (hkm.trans hmn).ne] at hx
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit ((x + y * if k = m then 1 else 0) + z * if k = n then 1 else 0)
hy : IsUnit ((x * if m = k then 1 else 0) + y + z * if m = n then 1 else 0)
hz : IsUnit (((x * if n = k then 1 else 0) + y * if n = m then 1 else 0) + z)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: rw [if_neg hkm.ne', if_neg hmn.ne] at hy
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (x + y * 0 + z * 0)
hy : IsUnit ((x * if m = k then 1 else 0) + y + z * if m = n then 1 else 0)
hz : IsUnit (((x * if n = k then 1 else 0) + y * if n = m then 1 else 0) + z)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: rw [if_neg (hkm.trans hmn).ne', if_neg hmn.ne'] at hz
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (x + y * 0 + z * 0)
hy : IsUnit (x * 0 + y + z * 0)
hz : IsUnit (((x * if n = k then 1 else 0) + y * if n = m then 1 else 0) + z)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: simp_rw [MulZeroClass.mul_zero, zero_add, add_zero] at hx hy hz
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hx : IsUnit (x + y * 0 + z * 0)
hy : IsUnit (x * 0 + y + z * 0)
hz : IsUnit (x * 0 + y * 0 + z)
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)

tactic: exact ⟨k, m, n, hkm, hmn, hx.unit, hy.unit, hz.unit, rfl⟩
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
q : ℤ[X]
k m n : ℕ
hkm : k < m
hmn : m < n
x y z : ℤ
hp : card {k, m, n} = 3 ∧ ∀ (k_1 : ℕ), k_1 ∈ {k, m, n} → IsUnit (coeff (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n) k_1)
hz : IsUnit z
hx : IsUnit x
hy : IsUnit y
⊢ IsUnitTrinomial (↑C x * X ^ k + ↑C y * X ^ m + ↑C z * X ^ n)