Patterns a 0-1 string can dodge forever

AI-generated · No human mathematician has yet refereed the proof.

An endless 0-1 string avoids a formula like ABA.BAB.ACA if no choice of blocks puts every fragment in it. Assuming seven such formulas are avoidable and five are not, Lean proves a four-letter one without fragment XXX is avoidable exactly when it contains one of the seven after renaming letters.

If the formulas of S₁, G₂ to G₆ and S₁₀ are 2-avoidable and none of the formulas of M₁ to M₅ is, then for every arrow diagram G on the 4 vertices 0, 1, 2, 3, the formula of G is 2-avoidable exactly when one of S₁, G₂ to G₆ and S₁₀ can be relabelled into G; and with no assumption, the diagrams on 4 vertices with at least one arrow fall into exactly 217 classes, of which exactly 12 hold one of those seven.

Ochem and Rosenfeld (2021) proved that the xyx-formula with all 12 fragments on four letters is 2-avoidable, their Theorem 23, and listed among things attempted without success to "Improve Theorem 23 by showing that some xyx-formula on 4 variables and fewer fragments is 2-avoidable." The site answers with the whole table: 12 of the 217 classes can be avoided and 205 cannot. The Lean traced here checks the census and the step from the outside facts to the table.

Seven minimal and five maximal diagrams split the 217 four-letter classes into 12 and 205

Walkthrough: 4 of 8 main results in Lean; in the Lean traced here, 2 more take outside facts as hypotheses and 2 are outside it

Ochem and Rosenfeld’s Lemma 18 is re-proved inside Lean. Their descent method and Narayana’s word are used by the certificate programs outside Lean; the Lean traced here proves only the logical form of such a descent, not the certificates.

Published inputs

  • Ochem & Rosenfeld (2021) (Re-proved in Lean): Introduced xyx-formulas, wrote each one as a diagram with an arrow X → Y for every fragment XYX, and proved (their Lemma 18) that an occurrence of a formula pulls back along an arrow-keeping map of diagrams.
  • Ochem & Rosenfeld (2021) (Assumed outside Lean): Proved their Theorem 23 with Cassaigne’s descent method; the paper’s seven descent certificates follow that method.
  • OEIS Foundation Inc.; Shallit (2025) (Assumed outside Lean): Narayana’s word, the fixed point of 0 ↦ 01, 1 ↦ 2, 2 ↦ 0, which the paper calls classical (Shallit surveyed its properties); its three binary images α(nar), β(nar) and γ(nar) are the avoiding words.

What this paper adds

  • Census, dichotomy & descent soundness: 217 classes of diagrams on 4 vertices; Above one of seven or below one of five; 12 classes contain one of the seven; Why a closed list of descent states rules out an occurrence
  • The classification, given the outside facts: 2-avoidable exactly when one of the seven fits inside; At most 8 fragments are never 2-avoidable
  • Certificates outside the Lean traced here: Five exhaustive searches; Seven descent proofs; Avoiding the seven together

A four-letter xyx-formula is 2-avoidable exactly when it contains one of seven (here given outside certificates)

Under the loopless reading (no fragment XXX), an xyx-formula on 4 variables is 2-avoidable exactly when its diagram contains one of the seven minimal diagrams; 12 of the 217 classes are 2-avoidable, 205 are not, and the fewest fragments of a 2-avoidable one is 9. The Lean traced here proves the classification from two facts checked outside it, that the seven are 2-avoidable and that M₁ to M₅ are not, and proves with no assumption that 12 of the 217 classes contain one of the seven.

4 of 8 main results in the Lean traced here: the count of 217 classes, the seven-or-five dichotomy, the 12 classes that contain one of the seven, and descent soundness. 2 are Lean + certificate: the classification and the at-most-8-fragments corollary, which assume that the seven are 2-avoidable (the classification) and that M₁ to M₅ are not (both), checked outside it. 2 are certificate only here: the exhaustive searches with the descent proofs, and the joint-avoidance results.

Listed as open in the paper

  • A proof that α(nar), β(nar) and γ(nar) avoid the seven minimal formulas by a second method (such as Walnut) or by hand.
  • The full census on 5 variables, beyond the transitive tournament TT₅, remains open.
  • Conjecture 9, that the binary words avoiding the formula of G₃ grow polynomially in number and every recurrent endless binary word avoiding it has the same set of factors as α(nar) or as one of its three complement or reversal images.
  • Extending the four-variable classification to 3-avoidability and to general avoidability indices.

Adjacent prior work (not used as inputs)

  • Ochem & Rosenfeld (2021), Theorem 23 and Section 7: Proved that the formula with all 12 fragments on four letters is 2-avoidable, and listed among items attempted without success finding a 2-avoidable xyx-formula on 4 variables with fewer fragments, the question this classification takes up.
  • Badkobeh & Ochem (2023): Studied characterizations of morphic words by the formulas they avoid, and caution that polynomial growth alone does not force uniqueness; the framework for Conjecture 9.
  • Ochem & Rosenfeld (2017) (not fully read); Gamard, Ochem, Richomme & Séébold (2018) (not fully read); Currie, Mol & Rampersad (2018) (not fully read): Related families of avoidable formulas, with two variables, circular formulas, and avoidance bases for formulas with reversal.

The formula S₁ as nine arrows

Write each fragment XYX as an arrow X → Y, with A, B, C, D as the vertices 0, 1, 2, 3. The formula ABA.ACA.ADA.BAB.BCB.BDB.CAC.CBC.CDC, S₁, has the arrows 01, 02, 03, 10, 12, 13, 20, 21, 23, the leading nine of the 12 positions, so its arc mask is 2⁹ − 1 = 511. Narayana's word grows from 0 by 0 → 01, 1 → 2, 2 → 0 and begins 0120010120120; replacing 0 by 0, 1 by 11 and 2 by 01 gives α(Narayana), which begins 0110100110110101101. Try the formula ABA.ACA.ADA.BAB.BCB.BDB.CAC.CDC.DAD, G₃, with A = 1, B = 0, C = 10, D = 01. The fragments become 101, 1101, 1011, 010, 0100, 0010, 10110, 100110 and 01101, and all of them except BDB = 0010 appear in those 19 letters. The site argues that 0010 never appears in α(Narayana); Lean checks the 19 letters, not that argument.

Diagrams, formulas and avoiding

Each arrow X → Y of a diagram stands for the fragment XYX, so an xyx-formula on four letters is a diagram on 4 vertices with no arrow from a vertex to itself. A string contains the formula when some non-empty block for each vertex puts every fragment in it as a factor, and the formula is 2-avoidable when some endless 0-1 string contains no occurrence. If a diagram can be relabelled into a larger one, avoiding the smaller formula avoids the larger, so adding arrows keeps a formula 2-avoidable.

  • 2-avoidability passes to a larger diagram

    If H can be relabelled into G and H is 2-avoidable, then so is G.

    theorem XYXAvoid.avoidable2_of_emb {V₁ : Type u_1} {V₂ : Type u_2} {H : LooplessDigraph V₁} {G : LooplessDigraph V₂} (e : DigraphEmb H G) (hH : Avoidable2 H) :
      Avoidable2 G
  • Relabelling H so that every arrow of H is an arrow of G
  • Same diagram up to relabelling
  • A relabelling is an arrow-keeping map
  • A same-diagram matching keeps arrows
  • A same-diagram matching can be reversed
  • A factor of an endless string
  • Arrow diagram
  • Arrow-keeping map
  • Occurrence of a formula in an endless string
  • An endless string avoids a formula
  • 2-avoidable
  • A string that avoids H avoids G when H maps into G

    If there is an arrow-keeping map from H to G and W avoids the formula of H, then W avoids the formula of G.

    theorem XYXAvoid.avoidsInf_of_hom {V₁ : Type u_1} {V₂ : Type u_2} {α : Type u_3} {H : LooplessDigraph V₁} {G : LooplessDigraph V₂} (φ : DigraphHom H G) {W : ℕ → α} (hav : AvoidsDigraphInf H W) :
      AvoidsDigraphInf G W
  • 2-avoidability passes along an arrow-keeping map

    If there is an arrow-keeping map from H to G and the formula of H is 2-avoidable, then so is the formula of G.

    theorem XYXAvoid.avoidable2_of_hom {V₁ : Type u_1} {V₂ : Type u_2} {H : LooplessDigraph V₁} {G : LooplessDigraph V₂} (φ : DigraphHom H G) (hH : Avoidable2 H) :
      Avoidable2 G
  • Relabelling does not change 2-avoidability

    Two diagrams that are the same up to relabelling are both 2-avoidable or both not.

    theorem XYXAvoid.avoidable2_iff_of_iso {V₁ : Type u_1} {V₂ : Type u_2} {H : LooplessDigraph V₁} {G : LooplessDigraph V₂} (e : DigraphIso H G) :
      Avoidable2 H ↔ Avoidable2 G

Diagrams as 12-digit numbers

A diagram on the vertices 0 to 3 has 12 possible arrows, so Lean records it as an arc mask, a number from 0 to 4,095 whose binary digits say which arrows are present. Every diagram on 4 vertices is the diagram of a mask up to relabelling, and each of the 24 relabellings of the vertices acts on masks by moving digits with their arrows.

  • Every diagram on 4 vertices has a mask

    Every arrow diagram on 4 vertices is, up to relabelling, the diagram of some arc mask.

    theorem XYXAvoid.exists_mask_iso (G : LooplessDigraph (Fin 4)) :
      ∃ m, Nonempty (DigraphIso (maskToDigraph m) G)
  • Arc mask
  • Powers of 2 up to 2¹¹
  • Arrow i is present
  • Packing 12 yes-or-no answers
  • The arrow at position i
  • The position of an arrow
  • The diagram of a mask
  • The mask of a diagram
  • Number of arrows
  • Sending 0, 1, 2, 3 to any vertices a, b, c, d
  • The 24 relabellings
  • The reverse relabelling
  • Relabelling k as a matching
  • Where relabelling moves an arrow
  • Where the reverse relabelling moves an arrow
  • Relabelling a mask
  • Relabelling a mask, as an arc mask
  • The reverse relabelling restores a mask

    Relabelling a mask by k and then by its reverse gives the mask back.

    theorem XYXAvoid.permMask_inv (k : Fin 24) (m : Mask4) :
      permMask (perm4InvIdx k) (permMask k m) = m

There are 217 classes with an arrow

The canonical mask of a mask is the smallest of its 24 relabellings, and Lean lists 218 canonical masks. Their classes share no mask, and Lean evaluates that their sizes add up to 4,096, so every mask is a relabelling of exactly one of them. Leaving out the empty diagram, there are 217 classes with at least one arrow.

  • There are 217 classes with at least one arrow

    Up to relabelling, there are exactly 217 arrow diagrams on 4 vertices with at least one arrow.

    theorem XYXAvoid.card_classes_4 :
      nonemptyClasses4.card = 217
  • The smallest relabelling
  • Canonical mask
  • Some relabelling gives the canonical mask

    Some relabelling of m equals its canonical mask.

    theorem XYXAvoid.exists_permMask_eq_canon4 (m : Mask4) :
      ∃ k, permMask k m = canon4 m
  • Relabelling does not change the canonical mask

    A mask and any relabelling of it have the same canonical mask.

  • The 218 canonical masks
  • Removing repeated numbers
  • Fast relabelling
  • All relabellings of a mask
  • The set of relabellings
  • The 218 classes hold 4,096 masks in all

    The numbers of different relabellings of the 218 listed masks add up to 4,096.

  • The 218 canonical masks, as arc masks
  • The set of the 218 canonical masks
  • The set of canonical masks has 218 members

    The set made from the list has 218 members.

    theorem XYXAvoid.canon218Finset_card :
      canon218Finset.card = 218
  • A listed mask is its own canonical mask

    For each listed mask, the canonical mask is the mask itself.

  • Different listed masks have no relabelling in common

    Two different listed masks share no relabelling.

  • Every mask is a relabelling of a listed one

    The relabellings of the 218 listed masks are all 4,096 masks.

  • Every canonical mask is listed

    The canonical mask of any mask is one of the 218.

  • The canonical masks are exactly the 218

    The canonical masks of all 4,096 masks form exactly the listed set.

  • All diagrams on 4 vertices, up to relabelling
  • All diagrams with an arrow, up to relabelling

12 classes hold one of 7, and 205 fit inside one of 5

Lean names seven diagrams, S₁, G₂ to G₆ and S₁₀, and five, M₁ to M₅, and checks that none of the seven fits inside any of the five. For each of the 217 classes a listed witness shows that one of the seven fits inside it, for 12 classes, or that it fits inside one of the five, for 205. Every class among the 12 has at least 9 arrows, and exactly 6 of them have 9.

  • Every mask holds one of the 7 or fits inside one of the 5

    Every one of the 4,096 masks either holds one of S₁, G₂ to G₆ and S₁₀ after relabelling, or fits inside one of M₁ to M₅ after relabelling.

    theorem XYXAvoid.mask4_dichotomy (m : Mask4) :
      isAboveMin7 m ∨ isBelowMax5 m
  • 12 classes hold one of the 7

    Exactly 12 of the 217 classes hold one of S₁, G₂ to G₆ and S₁₀.

    theorem XYXAvoid.card_avoidable_classes :
      avoidableClasses4.card = 12
  • Strictly increasing list
  • Every arrow of one mask is in the other
  • Fast arrow inclusion
  • One diagram fits inside another
  • Fitting inside can be decided
  • Fitting inside is transitive

    If m₁ fits inside m₂ and m₂ inside m₃, then m₁ fits inside m₃.

  • Relabelling the smaller diagram keeps fitting

    If a relabelling of m₁ fits inside m₂, so does m₁.

  • Relabelling the larger diagram keeps fitting

    If m₁ fits inside a relabelling of m₂, it fits inside m₂.

  • Fitting inside is relabelling into

    A mask fits inside another exactly when its diagram can be relabelled into the other's diagram.

  • The diagram S₁
  • The diagram G₂
  • The diagram G₃
  • The diagram G₄
  • The diagram G₅
  • The diagram G₆
  • The diagram S₁₀
  • The diagram M₁
  • The diagram M₂
  • The diagram M₃
  • The diagram M₄
  • The diagram M₅
  • The 7 diagrams S₁, G₂ to G₆ and S₁₀
  • The 5 diagrams M₁ to M₅
  • The 7 diagrams S₁, G₂ to G₆ and S₁₀, as diagrams
  • The 5 diagrams M₁ to M₅, as diagrams
  • None of the 7 fits inside any of M₁ to M₅

    No diagram of S₁, G₂ to G₆ and S₁₀ fits inside any of M₁ to M₅.

  • Witnesses for 12 classes
  • Witnesses for 205 classes
  • The 12 witnesses check out

    For each of the 12 witnesses, the named diagram, relabelled, has all its arrows in the mask; Lean evaluates it.

  • The 205 witnesses check out

    For each of the 205 witnesses, the mask, relabelled, has all its arrows in the named one of M₁ to M₅.

  • The 12 witness masks, each holding one of the 7
  • The 205 witness masks, each fitting inside one of the 5
  • Every canonical mask other than 0 is among the 12 or the 205

    Each of the 217 canonical masks other than 0 is in the list of 12 or the list of 205.

  • Holds one of the 7 diagrams S₁, G₂ to G₆ and S₁₀
  • Fits inside one of M₁ to M₅
  • Holding one of the 7 can be decided
  • Each of the 12 holds one of the 7

    Each of the 12 masks holds one of S₁, G₂ to G₆ and S₁₀.

  • Each of the 205 fits inside one of the 5

    Each of the 205 masks fits inside one of M₁ to M₅.

  • Classes holding one of the 7
  • Classes holding none of the 7
  • The classes holding one of the 7 are the 12

    The classes other than 0 that hold one of the 7 are exactly the 12 listed masks.

  • 205 of the 217 classes hold none of the 7

    Exactly 205 of the 217 classes hold none of S₁, G₂ to G₆ and S₁₀.

  • A class holding one of the 7 has at least 9 arrows

    Each of the 12 classes that hold one of S₁, G₂ to G₆ and S₁₀ has at least 9 arrows.

  • A class with at most 8 arrows holds none of the 7

    Every class other than 0 with at most 8 arrows holds none of S₁, G₂ to G₆ and S₁₀.

  • 6 classes with 9 arrows hold one of the 7

    Exactly 6 of the 12 classes that hold one of S₁, G₂ to G₆ and S₁₀ have 9 arrows.

The table, given the twelve outside facts

Assume that the formulas of the seven are 2-avoidable and those of M₁ to M₅ are not, as programs outside the Lean traced here report. Take any diagram on 4 vertices, and write it as the diagram of a mask. If one of the seven fits inside it, its formula is 2-avoidable; otherwise it fits inside one of M₁ to M₅, and it is not, because avoiding it would avoid that larger one. With only M₁ to M₅ assumed, the same argument shows that no diagram on 4 vertices with at most 8 arrows is 2-avoidable.

  • If the seven are 2-avoidable and M₁ to M₅ are not, a 4-vertex diagram is 2-avoidable exactly when one of the seven fits inside it

    Suppose the formulas of S₁, G₂ to G₆ and S₁₀ are 2-avoidable and those of M₁ to M₅ are not. Then the formula of an arrow diagram on 4 vertices is 2-avoidable exactly when one of the 7 can be relabelled into it.

    theorem XYXAvoid.r16_1_1_classification (h_min7 : ∀ (i : Fin 7), Avoidable2 (min7Graph i)) (h_max5 : ∀ (j : Fin 5), ¬Avoidable2 (max5Graph j)) (G : LooplessDigraph (Fin 4)) :
      Avoidable2 G ↔ ∃ i, Nonempty (DigraphEmb (min7Graph i) G)
  • If M₁ to M₅ are not 2-avoidable, no 4-vertex diagram with at most 8 arrows is

    Suppose none of the formulas of M₁ to M₅ is 2-avoidable. Then for every mask with at most 8 arrows, the formula of its diagram is not 2-avoidable.

    theorem XYXAvoid.r10_2_1_le8_unavoidable (h_max5 : ∀ (j : Fin 5), ¬Avoidable2 (max5Graph j)) (m : Mask4) (h8 : arcCount ↑m ≤ 8) :
      ¬Avoidable2 (maskToDigraph m)

Why a closed list of states rules out an occurrence

That the seven are 2-avoidable is outside the Lean traced here. It is shown by descent, which keeps a list of states, each a system of demands an occurrence must meet, with a count such as the number of blocks not yet fixed. The Lean traced here proves the logical form of such a proof: if every occurrence would satisfy the starting state at its total block length, and every satisfied state of the list leads to one with a lower count, or with the same count and a smaller size, then there is no occurrence. It does not read the lists themselves.

  • A closed list of states in which the count falls, or stays the same while the size falls, proves avoidance

    Give each state a count. Suppose every occurrence of G in W satisfies a starting state of a list at its total block length, and every satisfied state of the list leads to one with a lower count, satisfied at some size, possibly a larger one, or with the same count, satisfied at a smaller size. Then W avoids G.

    theorem XYXAvoid.freeze_or_desub_soundness {V : Type u_1} {α : Type u_2} {State : Type u_3} [Fintype V] (G : LooplessDigraph V) (W : ℕ → α) (freeVars : State → ℕ) (Sat : State → ℕ → Prop) (Cert : Set State) (s₀ : State) (hstart : s₀ ∈ Cert) (hinit : ∀ (h : V → List α),
      (∀ (v : V), h v ≠ []) → (∀ (u v : V), G.adj u v → IsFactorInf (h u ++ h v ++ h u) W) → Sat s₀ (occMeasure h)) (hclosed : ∀ s ∈ Cert,
      ∀ (μ : ℕ),
        Sat s μ →
          (∃ s' ∈ Cert, freeVars s' < freeVars s ∧ ∃ μ', Sat s' μ') ∨
            ∃ s' ∈ Cert, freeVars s' = freeVars s ∧ ∃ μ' < μ, Sat s' μ') :
      AvoidsDigraphInf G W
  • In a closed list of shrinking states, no state is ever satisfied

    Suppose every state of a list that is satisfied at some size leads to a state of the list satisfied at a smaller size. Then no state of the list is satisfied at any size, because sizes cannot shrink forever.

  • Total block length
Short

Watch on YouTube ↗