02.3 / Lab notebook
← Lab indexKaprekar Geometry and LLM Reliability
Could the gaps between a model’s scores flag an answer worth checking?
Start with four digits. Sort them in both directions, subtract the smaller number from the larger and repeat with the result. Of 10,000 starting states, 9,990 reach 6174 within seven steps. I studied what the gaps between the sorted digits preserve about that process. That result gave me a separate question to test on the gaps between a model’s sorted scores.
Scope and limits
Lean 4 proofs cover core counting lemmas. Formalising the full image theorem is still in progress. The use of sorted logits to route model requests remains a hypothesis.
Read the paperKaprekar Geometry / Workflow
How the digit routine becomes a smaller graph
- Define the digit routine
Keep a fixed digit width, including leading zeros. Subtract the ascending digit arrangement from the descending arrangement.
- Extract ordered gaps
Use differences between paired sorted digits to represent a state.
- Track the reduced graph
Follow the dynamics on the smaller graph of gap states.
- Weight the basins
Count the original states each reduced state represents using exact multinomial weights.
Worked explanationWork through 3524 → 6174
- Input
- Keep four decimal digits: 3524. Sort them into 5432 and 2345; their ordered gaps are 5 − 2 = 3 and 4 − 3 = 1.
- Decision / rule
- Subtract the ascending arrangement from the descending one: 5432 − 2345 = 3087. Repeat: 8730 − 0378 = 8352.
- Outcome
- One more step gives 8532 − 2358 = 6174. Then 7641 − 1467 = 6174, a fixed point.
Scope of this exampleAll-identical digits reach zero: 1111 − 1111 = 0000. A repeated pair is different: 1122 gives 2211 − 1122 = 1089. This arithmetic does not validate the separate LLM hypothesis.
Try it locally.
Run these commands from a checkout of the project. The repository includes setup details and prerequisites.
python3 -m venv .venv
.venv/bin/python -m pip install -e .
.venv/bin/kaprekar verify