theorem arxiv.id0911_2077.conjecture6_3
    (p : ℝ) (h_p : p ∈ Set.Ioo 0 (1 / 2)) (k : ℕ) (hk : 0 < k)
    (σ : ℝ) (h_σ : σ = (p * (1 - p)).sqrt) :
    letI hp' : (⟨p, le_of_lt h_p.1⟩ : ℝ≥0) ≤ 1 := by
      have : p ≤ 1 :=  le_trans (le_of_lt (Set.mem_Ioo.mp h_p).right) (by linarith)
      exact this
    1 - Φ ((1 / 2 - p) * sqrt (2 * k : ℝ≥0) / σ)
      + (1 / 2) * ((2 * k).choose k) * σ ^ (2 * k)
      ≤ ((PMF.binomial (⟨p, le_of_lt h_p.1⟩) hp' (2 * k)).toMeasure
        (Set.Ici ⟨k, by omega⟩)).toReal


theorem erdos_100_piepmeyer :
    ∃ A : Finset ℝ², A.card = 9 ∧ DistancesSeparated A ∧
      diam (A : Set ℝ²) < 5


theorem erdos_1043 :
    answer(False) ↔ ∀ (f : ℂ[X]), f.Monic → f.degree ≥ 1 →
      ∃ (u : ℂ), ‖u‖ = 1 ∧
      volume ((ℝ ∙ u).orthogonalProjection '' levelSet f) ≤ 2


theorem erdos_1051 :
    answer(True) ↔ ∀ (a : ℕ → ℤ), StrictMono a → GrowthCondition a →
      Irrational (ErdosSeries a)


theorem even_of_isUnitaryPerfect (n : ℕ) (hn : IsUnitaryPerfect n) : Even n


theorem erdos_1074.variants.EHSNumbers_infinite : EHSNumbers.Infinite


theorem erdos_1080 :
    answer(False) ↔
    ∃ c > (0 : ℝ), ∀ (V : Type) [Fintype V] [Nonempty V] (G : SimpleGraph V) (X Y : Set V),
      IsBipartition G X Y → X.ncard = ⌊(Fintype.card V : ℝ) ^ (2/3 : ℝ)⌋₊ →
      G.edgeSet.ncard ≥ c * Fintype.card V →
        ∃ (v : V) (walk : G.Walk v v), walk.IsCycle ∧ walk.length = 6


theorem erdos_1082.parts.ii : answer(False) ↔
    ∀ (A : Finset ℝ²) (hA : A.Nonempty) (hA_n3c : NonTrilinear (A : Set ℝ²)),
    ∃ (a : ℝ²) (ha : a ∈ A), A.card / 2 ≤ distinctDistancesFrom A a - 1


theorem erdos_1151_nonempty_fixed_point
    {x0 : ℝ} (hx0 : x0 ∈ SpaceI)
    {A : Set ℝ} (hA_closed : IsClosed A)
    (hA_nonempty : A.Nonempty)
    (hA_subset : A ⊆ SpaceI) :
    ∃ f : SpaceFun,
      clusterSet (fun m : ℕ => chebLagEval x0 f (m.succ)) = A


theorem erdos_12.parts.i : answer(True) ↔ ∃ (A : Set ℕ), IsGood A ∧
    (0 : ℝ) < Filter.atTop.liminf
      (fun N => (A ∩ Icc 1 N).ncard / (N : ℝ).sqrt)


theorem erdos_12.parts.ii : answer(False) ↔ ∃ c > (0 : ℝ), ∀ (A : Set ℕ), IsGood A →
    {N : ℕ| (A ∩ Icc 1 N).ncard < (N : ℝ) ^ (1 - c)}.Infinite


theorem isGood_example :
    IsGood {p ^ 2 | (p : ℕ) (_ : p ≡ 3 [MOD 4]) (_ : p.Prime)}


theorem erdos_125 :
    answer(False) ↔ (A + B).HasPosDensity


theorem erdos_125.variants.positive_lower_density :
    answer(False) ↔ 0 < (A + B).lowerDensity


theorem erdos_138.variants.difference :
    answer(True) ↔ atTop.Tendsto (fun k => (W (k + 1) - W k)) atTop


theorem erdos_152 : answer(True) ↔ Tendsto f atTop atTop


theorem erdos_152.variants.square : answer(True) ↔
    (fun n => f n : ℕ → ℝ) ≫ (fun n => n ^ 2 : ℕ → ℝ)


theorem erdos_189 :
    answer(False) ↔ Erdos189For
      (fun a b c d ↦
        line[ℝ, a, b].direction ⟂ line[ℝ, b, c].direction ∧
        line[ℝ, b, c].direction ⟂ line[ℝ, c, d].direction ∧
        line[ℝ, c, d].direction ⟂ line[ℝ, d, a].direction)
      (fun a b c d ↦ dist a b * dist b c)


theorem erdos_198.variants.concrete :  ∃ (A : Set ℕ), A = {n ! + n | n} ∧
    IsSidon A ∧ (∀ Y, IsAPOfLength Y ⊤ → (A ∩ Y).Nonempty)


theorem erdos_198 : (∀ A : Set ℕ, IsSidon A → (∃ Y, IsAPOfLength Y ⊤ ∧ Y ⊆ Aᶜ)) ↔
    answer(False)


theorem erdos_229 :
    letI := Polynomial.algebraPi ℂ ℂ ℂ
    answer(True) ↔ ∀ (S : ℕ → Set ℂ), (∀ n, derivedSet (S n) = ∅) →
    ∃ (f : ℂ → ℂ), Transcendental (Polynomial ℂ) f ∧ Differentiable ℂ f ∧ ∀ n ≥ 1,
      ∃ k, ∀ z ∈ S n, iteratedDeriv k f z = 0


theorem erdos_233.variants.lower_bound :
    (fun (N : ℕ) => N * (log N)^2) =O[atTop]
    (fun N => ((∑ n ∈ Finset.range N, (primeGap n) ^ 2) : ℝ))


theorem erdos_259 : Irrational (∑' n : ℕ, (μ n) ^ 2 * n / (2 ^ n))


theorem erdos_26 : answer(False) ↔ ∀ A : ℕ → ℕ, StrictMono A → IsThick A →
    ∃ k, IsBehrend (A · + k)


theorem erdos_26.variants.tenenbaum : answer(False) ↔ ∀ᵉ (A : ℕ → ℕ), StrictMono A → IsThick A →
    (∀ ε > (0 : ℝ), ∃ k, IsWeaklyBehrend (A · + k) ε)


theorem erdos_263.parts.ii : answer(False) ↔
    ∀ a : ℕ → ℕ,
      IsIrrationalitySequence a →
        atTop.Tendsto (fun n : ℕ => (a n : ℝ) ^ (1 / (n : ℝ))) atTop


theorem erdos_267.variants.specialization_pow_two :
    Irrational <| ∑' k, 1 / (Nat.fib <| 2^k)


theorem erdos_275 (r : ℕ) (a : Fin r → ℤ) (n : Fin r → ℕ)
    (H : ∃ k : ℤ, ∀ x ∈ Ico k (k + 2 ^ r), ∃ i, x ≡ a i [ZMOD n i]) (x : ℤ) :
    ∃ i, x ≡ a i [ZMOD n i]


theorem erdos_316 : answer(False) ↔ ∀ A : Finset ℕ, 0 ∉ A → 1 ∉ A →
    ∑ n ∈ A, (1 / n : ℚ) < 2 → ∃ (A₁ A₂ : Finset ℕ),
      Disjoint A₁ A₂ ∧ A = A₁ ∪ A₂ ∧
      ∑ n ∈ A₁, (1 / n : ℚ) < 1 ∧ ∑ n ∈ A₂, (1 / n : ℚ) <  1


theorem erdos_330_upper_density :
    MainTarget


theorem erdos_331 :
    answer(False) ↔
      ∀ A B : Set ℕ,
      (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count A n : ℝ)) →
      (fun (n : ℕ) ↦ (n : ℝ) ^ (1 / 2 : ℝ)) =O[atTop] (fun (n : ℕ) ↦ (count B n : ℝ)) →
      { s : ℕ × ℕ × ℕ × ℕ | let ⟨a₁, a₂, b₁, b₂⟩ := s
        a₁ ∈ A ∧ a₂ ∈ A ∧ b₁ ∈ B ∧ b₂ ∈ B ∧
        a₁ ≠ a₂ ∧ a₁ + b₂ = a₂ + b₁ }.Infinite


theorem erdos_350 (A : Finset ℕ) (hA : DecidableDistinctSubsetSums A) :
    ∑ n ∈ A, (1 / n : ℝ) < 2


theorem erdos_355 :
    answer(True) ↔ ∃ A : ℕ → ℕ, IsLacunary A ∧ ∃ u v : ℝ, u < v ∧ ∀ q : ℚ, ↑q ∈ Set.Ioo u v →
      q ∈ {∑ a ∈ A', (1 / a : ℚ) | (A' : Finset ℕ) (_ : ↑A' ⊆ Set.range A)}


theorem erdos_370 : answer(True) ↔
    { n | Nat.maxPrimeFac n < √n ∧ Nat.maxPrimeFac (n + 1) < √(n + 1) }.Infinite


theorem erdos_379 : atTop.limsup (fun n => (S n : ℕ∞)) = ⊤


theorem erdos_397 :
    answer(False) ↔
      {(M, N) : Finset ℕ × Finset ℕ | Disjoint M N ∧
      ∏ i ∈ M, centralBinom i = ∏ j ∈ N, centralBinom j}.Finite


theorem erdos_399 : answer(False) ↔
    ¬ ∃ (n x y k : ℕ), 1 < x * y ∧ 2 < k ∧ (n ! = x ^ k + y ^ k ∨ n ! + y ^ k = x ^ k)


theorem erdos_645 (c : ℕ → Bool) : ∃ x d, 0 < x ∧ x < d ∧
    (∃ C, c x = C ∧ c (x + d) = C ∧ c (x + 2 * d) = C)


theorem erdos_707 : (∀ (A : Set ℕ) (h : A.Finite), IsSidon A →
    ∃ᵉ (B : Set ℕ) (n > 0), A ⊆ B ∧ IsPerfectDifferenceSet B n) ↔ False


theorem erdos_741.parts.i : answer(False) ↔ ∀ A : Set ℕ, HasPosDensity (A + A) → ∃ A₁ A₂,
    A = A₁ ∪ A₂ ∧ Disjoint A₁ A₂ ∧ HasPosDensity (A₁ + A₁)
    ∧ HasPosDensity (A₂ + A₂)


theorem erdos_741.parts.ii : answer(True) ↔ ∃ A : Set ℕ, IsAddBasisOfOrder (A ∪ {0}) 2 ∧ ∀ A₁ A₂,
    A = A₁ ∪ A₂ → Disjoint A₁ A₂ → ¬ (IsSyndetic (A₁ + A₁) ∧ IsSyndetic (A₂ + A₂))


theorem erdos_741.variants.upper : answer(True) ↔ ∀ A : Set ℕ, 0 < upperDensity (A + A) → ∃ A₁ A₂,
    A = A₁ ∪ A₂ ∧ Disjoint A₁ A₂ ∧ 0 < upperDensity (A₁ + A₁)
    ∧ 0 < upperDensity (A₂ + A₂)


theorem erdos_828.variants.phi_dvd_self_iff_pow2_pow3 {n : ℕ} :
    φ n ∣ n ↔ n ≤ 1 ∨ ∃ᵉ (a > 0) (b), n = 2 ^ a * 3 ^ b


theorem erdos_846 : answer(False) ↔ ∀ᵉ (A : Set ℝ²) (ε > 0), A.Infinite → NonTrilinearFor A ε →
    WeaklyNonTrilinear A


theorem erdos_897.parts.i : answer(False) ↔ ∀ (f : ℕ → ℝ),
    (∀ᵉ (a > 0) (b > 0), a.Coprime b → f (a * b) = f a + f b) →
    ((Filter.atTop ⊓ Filter.principal {(p, k) : ℕ × ℕ | p.Prime}).limsup
      (fun (p, k) => (f (p^k) / (p^k : ℝ).log : EReal)) = ⊤) →
    Filter.atTop.limsup (fun (n : ℕ) => ((f (n+1) - f n) / (n : ℝ).log : EReal)) = ⊤


theorem erdos_897.parts.ii : answer(False) ↔ ∀ (f : ℕ → ℝ),
    (∀ᵉ (a > 0) (b > 0), a.Coprime b → f (a * b) = f a + f b) →
    ((Filter.atTop ⊓ Filter.principal {(p, k) : ℕ × ℕ | p.Prime}).limsup
      (fun (p, k) => (f (p^k) / (p^k : ℝ).log : EReal)) = ⊤) →
    Filter.atTop.limsup (fun (n : ℕ) => (f (n+1) / f n : EReal)) = ⊤


theorem erdos_978.variants.allow_fixed_divisors : answer(False) ↔
    ∀ {f : ℤ[X]}, Irreducible f → f.natDegree > 3 →
    (¬ ∃ l : ℕ, f.natDegree = 2 ^ l) → 0 < f.leadingCoeff →
    (¬ ∃ p : ℕ, p.Prime ∧ ∀ n : ℕ, (p : ℤ) ^ (f.natDegree - 1) ∣ f.eval (n : ℤ)) →
    {n : ℕ | Powerfree (f.natDegree - 2) (f.eval (n : ℤ))}.Infinite


theorem green_57 :
  answer(False) ↔
    ∀ (G : Type) [AddCommGroup G] [Fintype G] [DecidableEq G],
      Φ G = Φ' G


theorem green_57.variants.z3 :
    answer(False) ↔ (Φ (ZMod 3) = Φ' (ZMod 3))


theorem green_57.variants.z3_functional :
    let a : ZMod 3 → ℂ := ![(-1 : ℂ), -3, 3]
    answer(True) ↔
      supportFn (ZMod 3) a (Φ' (ZMod 3)) < supportFn (ZMod 3) a (Φ (ZMod 3))


theorem green_94_outer_measure :
   answer(False) ↔ ∀ A : Set ℝ,
   volume A > 0 →
   ∃ a b : ℝ, a ≠ 0 ∧ ∀ n : ℕ, a * (1 / 2^n) + b ∈ A


theorem mathoverflow_10799 : answer(False) ↔
    ∀ (n : ℕ) (_ : 2 ≤ n)
    (F : Finset (Finset (Fin n))) (_ : IsMonotoneIncreasing F)
    (s t : ℝ) (_ : 0 < s) (_ : s ≤ t) (_ : t < 1)
    (_ : t / s > 1000 * Real.log n),
    ∃ p, s ≤ p ∧ p ≤ t ∧ IsOptimal p F


theorem exists_semiring_unique_left_right_maximal_ne :
    answer(True) ↔ ∃ (R : Type) (_ : Semiring R) (hI : ∃! I : Ideal R, I.IsMaximal)
      (hJ : ∃! J : Ideal Rᵐᵒᵖ, J.IsMaximal),
        (hI.choose : Set R) ≠ MulOpposite.op ⁻¹' hJ.choose


theorem mutuallyUnbiasedBases_dim6_bounds :
    HasMUBs 6 3 ∧ ∀ m : ℕ, HasMUBs 6 m → m ≤ 7


theorem ame_11_5_open :
    answer(True) ↔ ExistsAME 11 5


theorem casas_alvero.positive_char_counterexample {p : ℕ} (hp : p.Prime) :
    ∃ (K : Type*) (_ : Field K) (_ : CharP K p),
      let P := X ^ (p + 1) - X ^ p
      Monic P ∧ HasCasasAlveroProp P ∧
      ¬∃ α : K, P = (X - C α) ^ P.natDegree


theorem cube_hamiltonian_arc_decomposition {m : ℕ} [NeZero m] (hm : Odd m) (hm' : 1 < m) :
    HasHamiltonianArcDecomposition m


theorem eqSystem_no_solution_even_ge4_d_eq_n_explicit :
    answer(True) ↔
      ∀ N : Nat, N ≥ 4 → Even N →
        ¬ ∃ W : WeightsN N N ℂ, EqSystemN N N W


theorem eqSystem10_no_solution_d10 :
    answer(True) ↔
      ¬ ∃ W : WeightsN 10 10 ℂ, EqSystemN 10 10 W


theorem eqSystem4_no_solution_d4 :
    answer(True) ↔
      ¬ ∃ W : WeightsN 4 4 ℂ, EqSystemN 4 4 W


theorem eqSystem4_no_solution_ge4 :
    answer(True) ↔
      ∀ D : Nat, D ≥ 4 →
        ¬ ∃ W : WeightsN 4 D ℂ, EqSystemN 4 D W


theorem eqSystem4_no_solution_ge4_int :
    answer(True) ↔
      ∀ D : Nat, D ≥ 4 →
        ¬ ∃ W : WeightsN 4 D ℤ, EqSystemN 4 D W


theorem eqSystem4_no_solution_ge4_real :
    answer(True) ↔
      ∀ D : Nat, D ≥ 4 →
        ¬ ∃ W : WeightsN 4 D ℝ, EqSystemN 4 D W


theorem eqSystem4_no_solution_ge4_trinary_int :
    answer(True) ↔
      ∀ D : Nat, D ≥ 4 →
        ¬ ∃ W : WeightsN 4 D ℤ,
            (∀ e, W e = (-1 : ℤ) ∨ W e = 0 ∨ W e = 1) ∧
              EqSystemN 4 D W


theorem eqSystem6_no_solution_d6 :
    answer(True) ↔
      ¬ ∃ W : WeightsN 6 6 ℂ, EqSystemN 6 6 W


theorem eqSystem8_no_solution_d10 :
    answer(True) ↔
      ¬ ∃ W : WeightsN 8 10 ℂ, EqSystemN 8 10 W


theorem isWeakGiuga_iff_prime_dvd {n : ℕ} (hn : n.Composite) :
    IsWeakGiuga n ↔ ∀ p ∈ n.primeFactors, p ∣ (n / p - 1)


theorem bounded_gap_legendre
    (H : ∃ c > 0, ∀ᶠ n in atTop, (n + 1).nth Nat.Prime - n.nth Nat.Prime <
      (n.nth Nat.Prime : ℝ) ^ (1 / (2 : ℝ) - c)) :
    ∀ᶠ n in atTop, ∃ p ∈ Set.Ioo (n ^ 2) ((n + 1) ^ 2), Nat.Prime p


theorem odd_perfect_number.euler_form (n : ℕ) (hn : Odd n) (hp : Perfect n) :
    ∃ (p m α : ℕ),
      p.Prime ∧
      p ≡ 1 [ZMOD 4] ∧
      α ≡ 1 [ZMOD 4] ∧
      ¬ p ∣ m ∧
      n = p^α * m^2


theorem wolstenholme_prime_16483 : IsWolstenholmePrime 16843


theorem wolstenholme_theorem (p : ℕ) (h : p > 3) (hp : Nat.Prime p) :
    (2 * p - 1).choose (p - 1) ≡ 1 [MOD p ^ 3]