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
p q : ℤ[X]
hp : IsUnitTrinomial p
h : ∀ (q : ℤ[X]), q ∣ p → q ∣ mirror p → IsUnit q
⊢ Irreducible p
refine' irreducible_of_mirror hp.not_isUnit (fun q hpq => _) h
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
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
have hq : IsUnitTrinomial q := (isUnitTrinomial_iff'' hpq).mp hp
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
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
obtain ⟨k, m, n, hkm, hmn, u, v, w, hp⟩ := hp
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
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
obtain ⟨k', m', n', hkm', hmn', x, y, z, hq⟩ := hq
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
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
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]
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
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
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]
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
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
subst hk
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
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
subst hn
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

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
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
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)
no goals
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'
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]
no goals
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'
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]
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
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
rw [h1] at hq
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

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
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
rcases irreducible_aux3 hkm hmn hkm' hmn' u v w x z hp hq hpq with (h2 | h2)
no goals
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
exact Or.inl h2
no goals
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
exact Or.inr (Or.inr (Or.inl h2))
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
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
rw [h1] at hq
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
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
rw [trinomial_def] at hp
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
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
rw [← neg_inj, neg_add, neg_add, ← neg_mul, ← neg_mul, ← neg_mul, ← C_neg, ← C_neg, ← C_neg]
  at hp
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
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
rw [← neg_mul_neg, ← mirror_neg] at hpq
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

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
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
rcases irreducible_aux3 hkm hmn hkm' hmn' (-u) (-v) (-w) x z hp hq hpq with (rfl | rfl)
no goals
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
exact Or.inr (Or.inl rfl)
no goals
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
exact Or.inr (Or.inr (Or.inr p.mirror_neg))