Theorem: Polynomial.exists_degree_le_of_mem_span_of_finite
File: Mathlib/RingTheory/Polynomial/Basic.lean

tactic: rcases Set.Finite.exists_maximal_wrt degree s s_fin hs with ⟨a, has, hmax⟩
state_before: R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
⊢ ∃ p' ∈ s, ∀ p ∈ Submodule.span R s, p.degree ≤ p'.degree
state_after: case intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
⊢ ∃ p' ∈ s, ∀ p ∈ Submodule.span R s, p.degree ≤ p'.degree

tactic: refine ⟨a, has, fun p hp => ?_⟩
state_before: case intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
⊢ ∃ p' ∈ s, ∀ p ∈ Submodule.span R s, p.degree ≤ p'.degree
state_after: case intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
⊢ p.degree ≤ a.degree

tactic: rcases exists_degree_le_of_mem_span hs hp with ⟨p', hp'⟩
state_before: case intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
⊢ p.degree ≤ a.degree
state_after: case intro.intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
⊢ p.degree ≤ a.degree

tactic: by_cases h : degree a ≤ degree p'
state_before: case intro.intro.intro
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
⊢ p.degree ≤ a.degree
state_after: case pos
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
h : a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree

case neg
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
h : ¬a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree

tactic: rw [← hmax p' hp'.left h] at hp'
state_before: case pos
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
h : a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree
state_after: case pos
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ a.degree
h : a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree

tactic: exact hp'.right
state_before: case pos
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ a.degree
h : a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree
state_after: no goals

tactic: exact le_trans hp'.right (not_le.mp h).le
state_before: case neg
R : Type u
S : Type u_1
inst✝ : Semiring R
s : Set R[X]
s_fin : s.Finite
hs : s.Nonempty
a : R[X]
has : a ∈ s
hmax : ∀ a' ∈ s, a.degree ≤ a'.degree → a.degree = a'.degree
p : R[X]
hp : p ∈ Submodule.span R s
p' : R[X]
hp' : p' ∈ s ∧ p.degree ≤ p'.degree
h : ¬a.degree ≤ p'.degree
⊢ p.degree ≤ a.degree
state_after: no goals