Theorem: minpoly.unique'
File: Mathlib/FieldTheory/Minpoly/Basic.lean

tactic: nontriviality A
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
⊢ p = minpoly A x

tactic: have hx : IsIntegral A x := ⟨p, hm, hp⟩
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
⊢ p = minpoly A x

tactic: obtain h | h := hl _ ((minpoly A x).degree_modByMonic_lt hm)
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
⊢ p = minpoly A x

tactic: swap
state_before: case inl
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
⊢ p = minpoly A x

case inr
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : ↑(Polynomial.aeval x) (minpoly A x %ₘ p) ≠ 0
⊢ p = minpoly A x

tactic: obtain ⟨r, hr⟩ := (dvd_iff_modByMonic_eq_zero hm).1 h
state_before: case inl
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
⊢ p = minpoly A x

tactic: rw [hr]
state_before: case inl.intro
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
⊢ p = minpoly A x

tactic: have hlead := congr_arg leadingCoeff hr
state_before: case inl.intro
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
⊢ p = p * r

tactic: rw [mul_comm, leadingCoeff_mul_monic hm, (monic hx).leadingCoeff] at hlead
state_before: case inl.intro
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : leadingCoeff (minpoly A x) = leadingCoeff (p * r)
⊢ p = p * r

tactic: have : natDegree r ≤ 0 := by
  have hr0 : r ≠ 0 := by
    rintro rfl
    exact ne_zero hx (MulZeroClass.mul_zero p ▸ hr)
  apply_fun natDegree  at hr
  rw [hm.natDegree_mul' hr0] at hr
  apply Nat.le_of_add_le_add_left
  rw [add_zero]
  exact hr.symm.trans_le (natDegree_le_natDegree <| min A x hm hp)
state_before: case inl.intro
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : 1 = leadingCoeff r
⊢ p = p * r

tactic: rw [eq_C_of_natDegree_le_zero this, ← Nat.eq_zero_of_le_zero this, ← leadingCoeff, ← hlead, C_1,
  mul_one]
state_before: case inl.intro
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : 1 = leadingCoeff r
this : natDegree r ≤ 0
⊢ p = p * r

tactic: exact (h <| (aeval_modByMonic_eq_self_of_root hm hp).trans <| aeval A x).elim
state_before: case inr
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : ↑(Polynomial.aeval x) (minpoly A x %ₘ p) ≠ 0
⊢ p = minpoly A x

tactic: have hr0 : r ≠ 0 := by
  rintro rfl
  exact ne_zero hx (MulZeroClass.mul_zero p ▸ hr)
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : 1 = leadingCoeff r
⊢ natDegree r ≤ 0

tactic: apply_fun natDegree  at hr
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
⊢ natDegree r ≤ 0

tactic: rw [hm.natDegree_mul' hr0] at hr
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree (p * r)
⊢ natDegree r ≤ 0

tactic: apply Nat.le_of_add_le_add_left
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree p + natDegree r
⊢ natDegree r ≤ 0

tactic: rw [add_zero]
state_before: case h
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree p + natDegree r
⊢ ?a + natDegree r ≤ ?a + 0

case a
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree p + natDegree r
⊢ ℕ

tactic: exact hr.symm.trans_le (natDegree_le_natDegree <| min A x hm hp)
state_before: case h
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree p + natDegree r
⊢ ?h + natDegree r ≤ ?h

case h
A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hlead : 1 = leadingCoeff r
hr0 : r ≠ 0
hr : natDegree (minpoly A x) = natDegree p + natDegree r
⊢ ℕ

tactic: rintro rfl
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
r : A[X]
hr : minpoly A x = p * r
hlead : 1 = leadingCoeff r
⊢ r ≠ 0

tactic: exact ne_zero hx (MulZeroClass.mul_zero p ▸ hr)
state_before: A : Type u_1
B : Type u_2
B' : Type ?u.42573
inst✝⁴ : CommRing A
inst✝³ : Ring B
inst✝² : Ring B'
inst✝¹ : Algebra A B
inst✝ : Algebra A B'
x : B
p : A[X]
hm : Monic p
hp : ↑(Polynomial.aeval x) p = 0
hl : ∀ (q : A[X]), degree q < degree p → q = 0 ∨ ↑(Polynomial.aeval x) q ≠ 0
✝ : Nontrivial A
hx : IsIntegral A x
h : minpoly A x %ₘ p = 0
hr : minpoly A x = p * 0
hlead : 1 = leadingCoeff 0
⊢ False