import Thesis.GeneralizedBernoulli

noncomputable section

/-!
# Bernoulli realization of the cyclotomic tower's special values

`F_α` is the degree-`p^α` subfield of `ℚ(μ_(p^(α+1)))`.  Its character group is
realized here by Dirichlet characters modulo `p^(α+1)` whose order divides
`p^α`.  The product formula in Theorem 2.16 and Theorem D then give the
following concrete representation of `ζ_(F_α)(1-n)`.
-/

namespace Thesis

open scoped BigOperators

variable (p : ℕ) [Fact p.Prime]

/-- Characters of the second kind, at level at most `p^(α+1)`. -/
def IsSecondKind (α : ℕ) {N : ℕ} (χ : DirichletCharacter ℂ_[p] N) : Prop :=
  χ ^ (p ^ α) = 1

instance (α N : ℕ) : DecidablePred (fun χ : DirichletCharacter ℂ_[p] N => IsSecondKind p α χ) :=
  fun _ => Classical.decEq _ _ _

/-- The finite character group `Γ̂_α`, realized by second-kind characters. -/
def secondKindChars (α : ℕ) : Finset (DirichletCharacter ℂ_[p] (p ^ (α + 1))) :=
  letI : NeZero (p ^ (α + 1)) := ⟨pow_ne_zero _ (Fact.out : Nat.Prime p).ne_zero⟩
  Finset.univ.filter fun χ => IsSecondKind p α χ

/-- The Bernoulli realization of `ζ_(F_α)(1-n)` for `n ≥ 1`. -/
noncomputable def cyclotomicTowerValue (α n : ℕ) : ℂ_[p] :=
  letI : NeZero (p ^ (α + 1)) := ⟨pow_ne_zero _ (Fact.out : Nat.Prime p).ne_zero⟩
  ∏ χ ∈ secondKindChars p α, primitiveDirichletValue χ n

/-- Definitions 3.1 and the `p`-adic absolute value are already in Mathlib. -/
abbrev padicAbsoluteValue (p : ℕ) (x : ℚ) : ℚ := padicNorm p x

end Thesis
