Zulip Chat Archive

Stream: Is there code for X?

Topic: Induction on leading coefficient of polynomial


Violeta Hernández (Aug 16 2025 at 11:44):

Do we have anything like this?

import Mathlib.Algebra.Polynomial.Degree.Operations

variable {R : Type*} [Ring R]
open Polynomial

theorem Polynomial.monomial_induction {motive : R[X]  Prop} (zero : motive 0)
    (add :  a n q, degree q < .some n  motive q  motive (C a * X ^ n + q)) (p : R[X]) :
    motive p := by
  induction hn : p.degree using WellFoundedLT.induction generalizing p with | ind n IH
  cases n with
  | bot => simp_all
  | coe n =>
    rw [ _root_.add_sub_cancel (C (p.coeff n) * X ^ n) p]
    have hpn : (p - C (p.coeff n) * X ^ n).degree < .some n := by
      rw [ hn]
      apply degree_sub_lt
      · simpa [degree_C_mul_X_pow _ (p.coeff_ne_zero_of_eq_degree hn)]
      · aesop
      · rw [leadingCoeff, natDegree_eq_of_degree_eq_some hn]
        simp
    exact add _ _ _ hpn (IH _ hpn _ rfl)

Violeta Hernández (Aug 16 2025 at 12:02):

I was only able to prove it for Ring R, but I think it should be true when only Semiring R.

Christian Merten (Aug 16 2025 at 12:34):

Is docs#Polynomial.induction_on not good enough?

Violeta Hernández (Aug 16 2025 at 12:35):

Nope, adding arbitrary polynomials is too strong for what I want to do

Ruben Van de Velde (Aug 16 2025 at 12:53):

Is the point of the subtraction to remove the leading term? That seems like something we should have a def for

Ruben Van de Velde (Aug 16 2025 at 12:56):

Eraselead

Ruben Van de Velde (Aug 16 2025 at 13:07):

docs#Polynomial.eraseLead , that is

Violeta Hernández (Aug 16 2025 at 13:14):

Yeah, that's much better

theorem monomial_induction {R} [Semiring R] {motive : R[X]  Prop} (zero : motive 0)
    (add :  a n q, degree q < .some n  motive q  motive (C a * X ^ n + q)) (p : R[X]) :
    motive p := by
  induction hn : p.degree using WellFoundedLT.induction generalizing p with | ind n IH
  cases n with
  | bot => simp_all
  | coe n =>
    rw [ eraseLead_add_C_mul_X_pow p, add_comm]
    have hp₀ : p  0 := by aesop
    have hpn : p.eraseLead.degree < .some n := hn  degree_eraseLead_lt hp₀
    apply add _ _ _ ((degree_eraseLead_lt hp₀).trans_eq _) (IH _ hpn _ rfl)
    rw [hn, natDegree_eq_of_degree_eq_some hn]

Yakov Pechersky (Aug 17 2025 at 01:33):

How about docs#Polynomial.degree_pos_induction_on

Violeta Hernández (Aug 17 2025 at 02:11):

That doesn't work for what I want either

Violeta Hernández (Aug 17 2025 at 02:11):

I do very specifically need to induct on the leading term


Last updated: Dec 20 2025 at 21:32 UTC