Theorem: Polynomial.mem_lifts_and_degree_eq
File: Mathlib/Algebra/Polynomial/Lifts.lean

tactic: generalize hd : p.natDegree = d
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
p : S[X]
hlifts : p ∈ lifts f
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
p : S[X]
hlifts : p ∈ lifts f
d : ℕ
hd : p.natDegree = d
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: revert hd p
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
p : S[X]
hlifts : p ∈ lifts f
d : ℕ
hd : p.natDegree = d
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
d : ℕ
⊢ ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = d → ∃ q, map f q = p ∧ q.degree = p.degree

tactic: induction' d using Nat.strong_induction_on with n hn
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
d : ℕ
⊢ ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = d → ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
⊢ ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = n → ∃ q, map f q = p ∧ q.degree = p.degree

tactic: intros p hlifts hdeg
state_before: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
⊢ ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = n → ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: by_cases erase_zero : p.eraseLead = 0
state_before: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case pos
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : p.eraseLead = 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: have deg_erase := Or.resolve_right (eraseLead_natDegree_lt_or_eraseLead_eq_zero p) erase_zero
state_before: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: have pzero : p ≠ 0 := by
  intro habs
  exfalso
  rw [habs, eraseLead_zero, eq_self_iff_true, not_true] at erase_zero
  exact erase_zero
state_before: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: have lead_zero : p.coeff p.natDegree ≠ 0 := by
  rw [← leadingCoeff, Ne, leadingCoeff_eq_zero]; exact pzero
state_before: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: obtain ⟨lead, hlead⟩ :=
  monomial_mem_lifts_and_degree_eq
    (monomial_mem_lifts p.natDegree ((lifts_iff_coeff_lifts p).1 hlifts p.natDegree))
state_before: case neg
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: have deg_lead : lead.degree = p.natDegree := by
  rw [hlead.2, ← C_mul_X_pow_eq_monomial, degree_C_mul_X_pow p.natDegree lead_zero]
state_before: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: rw [hdeg] at deg_erase
state_before: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: obtain ⟨erase, herase⟩ :=
  hn p.eraseLead.natDegree deg_erase (erase_mem_lifts p.natDegree hlifts)
    (refl p.eraseLead.natDegree)
state_before: case neg.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case neg.intro.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree

tactic: use erase + lead
state_before: case neg.intro.intro
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ map f (erase + lead) = p ∧ (erase + lead).degree = p.degree

tactic: constructor
state_before: case h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ map f (erase + lead) = p ∧ (erase + lead).degree = p.degree
state_after: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ map f (erase + lead) = p

case h.right
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (erase + lead).degree = p.degree

tactic: rw [degree_eq_natDegree pzero, ← deg_lead]
state_before: case h.right
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (erase + lead).degree = p.degree
state_after: case h.right
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (erase + lead).degree = lead.degree

tactic: apply degree_add_eq_right_of_degree_lt
state_before: case h.right
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (erase + lead).degree = lead.degree
state_after: case h.right.h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ erase.degree < lead.degree

tactic: rw [herase.2, deg_lead, ← degree_eq_natDegree pzero]
state_before: case h.right.h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ erase.degree < lead.degree
state_after: case h.right.h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (Polynomial.erase p.natDegree p).degree < p.degree

tactic: exact degree_erase_lt pzero
state_before: case h.right.h
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ (Polynomial.erase p.natDegree p).degree < p.degree
state_after: no goals

tactic: rw [← eraseLead_add_monomial_natDegree_leadingCoeff p, erase_zero, zero_add, leadingCoeff]
state_before: case pos
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : p.eraseLead = 0
⊢ ∃ q, map f q = p ∧ q.degree = p.degree
state_after: case pos
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : p.eraseLead = 0
⊢ ∃ q,
    map f q = (monomial p.natDegree) (p.coeff p.natDegree) ∧
      q.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree

tactic: exact
  monomial_mem_lifts_and_degree_eq
    (monomial_mem_lifts p.natDegree ((lifts_iff_coeff_lifts p).1 hlifts p.natDegree))
state_before: case pos
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : p.eraseLead = 0
⊢ ∃ q,
    map f q = (monomial p.natDegree) (p.coeff p.natDegree) ∧
      q.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
state_after: no goals

tactic: intro habs
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
⊢ p ≠ 0
state_after: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
habs : p = 0
⊢ False

tactic: rw [habs, eraseLead_zero, eq_self_iff_true, not_true] at erase_zero
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
habs : p = 0
⊢ False
state_after: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : False
deg_erase : p.eraseLead.natDegree < p.natDegree
habs : p = 0
⊢ False

tactic: exact erase_zero
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : False
deg_erase : p.eraseLead.natDegree < p.natDegree
habs : p = 0
⊢ False
state_after: no goals

tactic: rw [← leadingCoeff, Ne, leadingCoeff_eq_zero]
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
⊢ p.coeff p.natDegree ≠ 0
state_after: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
⊢ ¬p = 0

tactic: exact pzero
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
⊢ ¬p = 0
state_after: no goals

tactic: rw [hlead.2, ← C_mul_X_pow_eq_monomial, degree_C_mul_X_pow p.natDegree lead_zero]
state_before: R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < p.natDegree
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
⊢ lead.degree = ↑p.natDegree
state_after: no goals

tactic: simp only [hlead, herase, Polynomial.map_add]
state_before: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ map f (erase + lead) = p
state_after: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ Polynomial.erase p.natDegree p + (monomial p.natDegree) (p.coeff p.natDegree) = p

tactic: rw [← eraseLead, ← leadingCoeff]
state_before: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ Polynomial.erase p.natDegree p + (monomial p.natDegree) (p.coeff p.natDegree) = p
state_after: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ p.eraseLead + (monomial p.natDegree) p.leadingCoeff = p

tactic: rw [eraseLead_add_monomial_natDegree_leadingCoeff p]
state_before: case h.left
R : Type u
inst✝¹ : Semiring R
S : Type v
inst✝ : Semiring S
f : R →+* S
n : ℕ
hn : ∀ m < n, ∀ {p : S[X]}, p ∈ lifts f → p.natDegree = m → ∃ q, map f q = p ∧ q.degree = p.degree
p : S[X]
hlifts : p ∈ lifts f
hdeg : p.natDegree = n
erase_zero : ¬p.eraseLead = 0
deg_erase : p.eraseLead.natDegree < n
pzero : p ≠ 0
lead_zero : p.coeff p.natDegree ≠ 0
lead : R[X]
hlead :
  map f lead = (monomial p.natDegree) (p.coeff p.natDegree) ∧
    lead.degree = ((monomial p.natDegree) (p.coeff p.natDegree)).degree
deg_lead : lead.degree = ↑p.natDegree
erase : R[X]
herase : map f erase = Polynomial.erase p.natDegree p ∧ erase.degree = (Polynomial.erase p.natDegree p).degree
⊢ p.eraseLead + (monomial p.natDegree) p.leadingCoeff = p
state_after: no goals