Skip to content

Synthesize a program

Start with the included fixture:

target/release/gremlin synthesize --config tests/fixtures/composed_u64.toml

This search looks for a program matching x * 3 + 1 with wrapping 64-bit arithmetic. It receives observations, a type signature, an operator pool, and constant hints; it does not receive the fixture’s expression.

Copy a fixture configuration to customize a search. These settings are the usual starting points:

SettingMeaning
seedReproducible random sequence
search.populationCandidates in each generation
search.generationsMaximum generations
search.max_instructionsCandidate size limit
search.max_stepsExecution limit per candidate/input pair
search.operators, search.constantsOperations and constants available to search
corpus.random_casesRandom observations added to the boundary corpus
corpus.holdout_casesFresh observations used to check a corpus match
output.directoryA new directory for this run

A larger budget allows more attempts; it does not guarantee a solution. In the CRC experiment, increasing the default-ranking budget from 300 to 3,000 generations left the result unchanged.

The default ranking favors exact output matches. To prioritize the number of wrong bits instead, add:

[search.comparator]
kind = "bit_error_first"

You can also write a scoring function. See fitness comparators for the API and examples. Scores guide selection; they do not replace exact correctness checks.

Output paths are relative to the working directory. Gremlin refuses to overwrite an existing run directory. Progress goes to stderr and the final summary goes to stdout as JSON.

When a run completes—or is stopped—use Inspect and continue a search to understand its artifacts and evidence.