How Litex works

See how the software's parts work together, then follow individual statements as facts are checked, stored, inferred, and reused in later proofs.

The whole system

One component map. Knowledge that carries forward.

Choose the complete knowledge-building example or zoom into a definition, proof, reuse or computation. The fixed component map and detailed flow share one playback position.

Step 1 / 26

Litex component map

Components stay in place; highlighted parts participate in this step.
What happens now

One file enters the system

The standalone file contains a definition, object declarations and facts. The component map shows the software's responsibilities before we follow any one statement.

Example source

Define is_less(x, y) as x < y. Name a = 2 and b = 5, then establish the predicate, read its inferred inequality, and reuse it with c = a and d = b.
1
prop is_less(x, y R):
    x < y
2
have a R = 2
3
have b R = 5
4
by def $is_less(a, b)
5
a < b
6
have c R = a
7
have d R = b
8
$is_less(c, d)

Knowledge available to the next statement

No user knowledge has been committed yet.
This statement's JSON will appear after its effects are committed.
Checked failure boundariesReplacing “have d R = b” with “have d R” leaves d arbitrary. The recorded run cannot establish $is_less(c, d); it returns a search miss with no stored or inferred effects for that statement.
have d R
{
  "success": false,
  "statement": "$is_less(c, d)",
  "why_failed": {
    "phase": "search_proof",
    "goal": "$is_less(c, d)"
  },
  "stores": [],
  "infers": []
}
Detailed execution flowThe same example and playback position, expanded into its internal steps. Select a node to jump to its step; unused candidate routes show their explanation.
1 · Prepare
2 · Store & infer
3 · Use an inference
4 · Reuse with equal arguments
Statement and checking requests
Evidence coming back
Knowledge being recorded
Passed to the next part

The standalone file contains a definition, object declarations and facts. The component map shows the software's responsibilities before we follow any one statement.

Recorded execution, arranged as an explanatory walkthrough. Stepping backward changes the illustration; it does not roll back a running Litex session. JSON is the native summary, not a complete internal call trace.
Explore the atomic verification routes
Litex verification pipeline: a candidate fact passes through well-definedness and bounded local verification, supported by scoped knowledge and builtin rules. Success stores, infers and commits knowledge; failure preserves earlier context. The inset shows direct evidence, known properties, builtin rules, strategies, definitions and forall, and permitted rewriting.

An overview of checking an atomic fact: read the current knowledge, check that expressions are meaningful, and look for supported local grounds. Accepted facts extend the context; an unsuccessful check returns its stopping point while preserving earlier accepted knowledge.

Open original English diagram

A note from the author

Litex from a Systems Engineering Perspective

Litex's central work is to develop a language and verification mechanism that can support everyday mathematical reasoning. Through experiments, refactoring, and real proofs, I have gradually shaped a system of objects (Obj), facts (Fact), and statements (Stmt), with mechanical checks for common relationships between them. These two lines show how those responsibilities meet:

Checked Litex source

have fn reciprocal(x R: x != 0) R = 1 / x
reciprocal(2) = 1 / 2

The first line must establish a valid function before the second can use it. Inside the definition, x is a real number and x ≠ 0 is a local premise: it makes 1 / x meaningful and allows the body to be checked against the real return type. A successful declaration makes the named function, its restricted domain, and its defining equality available to later statements.

For reciprocal(2), the checker first establishes that 2 belongs to the input domain, including 2 ≠ 0. It can then use the recorded definition, substitute 2 for x, and justify the equality with 1 / 2. The condition belongs to the function's interface: every call must satisfy it, even though it was assumed locally while checking the definition.

Rejected at the input-condition check

reciprocal(0) = 0

At zero, the required condition would be 0 ≠ 0. The call therefore fails its well-definedness check before Litex tries to establish the final equality; no fact is stored for this failed statement.

  • Objects (Obj) — represent expressions such as the function, 1 / x, and reciprocal(2), with the conditions under which they are meaningful.

  • Facts (Fact) — express membership, nonzero conditions, and equalities. Their evidence supplies the premises needed by object checks and later deductions.

  • Statements (Stmt) — organize definitions and checks in sequence, determine which scope a premise belongs to, and publish successful results for the next statement.

The difficulty is in the connections between these small steps. An ordinary fact can involve object domains, function guards, definition unfolding, equality substitution, rule premises, and scope at once. Each check may be elementary, but their interfaces must remain consistent as expressions and proof structures nest. Missing support can force authors to repeat mechanical steps; poorly organized verification can miss available evidence or spend unnecessary effort searching for it.

Litex evolves by finding these breaks in real mathematics, refining the expression model, filling missing relationships, and reorganizing verification. The aim is to let common steps compose under explicit premises and within controlled search boundaries. Authors still choose mathematical constructions and key proof routes; the language handles the mechanically checkable connections. A few readable source lines are the visible result of coordinating many such branches around shared mechanisms.

AI makes it possible for me to sustain this intensive design cycle with my own time and resources: propose an organization, implement it, test it on real proofs, and revise it when it fails. My work is to decide which classifications, relationships, and verification flows can work together over time; AI helps me implement, check, and repeatedly change the many details. Without that assistance, I would have found it difficult to explore and implement at a comparable intensity over roughly two years.

Explore the Litex-to-Lean compiler design