The math room
Eight small environments turn mathematics into ordinary text, then grade the answer with ordinary code.
$ make math
$ make math-measure
The second command starts measure, opens a real WebSocket, and runs 300 tasks
through an independent reader. For every task that reader:
- solves only what appeared in
input_text; - submits the computed answer and expects reward 1;
- resets the same seed and expects the same text, byte for byte;
- adds junk to an otherwise correct answer and expects reward 0;
- steps once after
doneand expects the terminal observation to stay frozen.
Before the sweep it also sends a wrong JSON type and a 511-byte string. The first must be a recoverable protocol error; the second must safely score zero. Nothing in that list asks another model whether an answer looks convincing.
The shape of a task
Here is a complete measure prompt:
MEASURE — convert the clock before using the rate.
A cyclist travels at 40 kilometers per hour for 1 hour and 15 minutes,
including a 15-minute pause. How far does the cyclist travel?
Data: kind=conversion; speed=40 km/h; hours=1; minutes=15; pause=15 min
Return exactly: FINAL: <integer> km
The opening prose is how a person meets the problem. The Data: line says the
same thing compactly, so a unit, convention, or domain cannot hide in an
author's phrasing. The final line gives the answer grammar.
The action is always one string:
{"answer":"FINAL: 40 km"}
A correct answer pays integer 1. Any other string pays 0 and ends the
episode. The answer is revealed only then, when it can no longer be used to
earn reward.
This is intentionally less permissive than a chat interface. The environment is a source of training signal, so the boundary must be unambiguous. Free-form working can be produced or logged, but it is not passed to a second language model for grading.
The eight environments
| Environment | Port | What it practices | First-release tasks |
|---|---|---|---|
measure.c ↗ | 8831 | quantities, units, rates, and practical models | production rates, recipe scaling, time conversion |
algebra.c ↗ | 8832 | expressions and complete solution sets | linear equations, two-variable systems, integer-root quadratics |
change.c ↗ | 8833 | functions and how they vary | derivatives at a point, definite integrals, global maxima |
space.c ↗ | 8834 | coordinates and transformations | squared distance, matrix-vector images, transformed area |
discrete.c ↗ | 8835 | deterministic finite reasoning | recurrences, shortest paths, combinations |
chance.c ↗ | 8836 | finite uncertainty | draws, dependence, conditioning |
evidence.c ↗ | 8837 | reading data and computing evidence | aggregate rates, weighted means, medians with missing data |
reason.c ↗ | 8838 | proof and refutation | checked rule sequences or complete countermodels |
They are divided by the object a learner must reason about:
measurehas a graph of quantities with units;algebrahas a complete solution set;changehas a function and a domain;spacehas points and transformations;discretehas a recurrence, graph, or constrained finite selection;chancehas a known random process;evidencehas observed rows and a named statistic;reasonhas a claim and a proof state.
This is why probability and statistics are separate. In chance, the process
that produces outcomes is known. In evidence, the rows have already happened
and the task is to summarize them correctly. It is also why counting lives in
discrete: choosing a committee is deterministic mathematics until a random
selection rule is introduced.
Difficulty without theater
Every reset accepts:
{"seed":7,"difficulty":2}
There are three presets. Higher presets introduce a different reasoning
structure, not just wider integers. Level 2 samples both its new family and
level 1's; level 3 samples all three. Seeing difficulty: 3 therefore does not
tell a learner which operation to perform.
The knob is useful for curriculum sampling, but it is not an oracle of human difficulty. A short modeling problem can be harder than a long calculation. Real curricula should measure success by subfamily and keep a mixture of comfortable, frontier, and stretch tasks.
The current levels are:
| Environment | Level 1 | Added at level 2 | Added at level 3 |
|---|---|---|---|
| measure | one rate | proportional scaling | clock conversion and an optional pause |
| algebra | linear equation | unique system | complete quadratic root set |
| change | derivative at a point | definite integral | global maximum on a closed interval |
| space | squared distance | matrix image | area under a linear map |
| discrete | recurrence | shortest path | constrained unordered labeled selection |
| chance | one draw | dependent draws | conditioning |
| evidence | aggregate rates | weighted mean | a stated missing-value rule |
| reason | two-step chain | three-step chain | four-step chain |
These are foundations, not claims to contain whole university courses. General symbolic integration, arbitrary limits, affine-unit uncertainty, synthetic geometry proofs, eigenstructure, inferential statistics, and induction are named future work. Each needs a precise answer representation and verifier before it becomes a reward source.
Where entropy belongs
Not every token should be surprising. Stable instructions and stable return
grammars make the task easier to learn and the reward easier to audit. Swapping
calculate, determine, and work out at random would spend entropy on prose
without creating new mathematics.
The changing tokens should alter the decision: coefficients and quantities,
expression shapes, graph edges, table rows, conditioning events, and proof
dependencies. Most environments have three structural families; reason
varies the certificate side and dependency length instead. All eight use broad
value or structure ranges within those choices. mathlab also hashes every
complete prompt inside a preset; more than one repeat in ten fails the run.
That collision check is a warning light, not a complete diversity metric. A thousand different integers can still teach one shortcut. Real evaluation should hold out renderer templates and mathematical structures, then include human-written problems. This separates “the generator produced new bytes” from “the learner met a genuinely new decision.”
Grading without wishful thinking
Seven environments use a canonical bounded answer. reason accepts multiple
certificates and checks their meaning.
A proof looks like:
PROOF: r3,r1,r4
The server starts from the printed facts. Each named rule must be applicable at that moment, and the final derived facts must contain the claim.
A refutation looks like:
COUNTERMODEL: A=1,B=0,C=1,D=0,E=0
The server requires an assignment for every atom, checks every stated fact and
implication, and requires the claim to be false. A bare false earns nothing.
The other graders are intentionally modest:
- integers and reduced fractions use exact arithmetic;
- units are part of the answer, not decoration;
- roots are complete canonical sets;
- coordinate pairs have a declared order;
- probability states replacement and ordering;
- statistics states weighting and missing-value behavior.
There is no executable expression parser, no eval, no NaN-tolerant float
comparison, no unrestricted computer algebra system, and no learned judge.
mathlab: the reader on the other side
mathlab.c ↗ links no environment. It asks the server what it is,
resets it, copies input_text before the next network call invalidates the
observation, and solves the printed task with a separate implementation.
$ build/rel/bin/measure --host 127.0.0.1 --port 8831 &
$ build/rel/bin/mathlab measure http://127.0.0.1:8831 --tasks 300
The report has one row per preset:
preset tasks exact wrong accepted repeats
1 100 100 0 0
2 100 100 0 0
3 100 100 0 1
exact must equal tasks; disagreement is a defect, not an interesting model
result. wrong accepted must be zero. repeats counts equal 64-bit hashes of
input_text within a preset. It is reported rather than hidden, and the run
fails if more than one prompt in ten repeats within any preset. A few exact
collisions can genuinely occur; a dense cluster means the generator needs more
semantic variety.
Run every family and regenerate the committed evidence with:
$ make record-math
The result is math-recordings.txt ↗. It contains a hand
episode and the real mathlab report for each server.
Leaving them up for a training run
$ make math-up
math-up: measure http://127.0.0.1:8831
...
math-up: 8 servers on 127.0.0.1, manifest build/rel/math.json
$ cat build/rel/math.json
{
"measure": "http://127.0.0.1:8831",
"algebra": "http://127.0.0.1:8832",
...
}
$ make math-down
The manifest contains only names and URLs. Action and observation shapes come
from each server's /schema; the manifest does not try to duplicate them.
math-up has its own pidfile, so math-down cannot stop games started by
arcade-up.
What to measure in a real learning experiment
Exact-match accuracy is necessary but not enough. A serious run should also report:
- accuracy per environment and per task kind;
- the worst subfamily, not only the average;
- consistency when the same mathematics is reworded;
- performance on unseen structural templates;
- performance on human-written or human-edited transfer tasks;
- cheap baselines such as last-number, unitless, greedy-edge, unconditional probability, averaging averages, and bare true/false.
Seeds create new values. They do not by themselves create a strong test split. Renderer families, graph shapes, expression shapes, and combinations of skills must also be held out.
The committed environments establish the part that can be proved locally: deterministic generation, sufficient text, exact verification, live negative rewards, and terminal behavior. Whether a model learns and transfers is a separate experiment, and deserves separate evidence.