Theorem: FiniteField.sum_pow_lt_card_sub_one
File: Mathlib/FieldTheory/Finite/Basic.lean

tactic: by_cases hi : i = 0
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
⊢ ∑ x : K, x ^ i = 0

tactic: classical
  have hiq : ¬q - 1 ∣ i := by contrapose! h; exact Nat.le_of_dvd (Nat.pos_of_ne_zero hi) h
  let φ : Kˣ ↪ K := ⟨fun x ↦ x, Units.ext⟩
  have : univ.map φ = univ \ {0} := by
    ext x
    simp only [true_and_iff, Function.Embedding.coeFn_mk, mem_sdiff, Units.exists_iff_ne_zero,
      mem_univ, mem_map, exists_prop_of_true, mem_singleton]
  calc
    (∑ x : K, x ^ i) = ∑ x in univ \ {(0 : K)}, x ^ i := by
      rw [← sum_sdiff ({0} : Finset K).subset_univ, sum_singleton,
        zero_pow (Nat.pos_of_ne_zero hi), add_zero]
    _ = ∑ x : Kˣ, (x ^ i : K) := by simp [← this, univ.sum_map φ]
    _ = 0 := by rw [sum_pow_units K i, if_neg]; exact hiq
state_before: case neg
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
⊢ ∑ x : K, x ^ i = 0

tactic: simp only [hi, nsmul_one, sum_const, pow_zero, card_univ, cast_card_eq_zero]
state_before: case pos
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : i = 0
⊢ ∑ x : K, x ^ i = 0

tactic: have hiq : ¬q - 1 ∣ i := by contrapose! h; exact Nat.le_of_dvd (Nat.pos_of_ne_zero hi) h
state_before: case neg
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
⊢ ∑ x : K, x ^ i = 0

tactic: let φ : Kˣ ↪ K := ⟨fun x ↦ x, Units.ext⟩
state_before: case neg
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
⊢ ∑ x : K, x ^ i = 0

tactic: have : univ.map φ = univ \ {0} := by
  ext x
  simp only [true_and_iff, Function.Embedding.coeFn_mk, mem_sdiff, Units.exists_iff_ne_zero,
    mem_univ, mem_map, exists_prop_of_true, mem_singleton]
state_before: case neg
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
⊢ ∑ x : K, x ^ i = 0

tactic: calc
  (∑ x : K, x ^ i) = ∑ x in univ \ {(0 : K)}, x ^ i := by
    rw [← sum_sdiff ({0} : Finset K).subset_univ, sum_singleton,
      zero_pow (Nat.pos_of_ne_zero hi), add_zero]
  _ = ∑ x : Kˣ, (x ^ i : K) := by simp [← this, univ.sum_map φ]
  _ = 0 := by rw [sum_pow_units K i, if_neg]; exact hiq
state_before: case neg
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
this : map φ univ = univ \ {0}
⊢ ∑ x : K, x ^ i = 0

tactic: contrapose! h
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
⊢ ¬q - 1 ∣ i

tactic: exact Nat.le_of_dvd (Nat.pos_of_ne_zero hi) h
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
hi : ¬i = 0
h : q - 1 ∣ i
⊢ q - 1 ≤ i

tactic: ext x
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
⊢ map φ univ = univ \ {0}

tactic: simp only [true_and_iff, Function.Embedding.coeFn_mk, mem_sdiff, Units.exists_iff_ne_zero,
  mem_univ, mem_map, exists_prop_of_true, mem_singleton]
state_before: case a
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
x : K
⊢ x ∈ map φ univ ↔ x ∈ univ \ {0}

tactic: rw [← sum_sdiff ({0} : Finset K).subset_univ, sum_singleton,
  zero_pow (Nat.pos_of_ne_zero hi), add_zero]
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
this : map φ univ = univ \ {0}
⊢ ∑ x : K, x ^ i = ∑ x in univ \ {0}, x ^ i

tactic: simp [← this, univ.sum_map φ]
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
this : map φ univ = univ \ {0}
⊢ ∑ x in univ \ {0}, x ^ i = ∑ x : Kˣ, ↑(x ^ i)

tactic: rw [sum_pow_units K i, if_neg]
state_before: K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
this : map φ univ = univ \ {0}
⊢ ∑ x : Kˣ, ↑(x ^ i) = 0

tactic: exact hiq
state_before: case hnc
K : Type u_1
R : Type ?u.640358
inst✝¹ : Field K
inst✝ : Fintype K
i : ℕ
h : i < q - 1
hi : ¬i = 0
hiq : ¬q - 1 ∣ i
φ : Kˣ ↪ K := { toFun := fun x => ↑x, inj' := (_ : Function.Injective Units.val) }
this : map φ univ = univ \ {0}
⊢ ¬q - 1 ∣ i