Theorem: Polynomial.exists_approx_polynomial_aux
File: Mathlib/NumberTheory/ClassNumber/AdmissibleCardPowDegree.lean

tactic: have hb : b ≠ 0 := by
  rintro rfl
  specialize hA 0
  rw [degree_zero] at hA
  exact not_lt_of_le bot_le hA
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
⊢ ∃ i₀ i₁, i₀ ≠ i₁ ∧ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: set f : Fin m.succ → Fin d → Fq := fun i j => (A i).coeff (natDegree b - j.succ)
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
⊢ ∃ i₀ i₁, i₀ ≠ i₁ ∧ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: have : Fintype.card (Fin d → Fq) < Fintype.card (Fin m.succ) := by
  simpa using lt_of_le_of_lt hm (Nat.lt_succ_self m)
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
⊢ ∃ i₀ i₁, i₀ ≠ i₁ ∧ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: obtain ⟨i₀, i₁, i_ne, i_eq⟩ := Fintype.exists_ne_map_eq_of_card_lt f this
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
⊢ ∃ i₀ i₁, i₀ ≠ i₁ ∧ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: use i₀, i₁, i_ne
state_before: case intro.intro.intro
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
⊢ ∃ i₀ i₁, i₀ ≠ i₁ ∧ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: refine' (degree_lt_iff_coeff_zero _ _).mpr fun j hj => _
state_before: case intro.intro.intro
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
⊢ degree (A i₁ - A i₀) < ↑(natDegree b - d)

tactic: by_cases hbj : degree b ≤ j
state_before: case intro.intro.intro
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
⊢ coeff (A i₁ - A i₀) j = 0

tactic: rw [coeff_sub, sub_eq_zero]
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj : ¬degree b ≤ ↑j
⊢ coeff (A i₁ - A i₀) j = 0

tactic: rw [not_le, degree_eq_natDegree hb] at hbj
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj : ¬degree b ≤ ↑j
⊢ coeff (A i₁) j = coeff (A i₀) j

tactic: have hbj : j < natDegree b := (@WithBot.coe_lt_coe _ _ _).mp hbj
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj : ↑j < ↑(natDegree b)
⊢ coeff (A i₁) j = coeff (A i₀) j

tactic: have : j = b.natDegree - (natDegree b - j.succ).succ := by
  rw [← Nat.succ_sub hbj, Nat.succ_sub_succ, tsub_tsub_cancel_of_le hbj.le]
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj✝ : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hj : natDegree b - Nat.succ j < d
⊢ coeff (A i₁) j = coeff (A i₀) j

tactic: convert congr_fun i_eq.symm ⟨natDegree b - j.succ, hj⟩
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this✝ : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj✝ : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hj : natDegree b - Nat.succ j < d
this : j = natDegree b - Nat.succ (natDegree b - Nat.succ j)
⊢ coeff (A i₁) j = coeff (A i₀) j

tactic: rintro rfl
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
⊢ b ≠ 0

tactic: specialize hA 0
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree 0
⊢ False

tactic: rw [degree_zero] at hA
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
A : Fin (Nat.succ m) → Fq[X]
hA : degree (A 0) < degree 0
⊢ False

tactic: exact not_lt_of_le bot_le hA
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
A : Fin (Nat.succ m) → Fq[X]
hA : degree (A 0) < ⊥
⊢ False

tactic: simpa using lt_of_le_of_lt hm (Nat.lt_succ_self m)
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
⊢ Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))

tactic: refine' coeff_eq_zero_of_degree_lt (lt_of_lt_of_le _ hbj)
state_before: case pos
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj : degree b ≤ ↑j
⊢ coeff (A i₁ - A i₀) j = 0

tactic: exact lt_of_le_of_lt (degree_sub_le _ _) (max_lt (hA _) (hA _))
state_before: case pos
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj : degree b ≤ ↑j
⊢ degree (A i₁ - A i₀) < degree b

tactic: by_cases hd : natDegree b < d
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
⊢ natDegree b - Nat.succ j < d

tactic: exact lt_of_le_of_lt tsub_le_self hd
state_before: case pos
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hd : natDegree b < d
⊢ natDegree b - Nat.succ j < d

tactic: rw [not_lt] at hd
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hd : ¬natDegree b < d
⊢ natDegree b - Nat.succ j < d

tactic: have := lt_of_le_of_lt hj (Nat.lt_succ_self j)
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hd : d ≤ natDegree b
⊢ natDegree b - Nat.succ j < d

tactic: rwa [tsub_lt_iff_tsub_lt hd hbj] at this
state_before: case neg
Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this✝ : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hd : d ≤ natDegree b
this : natDegree b - d < Nat.succ j
⊢ natDegree b - Nat.succ j < d

tactic: rw [← Nat.succ_sub hbj, Nat.succ_sub_succ, tsub_tsub_cancel_of_le hbj.le]
state_before: Fq : Type u_1
inst✝¹ : Fintype Fq
inst✝ : Ring Fq
d m : ℕ
hm : Fintype.card Fq ^ d ≤ m
b : Fq[X]
A : Fin (Nat.succ m) → Fq[X]
hA : ∀ (i : Fin (Nat.succ m)), degree (A i) < degree b
hb : b ≠ 0
f : Fin (Nat.succ m) → Fin d → Fq := fun i j => coeff (A i) (natDegree b - ↑(Fin.succ j))
this : Fintype.card (Fin d → Fq) < Fintype.card (Fin (Nat.succ m))
i₀ i₁ : Fin (Nat.succ m)
i_ne : i₀ ≠ i₁
i_eq : f i₀ = f i₁
j : ℕ
hj✝ : natDegree b - d ≤ j
hbj✝ : ↑j < ↑(natDegree b)
hbj : j < natDegree b
hj : natDegree b - Nat.succ j < d
⊢ j = natDegree b - Nat.succ (natDegree b - Nat.succ j)