Litex

The Python of formal mathematics

Litex branching tree logo
Pronounced /ˈliːtɛk/ (LEE-tek), not LIE-tek.The name comes from Lisp and TeX. The branching tree stands for mathematics growing out of a few axioms.
Pen sketch of Isaac Newton
“Truth is ever to be found in simplicity, and not in the multiplicity and confusion of things.”
— Isaac Newton

Litex makes mathematics itself formal code.

Litex is a language for writing mathematics that a machine can check. Most proof assistants ask you to build a proof command by command: rewrite here, apply that lemma, split into cases. Litex asks for the mathematics instead. You define an object or state a fact in ordinary notation, and the checker looks through the definitions and facts already in scope for a reason that the step holds. If it finds none, it tells you which step failed and why.

One sentence of mathematics, already doing three jobs.

1 / 6

Every phrase has a job: it names an object, fixes a range, or states what has to be shown. Litex checks the same three things.

The way you would say it

. Then .

The same words in Litex

forall x R:
    x^2 >= 0

What the checker uses

Select a colored phrase to follow it into code and into the reason it holds.

See why each proof step holds

Why √2 is irrational

Secondary
Read this example in the manual

Assume √2 = p/q in lowest terms. Show that p and q must both be even, contradicting gcd(p, q) = 1.

Uses: Built-in primes · Reduced fractions · Euclid on powers

Hover to see why a step holds. ⌘ / Ctrl + click to follow its evidence. Edit, then Check (⌘ / Ctrl + Enter).

Loading the interactive reading…

Pen sketch of Donald Knuth
“An algorithm must be seen to be believed.”
— Donald Knuth

Litex makes formal code easier to write.

Litex takes on more of the details of proving. Authors write definitions and mathematical steps; the system automatically checks domain conditions, searches the context and built-in rules for justification, and records how each step holds. This is Litex’s exploration of a high-level language for formal mathematics—source that follows the mathematical argument, with the language handling the mechanical work of everyday reasoning.

How does Litex verify a statement?

  1. It looks for the definitions and facts that might apply.
  2. It matches a rule, then checks the rule's premises and domains.
  3. It records why the step holds and keeps the conclusion for later steps.

Search is bounded. You still supply the mathematical argument.

See the full checking process

From a general rule to a particular fact.

Set syllogism in Litex and Lean: from every element of A belonging to B and a belonging to A, Litex instantiates x with a and checks the premise to establish a in B. The parallel Lean example shows elaboration, a proof term and kernel checking.

Every element of A belongs to B, and a belongs to A. Litex finds the universal fact, substitutes a for x, checks its premise, and obtains a ∈ B.

Litex · Jiachen Shen · v2 · 2026-11-06litexlang.com ↗Source ↗ ↗SVG ↗ ↗Full size ↗

Measured: program length and checking time

1.0 means the formal source is as long as the informal text; lower is shorter.

Mathematical taskde Bruijn factor ↓Verification (ms) ↓Litex speedup ↑
LitexLeanLean ÷ Litex ↑LitexLean
Set theory: the set of positive reals is nonempty0.541.072.0×0.0846.43976.9×
Natural-number arithmetic: 1 + 1 = 21.005.205.2×0.0371.36136.7×
Universal statement: the sum of two positive reals is positive0.571.342.4×0.39210.48726.7×
The derivative of the square function at 3 is 60.511.342.6×1.46429.94520.5×

22–23 Oct 2026 · warm medians · native checking, excluding startup, imports, output and Lean replay.

See what the same statement means in Litex and in Lean →
Pen sketch of Alfred V. Aho & Jeffrey D. Ullman
“Computer science is a science of abstraction — creating the right model for thinking about a problem and devising the appropriate mechanizable techniques to solve it.”
— Alfred V. Aho & Jeffrey D. UllmanFoundations of Computer Science

Where this is going

Litex aims to be a high-level language for formal mathematics.

Programmers stopped writing machine code. Assembly came first, then C and Python: each step moved the language closer to how people think and left less machine detail to the writer. Formal mathematics is earlier on that road. Proof assistants still ask for proof terms and tactic scripts; Lean's kernel checks them. Checking belongs to the machine, but the writing does not — it is still closer to the machine than to the mathematics. Litex is meant to be the next layer: you write mathematics, the language handles the routine steps, and supported proofs compile to a system that checks them. Lean works today; the other backends are goals.

Litex as a universal mathematical frontend: an analogy with higher-level programming languages, bringing mathematical objects, facts, statements and proof-context management into a shared authoring language above different proof systems.View full-size diagram ↗

One Litex proof, and the Lean code the compiler generates for it.

Proof compilation

Litex source

Source ↗
# The number one equals itself.

1 = 1

Generated Lean

Complete file ↗
import Litex

set_option linter.unusedVariables false

namespace LitexCompiled.file_lean_x2f_examples_x2f_one_x5f_equals_x5f_itself_x2f_statement_x2e_lit

universe u
variable {M : Litex.Semantics.{u}}

theorem h_1 : Litex.Same (Litex.number (M := M) (1 : ℂ)) (Litex.number (M := M) (1 : ℂ)) :=
  (by
    litex_complete =>
      exact (
        (show @Eq M.Value _ _ from Eq.refl _)
      )
  )
end LitexCompiled.file_lean_x2f_examples_x2f_one_x5f_equals_x5f_itself_x2f_statement_x2e_lit
Definitions and proof rules: Litex.lean ↗
See what the compiler does today →
Pen sketch of G. H. Hardy
“A mathematician, like a painter or a poet, is a maker of patterns.”
— G. H. Hardy

Litex puts formal code to work beyond verification.

Turn a Litex proof into an interactive textbook, explore its dependency graph, export it to LaTeX, or reuse its theorems in another proof.

Interactive textbooks

Set a to 1. Hover over the next line to see why it holds.

Loading the interactive reading…

Open the textbook →

Knowledge graphs

Follow the definitions and facts one proof depends on.

Fns: 0 · Props: 0 · Theorems: 0 · Retained facts: 2 · Citations: 1 · Nodes: 2 · Edges: 1
(a + 1) = 2(a + 1) = 2factlet a = 1let a = 1fact
See the graph →

LaTeX

Newton’s update, typeset from its Litex definition.

Litex

have fn newton(x R+) R = (x + 2 / x) / 2
newton(x)=x+2x2\mathit{newton}(x) = \frac{x + \frac{2}{x}}{2}
See the output →

Python

Run the Newton step as a Python function.

Litex

algo newton_step(x R) R by cases:
    case x = 0: 1
    case x != 0: (x + 2 / x) / 2

Python

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")
See the Python →
Sessions and file reuse →
Pen sketch of Richard Feynman
“What I cannot create, I do not understand.”
— Richard Feynman

Litex grew out of Math for AI.

Litex is useful at every stage of AI work. When training a model, the verification record of every step can serve as feedback. When an agent works on a mathematics problem, it can submit one proof step at a time in the same Litex Session, repair the step that fails, and keep the results already accepted. In AI safety experiments, the action rules can be written down first, and Litex checks a proposed action against them before the agent acts.

Run with -session and keep the process open while AI adds or repairs statements.

First accepted definition

One statement in the live Session

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

Litex response

Actual interactive success response

success

The definition is accepted. Save it before moving on.

Pen sketch of Isaac Newton
“If I have seen further, it is by standing on the shoulders of giants.”
— Isaac Newton

Why this matters.

Language carries information and is itself information. Litex aims to make mathematics as code useful to everyone who uses and loves mathematics.

Sponsors and partners

FDU logo
AI Lab logo
Ant Phecda Lab logo
“From knotted cords to symbolic notation, the choice of representation has always shaped human thought. Arabic numerals and Newton's calculus notation prevailed because of their clarity and simplicity. As formal languages evolve today, Litex may likewise open new possibilities by enabling us to reason clearly, simply, and formally.”

Zeyu Zheng

PhD Candidate at CMU

“The only language capable of verifying advanced arguments using the mathematical notation familiar since elementary school.”

Yuniruyuni

Math Lover from Japan

More reader comments and acknowledgements
“I appreciate a serious contender in the field of interactive theorem proving. Currently the field is dominated by Lean and Rocq, and I appreciate that Litex is challenging this duopoly.”

Huỳnh Trần Khanh

Lean Expert from Vietnam

“Litex is a hacker-built, community-driven, and highly creative project that brings value to everyone working on AI and mathematics.”

Siqi Sun

CTO of Intelligen, Research Scientist at Shanghai AI Lab and Fudan University

“I'm a happy researcher dedicated to making AI more trustworthy and protective of humanity. Litex is the formal language that can help align AI reasoning with human understanding in this big AI dream!”

Jie Fu

Yoshua Bengio's Postdoc

“Litex is much easier to use compared to other formal languages like Lean. While it is still in its infancy, I believe it has the potential to become a powerful research tool that every scientist will be able to easily use and be eager to adopt in the future.”

Yan Lu

Research Scientist at Shanghai AI Lab

Special thanks to Wei Lin, Siqi Sun, Peng Sun, Yi Wang, Chenxuan Huang, Yan Lu, Sheng Xu, Hao Wu, Keyao Zhu, Xingjian Ma, and Zhaoxuan Hong for their support and advice.

Interested in language design, formalization experiments, or a real use case? Get in touch.

For a bug, include the code that reproduces it. One person maintains the code, the docs, and this website, so replies can take a while.

Litex is one large codebase maintained by one person. About 4,000 examples and more than 3,000 test functions run before each release, and the frontier models available to us review the source. Bugs remain. Lean compilation adds a second, independent check for the proofs it supports.