Subtraction depends on the number type
(1 : ℕ) - 2 = 0Natural-number subtraction stops at zero; it does not produce an integer −1.
Litex checks 1 - 2 = -1.
DefinitionExperimental beta
A hobby project started in 2024. Litex is still experimental.


“Truth is ever to be found in simplicity, and not in the multiplicity and confusion of things.”
Litex aims to be the Python of formal mathematics. It makes familiar mathematical expressions valid formal code. Write the mathematics, and let Litex explain the logic behind it. On selected measured common statements, its native verification is also 10–100× faster than Lean.
Assume √2 = p/q in lowest terms. Show that p and q must both be even, contradicting gcd(p, q) = 1.
Loading editor…
On common mathematical statements, Litex’s native verification is 10–100× faster than Lean.
Guided by the philosophy of “proof as search,” Litex introduces an innovative verification model for formal languages: each mathematical statement acts as a key, and the proof context as a database specialized for mathematics, used to find the relevant evidence and verification criteria.
Lean / Mathlib · real division
(1 : ℝ) / 0 = 0Mathlib defines real division at zero to return zero. In textbook real arithmetic, the expression is undefined. Definition
Litex checks the domain first: 1 / 0 is rejected before checking the equality.
This is a library convention, not a logical error or a requirement of type theory. Lean can also express explicit domain conditions.
(1 : ℕ) - 2 = 0Natural-number subtraction stops at zero; it does not produce an integer −1.
Litex checks 1 - 2 = -1.
DefinitionReal.sqrt (-1) = 0Undefined in textbook real arithmetic; Real.sqrt returns zero.
Litex requires x >= 0 and rejects sqrt(-1).
Definition⟨x, h⟩ : {y : ℝ // 0 ≤ y}A subtype-based interface may require ⟨x, h⟩: the value paired with its proof. Knowing 0 ≤ x leaves x’s type as ℝ.
Litex uses the known condition x >= 0 directly when checking the argument.
Definition01
Write the next mathematical fact.
You choose the argument. Litex seeks a justification in the available definitions, facts, and rules.
02
Keep familiar mathematical meanings.
Work with sets, elements, functions, and relations. Check that expressions are defined before checking their conclusions.
03
Explore, check, keep, and reuse.
In one live Session, an ordinary rejected step leaves earlier accepted definitions and facts available.
04
People guide. AI proposes. Litex checks.
Structured feedback shows what was accepted and where the next proposal needs repair.
05
Carry supported proofs into Lean.
The compiler replays supported verification records as Lean proofs. It is partially implemented and runnable; see the examples and progress below.

“A mathematician, like a painter or a poet, is a maker of patterns.”
With Litex, you can define mathematical objects, write proofs, and have the computer check each step. Results you have proved can support later calculations and proofs.
Edit and run the geometry proof below. Inspect each checked step, its verification record, and the knowledge graph linking definitions and results.
Describe the objects, their properties, and the conditions under which they can be used.
Write a statement or proof, run the check, and revise it using the feedback.
Use earlier accepted definitions and facts in later steps, wherever they remain in scope.
Save definitions and theorems in files so other files in the project can use them.
Loading editor…
Keep one Session open with -session. A rejected equality leaves the earlier value of a available for the next check.
Terminal REPLRecorded terminal Session · selected JSON fields
litex -strict -lang en -session -e 'have a R = 2'
litex> a = 3
{"run_result": "failure", "session_terminated": false}
litex> a + 1 = 3
{"run_result": "success", "session_terminated": false}Prove in newton.lit that a positive number whose square is 2 stays unchanged by a Newton step. Then use that theorem for √2 in example.lit.
example.litUse the theorem from newton.lit
release obj def newton::newton_sqrt_two
release thm newton::fixed_point(sqrt(2))newton.litNewton step and fixed-point theorem
claim:
? forall x R+:
(x + 2 / x) / 2 $in R+
2 / x > 0
x + 2 / x > 0
(x + 2 / x) / 2 > 0
have fn newton_sqrt_two(x R+) R+ = (x + 2 / x) / 2
thm fixed_point:
? forall x R+:
x^2 = 2
=>:
newton_sqrt_two(x) = x
x = x * x / x = x^2 / x = 2 / x
newton_sqrt_two(x) = (x + 2 / x) / 2 = (x + x) / 2 = xlitex.configLoad the library before the example
[export]
newton = "./newton.lit"
example = "./example.lit"These files belong to one project. The prefix newton:: identifies a definition or theorem from newton.lit.
Litex emphasizes readable mathematical writing. It can turn definitions, statements, and proof steps into LaTeX for notes, teaching materials, and papers. Here, a short proof shows how the Newton step for √2 turns the old error into its square divided by 2x. Compare the checked source with the generated mathematical text.
LitexChecked mathematical source
have r R+ = sqrt(2)
have fn newton(x R+) R = (x + 2 / x) / 2
claim:
? forall x R+:
newton(x) - r = (x - r)^2 / (2 * x)
r^2 = 2
(x - r)^2 = x^2 - 2 * x * r + r^2 = x^2 - 2 * x * r + 2
newton(x) - r = (x^2 - 2 * x * r + 2) / (2 * x) = (x - r)^2 / (2 * x)Let satisfy .
Definition newton.
Let .
Claim.
For every , we have .
Proof.
Further down, see examples of generating executable code and translating Litex proofs for Lean to check.
Explore code generation and Lean compilation
To understand is to see connections.
You choose the mathematical constructions and key intermediate steps. Litex handles the supported local checks; those steps build up a larger proof.
Litex records the mathematics behind your code: definitions, accepted facts, equality relationships, and their scopes. This indexed knowledge forms the context that later proofs can query.
The engine matches a goal against this context and hundreds of builtin mathematical rule branches (bt rules). It checks the required premises and domain conditions, then makes accepted conclusions available for later steps. Search is bounded; authors still supply the main mathematical ideas.

To check a statement, Litex first checks that its expressions are meaningful, then looks for justification in the available definitions, facts, and rules. A statement that passes can be used in later steps. If it fails, Litex reports where the check stopped and keeps earlier accepted results available.
Open original English diagramEach step can use any available fact in its scope, or be established directly by a builtin rule. It need not follow only from the immediately preceding line.
When a builtin rule is used, the record gives its name, arguments, and premise proofs.
The Lean compiler replays supported checks as Lean proof steps. Each verification route needs a faithful mapping; integration is ongoing.

Give AI a language for checkable mathematical work.
Follow a reciprocal proof from a missing condition to success. Click each step to inspect the code and feedback.

A reciprocal proof, repaired from feedback. Output previews are illustrative.
YOUR MATHEMATICAL TASK
Define the reciprocal on nonzero real numbers and prove that multiplying it by its argument gives one.
01 · Start a session
Run with -session and keep the process open while AI adds or repairs statements.
litex -strict -lang en -sessionFirst accepted definitionOne statement in the live Session
have fn reciprocal(x R: x != 0) R = 1 / xLitex responseActual interactive success response
successThe definition is accepted. Save it before moving on.
In an expanding set of formalization experiments, Litex has shown advantages in interacting with AI agents on some mathematical tasks.

“The best way to predict the future is to invent it.”
Generate executable code, compile supported proofs to Lean, and learn through mathematical examples.
Generate Python for a Newton step toward √2, restarting at 1 when the input is zero.
LitexChecked computational definition
algo newton_step(x R) R by cases:
case x = 0: 1
case x != 0: (x + 2 / x) / 2PythonGenerated by the current CLI
def newton_step(x):
if x == 0.0:
return 1.0
elif x != 0.0:
return ((x + (2.0 / x)) / 2.0)
raise AssertionError("unreachable verified Litex cases")Executed: 1.0 → 1.5 → 1.4166666667.
Experimental extraction for supported numeric definitions, with Python and C99 targets. Generated code uses floating-point arithmetic.View Python / C extraction on GitHubFor supported proofs, the compiler turns verification records into Lean proofs for independent checking.
Litex’s large Rust core handles proof search; Lean’s small kernel offers an independent check of the generated proof.
Litex exceeded 200,000 tracked Rust lines under src/ on 15 October 2026, including tests, comments, and blank lines. Lean’s 2015 paper reported about 6,000 lines for its first kernel layer, not today’s Lean 4. These counts cover different scopes; a small kernel aids review but does not guarantee correctness.
LitexWhat you write in Litex
1 = 1Ordinary LeanTypical handwritten style
example : (1 : ℂ) = 1 := by
rflLean from LitexCompiler output · excerpt
import Litex
theorem __fact0 : Litex.Same (1 : ℂ) (1 : ℂ) := by
exact Litex.Same.refl (1 : ℂ)LitexChecked mathematical source
1 = 1Execute
Verification recordExecution feedback · excerpt
{
"statement": "1 = 1",
"statement_result": "accepted",
"proof_method": {
"type": "they_are_the_same",
"rule_name": "Same object"
}
}Compile evidence
Lean from LitexEarlier compiler output · excerpt
import Litex
theorem __fact0 : Litex.Same (1 : ℂ) (1 : ℂ) := by
exact Litex.Same.refl (1 : ℂ)Planned lessons span school mathematics and core undergraduate subjects. Browse the examples available so far.
Explore mathematicsA wider horizon

“Mathematics is the queen of the sciences.”
— Carl Friedrich Gauss
Language carries mathematical knowledge. Litex aims to let everyone who uses mathematics read, check, and help build that knowledge.
Litex organizes proof as search: mathematical statements become lookup keys for finding the required conditions and verification rules in a database specialized for mathematics. Rather than organize proof computation around a general-purpose lambda calculus, it aims to reduce the extra layers needed to express everyday mathematics.