[{"data":1,"prerenderedAt":4},["ShallowReactive",2],{"eL3bGP1Psy":3},"# superperm-upper-43-80\n\nA superpermutation on `K` symbols is a word containing every permutation of\nthose symbols as a contiguous substring. This repository contains Lean proofs\nthat there are superpermutations on `K` symbols of length\n\n$$\nK!+(K-1)!+(K-2)!+\\left(\\frac{43}{80}+o(1)\\right)(K-3)!,\n$$\n\ntogether with explicit superpermutations on 8 through 13 symbols.\n[docs/upper-bound-explained.pdf](docs/upper-bound-explained.pdf) is a brief\nsummary of the construction and of the known bounds.\n\n## Results\n\nWrite $F_3(K)=K!+(K-1)!+(K-2)!$. Egan's construction gives superpermutations\nof length $F_3(K)+(K-3)!+K-3$, and Raudvere improved this by one for every\n$K\\ge8$. The main theorem proved here lowers the coefficient of $(K-3)!$\nfrom $1$ to $43/80$:\n\n> For every rational $\\varepsilon>0$ there is an $N\\ge11$ such that every\n> $K\\ge N$ has a superpermutation of length at most\n> $F_3(K)+(43/80+\\varepsilon)(K-3)!$.\n\nThis follows from an explicit bound at every size. For integers $m\\ge9$ and\n$2\\le a\\le m$, put $h=m-1$ and $H=h!$. Then there is a superpermutation on\n$K=m+2$ symbols of length at most\n\n$$\nF_3(m+2)+\\frac{43}{80}H+(a-2)\\frac{17H}{240h}\n+(m-a)\\min\\left(\\frac{17H}{240h},\\frac{(m+1)!}{(a+1)!}\\right).\n$$\n\nFor a given `K ≥ 11`, set `m = K - 2`, try every `a`, and take the floor\nof the smallest value; `python3 tools/finite_bound.py` does this. Both\nstatements have complete Lean proofs. The sharper error term\n`O(log K / (K log log K))` in the coefficient has an\n[ordinary proof](docs/upper-error-term.md) and is not formalized.\n\nThe library also proves the earlier uniform bounds\n$F_3(K)+\\frac35(K-3)!$ for `K ≥ 10` and $F_3(K)+\\frac{101}{120}(K-3)!$ for\n`K ≥ 8`, and the existence of words of lengths 46,181, 408,743 and\n4,035,009 on 8, 9 and 10 symbols. [THEOREMS.md](THEOREMS.md) states\nexactly what is formalized.\n\n## Explicit words\n\n| Symbols | Egan | Egan − 1 | Proved in Lean | Word in this repository |\n|---:|---:|---:|---:|---|\n| 8 | 46,205 | 46,204 | 46,181 | [46,181](words/8/superpermutation-8-46181.txt) |\n| 9 | 408,966 | 408,965 | 408,743 | [408,732](words/9/superpermutation-9-408732.txt) |\n| 10 | 4,037,047 | 4,037,046 | 4,035,009 | [4,034,889](words/10/superpermutation-10-4034889.txt) |\n| 11 | 43,948,808 | 43,948,807 | 43,932,117 | [43,930,680](words/11/superpermutation-11-43930680.txt.xz) (XZ) |\n| 12 | 522,910,089 | 522,910,088 | 522,759,498 | [522,745,581](words/12/superpermutation-12-522745581.txt.xz) (XZ) |\n| 13 | 6,749,568,010 | 6,749,568,009 | 6,748,047,864 | [6,747,918,066](words/13/superpermutation-13-6747918066.txt.xz) (XZ) |\n\nThe eight-symbol word is exactly the construction. For 9 through 13 symbols,\nthe cuts and order of the pieces were then optimized by computer search.\nThose shorter words are not proved in Lean; they are checked by the\nindependent scanner described below. Each file is one line over the alphabet\n`0123456789ABC`, truncated to the required size, followed by one newline\nthat is not counted in the length. The files marked XZ are compressed with\n`xz`, since the words on 11, 12 and 13 symbols would otherwise take about\n44 MB, 523 MB and 6.7 GB; `xz -dk FILE` restores the text file.\n[words/manifest.json](words/manifest.json) records the lengths and hashes.\n\nThe words on 9 through 13 symbols improve on the ones first posted here, which\nare kept in the same folders. They use the same constructions (for 12 and 13\nsymbols, a tighter one in which the connector cycles are chosen again at that\nsize); the gains come entirely from the last step, choosing where each\ncomponent word is cut open and in what order the component words are\noverlapped, which is now optimized by integer programming and local search\nover far more cut positions, exploiting at 12 and 13 symbols that the\ncomponents fall into 48 large groups that are relabellings of one another. At\n10 symbols, six connector cycles were also replaced by one open connector path\nthrough the 28 closed trails they met.\n\nChoosing the connector cycles at 12 and 13 symbols gives the coefficients\n21659/40320 = 0.53718 and 4061/7560 = 0.53717 in place of 43/80 = 0.5375;\nthese are checked by computer but not proved in Lean.\n`tools/generate_large_words.py` rebuilds the older words of lengths\n522,752,900 and 6,747,987,126 on 12 and 13 symbols.\n\n## Check the Lean proofs\n\n| File | Purpose |\n|---|---|\n| [Challenge.lean](Challenge.lean) | The statements, including an independent definition of coverage, separate from the proofs. |\n| [Solution.lean](Solution.lean) | Proofs of the statements in `Challenge.lean`. |\n| [AxiomCheck.lean](AxiomCheck.lean) | Prints the axioms each public theorem depends on. |\n\nThe project pins Lean 4.31.0 and Mathlib. With `elan` and Git installed,\nrun from the repository root:\n\n```sh\nlake exe cache get\nlake build\n```\n\nThe default build compiles the proofs and prints the axiom report. Every\npublic theorem should depend only on `propext`, `Classical.choice` and\n`Quot.sound`; nothing uses `native_decide`. The first build checks the\nfinite certificates behind the construction, which takes a while. To compile\nonly the statements, run `lake build Challenge`.\n\n## Check the word files\n\nThe checker needs a C++17 compiler and Python's standard library. It scans\nevery window of the word, independently of the construction, and confirms\nthat all permutations occur:\n\n```sh\npython3 tools/verify_words.py               # 8 through 11 symbols\npython3 tools/verify_words.py --deletions   # also try deleting each letter\npython3 tools/verify_words.py --degrees 12 13 --deletions\n```\n\nThe `--deletions` option confirms that no single letter can be removed while\nkeeping coverage; it does not rule out other local changes. Compressed files\nare checked against their hashes, extracted one at a time to a temporary\ndirectory and removed afterwards. The thirteen-symbol word expands to about\n6.75 GB, and its check needs about 13 GB of memory.\n\nTo check another word directly:\n\n```sh\nc++ -O3 -std=c++17 tools/literal_check.cpp -o literal_check\n./literal_check 8 01234567 words/8/superpermutation-8-46181.txt --deletions\n```\n\n## Reconstruct the largest words\n\nThe older twelve- and thirteen-symbol words, of lengths 522,752,900 and\n6,747,987,126, can be rebuilt without any solver from the ten-symbol starting\ndata and saved component orders:\n\n```sh\npython3 tools/generate_large_words.py 12 --output-dir generated\npython3 tools/generate_large_words.py 13 --output-dir generated\npython3 tools/verify_words.py --degrees 12 13 --large-dir generated --deletions\n```\n\nThe rebuilt words are checked against the hashes in the manifest. At thirteen\nsymbols the constructor needs about 13.5 GB of disk space. The input data is\nin `tools/construction-input.txt` and `tools/recipes/`.\n\n## AI disclosure\n\nThis project made heavy use of AI models (largely OpenAI's ChatGPT 6 Astra\nand Anthropic's Claude Opus 5.5) for research, formalization, and drafting\nthis repository's documentation.\n\n## License\n\nApache License 2.0; see [LICENSE](LICENSE).\n",1791742513929]