Theorem: Polynomial.IsUnitTrinomial.irreducible_of_coprime
File: Mathlib/Data/Polynomial/UnitTrinomial.lean

tactic: refine' irreducible_of_mirror hp.not_isUnit (fun q hpq => _) h
state_before: p q : ℤ[X]
hp : IsUnitTrinomial p
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
⊢ Irreducible p

tactic: have hq : IsUnitTrinomial q := (isUnitTrinomial_iff'' hpq).mp hp
state_before: p q✝ : ℤ[X]
hp : IsUnitTrinomial p
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: obtain ⟨k, m, n, hkm, hmn, u, v, w, hp⟩ := hp
state_before: p q✝ : ℤ[X]
hp : IsUnitTrinomial p
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
hq : IsUnitTrinomial q
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: obtain ⟨k', m', n', hkm', hmn', x, y, z, hq⟩ := hq
state_before: case intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
hq : IsUnitTrinomial q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: have hk : k = k' := by
  rw [← mul_right_inj' (show 2 ≠ 0 from two_ne_zero), ←
    trinomial_natTrailingDegree hkm hmn u.ne_zero, ← hp, ← natTrailingDegree_mul_mirror, hpq,
    natTrailingDegree_mul_mirror, hq, trinomial_natTrailingDegree hkm' hmn' x.ne_zero]
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
k' m' n' : ℕ
hkm' : k' < m'
hmn' : m' < n'
x y z : ℤˣ
hq : q = trinomial k' m' n' ↑x ↑y ↑z
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: have hn : n = n' := by
  rw [← mul_right_inj' (show 2 ≠ 0 from two_ne_zero), ← trinomial_natDegree hkm hmn w.ne_zero, ←
    hp, ← natDegree_mul_mirror, hpq, natDegree_mul_mirror, hq,
    trinomial_natDegree hkm' hmn' z.ne_zero]
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
k' m' n' : ℕ
hkm' : k' < m'
hmn' : m' < n'
x y z : ℤˣ
hq : q = trinomial k' m' n' ↑x ↑y ↑z
hk : k = k'
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: subst hk
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
k' m' n' : ℕ
hkm' : k' < m'
hmn' : m' < n'
x y z : ℤˣ
hq : q = trinomial k' m' n' ↑x ↑y ↑z
hk : k = k'
hn : n = n'
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: subst hn
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' n' : ℕ
hmn' : m' < n'
x y z : ℤˣ
hn : n = n'
hkm' : k < m'
hq : q = trinomial k m' n' ↑x ↑y ↑z
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rcases eq_or_eq_neg_of_sq_eq_sq (y : ℤ) (v : ℤ)
    ((Int.isUnit_sq y.isUnit).trans (Int.isUnit_sq v.isUnit).symm) with
  (h1 | h1)
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑y ↑z
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rw [← mul_right_inj' (show 2 ≠ 0 from two_ne_zero), ←
  trinomial_natTrailingDegree hkm hmn u.ne_zero, ← hp, ← natTrailingDegree_mul_mirror, hpq,
  natTrailingDegree_mul_mirror, hq, trinomial_natTrailingDegree hkm' hmn' x.ne_zero]
state_before: p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
k' m' n' : ℕ
hkm' : k' < m'
hmn' : m' < n'
x y z : ℤˣ
hq : q = trinomial k' m' n' ↑x ↑y ↑z
⊢ k = k'

tactic: rw [← mul_right_inj' (show 2 ≠ 0 from two_ne_zero), ← trinomial_natDegree hkm hmn w.ne_zero, ←
  hp, ← natDegree_mul_mirror, hpq, natDegree_mul_mirror, hq,
  trinomial_natDegree hkm' hmn' z.ne_zero]
state_before: p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
k' m' n' : ℕ
hkm' : k' < m'
hmn' : m' < n'
x y z : ℤˣ
hq : q = trinomial k' m' n' ↑x ↑y ↑z
hk : k = k'
⊢ n = n'

tactic: rw [h1] at hq
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inl
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑y ↑z
h1 : ↑y = ↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rcases irreducible_aux3 hkm hmn hkm' hmn' u v w x z hp hq hpq with (h2 | h2)
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inl
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑v ↑z
h1 : ↑y = ↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: exact Or.inl h2
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inl.inl
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑v ↑z
h1 : ↑y = ↑v
h2 : q = p
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: exact Or.inr (Or.inr (Or.inl h2))
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inl.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑v ↑z
h1 : ↑y = ↑v
h2 : q = mirror p
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rw [h1] at hq
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n ↑x ↑y ↑z
h1 : ↑y = -↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rw [trinomial_def] at hp
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = trinomial k m n ↑u ↑v ↑w
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n (↑x) (-↑v) ↑z
h1 : ↑y = -↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rw [← neg_inj, neg_add, neg_add, ← neg_mul, ← neg_mul, ← neg_mul, ← C_neg, ← C_neg, ← C_neg]
  at hp
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp : p = ↑C ↑u * X ^ k + ↑C ↑v * X ^ m + ↑C ↑w * X ^ n
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n (↑x) (-↑v) ↑z
h1 : ↑y = -↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rw [← neg_mul_neg, ← mirror_neg] at hpq
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq : p * mirror p = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp✝ : p = ↑C ↑u * X ^ k + ↑C ↑v * X ^ m + ↑C ↑w * X ^ n
hp : -p = ↑C (-↑u) * X ^ k + ↑C (-↑v) * X ^ m + ↑C (-↑w) * X ^ n
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n (↑x) (-↑v) ↑z
h1 : ↑y = -↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: rcases irreducible_aux3 hkm hmn hkm' hmn' (-u) (-v) (-w) x z hp hq hpq with (rfl | rfl)
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr
p q✝ : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
q : ℤ[X]
hpq✝ : p * mirror p = q * mirror q
hpq : -p * mirror (-p) = q * mirror q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp✝ : p = ↑C ↑u * X ^ k + ↑C ↑v * X ^ m + ↑C ↑w * X ^ n
hp : -p = ↑C (-↑u) * X ^ k + ↑C (-↑v) * X ^ m + ↑C (-↑w) * X ^ n
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
hq : q = trinomial k m' n (↑x) (-↑v) ↑z
h1 : ↑y = -↑v
⊢ q = p ∨ q = -p ∨ q = mirror p ∨ q = -mirror p

tactic: exact Or.inr (Or.inl rfl)
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr.inl
p q : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp✝ : p = ↑C ↑u * X ^ k + ↑C ↑v * X ^ m + ↑C ↑w * X ^ n
hp : -p = ↑C (-↑u) * X ^ k + ↑C (-↑v) * X ^ m + ↑C (-↑w) * X ^ n
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
h1 : ↑y = -↑v
hpq✝ : p * mirror p = -p * mirror (-p)
hpq : -p * mirror (-p) = -p * mirror (-p)
hq : -p = trinomial k m' n (↑x) (-↑v) ↑z
⊢ -p = p ∨ -p = -p ∨ -p = mirror p ∨ -p = -mirror p

tactic: exact Or.inr (Or.inr (Or.inr p.mirror_neg))
state_before: case intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.intro.inr.inr
p q : ℤ[X]
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
k m n : ℕ
hkm : k < m
hmn : m < n
u v w : ℤˣ
hp✝ : p = ↑C ↑u * X ^ k + ↑C ↑v * X ^ m + ↑C ↑w * X ^ n
hp : -p = ↑C (-↑u) * X ^ k + ↑C (-↑v) * X ^ m + ↑C (-↑w) * X ^ n
m' : ℕ
x y z : ℤˣ
hkm' : k < m'
hmn' : m' < n
h1 : ↑y = -↑v
hpq✝ : p * mirror p = mirror (-p) * mirror (mirror (-p))
hpq : -p * mirror (-p) = mirror (-p) * mirror (mirror (-p))
hq : mirror (-p) = trinomial k m' n (↑x) (-↑v) ↑z
⊢ mirror (-p) = p ∨ mirror (-p) = -p ∨ mirror (-p) = mirror p ∨ mirror (-p) = -mirror p