miniopenenv

arcade/MATH.md → html

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:

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.

§ 1 · The shape of a task

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.

§ 2 · The eight environments

The eight environments

EnvironmentPortWhat it practicesFirst-release tasks
measure.c ↗8831quantities, units, rates, and practical modelsproduction rates, recipe scaling, time conversion
algebra.c ↗8832expressions and complete solution setslinear equations, two-variable systems, integer-root quadratics
change.c ↗8833functions and how they varyderivatives at a point, definite integrals, global maxima
space.c ↗8834coordinates and transformationssquared distance, matrix-vector images, transformed area
discrete.c ↗8835deterministic finite reasoningrecurrences, shortest paths, combinations
chance.c ↗8836finite uncertaintydraws, dependence, conditioning
evidence.c ↗8837reading data and computing evidenceaggregate rates, weighted means, medians with missing data
reason.c ↗8838proof and refutationchecked rule sequences or complete countermodels

They are divided by the object a learner must reason about:

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.

§ 3 · Difficulty without theater

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:

EnvironmentLevel 1Added at level 2Added at level 3
measureone rateproportional scalingclock conversion and an optional pause
algebralinear equationunique systemcomplete quadratic root set
changederivative at a pointdefinite integralglobal maximum on a closed interval
spacesquared distancematrix imagearea under a linear map
discreterecurrenceshortest pathconstrained unordered labeled selection
chanceone drawdependent drawsconditioning
evidenceaggregate ratesweighted meana stated missing-value rule
reasontwo-step chainthree-step chainfour-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.

§ 4 · Where entropy belongs

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.”

§ 5 · Grading without wishful thinking

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:

There is no executable expression parser, no eval, no NaN-tolerant float comparison, no unrestricted computer algebra system, and no learned judge.

§ 6 · mathlab: the reader on the other side

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.

§ 7 · Leaving them up for a training run

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.

§ 8 · What to measure in a real learning experiment

What to measure in a real learning experiment

Exact-match accuracy is necessary but not enough. A serious run should also report:

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.