Litex

Python of Formal Mathematics

Litex branching tree logo
Litex: Lisp for logic, TeX for beauty.A branching tree of formal mathematics, growing from minimal 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 is a high-level language for formal mathematics

Litex is a high-level language for formal mathematics. Instead of building proofs command by command, you write natural mathematical statements: Litex automatically checks domain conditions (such as nonzero denominators) and searches existing context for justifications.

Litex makes formal code feel natural

1 / 6

Everyday mathematical writing already has rigorous logical structure; Litex lets that structure become checkable formal code directly.

The way you would say it

. Then .

The same words in Litex

forall x R:
    x^2 >= 0

The same words in Lean

Extra proof commands
theorem nonneg_sq (x : ℝ) : x ^ 2 ≥ 0 := by
  exact sq_nonneg x

Lean requires a theorem name ('nonneg_sq'), ':= by', and a library lemma call ('exact sq_nonneg x') beyond the mathematical statement itself.

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

Click a statement to locate its JSON record. Hover for proof details. Edit, then Check (⌘ / Ctrl + Enter).

Why √2 is irrational

(Secondary)

Loading the interactive reading…

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

Litex automatically checks domains and finds justifications

Litex takes on routine deduction. Just as Python manages memory so programmers can focus on algorithms, Litex automatically checks domain conditions and verifies routine steps so authors can focus on the mathematical argument.

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 ↗
See the full checking process

What does Litex build on?

Litex provides basic mathematical objects and their relations, mathematical axioms, and reasoning mechanisms such as syllogisms, contradiction and case analysis: the bricks and mortar. Your definitions, assumptions and verified facts form the context in which it searches for evidence.

What about a complicated proof?

Finding a proof may require deep insight. Checking it can be broken down into basic steps: substitution, calculation and applying established results. Litex also automatically checks domain conditions, such as a denominator being nonzero, and retrieves known facts. It searches for evidence for each step and makes its conclusion available to later steps, without needing a dedicated builtin rule for every new theorem.

What about abstract concepts?

An abstract concept can be defined by combining existing objects, properties and conditions. Litex lets you define new mathematical concepts yourself. Your concepts can then be used in the next layer of definitions and proofs, building the edifice of mathematics step by step.

A finite set of basic mechanisms can be combined repeatedly. This does not mean Litex already covers all mathematics; support for particular constructions and proofs still needs to be tested in practice.

Measured: program length and checking time

The de Bruijn factor compares formal code length to ordinary mathematical text: 1.0 means equal length; 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

A High-Level Language & Universal Frontend

Litex: A universal mathematical frontend across proof systems.

In programming, developers moved from assembly to Python to focus on algorithms. In formal mathematics, Litex serves as a high-level language and universal frontend: write mathematics once with automatic domain checks, compile supported proofs directly to Lean 4 today for independent kernel verification, and extend toward Coq (Rocq) and Isabelle on the roadmap.

Litex as a universal mathematical frontend: an analogy with higher-level programming languages, bringing mathematical objects, facts, statements and automatic domain checking into a shared authoring language above Lean, Coq, and Isabelle.View full-size diagram ↗

Live compiler example: a Litex source and the Lean 4 proof generated from 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

One Litex source, beyond proof checking

From a single formal Litex source—without maintaining separate prose and proof files—generate a typeset interactive textbook (litex -reading -latex), inspect its dependency graph, export LaTeX, or compile supported numerical definitions to Python.

Interactive textbooks

litex -reading -latex

Conventional digital math notes either offer natural-language prose with no formal verification, or place prose and low-level proof scripts in two disconnected layers. In Litex, a single verified source is enough: litex -reading -latex compiles it directly into the typeset textbook below—click any sentence or symbol to inspect its cited reasons and domain conditions, switch to the Litex source, or click “Try editing” to modify and recheck in place.

Loading the interactive reading…

Open full interactive demo →

Knowledge graphs

Inspect the dependency graph of axioms, definitions, and theorems behind a proof, and click any node to read the statement.

Fns: 1 · Props: 0 · Theorems: 0 · Retained facts: 3 · Citations: 4 · Nodes: 4 · Edges: 4
(newton(x) - r) = (((x - r) ^ 2) / (2 * x))(newton(x) - r) =…facthave r R+ = sqrt (2)have r R+ = sqrt …factnewtonnewtondefinitionrelease thm newton_error((3 / 2))release thm newto…fact
See the graph →

LaTeX

Export clean, publication-ready LaTeX directly from your checked Litex definitions and proofs.

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

Compile supported numerical definitions directly into runnable Python functions.

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

Interactive sessions and AI exploration sandboxes

Litex provides an interactive Session environment for AI agents and human authors. Submit one proof step at a time: when a step fails, Litex reports the exact reason—such as a missing domain condition x != 0—without terminating the Session or discarding earlier accepted facts. The agent repairs that step in place and continues.

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

Selected fields from the actual interactive success response

{
  "kind": "run",
  "run_result": "success",
  "target": "repl",
  "session_terminated": false,
  "termination": null
}

The definition is accepted. Save it before moving on.

Start an interactive Session with: litex -strict -lang en -session

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

The vision of Litex

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, Zhaoxuan Hong, and Qiushi Geng 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.