-- Mathlib/RingTheory/Polynomial/Cyclotomic/Eval.lean
theorem cyclotomic_pos {n : ℕ} (hn : 2 < n) {R} [LinearOrderedCommRing R] (x : R) :
    0 < eval x (cyclotomic n R)

Proof state:
case h.inl.hb.inr.inl
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
hx : 0 < x + 1
hi : 2 ≠ 1 ∧ 2 ∣ n ∧ 2 < n
⊢ 0 ≤ eval x (cyclotomic 2 R)

Tactic:
simpa only [eval_X, eval_one, cyclotomic_two, eval_add] using hx.le

Result:
no goals

Proof state:
case h.inl.hb
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : 0 < ∑ i ∈ range n, x ^ i
i : ℕ
hi : i ∈ n.properDivisors.erase 1
⊢ 0 ≤ eval x (cyclotomic i R)

Tactic:
simp only [Finset.mem_erase, mem_properDivisors] at hi

Result:
case h.inl.hb
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : 0 < ∑ i ∈ range n, x ^ i
i : ℕ
hi : i ≠ 1 ∧ i ∣ n ∧ i < n
⊢ 0 ≤ eval x (cyclotomic i R)

Proof state:
case h.inl.hb.inl.refine_2
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
hk : Odd n
hi : 2 ≠ 1 ∧ 2 ∣ n ∧ 2 < n
⊢ False

Tactic:
exact not_odd_iff_even.2 (even_iff_two_dvd.mpr hi.2.1) hk

Result:
no goals

Proof state:
case h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : ∏ i ∈ n.divisors.erase 1, cyclotomic i R = ∑ i ∈ range n, X ^ i
⊢ 0 < eval x (cyclotomic n R)

Tactic:
apply_fun eval x at this

Result:
case h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (∏ i ∈ n.divisors.erase 1, cyclotomic i R) = eval x (∑ i ∈ range n, X ^ i)
⊢ 0 < eval x (cyclotomic n R)

Proof state:
case h.inl.hb.inl.refine_1
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
hk : Odd n
hi : 0 ≠ 1 ∧ 0 ∣ n ∧ 0 < n
⊢ False

Tactic:
exact hn'.ne' (zero_dvd_iff.mp hi.2.1)

Result:
no goals

Proof state:
case h.inl.hb.inr.inr
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
i : ℕ
hi : i ≠ 1 ∧ i ∣ n ∧ i < n
hx : 0 < x + 1
hk : i ≠ 2
⊢ i ≠ 0

Tactic:
rintro rfl

Result:
case h.inl.hb.inr.inr
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
hx : 0 < x + 1
hi : 0 ≠ 1 ∧ 0 ∣ n ∧ 0 < n
hk : 0 ≠ 2
⊢ False

Proof state:
case h.inr.inr.h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : ∑ i ∈ range n, x ^ i < 0
⊢ eval x (cyclotomic n R) * ?h.inr.inr.b < 0

Tactic:
rwa [this]

Result:
no goals

Proof state:
n : ℕ
hn : 2 < n
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
⊢ 0 < eval x (cyclotomic n R)

Tactic:
induction' n using Nat.strong_induction_on with n ih

Result:
case h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
⊢ 0 < eval x (cyclotomic n R)

Proof state:
case h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
⊢ 0 < eval x (cyclotomic n R)

Tactic:
have hn'' : 1 < n := one_lt_two.trans hn

Result:
case h
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
⊢ 0 < eval x (cyclotomic n R)

Proof state:
case h.inr.inr.hb.ha
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : Even n ∧ x + 1 < 0
h2 : 2 ∈ n.properDivisors.erase 1
⊢ 0 ≤ ∏ x_1 ∈ (n.properDivisors.erase 1).erase 2, eval x (cyclotomic x_1 R)

Tactic:
refine Finset.prod_nonneg fun i hi => le_of_lt ?_

Result:
case h.inr.inr.hb.ha
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : Even n ∧ x + 1 < 0
h2 : 2 ∈ n.properDivisors.erase 1
i : ℕ
hi : i ∈ (n.properDivisors.erase 1).erase 2
⊢ 0 < eval x (cyclotomic i R)

Proof state:
case h.inr.inr.hb
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : Even n ∧ x + 1 < 0
h2 : 2 ∈ n.properDivisors.erase 1
⊢ (∏ x_1 ∈ (n.properDivisors.erase 1).erase 2, eval x (cyclotomic x_1 R)) * eval x (cyclotomic 2 R) ≤ 0

Tactic:
apply mul_nonpos_of_nonneg_of_nonpos

Result:
case h.inr.inr.hb.ha
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : Even n ∧ x + 1 < 0
h2 : 2 ∈ n.properDivisors.erase 1
⊢ 0 ≤ ∏ x_1 ∈ (n.properDivisors.erase 1).erase 2, eval x (cyclotomic x_1 R)

case h.inr.inr.hb.hb
R : Type u_1
inst✝ : LinearOrderedCommRing R
x : R
n : ℕ
ih : ∀ m < n, 2 < m → 0 < eval x (cyclotomic m R)
hn : 2 < n
hn' : 0 < n
hn'' : 1 < n
this : eval x (cyclotomic n R) * eval x (∏ x ∈ n.properDivisors.erase 1, cyclotomic x R) = ∑ i ∈ range n, x ^ i
h : Even n ∧ x + 1 < 0
h2 : 2 ∈ n.properDivisors.erase 1
⊢ eval x (cyclotomic 2 R) ≤ 0