Theorem: Polynomial.mod_eq_self_iff
File: Mathlib/Algebra/Polynomial/FieldDivision.lean

tactic: classical
have : ¬degree (q * C (leadingCoeff q)⁻¹) ≤ degree p :=
  not_le_of_gt <| by rwa [degree_mul_leadingCoeff_inv q hq0]
rw [mod_def, modByMonic, dif_pos (monic_mul_leadingCoeff_inv hq0)]
unfold divModByMonicAux
dsimp
simp only [this, false_and_iff, if_false]
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
⊢ p % q = p
state_after: no goals

tactic: have : ¬degree (q * C (leadingCoeff q)⁻¹) ≤ degree p :=
  not_le_of_gt <| by rwa [degree_mul_leadingCoeff_inv q hq0]
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
⊢ p % q = p
state_after: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ p % q = p

tactic: rw [mod_def, modByMonic, dif_pos (monic_mul_leadingCoeff_inv hq0)]
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ p % q = p
state_after: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (p.divModByMonicAux ⋯).2 = p

tactic: unfold divModByMonicAux
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (p.divModByMonicAux ⋯).2 = p
state_after: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (if h : (q * C q.leadingCoeff⁻¹).degree ≤ p.degree ∧ p ≠ 0 then
        let z := C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree);
        let_fun _wf := ⋯;
        let dm := (p - q * C q.leadingCoeff⁻¹ * z).divModByMonicAux ⋯;
        (z + dm.1, dm.2)
      else (0, p)).2 =
    p

tactic: dsimp
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (if h : (q * C q.leadingCoeff⁻¹).degree ≤ p.degree ∧ p ≠ 0 then
        let z := C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree);
        let_fun _wf := ⋯;
        let dm := (p - q * C q.leadingCoeff⁻¹ * z).divModByMonicAux ⋯;
        (z + dm.1, dm.2)
      else (0, p)).2 =
    p
state_after: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (if (q * C q.leadingCoeff⁻¹).degree ≤ p.degree ∧ ¬p = 0 then
        (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree) +
            ((p -
                    q * C q.leadingCoeff⁻¹ *
                      (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree))).divModByMonicAux
                ⋯).1,
          ((p -
                  q * C q.leadingCoeff⁻¹ *
                    (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree))).divModByMonicAux
              ⋯).2)
      else (0, p)).2 =
    p

tactic: simp only [this, false_and_iff, if_false]
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
this : ¬(q * C q.leadingCoeff⁻¹).degree ≤ p.degree
⊢ (if (q * C q.leadingCoeff⁻¹).degree ≤ p.degree ∧ ¬p = 0 then
        (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree) +
            ((p -
                    q * C q.leadingCoeff⁻¹ *
                      (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree))).divModByMonicAux
                ⋯).1,
          ((p -
                  q * C q.leadingCoeff⁻¹ *
                    (C p.leadingCoeff * X ^ (p.natDegree - (q * C q.leadingCoeff⁻¹).natDegree))).divModByMonicAux
              ⋯).2)
      else (0, p)).2 =
    p
state_after: no goals

tactic: rwa [degree_mul_leadingCoeff_inv q hq0]
state_before: R : Type u
S : Type v
k : Type y
A : Type z
a b : R
n : ℕ
inst✝ : Field R
p q : R[X]
hq0 : q ≠ 0
h : p.degree < q.degree
⊢ (q * C q.leadingCoeff⁻¹).degree > p.degree
state_after: no goals