Erdős problem #340: evidence on A−A of the Mian–Chowla sequence A developer formalized a result on Erdős problem #340 in Lean 4, proving that growth information alone cannot settle whether the difference set A − A of the greedy Sidon (Mian–Chowla) sequence has positive density. The proof, written in core Lean 4 without Mathlib and with assistance from Claude Opus 5.5, constructs for every monotone f a Sidon set A whose difference set contains all positive integers while having at most 2N elements below f(N). | | /- | | | A Sidon set whose difference set is ALL positive integers, | | | and which is nevertheless as sparse as we like. | | | | | | Context: Erdős problem 340 asks whether the difference set A − A of the | | | greedy Sidon sequence Mian–Chowla has positive density. This file proves | | | that growth information alone cannot settle such a question: for every | | | monotone f there is a Sidon set A with A − A ⊇ {1,2,3,...} and at most 2N | | | elements below f N . | | | | | | Core Lean 4 only no Mathlib . Written with Claude Opus 5.5 Anthropic . | | | -/ | | | | | | /-- A is a Sidon set: a + b = c + e forces {a,b} = {c,e}. -/ | | | def IsSidon A : Nat → Prop : Prop := | | | ∀ a b c e, A a → A b → A c → A e → a + b = c + e → | | | a = c ∧ b = e ∨ a = e ∧ b = c | | | | | | def mx : List Nat → Nat | | | \| = 0 | | | \| a :: l = max a mx l | | | | | | theorem le mx S : List Nat : ∀ s, s ∈ S → s ≤ mx S := by | | | induction S with | | | \| nil = intro s h; simp at h | | | \| cons a l ih = | | | intro s h | | | simp only List.mem cons at h | | | simp only mx | | | rcases h with h \| h | | | · subst h; exact Nat.le max left | | | · exact Nat.le trans ih s h Nat.le max right | | | | | | /-- Where the new pair goes at step k: far beyond everything so far. -/ | | | def nxt f : Nat → Nat k : Nat S : List Nat : Nat := | | | 2 mx S + k + 1 + f k + 1 | | | | | | /-- Step k makes sure the difference k+1 occurs. -/ | | | def step f : Nat → Nat k : Nat S : List Nat : List Nat := | | | if ∃ s ∈ S, s + k + 1 ∈ S then S | | | else nxt f k S :: nxt f k S + k + 1 :: S | | | | | | def st f : Nat → Nat : Nat → List Nat | | | \| 0 = | | | \| k + 1 = step f k st f k | | | | | | theorem step pos f : Nat → Nat k : Nat S : List Nat | | | hc : ∃ s ∈ S, s + k + 1 ∈ S : step f k S = S := by | | | unfold step; exact if pos hc | | | | | | theorem step neg f : Nat → Nat k : Nat S : List Nat | | | hc : ¬ ∃ s ∈ S, s + k + 1 ∈ S : | | | step f k S = nxt f k S :: nxt f k S + k + 1 :: S := by | | | unfold step; exact if neg hc | | | | | | theorem mem aux {S : List Nat} {d x z : Nat} | | | hx : ∀ s, s ∈ S → 2 s + d < x h : z ∈ x :: x + d :: S : | | | z = x ∨ z = x + d ∨ z ∈ S ∧ 2 z + d < x := by | | | simp only List.mem cons at h | | | rcases h with h \| h \| h | | | · exact Or.inl h | | | · exact Or.inr Or.inl h | | | · exact Or.inr Or.inr ⟨h, hx z h⟩ | | | | | | /-- Key lemma: adding a far-away pair {x, x+d} to a Sidon set keeps it Sidon, | | | provided d was not already a difference. -/ | | | theorem sidon add pair S : List Nat d x : Nat | | | hS : IsSidon · ∈ S hd0 : 0 < d | | | hd : ¬ ∃ s ∈ S, s + d ∈ S | | | hx : ∀ s, s ∈ S → 2 s + d < x : | | | IsSidon · ∈ x :: x + d :: S := by | | | have hd' : ∀ s, s ∈ S → s + d ∈ S → False := fun s h1 h2 = hd ⟨s, h1, h2⟩ | | | intro a b c e ha hb hc he h | | | change a ∈ x :: x + d :: S at ha | | | change b ∈ x :: x + d :: S at hb | | | change c ∈ x :: x + d :: S at hc | | | change e ∈ x :: x + d :: S at he | | | rcases mem aux hx ha with ha \| ha \| ⟨ha, ba⟩ <; | | | rcases mem aux hx hb with hb \| hb \| ⟨hb, bb⟩ <; | | | rcases mem aux hx hc with hc \| hc \| ⟨hc, bc⟩ <; | | | rcases mem aux hx he with he \| he \| ⟨he, be⟩ | | | all goals first | | | \| omega | | | \| exact hS a b c e ha hb hc he h | | | \| exact hd' a ha by rw show a + d = b by omega ; exact hb .elim | | | \| exact hd' a ha by rw show a + d = c by omega ; exact hc .elim | | | \| exact hd' a ha by rw show a + d = e by omega ; exact he .elim | | | \| exact hd' b hb by rw show b + d = a by omega ; exact ha .elim | | | \| exact hd' b hb by rw show b + d = c by omega ; exact hc .elim | | | \| exact hd' b hb by rw show b + d = e by omega ; exact he .elim | | | \| exact hd' c hc by rw show c + d = a by omega ; exact ha .elim | | | \| exact hd' c hc by rw show c + d = b by omega ; exact hb .elim | | | \| exact hd' c hc by rw show c + d = e by omega ; exact he .elim | | | \| exact hd' e he by rw show e + d = a by omega ; exact ha .elim | | | \| exact hd' e he by rw show e + d = b by omega ; exact hb .elim | | | \| exact hd' e he by rw show e + d = c by omega ; exact hc .elim | | | | | | theorem step sup f : Nat → Nat k : Nat S : List Nat n : Nat | | | h : n ∈ S : n ∈ step f k S := by | | | by cases hc : ∃ s ∈ S, s + k + 1 ∈ S | | | · rw step pos f k S hc ; exact h | | | · rw step neg f k S hc ; simp h | | | | | | theorem sidon step f : Nat → Nat k : Nat S : List Nat | | | hS : IsSidon · ∈ S : IsSidon · ∈ step f k S := by | | | by cases hc : ∃ s ∈ S, s + k + 1 ∈ S | | | · rw step pos f k S hc ; exact hS | | | · rw step neg f k S hc | | | apply sidon add pair S k + 1 nxt f k S hS Nat.succ pos k hc | | | intro s hs | | | have := le mx S s hs | | | unfold nxt | | | omega | | | | | | theorem sidon st f : Nat → Nat : ∀ k, IsSidon · ∈ st f k | | | \| 0 = by | | | intro a b c e ha | | | change a ∈ : List Nat at ha | | | simp at ha | | | \| k + 1 = sidon step f k st f k sidon st f k | | | | | | theorem st mono f : Nat → Nat {k : Nat} : | | | ∀ K, k ≤ K → ∀ n, n ∈ st f k → n ∈ st f K := by | | | intro K | | | induction K with | | | \| zero = | | | intro hk n h | | | have : k = 0 := by omega | | | subst this; exact h | | | \| succ K ih = | | | intro hk n h | | | rcases Nat.lt or ge k K + 1 with hlt \| hge | | | · exact step sup f K st f K n ih by omega n h | | | · have : k = K + 1 := by omega | | | subst this; exact h | | | | | | /-- The union of all stages is a Sidon set. -/ | | | theorem sidon A f : Nat → Nat : IsSidon fun n = ∃ k, n ∈ st f k := by | | | rintro a b c e ⟨ka, ha⟩ ⟨kb, hb⟩ ⟨kc, hc⟩ ⟨ke, he⟩ h | | | exact sidon st f ka + kb + kc + ke a b c e | | | st mono f by omega a ha st mono f by omega b hb | | | st mono f by omega c hc st mono f by omega e he h | | | | | | /-- Every positive integer is a difference of two elements. -/ | | | theorem covers f : Nat → Nat d : Nat hd : 0 < d : | | | ∃ a, ∃ k, a ∈ st f k ∧ ∃ k, a + d ∈ st f k := by | | | obtain ⟨k, rfl⟩ : ∃ k, d = k + 1 := ⟨d - 1, by omega⟩ | | | by cases hc : ∃ s ∈ st f k, s + k + 1 ∈ st f k | | | · obtain ⟨s, hs1, hs2⟩ := hc | | | exact ⟨s, ⟨k, hs1⟩, ⟨k, hs2⟩⟩ | | | · refine ⟨nxt f k st f k , ⟨k + 1, ? ⟩, ⟨k + 1, ? ⟩⟩ | | | · show ∈ step f k st f k | | | rw step neg f k hc ; simp | | | · show ∈ step f k st f k | | | rw step neg f k hc ; simp | | | | | | theorem small in f : Nat → Nat hf : ∀ a b, a ≤ b → f a ≤ f b N : Nat : | | | ∀ j n, n ∈ st f N + j → n < f N → n ∈ st f N := by | | | intro j | | | induction j with | | | \| zero = intro n h ; exact h | | | \| succ j ih = | | | intro n h hn | | | have h' : n ∈ step f N + j st f N + j := h | | | by cases hc : ∃ s ∈ st f N + j , s + N + j + 1 ∈ st f N + j | | | · rw step pos f hc at h' | | | exact ih n h' hn | | | · rw step neg f hc at h' | | | simp only List.mem cons at h' | | | have hfj := hf N N + j by omega | | | rcases h' with h' \| h' \| h' | | | · unfold nxt at h'; omega | | | · unfold nxt at h'; omega | | | · exact ih n h' hn | | | | | | /-- Every element below f N already lies in stage N. -/ | | | theorem sparse f : Nat → Nat hf : ∀ a b, a ≤ b → f a ≤ f b N : Nat : | | | ∀ n, ∃ k, n ∈ st f k → n < f N → n ∈ st f N := by | | | rintro n ⟨k, hk⟩ hn | | | rcases Nat.le total k N with h \| h | | | · exact st mono f N h n hk | | | · obtain ⟨j, rfl⟩ : ∃ j, k = N + j := ⟨k - N, by omega⟩ | | | exact small in f hf N j n hk hn | | | | | | /-- Stage N has at most 2N elements. -/ | | | theorem len st f : Nat → Nat : ∀ N, st f N .length ≤ 2 N | | | \| 0 = by simp st | | | \| N + 1 = by | | | have ih := len st f N | | | show step f N st f N .length ≤ 2 N + 1 | | | by cases hc : ∃ s ∈ st f N, s + N + 1 ∈ st f N | | | · rw step pos f hc ; omega | | | · rw step neg f hc ; simp only List.length cons ; omega | | | | | | /-- MAIN THEOREM. For every monotone f : ℕ → ℕ there is a Sidon set A ⊆ ℕ such that | | | every positive integer d is a difference a' − a of two elements of A, while | | | A has at most 2N elements below f N . Taking f fast-growing makes A | | | arbitrarily sparse. -/ | | | theorem sparse sidon with all differences f : Nat → Nat | | | hf : ∀ a b, a ≤ b → f a ≤ f b : | | | ∃ A : Nat → Prop, | | | IsSidon A ∧ | | | ∀ d, 0 < d → ∃ a, A a ∧ A a + d ∧ | | | ∀ N, ∃ T : List Nat, T.length ≤ 2 N ∧ ∀ n, A n → n < f N → n ∈ T := | | | ⟨fun n = ∃ k, n ∈ st f k, sidon A f, covers f, | | | fun N = ⟨st f N, len st f N, sparse f hf N⟩⟩ | | | | | | print axioms sparse sidon with all differences |