Lean4
/-- The following two lemmas should be viewed as a hand-made "congr"-lemmas.
They achieve the following goals.
* They introduce *two* fresh metavariables replacing the given one `deg`,
one for the `natDegree ≤` computation and one for the `coeff =` computation.
This helps `compute_degree`, since it does not "pre-estimate" the degree,
but it "picks it up along the way".
* They split checking the inequality `coeff p n ≠ 0` into the task of
finding a value `c` for the `coeff` and then
proving that this value is non-zero by `coeff_ne_zero`.
-/
theorem natDegree_eq_of_le_of_coeff_ne_zero' {deg m o : ℕ} {c : R} {p : R[X]} (h_natDeg_le : natDegree p ≤ m)
(coeff_eq : coeff p o = c) (coeff_ne_zero : c ≠ 0) (deg_eq_deg : m = deg) (coeff_eq_deg : o = deg) :
natDegree p = deg := by
subst coeff_eq deg_eq_deg coeff_eq_deg
exact natDegree_eq_of_le_of_coeff_ne_zero ‹_› ‹_›