/-- When `F` and `F'` are finite fields and `χ : F → F'` is a nontrivial quadratic character,
then `(χ(-1) * #F)^(#F'/2) = χ(#F')`. -/
theorem Char.card_pow_card {F : Type*} [Field F] [Fintype F] {F' : Type*} [Field F'] [Fintype F']
    {χ : MulChar F F'} (hχ₁ : IsNontrivial χ) (hχ₂ : IsQuadratic χ)
    (hch₁ : ringChar F' ≠ ringChar F) (hch₂ : ringChar F' ≠ 2) :
    (χ (-1) * Fintype.card F) ^ (Fintype.card F' / 2) = χ (Fintype.card F') := by
  obtain ⟨n, hp, hc⟩ := FiniteField.card F (ringChar F)
  obtain ⟨n', hp', hc'⟩ := FiniteField.card F' (ringChar F')
  let ψ := primitiveCharFiniteField F F' hch₁
  -- Porting note: this was a `let` but then Lean would time out at
  -- unification so it is changed to as `set` and `FF'` is replaced by its
  -- definition before unification
  set FF' := CyclotomicField ψ.n F' with FF'_def
  have hchar := Algebra.ringChar_eq F' FF'
  apply (algebraMap F' FF').injective
  rw [map_pow, map_mul, map_natCast, hc', hchar, Nat.cast_pow]
  simp only [← MulChar.ringHomComp_apply]
  haveI := Fact.mk hp'
  haveI := Fact.mk (hchar.subst hp')
  rw [Ne, ← Nat.prime_dvd_prime_iff_eq hp' hp, ← isUnit_iff_not_dvd_char, hchar] at hch₁
  -- Porting note: original proof is below and, as noted above, `FF'` needs to
  -- be replaced by its definition before unification to avoid time out
  -- exact Char.card_pow_char_pow (hχ₂.comp _) ψ.char (ringChar FF') n' hch₁ (hchar ▸ hch₂)
  --      (gaussSum_sq (hχ₁.comp <| RingHom.injective _) (hχ₂.comp _) ψ.prim)
  have := Char.card_pow_char_pow (hχ₂.comp (algebraMap F' FF')) ψ.char
    (ringChar FF') n' hch₁ (hchar ▸ hch₂)
    (gaussSum_sq (hχ₁.comp <| RingHom.injective _) (hχ₂.comp _) ψ.prim)
  

Proof state:
case intro.intro.intro.intro.a
R : Type u
inst✝⁷ : CommRing R
inst✝⁶ : Fintype R
R' : Type v
inst✝⁵ : CommRing R'
inst✝⁴ : IsDomain R'
F : Type u_1
inst✝³ : Field F
inst✝² : Fintype F
F' : Type u_2
inst✝¹ : Field F'
inst✝ : Fintype F'
χ : MulChar F F'
hχ₁ : MulChar.IsNontrivial χ
hχ₂ : IsQuadratic χ
hch₁✝ : ringChar F' ≠ ringChar F
hch₂ : ringChar F' ≠ 2
n : ℕ+
hp : Nat.Prime (ringChar F)
hc : Fintype.card F = ringChar F ^ ↑n
n' : ℕ+
hp' : Nat.Prime (ringChar F')
hc' : Fintype.card F' = ringChar F' ^ ↑n'
ψ : PrimitiveAddChar F F' := primitiveCharFiniteField F F' hch₁✝
FF' : Type u_2 := CyclotomicField (PrimitiveAddChar.n ψ) F'
hch₁ : IsUnit ↑(ringChar FF')
FF'_def : FF' = CyclotomicField (PrimitiveAddChar.n ψ) F'
hchar : ringChar F' = ringChar FF'
this✝¹ : Fact (Nat.Prime (ringChar F'))
this✝ : Fact (Nat.Prime (ringChar FF'))
this :
  ((ringHomComp χ (algebraMap F' FF')) (-1) * ↑(Fintype.card F)) ^ (ringChar FF' ^ ↑n' / 2) =
    (ringHomComp χ (algebraMap F' FF')) (↑(ringChar FF') ^ ↑n')
⊢ ((ringHomComp χ (algebraMap F' (CyclotomicField (PrimitiveAddChar.n (primitiveCharFiniteField F F' hch₁✝)) F')))
          (-1) *
        ↑(Fintype.card F)) ^
      (ringChar (CyclotomicField (PrimitiveAddChar.n (primitiveCharFiniteField F F' hch₁✝)) F') ^ ↑n' / 2) =
    (ringHomComp χ (algebraMap F' (CyclotomicField (PrimitiveAddChar.n (primitiveCharFiniteField F F' hch₁✝)) F')))
      (↑(ringChar (CyclotomicField (PrimitiveAddChar.n (primitiveCharFiniteField F F' hch₁✝)) F')) ^ ↑n')

Next tactic:
simp_rw [FF'_def] at this