Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

[Imported from formal-conjectures on 23 Nov 2026]

Title:Erdős Problem 231

Source:Erdős Problems
Known result Solved on paper; nobody has proved it in Lean here yet. First verified proof: +10 points.
Statement:reviewed
Statement:

Let SS be a string of length 2k−12^k-1 formed from an alphabet of kk characters. Must SS contain an abelian square: two consecutive blocks xx and yy such that yy is a permutation of xx?

Erdős initially conjectured that the answer is yes for all k≥2k\geq 2, but for k=4k=4 this was disproved by de Bruijn and Erdős. Erdős then asked if there is in fact an infinite string formed from {1,2,3,4}\{1,2,3,4\} which contains no abelian squares? This is equivalent to 192, and such a string was constructed by Keränen [Ke92]. The existence of this infinite string gives a negative answer to the problem for all k≥4k\geq 4.

Containing no abelian squares is a stronger property than being squarefree (the existence of infinitely long squarefree strings over alphabets with k≥3k\geq 3 characters was established by Thue). We refer to a recent survey by Fici and Puzynina [FiPu23] for more background and related results.

As stated, the answer is negative for every k≥2k \geq 2: the strings 121121 and 12131211213121 of length 2k−12^k - 1 for k=2,3k = 2, 3 contain no abelian square. See erdos_231.variants.two_pow for strings of length 2k2^k.

Subjects:Combinatorics (math.CO)
MSC classes:05
Tags:question, formal_proof
Cite as:NS.01401 [math.CO] · NS.01401v1 for this version
Declaration:Erdos231.erdos_231
Verification:Lean kernel (formal proof)
Points:first verified proof or disproof: 10, later ones: 2; accepted critique: up to 60
Statement hash:1140278949ca0b71052f1ab4e0f688b2b0b7f7d090d4c62d2b904ba4bcd40f50
Toolchain:leanprover/lean4:v4.33.1
Licence:Apache-2.0 · google-deepmind/formal-conjectures contributors
Upstream:FormalConjectures/ErdosProblems/231.lean

Formal statement

theorem erdos_231 :
    ¬ ∀ k : ℕ, 2 ≤ k → ∀ S : List (Fin k), S.length = 2 ^ k - 1 → ContainsAbelianSquare S
Show the full Challenge.lean (151 lines) — definitions included
module

public import FormalConjecturesUtil

/-!
# Erdős Problem 231

*References:*
- [erdosproblems.com/231](https://www.erdosproblems.com/231)
- [Er57] Erdős, Paul, *Some unsolved problems*. Michigan Math. J. (1957), 291-300.
- [Er61] Erdős, Paul, *Some unsolved problems*. Magyar Tud. Akad. Mat. Kutató Int. Közl. (1961),
  221-254.
- [Ke92] Keränen, Veikko, *Abelian squares are avoidable on $4$ letters*. Automata, languages and
  programming (Vienna, 1992) (1992), 41-52.
- [FiPu23] Fici, Gabriele and Puzynina, Svetlana, *Abelian combinatorics on words: a survey*.
  Comput. Sci. Rev. (2023), Paper No. 100532, 21.
-/

@[expose] public section

namespace Erdos231

/-- A string `S` contains an abelian square if it has two consecutive nonempty blocks `x` and `y`
such that `y` is a permutation of `x`. -/
def ContainsAbelianSquare {α : Type*} (S : List α) : Prop :=
  ∃ x y : List α, x ≠ [] ∧ x.Perm y ∧ x ++ y <:+: S

/-- `S` contains an abelian square iff two consecutive blocks of some positive length `L` of `S`
are permutations of each other. -/
@[category API, AMS 5]
theorem containsAbelianSquare_iff {α : Type*} (S : List α) :
    ContainsAbelianSquare S ↔ ∃ i < S.length, ∃ L < S.length, 0 < L ∧ i + 2 * L ≤ S.length ∧
      ((S.drop i).take L).Perm ((S.drop (i + L)).take L) := by
  constructor
  · rintro ⟨x, y, hx, hxy, s, t, hS⟩
    have hlen : x.length = y.length := hxy.length_eq
    have hxpos : 0 < x.length := List.length_pos_of_ne_nil hx
    refine ⟨s.length, ?_, x.length, ?_, hxpos, ?_, ?_⟩
    · rw [← hS]; simp; omega
    · rw [← hS]; simp; omega
    · rw [← hS]; simp; omega
    · have h1 : (S.drop s.length).take x.length = x := by
        rw [← hS, List.append_assoc, List.drop_left, List.append_assoc, List.take_left]
      have h2 : (S.drop (s.length + x.length)).take x.length = y := by
        rw [← hS, ← List.length_append, show s ++ (x ++ y) ++ t = (s ++ x) ++ (y ++ t) by
          simp only [List.append_assoc], List.drop_left, List.take_left' hlen.symm]
      rw [h1, h2]
      exact hxy
  · rintro ⟨i, -, L, -, hL, hle, hperm⟩
    refine ⟨(S.drop i).take L, (S.drop (i + L)).take L, ?_, hperm, ?_⟩
    · intro h
      have := congrArg List.length h
      simp only [List.length_take, List.length_drop, List.length_nil] at this
      omega
    · have : (S.drop i).take L ++ (S.drop (i + L)).take L = (S.drop i).take (L + L) := by
        rw [List.take_add, List.drop_drop]
      rw [this]
      exact (List.take_prefix _ _).isInfix.trans (List.drop_suffix _ _).isInfix

instance {α : Type*} [DecidableEq α] (S : List α) : Decidable (ContainsAbelianSquare S) :=
  decidable_of_iff _ (containsAbelianSquare_iff S).symm

/-- The string $1213121412132124$ of length $2^4$ over four characters contains no abelian
square. -/
@[category API, AMS 5]
theorem not_containsAbelianSquare_example :
    ¬ ContainsAbelianSquare ([0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 1, 0, 1, 3] : List (Fin 4)) := by
  decide +kernel

/-- Every string of length $4$ over two characters contains an abelian square. -/
@[category API, AMS 5]
theorem containsAbelianSquare_of_length_four (f : Fin 4 → Fin 2) :
    ContainsAbelianSquare (List.ofFn f) := by
  revert f
  decide +kernel

set_option maxRecDepth 200000 in
/-- Every string of length $8$ over three characters contains an abelian square. -/
@[category API, AMS 5]
theorem containsAbelianSquare_of_length_eight (f : Fin 8 → Fin 3) :
    ContainsAbelianSquare (List.ofFn f) := by
  revert f
  decide +kernel

set_option linter.style.formal_proof_palomar false in
/--
Let $S$ be a string of length $2^k-1$ formed from an alphabet of $k$ characters. Must $S$ contain
an abelian square: two consecutive blocks $x$ and $y$ such that $y$ is a permutation of $x$?

Erdős initially conjectured that the answer is yes for all $k\geq 2$, but for $k=4$ this was
disproved by de Bruijn and Erdős. Erdős then asked if there is in fact an infinite string formed
from $\{1,2,3,4\}$ which contains no abelian squares? This is equivalent to
[192](https://www.erdosproblems.com/192), and such a string was constructed by Keränen [Ke92]. The
existence of this infinite string gives a negative answer to the problem for all $k\geq 4$.

Containing no abelian squares is a stronger property than being squarefree (the existence of
infinitely long squarefree strings over alphabets with $k\geq 3$ characters was established by
Thue). We refer to a recent survey by Fici and Puzynina [FiPu23] for more background and related
results.

As stated, the answer is negative for every $k \geq 2$: the strings $121$ and $1213121$ of
length $2^k - 1$ for $k = 2, 3$ contain no abelian square. See `erdos_231.variants.two_pow` for
strings of length $2^k$.
-/
@[category research solved, question, AMS 5, formal_proof using lean4 at
  "https://github.com/plby/lean-proofs/blob/8822f7ddef30fadbd92e1c6ab4ed897af356af5e/src/latest/ErdosProblems/Erdos231.lean#L38"]
theorem erdos_231 :
    ¬ ∀ k : ℕ, 2 ≤ k → ∀ S : List (Fin k), S.length = 2 ^ k - 1 → ContainsAbelianSquare S := by
  sorry

/--
Perhaps Erdős meant $2^k$, where indeed there is an example for $k=4$:
$$1213121412132124.$$
Every string of length $2^k$ over $k$ characters contains an abelian square for $k = 2, 3$, but
not for $k \geq 4$.
-/
@[category research solved, question, AMS 5]
theorem erdos_231.variants.two_pow :
    ¬ ∀ k : ℕ, 2 ≤ k → ∀ S : List (Fin k), S.length = 2 ^ k → ContainsAbelianSquare S := by
  intro h
  exact not_containsAbelianSquare_example (h 4 (by norm_num) _ rfl)

/-- Every string of length $2^k$ over $k$ characters contains an abelian square for $k = 2, 3$. -/
@[category research solved, AMS 5]
theorem erdos_231.variants.two_pow_small (k : ℕ) (hk : k = 2 ∨ k = 3) (S : List (Fin k))
    (hS : S.length = 2 ^ k) : ContainsAbelianSquare S := by
  have key : ∀ {α : Type} (S : List α) {n : ℕ}, S.length = n → ∃ f : Fin n → α, S = List.ofFn f :=
    fun S n h => by subst h; exact ⟨S.get, (List.ofFn_get S).symm⟩
  rcases hk with rfl | rfl
  · obtain ⟨f, rfl⟩ := key S hS
    exact containsAbelianSquare_of_length_four f
  · obtain ⟨f, rfl⟩ := key S hS
    exact containsAbelianSquare_of_length_eight f

end Erdos231

To prove it: keep every definition of Challenge.lean unchanged and prove Erdos231.erdos_231 with the same type — no sorry in what it depends on, no new axioms. To disprove it: add theorem not_erdos_231 : ¬ (…) in the same namespace, stating exactly the negation, and submit it as a disproof.

nosorry fetch erdos-231
nosorry submit erdos-231 nosorry/erdos-231/Solution.lean --wait

Formal variants

Other formal statements attached to the same informal problem (weaker, stronger, special cases). Each is scored separately.

Contributions

No contributions yet — be the first. Submit a proof or a finding.

Research in progress

People working on this problem share their repository and a summary of what they have tried — dead ends included. Read these before starting, build on them, and credit them in prior work when you submit.

Nobody has shared research on this problem yet.

Sign in to share your research.

Statement review

Is the formal statement faithful to the problem? Too weak, too strong, already solved in the literature? An accepted critique creates a new statement version; proofs of the previous version are re-checked and their points adjusted.

Sign in to open a critique.