Theorem: odd_sq_dvd_geom_sum₂_sub
File: Mathlib/NumberTheory/Multiplicity.lean

tactic: have h1 : ∀ (i : ℕ),
    (p : R) ^ 2 ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * i + a ^ i) := by
  intro i
  calc
    ↑p ^ 2 ∣ (↑p * b) ^ 2 := by simp only [mul_pow, dvd_mul_right]
    _ ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i) := by
      simp only [sq_dvd_add_pow_sub_sub (↑p * b) a i, ← sub_sub]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
⊢ ↑p ^ 2 ∣ ∑ i in range p, (a + ↑p * b) ^ i * a ^ (p - 1 - i) - ↑p * a ^ (p - 1)

tactic: simp_rw [← mem_span_singleton, ← Ideal.Quotient.eq] at *
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 : ∀ (i : ℕ), ↑p ^ 2 ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
⊢ ↑p ^ 2 ∣ ∑ i in range p, (a + ↑p * b) ^ i * a ^ (p - 1 - i) - ↑p * a ^ (p - 1)

tactic: let s : R := (p : R)^2
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ i in range p, (a + ↑p * b) ^ i * a ^ (p - 1 - i)) =
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * a ^ (p - 1))

tactic: intro i
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
⊢ ∀ (i : ℕ), ↑p ^ 2 ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)

tactic: calc
  ↑p ^ 2 ∣ (↑p * b) ^ 2 := by simp only [mul_pow, dvd_mul_right]
  _ ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i) := by
    simp only [sq_dvd_add_pow_sub_sub (↑p * b) a i, ← sub_sub]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
i : ℕ
⊢ ↑p ^ 2 ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)

tactic: simp only [mul_pow, dvd_mul_right]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
i : ℕ
⊢ ↑p ^ 2 ∣ (↑p * b) ^ 2

tactic: simp only [sq_dvd_add_pow_sub_sub (↑p * b) a i, ← sub_sub]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
i : ℕ
⊢ (↑p * b) ^ 2 ∣ (a + ↑p * b) ^ i - (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)

tactic: simp_rw [RingHom.map_geom_sum₂, ← map_pow, h1, ← _root_.map_mul]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ i in range p, (a + ↑p * b) ^ i * a ^ (p - 1 - i)) =
    ∑ i in range p, ↑(Ideal.Quotient.mk (span {s})) ((a ^ (i - 1) * (↑p * b) * ↑i + a ^ i) * a ^ (p - 1 - i))

tactic: ring
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ∑ i in range p, ↑(Ideal.Quotient.mk (span {s})) ((a ^ (i - 1) * (↑p * b) * ↑i + a ^ i) * a ^ (p - 1 - i)) =
    ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x + (p - 1 - x)))

tactic: simp only [← pow_add, map_add, Finset.sum_add_distrib, ← map_sum]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ∑ x in range p,
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (x - 1) * a ^ (p - 1 - x) * ↑p * b * ↑x + a ^ x * a ^ (p - 1 - x)) =
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x + (p - 1 - x)))

tactic: congr
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x - 1 + (p - 1 - x)) * ↑p * b * ↑x) +
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x + (p - 1 - x))) =
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x + (p - 1 - x)))

tactic: simp [pow_add a, mul_assoc]
state_before: case e_a.h.e_6.h.e_f
R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ (fun x => a ^ (x - 1 + (p - 1 - x)) * ↑p * b * ↑x) = fun x => a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))

tactic: rw [add_right_inj]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x + (p - 1 - x))) =
    ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (p - 1))

tactic: have : ∀ (x : ℕ), (hx : x ∈ range p) →  a ^ (x + (p - 1 - x)) = a ^ (p - 1) := by
  intro x hx
  rw [← Nat.add_sub_assoc _ x, Nat.add_sub_cancel_left]
  exact Nat.le_pred_of_lt (Finset.mem_range.mp hx)
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x + (p - 1 - x))) =
    ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (p - 1))

tactic: rw [Finset.sum_congr rfl this]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∀ (x : ℕ), x ∈ range p → a ^ (x + (p - 1 - x)) = a ^ (p - 1)
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x + (p - 1 - x))) =
    ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (p - 1))

tactic: intro x hx
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ∀ (x : ℕ), x ∈ range p → a ^ (x + (p - 1 - x)) = a ^ (p - 1)

tactic: rw [← Nat.add_sub_assoc _ x, Nat.add_sub_cancel_left]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : x ∈ range p
⊢ a ^ (x + (p - 1 - x)) = a ^ (p - 1)

tactic: exact Nat.le_pred_of_lt (Finset.mem_range.mp hx)
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : x ∈ range p
⊢ x ≤ p - 1

tactic: simp only [add_right_inj, Finset.sum_const, Finset.card_range, nsmul_eq_mul]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (p - 1)) =
    ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1))

tactic: simp only [Finset.mul_sum, ← mul_assoc, ← pow_add]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (∑ x in range p, a ^ (x - 1) * (a ^ (p - 1 - x) * (↑p * (b * ↑x)))) +
      ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1)) =
    ↑(Ideal.Quotient.mk (span {s})) (↑p * b * ∑ x in range p, a ^ (p - 2) * ↑x) +
      ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1))

tactic: rw [Finset.sum_congr rfl]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, a ^ (x - 1 + (p - 1 - x)) * ↑p * b * ↑x) +
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * a ^ (p - 1)) =
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (∑ x in range p, ↑p * b * a ^ (p - 2) * ↑x) +
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * a ^ (p - 1))

tactic: rintro (⟨⟩ | ⟨x⟩) hx
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ∀ (x : ℕ), x ∈ range p → a ^ (x - 1 + (p - 1 - x)) * ↑p * b * ↑x = ↑p * b * a ^ (p - 2) * ↑x

tactic: rw [Nat.cast_zero, MulZeroClass.mul_zero, MulZeroClass.mul_zero]
state_before: case zero
R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
hx : Nat.zero ∈ range p
⊢ a ^ (Nat.zero - 1 + (p - 1 - Nat.zero)) * ↑p * b * ↑Nat.zero = ↑p * b * a ^ (p - 2) * ↑Nat.zero

tactic: have : x.succ - 1 + (p - 1 - x.succ) = p - 2 := by
  rw [← Nat.add_sub_assoc (Nat.le_pred_of_lt (Finset.mem_range.mp hx))]
  exact congr_arg Nat.pred (Nat.add_sub_cancel_left _ _)
state_before: case succ
R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : Nat.succ x ∈ range p
⊢ a ^ (Nat.succ x - 1 + (p - 1 - Nat.succ x)) * ↑p * b * ↑(Nat.succ x) = ↑p * b * a ^ (p - 2) * ↑(Nat.succ x)

tactic: rw [this]
state_before: case succ
R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : Nat.succ x ∈ range p
this : Nat.succ x - 1 + (p - 1 - Nat.succ x) = p - 2
⊢ a ^ (Nat.succ x - 1 + (p - 1 - Nat.succ x)) * ↑p * b * ↑(Nat.succ x) = ↑p * b * a ^ (p - 2) * ↑(Nat.succ x)

tactic: ring1
state_before: case succ
R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : Nat.succ x ∈ range p
this : Nat.succ x - 1 + (p - 1 - Nat.succ x) = p - 2
⊢ a ^ (p - 2) * ↑p * b * ↑(Nat.succ x) = ↑p * b * a ^ (p - 2) * ↑(Nat.succ x)

tactic: rw [← Nat.add_sub_assoc (Nat.le_pred_of_lt (Finset.mem_range.mp hx))]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : Nat.succ x ∈ range p
⊢ Nat.succ x - 1 + (p - 1 - Nat.succ x) = p - 2

tactic: exact congr_arg Nat.pred (Nat.add_sub_cancel_left _ _)
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x✝ y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
x : ℕ
hx : Nat.succ x ∈ range p
⊢ Nat.succ x - 1 + (p - 1) - Nat.succ x = p - 2

tactic: have : Finset.sum (range p) (fun (x : ℕ) ↦ (x : R)) =
    ((Finset.sum (range p) (fun (x : ℕ)  ↦ (x : ℕ)))) := by simp only [Nat.cast_sum]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ↑(Ideal.Quotient.mk (span {s})) (↑p * b * ∑ x in range p, a ^ (p - 2) * ↑x) +
      ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1)) =
    ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1))

tactic: simp only [add_left_eq_self, ← Finset.mul_sum, this]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {s})) (↑p * b * ∑ x in range p, a ^ (p - 2) * ↑x) +
      ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1)) =
    ↑(Ideal.Quotient.mk (span {s})) (↑p * a ^ (p - 1))

tactic: norm_cast
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * b * (a ^ (p - 2) * ↑(∑ x in range p, x))) = 0

tactic: simp only [Finset.sum_range_id]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * b * (a ^ (p - 2) * ↑(∑ x in range p, x))) = 0

tactic: norm_cast
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * b * (a ^ (p - 2) * ↑(p * (p - 1) / 2))) = 0

tactic: simp only [Nat.cast_mul, _root_.map_mul,
    Nat.mul_div_assoc p (even_iff_two_dvd.mp (Nat.Odd.sub_odd hp odd_one))]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (↑p * b * (a ^ (p - 2) * ↑(p * (p - 1) / 2))) = 0

tactic: ring
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑p * ↑(Ideal.Quotient.mk (span {↑p ^ 2})) b *
      (↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (p - 2)) *
        (↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑p * ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑((p - 1) / 2))) =
    0

tactic: rw [mul_assoc, mul_assoc]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑p ^ 2 * ↑(Ideal.Quotient.mk (span {↑p ^ 2})) b *
        ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (p - 2)) *
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑((p - 1) / 2) =
    0

tactic: refine' mul_eq_zero_of_left _ _
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑p ^ 2 *
      (↑(Ideal.Quotient.mk (span {↑p ^ 2})) b *
        (↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (p - 2)) * ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑((p - 1) / 2))) =
    0

tactic: refine' Ideal.Quotient.eq_zero_iff_mem.mpr _
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ↑p ^ 2 = 0

tactic: simp [mem_span_singleton]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
this : ∑ x in range p, ↑x = ↑(∑ x in range p, x)
⊢ (fun x => x ^ 2) ↑p ∈ span {↑p ^ 2}

tactic: simp only [Nat.cast_sum]
state_before: R : Type u_1
n : ℕ
inst✝ : CommRing R
a b x y : R
p : ℕ
hp : Odd p
h1 :
  ∀ (i : ℕ),
    ↑(Ideal.Quotient.mk (span {↑p ^ 2})) ((a + ↑p * b) ^ i) =
      ↑(Ideal.Quotient.mk (span {↑p ^ 2})) (a ^ (i - 1) * (↑p * b) * ↑i + a ^ i)
s : R := ↑p ^ 2
⊢ ∑ x in range p, ↑x = ↑(∑ x in range p, x)