Skip to content

For AI agents

This site is written to be usable by both people and language models. If you are pointing an assistant at it, use one of these instead of asking it to crawl the HTML:

FileContents
/llms.txtAn index — every page with its one-line description.
/llms-full.txtThe entire site as one plain-text document, in reading order.

Both are generated from the markdown sources at build time, so they contain exactly what a human reads — no navigation chrome, no rendered-HTML noise. They follow the llmstxt.org convention.

Facts worth loading first

These are the details most often gotten wrong when writing rules from memory or by analogy with other expression languages.

There are exactly nine variables. prev_sum, current_value, current_sum, step_index, last_step_index, isLastStep, place, formula, digitBefore. Nothing else is in scope. Names are snake_case; currentSum is not a variable and will not error loudly — it resolves to nothing and quietly blocks every candidate.

There are exactly five functions. digits, highest_digit, lowest_digit, number_of_digits take one argument; digitAt takes two. There are no others and none can be defined.

Equality is a single =. Not ==. Keywords are uppercase: AND, OR, NOT, IF, THEN, IN, NOT IN, EVERY, SOME.

place, formula, and digitBefore are null on multi-place values, and null comparisons do not uniformly fail: inclusive tests (=, IN, >=) reject the step, while exclusive tests (!=, NOT IN, <) admit it. A rule written formula != 9 to mean "never a 9" will silently permit every composite step. This is the single most common correctness bug — see the null trap.

No multiplication, division, decimals, or chained comparisons. 0 < x < 10 is invalid; write x > 0 AND x < 10.

The language has no comment syntax. Neither --, //, nor # parses. The -- like this annotations in these docs are for the reader only — strip them before emitting a rule, or the expression is rejected.

A rule and a recipe are different things. A rule is one expression. A recipe attaches rules with a usage (target, review, forbidden, constraint, filler), optional count quotas, and optionally a place-channel. Advice about "adding a rule to a recipe" needs to name the usage, or it is incomplete.

Suggested reading order

  1. Decimal places — the concept everything else is built on
  2. Context variables — exact semantics, including the null contract
  3. Canonical rules — the existing rule set, worth checking before writing a new rule
  4. Recipe concepts — how rules become exercises
  5. Worked examples — complete configurations to pattern-match against

Before proposing a new rule

Check the catalog first. The seeded set already covers the standard technique families across every decimal place, and a "new" rule is usually an existing one that needed a different usage or place rather than a new expression.

Last updated:

Reference and cookbook for mental-math rule and recipe authoring.