/- Copyright 2026 The Formal Conjectures Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -/ module public import FormalConjecturesUtil

Erdős Problem 696

References:

@[expose] public sectionnamespace Erdos696

A strictly-increasing chain of natural numbers $d_1 < d_2 < \dots$ such that consecutive elements satisfy $d_{i+1} \equiv 1 \pmod{d_i}$, and every element divides $n$ and satisfies the auxiliary predicate $P$.

def ValidChain (n : ℕ) (P : ℕ → Prop) (s : List ℕ) : Prop := s.IsChain (fun a b => a < b ∧ b ≡ 1 [MOD a]) ∧ ∀ d ∈ s, d ∣ n ∧ P dopen Classical in

$h(n)$ is the largest $\ell$ such that there is a sequence of primes $p_1<\cdots < p_\ell$ all dividing $n$ with $p_{i+1}\equiv 1\pmod{p_i}$.

noncomputable def h (n : ℕ) : ℕ := Nat.findGreatest (fun k => ∃ s : List ℕ, s.length = k ∧ ValidChain n Nat.Prime s) nopen Classical in

$H(n)$ is the largest $u$ such that there is a sequence of integers $d_1<\cdots < d_u$ all dividing $n$ with $d_{i+1}\equiv 1\pmod{d_i}$.

noncomputable def H (n : ℕ) : ℕ := Nat.findGreatest (fun k => ∃ s : List ℕ, s.length = k ∧ ValidChain n (fun _ => True) s) n

The prime-chain definition has the expected value at $n = 1$.

hk:0 < 1hk_le:1 ≤ 1p:ℕhslen:[p].length = 1hvalid:ValidChain 1 Nat.Prime [p]⊢ p = 1 exact Nat.dvd_one.mp (hvalid.2 p (hk:0 < 1hk_le:1 ≤ 1p:ℕhslen:[p].length = 1hvalid:ValidChain 1 Nat.Prime [p]⊢ p ∈ [p] All goals completed! 🐙)).1

Is it true that $H(n)/h(n)\to \infty$ for almost all $n$?

Formalised as: for every threshold $M$, the set of $n$ with $h(n) > 0$ and $H(n)/h(n) > M$ has natural density $1$. This is false: in fact, $H(n)/h(n) = 2 + o(1)$ for almost all $n$.

@[category research solved, question, AMS 11] theorem erdos_696 : ¬ ∀ M : ℝ, {n : ℕ | (h n : ℝ) > 0 ∧ (H n : ℝ) / (h n : ℝ) > M}.HasDensity 1 := ⊢ ¬∀ (M : ℝ), {n | ↑(h n) > 0 ∧ ↑(H n) / ↑(h n) > M}.HasDensity 1 All goals completed! 🐙end Erdos696