l3lab/ntp-mathlib huggingface dataset:
/-- Define a `CommRing` structure on a Type by proving a minimized set of axioms.
Note that this uses the default definitions for `npow`, `nsmul`, `zsmul` and `sub`
See note [reducible non-instances]. -/
@[reducible]
def CommRing.ofMinimalAxioms {R : Type u}
    [Add R] [Mul R] [Neg R] [Zero R] [One R]
    (add_assoc : ∀ a b c : R, a + b + c = a + (b + c))
    (zero_add : ∀ a : R, 0 + a = a)
    (add_left_neg : ∀ a : R, -a + a = 0)
    (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c))
    (mul_comm : ∀ a b : R, a * b = b * a)
    (one_mul : ∀ a : R, 1 * a = a)
    (left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c) : CommRing R :=
  haveI mul_one : ∀ a : R, a * 1 = a := fun a => by
    

Proof state:
R : Type u
inst✝⁴ : Add R
inst✝³ : Mul R
inst✝² : Neg R
inst✝¹ : Zero R
inst✝ : One R
add_assoc : ∀ (a b c : R), a + b + c = a + (b + c)
zero_add : ∀ (a : R), 0 + a = a
add_left_neg : ∀ (a : R), -a + a = 0
mul_assoc : ∀ (a b c : R), a * b * c = a * (b * c)
mul_comm : ∀ (a b : R), a * b = b * a
one_mul : ∀ (a : R), 1 * a = a
left_distrib : ∀ (a b c : R), a * (b + c) = a * b + a * c
a : R
⊢ a * 1 = a

Next tactic:
rw [mul_comm, one_mul]
/-- Define a `CommRing` structure on a Type by proving a minimized set of axioms.
Note that this uses the default definitions for `npow`, `nsmul`, `zsmul` and `sub`
See note [reducible non-instances]. -/
@[reducible]
def CommRing.ofMinimalAxioms {R : Type u}
    [Add R] [Mul R] [Neg R] [Zero R] [One R]
    (add_assoc : ∀ a b c : R, a + b + c = a + (b + c))
    (zero_add : ∀ a : R, 0 + a = a)
    (add_left_neg : ∀ a : R, -a + a = 0)
    (mul_assoc : ∀ a b c : R, a * b * c = a * (b * c))
    (mul_comm : ∀ a b : R, a * b = b * a)
    (one_mul : ∀ a : R, 1 * a = a)
    (left_distrib : ∀ a b c : R, a * (b + c) = a * b + a * c) : CommRing R :=
  haveI mul_one : ∀ a : R, a * 1 = a := fun a => by
    rw [mul_comm, one_mul]
  haveI right_distrib : ∀ a b c : R, (a + b) * c = a * c + b * c := fun a b c => by
    

Proof state:
R : Type u
inst✝⁴ : Add R
inst✝³ : Mul R
inst✝² : Neg R
inst✝¹ : Zero R
inst✝ : One R
add_assoc : ∀ (a b c : R), a + b + c = a + (b + c)
zero_add : ∀ (a : R), 0 + a = a
add_left_neg : ∀ (a : R), -a + a = 0
mul_assoc : ∀ (a b c : R), a * b * c = a * (b * c)
mul_comm : ∀ (a b : R), a * b = b * a
one_mul : ∀ (a : R), 1 * a = a
left_distrib : ∀ (a b c : R), a * (b + c) = a * b + a * c
mul_one : ∀ (a : R), a * 1 = a
a b c : R
⊢ (a + b) * c = a * c + b * c

Next tactic:
rw [mul_comm, left_distrib, mul_comm, mul_comm b c]
/-- The weak-star topology is coarser than the dual-norm topology. -/
theorem dual_norm_topology_le_weak_dual_topology :
    (UniformSpace.toTopologicalSpace : TopologicalSpace (Dual 𝕜 E)) ≤
      (WeakDual.instTopologicalSpace : TopologicalSpace (WeakDual 𝕜 E)) := by
  

Proof state:
𝕜 : Type u_1
inst✝² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝¹ : SeminormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
⊢ UniformSpace.toTopologicalSpace ≤ WeakDual.instTopologicalSpace

Next tactic:
convert (@toWeakDual_continuous _ _ _ _ (by assumption)).le_induced
/-- The weak-star topology is coarser than the dual-norm topology. -/
theorem dual_norm_topology_le_weak_dual_topology :
    (UniformSpace.toTopologicalSpace : TopologicalSpace (Dual 𝕜 E)) ≤
      (WeakDual.instTopologicalSpace : TopologicalSpace (WeakDual 𝕜 E)) := by
  convert (@toWeakDual_continuous _ _ _ _ (by 

Proof state:
𝕜 : Type u_1
inst✝² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝¹ : SeminormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
⊢ NormedSpace 𝕜 E

Next tactic:
assumption
/-- The weak-star topology is coarser than the dual-norm topology. -/
theorem dual_norm_topology_le_weak_dual_topology :
    (UniformSpace.toTopologicalSpace : TopologicalSpace (Dual 𝕜 E)) ≤
      (WeakDual.instTopologicalSpace : TopologicalSpace (WeakDual 𝕜 E)) := by
  convert (@toWeakDual_continuous _ _ _ _ (by assumption)).le_induced
  

Proof state:
case h.e'_4
𝕜 : Type u_1
inst✝² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝¹ : SeminormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
⊢ WeakDual.instTopologicalSpace = TopologicalSpace.induced (fun x' => toWeakDual x') WeakDual.instTopologicalSpace

Next tactic:
exact induced_id.symm
/-- The polar `polar 𝕜 s` of a set `s : E` is a closed subset when the weak star topology
is used. -/
theorem isClosed_polar (s : Set E) : IsClosed (polar 𝕜 s) := by
  

Proof state:
𝕜 : Type u_1
inst✝² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝¹ : SeminormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
s : Set E
⊢ IsClosed (polar 𝕜 s)

Next tactic:
simp only [polar_def, setOf_forall]
/-- The polar `polar 𝕜 s` of a set `s : E` is a closed subset when the weak star topology
is used. -/
theorem isClosed_polar (s : Set E) : IsClosed (polar 𝕜 s) := by
  simp only [polar_def, setOf_forall]
  

Proof state:
𝕜 : Type u_1
inst✝² : NontriviallyNormedField 𝕜
E : Type u_2
inst✝¹ : SeminormedAddCommGroup E
inst✝ : NormedSpace 𝕜 E
s : Set E
⊢ IsClosed (⋂ i ∈ s, {x | ‖x i‖ ≤ 1})

Next tactic:
exact isClosed_biInter fun x hx => isClosed_Iic.preimage (WeakBilin.eval_continuous _ _).norm
theorem trailingDegree_eq_top : trailingDegree p = ⊤ ↔ p = 0 :=
  ⟨fun h => support_eq_empty.1 (Finset.min_eq_top.1 h), fun h => by 

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : p = 0
⊢ trailingDegree p = ⊤

Next tactic:
simp [h]
theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) :
    trailingDegree p = (natTrailingDegree p : ℕ∞) := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p ≠ 0
⊢ trailingDegree p = ↑(natTrailingDegree p)

Next tactic:
let ⟨n, hn⟩ :=
    not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp))
theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) :
    trailingDegree p = (natTrailingDegree p : ℕ∞) := by
  let ⟨n, hn⟩ :=
    not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp))
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p ≠ 0
n : ℕ
hn : ¬n ∉ trailingDegree p
⊢ trailingDegree p = ↑(natTrailingDegree p)

Next tactic:
have hn : trailingDegree p = n := Classical.not_not.1 hn
theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) :
    trailingDegree p = (natTrailingDegree p : ℕ∞) := by
  let ⟨n, hn⟩ :=
    not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp))
  have hn : trailingDegree p = n := Classical.not_not.1 hn
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p ≠ 0
n : ℕ
hn✝ : ¬n ∉ trailingDegree p
hn : trailingDegree p = ↑n
⊢ trailingDegree p = ↑(natTrailingDegree p)

Next tactic:
rw [natTrailingDegree, hn]
theorem trailingDegree_eq_natTrailingDegree (hp : p ≠ 0) :
    trailingDegree p = (natTrailingDegree p : ℕ∞) := by
  let ⟨n, hn⟩ :=
    not_forall.1 (mt Option.eq_none_iff_forall_not_mem.2 (mt trailingDegree_eq_top.1 hp))
  have hn : trailingDegree p = n := Classical.not_not.1 hn
  rw [natTrailingDegree, hn]
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p ≠ 0
n : ℕ
hn✝ : ¬n ∉ trailingDegree p
hn : trailingDegree p = ↑n
⊢ ↑n = ↑(Option.getD (↑n) 0)

Next tactic:
rfl
theorem trailingDegree_eq_iff_natTrailingDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hp : p ≠ 0
⊢ trailingDegree p = ↑n ↔ natTrailingDegree p = n

Next tactic:
rw [trailingDegree_eq_natTrailingDegree hp]
theorem trailingDegree_eq_iff_natTrailingDegree_eq {p : R[X]} {n : ℕ} (hp : p ≠ 0) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  rw [trailingDegree_eq_natTrailingDegree hp]
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hp : p ≠ 0
⊢ ↑(natTrailingDegree p) = ↑n ↔ natTrailingDegree p = n

Next tactic:
exact WithTop.coe_eq_coe
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
⊢ trailingDegree p = ↑n ↔ natTrailingDegree p = n

Next tactic:
constructor
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · 

Proof state:
case mp
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
⊢ trailingDegree p = ↑n → natTrailingDegree p = n

Next tactic:
intro H
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    

Proof state:
case mp
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
H : trailingDegree p = ↑n
⊢ natTrailingDegree p = n

Next tactic:
rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    

Proof state:
case mp
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
H : trailingDegree p = ↑n
⊢ p ≠ 0

Next tactic:
rintro rfl
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    

Proof state:
case mp
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hn : 0 < n
H : trailingDegree 0 = ↑n
⊢ False

Next tactic:
rw [trailingDegree_zero] at H
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    

Proof state:
case mp
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hn : 0 < n
H : ⊤ = ↑n
⊢ False

Next tactic:
exact Option.noConfusion H
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · 

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
⊢ natTrailingDegree p = n → trailingDegree p = ↑n

Next tactic:
intro H
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · intro H
    

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
H : natTrailingDegree p = n
⊢ trailingDegree p = ↑n

Next tactic:
rwa [trailingDegree_eq_iff_natTrailingDegree_eq]
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · intro H
    rwa [trailingDegree_eq_iff_natTrailingDegree_eq]
    

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
hn : 0 < n
H : natTrailingDegree p = n
⊢ p ≠ 0

Next tactic:
rintro rfl
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · intro H
    rwa [trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hn : 0 < n
H : natTrailingDegree 0 = n
⊢ False

Next tactic:
rw [natTrailingDegree_zero] at H
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · intro H
    rwa [trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [natTrailingDegree_zero] at H
    

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hn : 0 < n
H : 0 = n
⊢ False

Next tactic:
rw [H] at hn
theorem trailingDegree_eq_iff_natTrailingDegree_eq_of_pos {p : R[X]} {n : ℕ} (hn : 0 < n) :
    p.trailingDegree = n ↔ p.natTrailingDegree = n := by
  constructor
  · intro H
    rwa [← trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [trailingDegree_zero] at H
    exact Option.noConfusion H
  · intro H
    rwa [trailingDegree_eq_iff_natTrailingDegree_eq]
    rintro rfl
    rw [natTrailingDegree_zero] at H
    rw [H] at hn
    

Proof state:
case mpr
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hn : n < n
H : 0 = n
⊢ False

Next tactic:
exact lt_irrefl _ hn
theorem natTrailingDegree_eq_of_trailingDegree_eq_some {p : R[X]} {n : ℕ}
    (h : trailingDegree p = n) : natTrailingDegree p = n :=
  have hp0 : p ≠ 0 := fun hp0 => by 

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
h : trailingDegree p = ↑n
hp0 : p = 0
⊢ False

Next tactic:
rw [hp0] at h
theorem natTrailingDegree_eq_of_trailingDegree_eq_some {p : R[X]} {n : ℕ}
    (h : trailingDegree p = n) : natTrailingDegree p = n :=
  have hp0 : p ≠ 0 := fun hp0 => by rw [hp0] at h; 

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
h : trailingDegree 0 = ↑n
hp0 : p = 0
⊢ False

Next tactic:
exact Option.noConfusion h
theorem natTrailingDegree_eq_of_trailingDegree_eq_some {p : R[X]} {n : ℕ}
    (h : trailingDegree p = n) : natTrailingDegree p = n :=
  have hp0 : p ≠ 0 := fun hp0 => by rw [hp0] at h; exact Option.noConfusion h
  Option.some_inj.1 <|
    show (natTrailingDegree p : ℕ∞) = n by 

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p✝ q r p : R[X]
n : ℕ
h : trailingDegree p = ↑n
hp0 : p ≠ 0
⊢ ↑(natTrailingDegree p) = ↑n

Next tactic:
rwa [← trailingDegree_eq_natTrailingDegree hp0]
@[simp]
theorem natTrailingDegree_le_trailingDegree : ↑(natTrailingDegree p) ≤ trailingDegree p := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
⊢ ↑(natTrailingDegree p) ≤ trailingDegree p

Next tactic:
by_cases hp : p = 0
@[simp]
theorem natTrailingDegree_le_trailingDegree : ↑(natTrailingDegree p) ≤ trailingDegree p := by
  by_cases hp : p = 0;
  · 

Proof state:
case pos
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p = 0
⊢ ↑(natTrailingDegree p) ≤ trailingDegree p

Next tactic:
rw [hp, trailingDegree_zero]
@[simp]
theorem natTrailingDegree_le_trailingDegree : ↑(natTrailingDegree p) ≤ trailingDegree p := by
  by_cases hp : p = 0;
  · rw [hp, trailingDegree_zero]
    

Proof state:
case pos
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : p = 0
⊢ ↑(natTrailingDegree 0) ≤ ⊤

Next tactic:
exact le_top
@[simp]
theorem natTrailingDegree_le_trailingDegree : ↑(natTrailingDegree p) ≤ trailingDegree p := by
  by_cases hp : p = 0;
  · rw [hp, trailingDegree_zero]
    exact le_top
  

Proof state:
case neg
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
hp : ¬p = 0
⊢ ↑(natTrailingDegree p) ≤ trailingDegree p

Next tactic:
rw [trailingDegree_eq_natTrailingDegree hp]
theorem natTrailingDegree_eq_of_trailingDegree_eq [Semiring S] {q : S[X]}
    (h : trailingDegree p = trailingDegree q) : natTrailingDegree p = natTrailingDegree q := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝¹ : Semiring R
p q✝ r : R[X]
inst✝ : Semiring S
q : S[X]
h : trailingDegree p = trailingDegree q
⊢ natTrailingDegree p = natTrailingDegree q

Next tactic:
unfold natTrailingDegree
theorem natTrailingDegree_eq_of_trailingDegree_eq [Semiring S] {q : S[X]}
    (h : trailingDegree p = trailingDegree q) : natTrailingDegree p = natTrailingDegree q := by
  unfold natTrailingDegree
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝¹ : Semiring R
p q✝ r : R[X]
inst✝ : Semiring S
q : S[X]
h : trailingDegree p = trailingDegree q
⊢ Option.getD (trailingDegree p) 0 = Option.getD (trailingDegree q) 0

Next tactic:
rw [h]
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff p n ≠ 0
⊢ natTrailingDegree p ≤ n

Next tactic:
have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff p n ≠ 0
this : ↑(natTrailingDegree p) = ↑(natTrailingDegree p)
⊢ natTrailingDegree p ≤ n

Next tactic:
rw [← WithTop.coe_le_coe, this, ← trailingDegree_eq_natTrailingDegree]
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
  rw [← WithTop.coe_le_coe, this, ← trailingDegree_eq_natTrailingDegree]
  · 

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff p n ≠ 0
this : ↑(natTrailingDegree p) = ↑(natTrailingDegree p)
⊢ trailingDegree p ≤ ↑n

Next tactic:
exact le_trailingDegree_of_ne_zero h
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
  rw [← WithTop.coe_le_coe, this, ← trailingDegree_eq_natTrailingDegree]
  · exact le_trailingDegree_of_ne_zero h
  · 

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff p n ≠ 0
this : ↑(natTrailingDegree p) = ↑(natTrailingDegree p)
⊢ p ≠ 0

Next tactic:
intro h
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
  rw [← WithTop.coe_le_coe, this, ← trailingDegree_eq_natTrailingDegree]
  · exact le_trailingDegree_of_ne_zero h
  · intro h
    

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h✝ : coeff p n ≠ 0
this : ↑(natTrailingDegree p) = ↑(natTrailingDegree p)
h : p = 0
⊢ False

Next tactic:
subst h
theorem natTrailingDegree_le_of_ne_zero (h : coeff p n ≠ 0) : natTrailingDegree p ≤ n := by
  have : WithTop.some (natTrailingDegree p) = Nat.cast (natTrailingDegree p) := rfl
  rw [← WithTop.coe_le_coe, this, ← trailingDegree_eq_natTrailingDegree]
  · exact le_trailingDegree_of_ne_zero h
  · intro h
    subst h
    

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
q r : R[X]
h : coeff 0 n ≠ 0
this : ↑(natTrailingDegree 0) = ↑(natTrailingDegree 0)
⊢ False

Next tactic:
exact h rfl
theorem trailingDegree_le_trailingDegree (h : coeff q (natTrailingDegree p) ≠ 0) :
    trailingDegree q ≤ trailingDegree p := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff q (natTrailingDegree p) ≠ 0
⊢ trailingDegree q ≤ trailingDegree p

Next tactic:
by_cases hp : p = 0
theorem trailingDegree_le_trailingDegree (h : coeff q (natTrailingDegree p) ≠ 0) :
    trailingDegree q ≤ trailingDegree p := by
  by_cases hp : p = 0
  · 

Proof state:
case pos
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff q (natTrailingDegree p) ≠ 0
hp : p = 0
⊢ trailingDegree q ≤ trailingDegree p

Next tactic:
rw [hp]
theorem trailingDegree_le_trailingDegree (h : coeff q (natTrailingDegree p) ≠ 0) :
    trailingDegree q ≤ trailingDegree p := by
  by_cases hp : p = 0
  · rw [hp]
    

Proof state:
case pos
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff q (natTrailingDegree p) ≠ 0
hp : p = 0
⊢ trailingDegree q ≤ trailingDegree 0

Next tactic:
exact le_top
theorem trailingDegree_le_trailingDegree (h : coeff q (natTrailingDegree p) ≠ 0) :
    trailingDegree q ≤ trailingDegree p := by
  by_cases hp : p = 0
  · rw [hp]
    exact le_top
  · 

Proof state:
case neg
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff q (natTrailingDegree p) ≠ 0
hp : ¬p = 0
⊢ trailingDegree q ≤ trailingDegree p

Next tactic:
rw [trailingDegree_eq_natTrailingDegree hp]
theorem trailingDegree_le_trailingDegree (h : coeff q (natTrailingDegree p) ≠ 0) :
    trailingDegree q ≤ trailingDegree p := by
  by_cases hp : p = 0
  · rw [hp]
    exact le_top
  · rw [trailingDegree_eq_natTrailingDegree hp]
    

Proof state:
case neg
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
h : coeff q (natTrailingDegree p) ≠ 0
hp : ¬p = 0
⊢ trailingDegree q ≤ ↑(natTrailingDegree p)

Next tactic:
exact le_trailingDegree_of_ne_zero h
theorem trailingDegree_ne_of_natTrailingDegree_ne {n : ℕ} :
    p.natTrailingDegree ≠ n → trailingDegree p ≠ n := by
  -- Porting note: Needed to account for different coercion behaviour & add the lemma below
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
⊢ natTrailingDegree p ≠ n → trailingDegree p ≠ ↑n

Next tactic:
have : Nat.cast n = WithTop.some n := rfl
theorem trailingDegree_ne_of_natTrailingDegree_ne {n : ℕ} :
    p.natTrailingDegree ≠ n → trailingDegree p ≠ n := by
  -- Porting note: Needed to account for different coercion behaviour & add the lemma below
  have : Nat.cast n = WithTop.some n := rfl
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
this : ↑n = ↑n
⊢ natTrailingDegree p ≠ n → trailingDegree p ≠ ↑n

Next tactic:
exact mt fun h => by rw [natTrailingDegree, h, this, ← WithTop.some_eq_coe, Option.getD_some]
theorem trailingDegree_ne_of_natTrailingDegree_ne {n : ℕ} :
    p.natTrailingDegree ≠ n → trailingDegree p ≠ n := by
  -- Porting note: Needed to account for different coercion behaviour & add the lemma below
  have : Nat.cast n = WithTop.some n := rfl
  exact mt fun h => by 

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
this : ↑n = ↑n
h : trailingDegree p = ↑n
⊢ natTrailingDegree p = n

Next tactic:
rw [natTrailingDegree, h, this, ← WithTop.some_eq_coe, Option.getD_some]
theorem natTrailingDegree_le_of_trailingDegree_le {n : ℕ} {hp : p ≠ 0}
    (H : (n : ℕ∞) ≤ trailingDegree p) : n ≤ natTrailingDegree p := by
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hp : p ≠ 0
H : ↑n ≤ trailingDegree p
⊢ n ≤ natTrailingDegree p

Next tactic:
rw [trailingDegree_eq_natTrailingDegree hp] at H
theorem natTrailingDegree_le_of_trailingDegree_le {n : ℕ} {hp : p ≠ 0}
    (H : (n : ℕ∞) ≤ trailingDegree p) : n ≤ natTrailingDegree p := by
  rw [trailingDegree_eq_natTrailingDegree hp] at H
  

Proof state:
R : Type u
S : Type v
a b : R
n✝ m : ℕ
inst✝ : Semiring R
p q r : R[X]
n : ℕ
hp : p ≠ 0
H : ↑n ≤ ↑(natTrailingDegree p)
⊢ n ≤ natTrailingDegree p

Next tactic:
exact WithTop.coe_le_coe.mp H
theorem natTrailingDegree_le_natTrailingDegree {hq : q ≠ 0}
    (hpq : p.trailingDegree ≤ q.trailingDegree) : p.natTrailingDegree ≤ q.natTrailingDegree := by
  

Proof state:
R : Type u
S : Type v
a b : R
n m : ℕ
inst✝ : Semiring R
p q r : R[X]
hq : q ≠ 0
hpq : trailingDegree p ≤ trailingDegree q
⊢ natTrailingDegree p ≤ natTrailingDegree q

Next tactic:
by_cases hp : p = 0