l3lab/ntp-mathlib huggingface dataset:
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this✝ : DecidableEq R := Classical.decEq R
h : degree q ≤ degree p ∧ p ≠ 0
_wf : degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p
this : degree (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq).2 < degree q
⊢ degree
      (C (leadingCoeff p) * X ^ (natDegree p - natDegree q) +
            (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).1,
          (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).2).2 <
    degree q

Next tactic:
exact this
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
⊢ ¬degree q ≤ degree p → degree (p %ₘ q) < degree q

Next tactic:
unfold modByMonic divModByMonicAux
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
⊢ ¬degree q ≤ degree p →
    degree
        (if h : Monic q then
          (if h_1 : degree q ≤ degree p ∧ p ≠ 0 then
              let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q);
              let_fun _wf := (_ : degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p);
              let dm := divModByMonicAux (p - q * z) (_ : Monic q);
              (z + dm.1, dm.2)
            else (0, p)).2
        else p) <
      degree q

Next tactic:
dsimp
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
⊢ ¬degree q ≤ degree p →
    degree
        (if h : Monic q then
          (if degree q ≤ degree p ∧ ¬p = 0 then
              (C (leadingCoeff p) * X ^ (natDegree p - natDegree q) +
                  (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).1,
                (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).2)
            else (0, p)).2
        else p) <
      degree q

Next tactic:
rw [dif_pos hq, if_neg h]
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
⊢ ¬degree q ≤ degree p → degree (0, p).2 < degree q

Next tactic:
exact lt_of_not_ge
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          exact lt_of_not_ge)
        (by
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
⊢ ¬p ≠ 0 → degree (p %ₘ q) < degree q

Next tactic:
intro hp
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          exact lt_of_not_ge)
        (by
          intro hp
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
hp : ¬p ≠ 0
⊢ degree (p %ₘ q) < degree q

Next tactic:
unfold modByMonic divModByMonicAux
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          exact lt_of_not_ge)
        (by
          intro hp
          unfold modByMonic divModByMonicAux
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
hp : ¬p ≠ 0
⊢ degree
      (if h : Monic q then
        (if h_1 : degree q ≤ degree p ∧ p ≠ 0 then
            let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree q);
            let_fun _wf := (_ : degree (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) < degree p);
            let dm := divModByMonicAux (p - q * z) (_ : Monic q);
            (z + dm.1, dm.2)
          else (0, p)).2
      else p) <
    degree q

Next tactic:
dsimp
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          exact lt_of_not_ge)
        (by
          intro hp
          unfold modByMonic divModByMonicAux
          dsimp
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
hp : ¬p ≠ 0
⊢ degree
      (if h : Monic q then
        (if degree q ≤ degree p ∧ ¬p = 0 then
            (C (leadingCoeff p) * X ^ (natDegree p - natDegree q) +
                (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).1,
              (divModByMonicAux (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) (_ : Monic q)).2)
          else (0, p)).2
      else p) <
    degree q

Next tactic:
rw [dif_pos hq, if_neg h, Classical.not_not.1 hp]
theorem degree_modByMonic_lt [Nontrivial R] :
    ∀ (p : R[X]) {q : R[X]} (_hq : Monic q), degree (p %ₘ q) < degree q
  | p, q, hq =>
    letI := Classical.decEq R
    if h : degree q ≤ degree p ∧ p ≠ 0 then by
      have _wf := div_wf_lemma ⟨h.1, h.2⟩ hq
      have :=
        degree_modByMonic_lt (p - q * (C (leadingCoeff p) * X ^ (natDegree p - natDegree q))) hq
      unfold modByMonic at this ⊢
      unfold divModByMonicAux
      dsimp
      rw [dif_pos hq] at this ⊢
      rw [if_pos h]
      exact this
    else
      Or.casesOn (not_and_or.1 h)
        (by
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h]
          exact lt_of_not_ge)
        (by
          intro hp
          unfold modByMonic divModByMonicAux
          dsimp
          rw [dif_pos hq, if_neg h, Classical.not_not.1 hp]
          

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝¹ : Ring R
p✝ q✝ : R[X]
inst✝ : Nontrivial R
p q : R[X]
hq : Monic q
this : DecidableEq R := Classical.decEq R
h : ¬(degree q ≤ degree p ∧ p ≠ 0)
hp : ¬p ≠ 0
⊢ degree (0, 0).2 < degree q

Next tactic:
exact lt_of_le_of_ne bot_le (Ne.symm (mt degree_eq_bot.1 hq.ne_zero))
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hq : q ≠ 1
⊢ natDegree (p %ₘ q) < natDegree q

Next tactic:
by_cases hpq : p %ₘ q = 0
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  by_cases hpq : p %ₘ q = 0
  · 

Proof state:
case pos
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hq : q ≠ 1
hpq : p %ₘ q = 0
⊢ natDegree (p %ₘ q) < natDegree q

Next tactic:
rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  by_cases hpq : p %ₘ q = 0
  · rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
    

Proof state:
case pos
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hq : q ≠ 1
hpq : p %ₘ q = 0
⊢ natDegree q ≠ 0

Next tactic:
contrapose! hq
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  by_cases hpq : p %ₘ q = 0
  · rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
    contrapose! hq
    

Proof state:
case pos
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hpq : p %ₘ q = 0
hq : natDegree q = 0
⊢ q = 1

Next tactic:
exact eq_one_of_monic_natDegree_zero hmq hq
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  by_cases hpq : p %ₘ q = 0
  · rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
    contrapose! hq
    exact eq_one_of_monic_natDegree_zero hmq hq
  · 

Proof state:
case neg
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hq : q ≠ 1
hpq : ¬p %ₘ q = 0
⊢ natDegree (p %ₘ q) < natDegree q

Next tactic:
haveI := Nontrivial.of_polynomial_ne hpq
theorem natDegree_modByMonic_lt (p : R[X]) {q : R[X]} (hmq : Monic q) (hq : q ≠ 1) :
    natDegree (p %ₘ q) < q.natDegree := by
  by_cases hpq : p %ₘ q = 0
  · rw [hpq, natDegree_zero, Nat.pos_iff_ne_zero]
    contrapose! hq
    exact eq_one_of_monic_natDegree_zero hmq hq
  · haveI := Nontrivial.of_polynomial_ne hpq
    

Proof state:
case neg
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q✝ p q : R[X]
hmq : Monic q
hq : q ≠ 1
hpq : ¬p %ₘ q = 0
this : Nontrivial R
⊢ natDegree (p %ₘ q) < natDegree q

Next tactic:
exact natDegree_lt_natDegree hpq (degree_modByMonic_lt p hmq)
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ 0 %ₘ p = 0

Next tactic:
classical
  unfold modByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
  · rw [dif_neg hp]
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  classical
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ 0 %ₘ p = 0

Next tactic:
unfold modByMonic divModByMonicAux
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  classical
  unfold modByMonic divModByMonicAux
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ (if h : Monic p then
      (if h_1 : degree p ≤ degree 0 ∧ 0 ≠ 0 then
          let z := C (leadingCoeff 0) * X ^ (natDegree 0 - natDegree p);
          let_fun _wf := (_ : degree (0 - p * (C (leadingCoeff 0) * X ^ (natDegree 0 - natDegree p))) < degree 0);
          let dm := divModByMonicAux (0 - p * z) (_ : Monic p);
          (z + dm.1, dm.2)
        else (0, 0)).2
    else 0) =
    0

Next tactic:
dsimp
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  classical
  unfold modByMonic divModByMonicAux
  dsimp
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).2
    else 0) =
    0

Next tactic:
by_cases hp : Monic p
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  classical
  unfold modByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · 

Proof state:
case pos
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
hp : Monic p
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).2
    else 0) =
    0

Next tactic:
rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
@[simp]
theorem zero_modByMonic (p : R[X]) : 0 %ₘ p = 0 := by
  classical
  unfold modByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
  · 

Proof state:
case neg
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
hp : ¬Monic p
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).2
    else 0) =
    0

Next tactic:
rw [dif_neg hp]
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ 0 /ₘ p = 0

Next tactic:
classical
  unfold divByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
  · rw [dif_neg hp]
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  classical
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ 0 /ₘ p = 0

Next tactic:
unfold divByMonic divModByMonicAux
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  classical
  unfold divByMonic divModByMonicAux
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ (if h : Monic p then
      (if h_1 : degree p ≤ degree 0 ∧ 0 ≠ 0 then
          let z := C (leadingCoeff 0) * X ^ (natDegree 0 - natDegree p);
          let_fun _wf := (_ : degree (0 - p * (C (leadingCoeff 0) * X ^ (natDegree 0 - natDegree p))) < degree 0);
          let dm := divModByMonicAux (0 - p * z) (_ : Monic p);
          (z + dm.1, dm.2)
        else (0, 0)).1
    else 0) =
    0

Next tactic:
dsimp
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  classical
  unfold divByMonic divModByMonicAux
  dsimp
  

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).1
    else 0) =
    0

Next tactic:
by_cases hp : Monic p
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  classical
  unfold divByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · 

Proof state:
case pos
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
hp : Monic p
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).1
    else 0) =
    0

Next tactic:
rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
@[simp]
theorem zero_divByMonic (p : R[X]) : 0 /ₘ p = 0 := by
  classical
  unfold divByMonic divModByMonicAux
  dsimp
  by_cases hp : Monic p
  · rw [dif_pos hp, if_neg (mt And.right (not_not_intro rfl))]
  · 

Proof state:
case neg
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
hp : ¬Monic p
⊢ (if h : Monic p then
      (if degree p ≤ ⊥ ∧ ¬0 = 0 then
          (C 0 * X ^ (0 - natDegree p) + (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).1,
            (divModByMonicAux (0 - p * (C 0 * X ^ (0 - natDegree p))) (_ : Monic p)).2)
        else (0, 0)).1
    else 0) =
    0

Next tactic:
rw [dif_neg hp]
@[simp]
theorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this : DecidableEq R := Classical.decEq R
h : Monic 0
⊢ p %ₘ 0 = p

Next tactic:
haveI := monic_zero_iff_subsingleton.mp h
@[simp]
theorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    haveI := monic_zero_iff_subsingleton.mp h
    

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this✝ : DecidableEq R := Classical.decEq R
h : Monic 0
this : Subsingleton R
⊢ p %ₘ 0 = p

Next tactic:
simp [eq_iff_true_of_subsingleton]
@[simp]
theorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    haveI := monic_zero_iff_subsingleton.mp h
    simp [eq_iff_true_of_subsingleton]
  else by 

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this : DecidableEq R := Classical.decEq R
h : ¬Monic 0
⊢ p %ₘ 0 = p

Next tactic:
unfold modByMonic divModByMonicAux
@[simp]
theorem modByMonic_zero (p : R[X]) : p %ₘ 0 = p :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    haveI := monic_zero_iff_subsingleton.mp h
    simp [eq_iff_true_of_subsingleton]
  else by unfold modByMonic divModByMonicAux; 

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this : DecidableEq R := Classical.decEq R
h : ¬Monic 0
⊢ (if h : Monic 0 then
      (if h_1 : degree 0 ≤ degree p ∧ p ≠ 0 then
          let z := C (leadingCoeff p) * X ^ (natDegree p - natDegree 0);
          let_fun _wf := (_ : degree (p - 0 * (C (leadingCoeff p) * X ^ (natDegree p - natDegree 0))) < degree p);
          let dm := divModByMonicAux (p - 0 * z) (_ : Monic 0);
          (z + dm.1, dm.2)
        else (0, p)).2
    else p) =
    p

Next tactic:
rw [dif_neg h]
@[simp]
theorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this : DecidableEq R := Classical.decEq R
h : Monic 0
⊢ p /ₘ 0 = 0

Next tactic:
haveI := monic_zero_iff_subsingleton.mp h
@[simp]
theorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    haveI := monic_zero_iff_subsingleton.mp h
    

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this✝ : DecidableEq R := Classical.decEq R
h : Monic 0
this : Subsingleton R
⊢ p /ₘ 0 = 0

Next tactic:
simp [eq_iff_true_of_subsingleton]
@[simp]
theorem divByMonic_zero (p : R[X]) : p /ₘ 0 = 0 :=
  letI := Classical.decEq R
  if h : Monic (0 : R[X]) then by
    haveI := monic_zero_iff_subsingleton.mp h
    simp [eq_iff_true_of_subsingleton]
  else by 

Proof state:
R : Type u
S : Type v
T : Type w
A : Type z
a b : R
n : ℕ
inst✝ : Ring R
p✝ q p : R[X]
this : DecidableEq R := Classical.decEq R
h : ¬Monic 0
⊢ p /ₘ 0 = 0

Next tactic:
unfold divByMonic divModByMonicAux