import Mathlib.Analysis.Complex.CauchyIntegral
import Nevanlinna.harmonicAt_examples
import Nevanlinna.harmonicAt_meanValue
import Mathlib.Analysis.Analytic.IsolatedZeros


lemma xx
  {f : ℂ → ℂ}
  {S : Set ℂ}
  (h₁S : IsPreconnected S)
  (h₂S : IsCompact S)
  (hf : ∀ s ∈ S, AnalyticAt ℂ f s) :
  ∃ o : ℂ → ℕ, ∃ F : ℂ → ℂ, ∀ z ∈ S, (AnalyticAt ℂ F z) ∧ (F z ≠ 0) ∧ (f z = F z * ∏ᶠ s ∈ S, (z - s) ^ (o s)) := by

  let o : ℂ → ℕ := by
    intro z
    if hz : z ∈ S then
      let A := hf z hz
      let B := A.order

      exact A.order
    else
      exact 0

  sorry


theorem jensen_case_R_eq_one'
  (f : ℂ → ℂ)
  (h₁f : Differentiable ℂ f)
  (h₂f : f 0 ≠ 0)
  (S : Finset ℕ)
  (a : S → ℂ)
  (ha : ∀ s, a s ∈ Metric.ball 0 1)
  (F : ℂ → ℂ)
  (h₁F : Differentiable ℂ F)
  (h₂F : ∀ z, F z ≠ 0)
  (h₃F : f = fun z ↦ (F z) * ∏ s : S, (z - a s))
  :
  Real.log ‖f 0‖ = -∑ s, Real.log (‖a s‖⁻¹) + (2 * Real.pi)⁻¹ * ∫ (x : ℝ) in (0)..2 * Real.pi, Real.log ‖f (circleMap 0 1 x)‖ := by
  sorry
