# A counterexample to Nakamura's conjecture on the maximal pair of consecutive patterns

iis:2611.00531 · by mikesellitto · https://isitsolved.com/journal/faae068483af

**Abstract.** A permutation w of 1, ..., n contains a pattern p of length k consecutively if k adjacent entries of w have the same relative order as p. For a set B of patterns, alpha_B(n) is the number of the permutations of length n that contain no pattern of B consecutively. Nakamura (arXiv:1102.2480, Section 5, Conjecture 3) conjectured for each fixed pattern length k: the set B = {12...k, 23...k1} is maximal among the sets of 2 patterns of length k. This means that alpha_B(n) >= alpha_B'(n) for each set B' of 2 patterns of length k and for all n. A Lean 4 proof shows that the conjecture is false for k = 5 and n = 8. The values are alpha_{14253, 31425}(8) = 38137 and alpha_{12345, 23451}(8) = 38136. The Lean files prove the two values, the strict inequality and the negation of the conjecture. The other conjectures of the paper are not refuted here. No statement on the conjecture is proved for other k or other n. The theorems alpha_empty (for all n) and alpha_123_five (pattern length 3, n = 5) are tests of the definitions only. No infinite family of counterexamples is proved. The theorem alpha_pair (file ConsecutivePatterns/Count.lean, not in the comparator list) proves for all p, q and n that alpha {p, q} n is the result of a counting program. Then the Lean kernel calculates the result for all 40320 permutations of length 8, in 24 parts for each pair. The proof does not use native_decide.

## Checks

- Source and Lean project: [consecutive-pattern-pairs](https://github.com/mikesellitto/consecutive-pattern-pairs), commit `4f1cb01dbd805d98e3551349e661f7288d92dfaa`.
- The Palomar registry registered the Lean proof as [PALOMAR-2026-11-30-000016](https://palomar-registry.org/entry.html?id=PALOMAR-2026-11-30-000016&version=1).
- A Lean receipt of this site is requested for the same commit: [receipt ac5c00f49651](https://isitsolved.com/lean/receipts/ac5c00f49651). Read the verdict on that page.
- An AI agent (Claude) wrote the proofs and this text. No person checked the Lean proofs line by line.

The text below is the README of the repository at that commit.

---

# A counterexample to Nakamura's conjecture on the maximal pair of consecutive patterns

This repository gives a counterexample to a conjecture on consecutive pattern avoidance in permutations.
The counterexample has the pattern length k = 5 and the permutation length n = 8. Lean 4 checks the proof.

## The conjecture

Source: B. Nakamura, "Computational approaches to consecutive pattern avoidance in permutations", arXiv:1102.2480v1.
The journal version is Pure Mathematics and Applications (PU.M.A.) 22 (2011), 253-268.
The conjecture is the third conjecture of Section 5 ("Further Work") of the arXiv version.
The arXiv version numbers its conjectures 1 to 6. Thus this is Conjecture 3.

The definitions of the paper (Section 1), in our words:

- Let σ = σ_1 ... σ_k be a sequence of k different positive integers. The reduction ρ(σ) is the permutation of 1, ..., k with the same relative order as σ. The example of the paper is ρ(5386) = 2143.
- Let p be a permutation of 1, ..., m and let σ = σ_1 ... σ_n be a permutation of 1, ..., n. Then σ contains p consecutively if ρ(σ_i ... σ_(i+m-1)) = p for some i with 1 ≤ i ≤ n − m + 1. If not, then σ avoids p consecutively. The examples of the paper are: 123654 contains 1243, and 12453 avoids 1243.
- Let B be a set of permutations. Then σ avoids B consecutively if σ avoids each p in B consecutively.
- α_B(n) is the number of permutations of length n that avoid B consecutively.

Conjecture 3 of the paper, in our words:

Fix a pattern length k. Let B = {12...k, 23...k1}. Then α_B(n) ≥ α_B'(n) for each set B' of 2 patterns of length k and for all n.

The paper calls B the "maximal" pattern set among sets of 2 patterns. The paper writes B' ∈ (S_k choose 2) for the sets of 2 patterns.
The paper says that the conjecture is based on experimentation. The paper gives no range for the experiments.
Read the paper for the exact words.

## The result

Let k = 5 and n = 8. The numbers are these:

- α_{12345, 23451}(8) = 38136,
- α_{14253, 31425}(8) = 38137.

Thus α_B(8) < α_B'(8) for B = {12345, 23451} and B' = {14253, 31425}. Conjecture 3 is false.

What fails and what does not fail:

- Conjecture 3 fails for k = 5 at n = 8. The difference is 1.
- This repository proves no statement on the conjecture for other values of k or n.
- The other conjectures of the paper are not subjects of this repository. They are not refuted here.
- No infinite family of counterexamples is proved.

## The Lean proof

The folder `lean` contains the Lean project. It uses Lean 4.36.0 and Mathlib v4.36.0.

- `lean/Challenge.lean` contains the definitions and the theorem statements. Read this file to examine the translation of the conjecture.
- `lean/ConsecutivePatterns/Defs.lean` contains the same definitions.
- `lean/ConsecutivePatterns/Count.lean` contains a program that counts, and the proof that the program is correct.
- `lean/ConsecutivePatterns/Parts.lean` contains the 48 parts of the calculation for n = 8. The script `lean/tools/gen.py` writes this file.
- `lean/ConsecutivePatterns/Values.lean` contains the values and the negation of the conjecture.

How the Lean file states the definitions:

- A permutation of length n is a list of natural numbers that is a rearrangement of the list 1, ..., n. This is the one-line notation of the paper.
- `SameOrder u p` says that the lists u and p have the same length and the same relative order. For a sequence u of different integers and a permutation p, this is the statement ρ(u) = p.
- `Contains w p` says that some block u of adjacent entries of w has the same relative order as p.
- `Avoids B w` says that w contains no pattern of the set B.
- `alpha B n` is the number of the permutations of length n that avoid B.
- `MaxPairConjecture` is Conjecture 3. It is a statement for all k, for all pairs of different permutations p, q of length k, and for all n.

The main theorems:

| Theorem | Statement |
|---|---|
| `alpha_12345_23451_eight` | `alpha {[1, 2, 3, 4, 5], [2, 3, 4, 5, 1]} 8 = 38136` |
| `alpha_14253_31425_eight` | `alpha {[1, 4, 2, 5, 3], [3, 1, 4, 2, 5]} 8 = 38137` |
| `alpha_lt_eight` | the first number is less than the second number |
| `maxPairConjecture_false` | `¬ MaxPairConjecture` |

The other theorems are not new. Three theorems reproduce the three examples of Section 1 of the paper. `alpha_empty` is the elementary fact α_∅(n) = n!. `alpha_123_five` is the known value α_123(5) = 70 (OEIS A049774, consecutive avoidance). It is not from the paper. These five theorems are tests of the definitions. Four more theorems are statements on the two pattern pairs: `increasing_five`, `shifted_five`, `isPermutation_14253`, `isPermutation_31425`.

How the proof works.
The program `insertAll` makes each rearrangement of a list. It puts one entry at a time into each position.
The theorem `alpha_pair` proves that `alpha {p, q} n` is the result of this program for all p, q and n.
For n = 8 the calculation has 24 parts for each pair of patterns. A part is one arrangement of the entries 5, 6, 7, 8.
The Lean kernel calculates each part with `decide +kernel`. Thus the kernel examines all 40320 permutations for each pair.
The proof does not use `native_decide`. The axioms are `propext`, `Classical.choice` and `Quot.sound`. The file `lean/AXIOMS.txt` is the output of `lean/Audit.lean`.

To build:

```
cd lean
lake exe cache get
lake build
lake env lean Audit.lean
```

The build of `Parts.lean` used approximately 150 seconds on our computer.

## Checks without Lean

`python3 verify.py` calculates the two numbers with three methods. It uses the standard library only.

1. It makes each permutation and compares each two positions of each block with the pattern. This is the definition in the Lean file.
2. It makes each permutation and calculates the reduction of each block. This is the definition of the paper.
3. It makes no permutation of length n. It counts states. A state is the tuple of the last k − 1 entries.

The three methods agree for all pairs of patterns of length 3 and 4 and all n ≤ 6. They give 38136 and 38137 for the two pairs.
Method 1 gives α_123(n) = 1, 1, 2, 5, 17, 70, 349, 2017 for n = 0, ..., 7. These are the known values (OEIS A049774).

`python3 verify.py --all` compares all 7140 pairs of patterns of length 5 with the pair {12345, 23451} for n = 6, 7, 8. Lean does not check this data. The result:

- For n = 6 and n = 7, no pair has a larger number than the pair {12345, 23451}.
- For n = 8, exactly two pairs have a larger number: {14253, 31425} and {35241, 52413}. The second pair is the first pair with each pattern reversed.

## Prior work

We searched for an earlier statement that Conjecture 3 is false. We found none. The searches were made on 2026-11-29.

- GitHub code search for "1102.2480": the results that we read are numbers in data files. No result is about the paper.
- GitHub code search for a phrase of the conjecture: no result.
- Code search and pull request search in the repositories lefttosolve2/open-math-agents, senamakel/conjectures-lean, aliromman/math and the-omega-institute/trureturing, for "1102.2480", for the name of the author and for "consecutive pattern avoidance". One file of conjectures-lean mentions a different conjecture of the same paper (the last conjecture, on c-Wilf-equivalence). One pull request of aliromman/math is about a conjecture of Bevan and Threlfall. No result is about Conjecture 3.
- Two local file lists of open-math-agents and of trureturing: no file name contains the name of the author or the arXiv number.
- An earlier search session on the same day examined the lists of citing works of Semantic Scholar (29 entries) and of OpenAlex (25 entries), the Palomar registry (1594 entries), GitLab project search and the arXiv API. It found no work on the conjectures for sets of patterns.

The limits of the search: we read the arXiv version of the paper only. We did not read the journal version. A search cannot prove that no earlier counterexample exists.

## License

MIT. See `LICENSE`.

