How Litex works
An analogy with programming languages: C and Python hide low-level registers and memory management so programmers can express algorithms directly. Likewise, Litex acts as a high-level language for formal mathematics: you state mathematical facts directly while Litex checks domain conditions automatically, and supported proofs can compile to Lean 4 for independent kernel verification (with Coq and Isabelle on the roadmap).
Litex makes formal code feel natural
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 commandstheorem nonneg_sq (x : ℝ) : x ^ 2 ≥ 0 := by
exact sq_nonneg xLean 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.
Definitions and proofs
Definitions introduce mathematical objects and build context. Proofs use that context and checked rules to establish new facts.
have x R
0 <= (x + 1)^2have x R introduces an arbitrary real object x. R is the existing builtin set of real numbers; this declaration does not assign x a particular numerical value.
I Definitions: build context
II Proofs: use established context
Introduce a real object
have x R is an object-definition/declaration statement: introduce x in the existing real-number carrier. It supplies an object and its membership for later proofs, while leaving its numerical value arbitrary.
An explanation of a verified example. The search order follows the source; the figure is not a recording of every attempted candidate. A search miss does not prove a statement false.
Verification evidence and implementation
Definition.DefineObj.HaveObjInNonemptySetStmt{
"source": "golitex/examples/proof_search",
"example": "have x R\n0 <= (x + 1)^2",
"strict": true,
"result": "success",
"rule": "builtin.LessEqualFactSearchProofByBuiltinRule::EvenPowNonnegative",
"premise": {
"search": "ByStructuralMembership",
"constructor": "Add",
"left": "Known",
"right": "Closed"
},
"declaration": {
"statement_kind": "Definition.DefineObj.HaveObjInNonemptySetStmt",
"symbol_ids": [
"local:i1"
],
"carrier_well_defined": true,
"nonempty_rule_ids": [
"builtin.IsNonemptySetFactSearchProofByBuiltinRule::StandardSetNonempty"
],
"stored_membership_id": "f2"
}
}What you can write in Litex
Objects are what mathematics talks about; facts express propositions about them; statements introduce objects, define concepts and organize proofs.
See the Manual for the detailed syntax, complete examples and conditions for the forms below.
Read the Manual · Full examplesObj · Objects and expressions
For example, x, R and x + 1 are objects. An expression must satisfy its domain conditions before a fact about it can be checked.
| Category | Common forms · overview | Mathematical role |
|---|---|---|
| Numbers and number sets | 01.5NZQRCN+R+R*iepi | Exact numbers, standard number sets, positive and nonzero subsets, and mathematical constants. |
| Arithmetic | a + ba - b-aa * ba / ba^babs(x)min(a, b)max(a, b) | Arithmetic, powers, absolute values and comparisons through extrema. |
| Integer operations | floor(x)ceil(x)a % dquot(a, d)gcd(a, b)lcm(a, b)factorial(n) | Rounding, remainders, integer quotients, divisors and factorials. |
| Common mathematical functions | sqrt(x)exp(x)ln(x)log(b, x)sin(x)cos(x)tan(x)re(z)img(z)C_abs(z) | Roots, exponentials, logarithms, trigonometry and complex coordinates, under their domain conditions. |
| Sets and intervals | {a, b}{}{x A: filters}union(A, B)intersect(A, B)set_minus(A, B)power_set(A)range(a, b)'[a,b] | Displayed sets, bounded set builders, set operations, integer ranges and real intervals. |
| Functions | f(x)fn(x S) Tfn(x S) T {body}fn_range(f) | Function applications, function spaces, anonymous functions and images. |
| Tuples, products and sequences | (a, b)cart(A, B)finite_seq(S, n)seq(S) | Ordered data, product carriers and finite or infinite sequence spaces. |
| Finite aggregates | sum(a,b,f)product(a,b,f)finite_set_sum(S,f)finite_set_product(S,f)finite_set_size(S)finite_set_max(S)finite_set_min(S) | Sums, products, finite cardinalities and finite-set extrema. |
| Structured objects | structobject.fieldtemplate | Structured carriers, definition-owned fields and parameterized instances; see the Manual for full syntax. |
Fact · Mathematical propositions
A fact can be atomic, such as x $in R, or have a logical shape, such as a universal or existential statement. Declared predicates extend the vocabulary.
| Category | Common forms · overview | Mathematical role |
|---|---|---|
| Equality and order | a = ba != ba < ba <= ba > ba >= b | Compare mathematical objects or ordered values. |
| Membership | x $in Snot x $in S | An object belongs, or does not belong, to a set. |
| Set properties and relations | $is_set(S)$is_nonempty_set(S)$is_finite_set(S)A $subset BA $superset BA $proper_subset BA $proper_superset B | Sethood, nonemptiness, finiteness, inclusion and proper inclusion. |
| Number theory | $prime(n)$coprime(a,b)$dvd(a,b) | Primality, coprimality and divisibility. In $dvd(a,b), b divides a. |
| Mapping properties | $injective(A,B,f)$surjective(A,B,f)$bijective(A,B,f) | Injective, surjective and bijective functions between declared carriers. |
| Logical combinations | andora < b <= c | Supported conjunctions, disjunctions and relation chains. |
| Quantifiers | forallexistexist!not forallnot exist | Universal laws, existence, unique existence and supported negated quantifiers. |
| Defined properties | $P(arguments) | Apply a previously declared predicate to mathematical objects. |
Stmt · Statements and proof actions
A statement contributes to the mathematical context. A bare fact is also a statement: it asks Litex to check the proposition.
| Category | Common forms · overview | Mathematical role |
|---|---|---|
| Introduce objects | have x Shave x S = valuehave x S: factslet name = expression | Introduce a member, specify a value or proved conditions, or name an expression. |
| Define functions | have fnhave fn … by caseshave fn … by induchave fn … by exist! | Define a function by an expression, cases, a decreasing measure or unique existence. |
| Define concepts | propstructtemplate | Define predicates, structured carriers and parameterized declaration families. |
| State and prove | a + 1 = 3claimthmsketch | Check a fact directly, organize a local proof, name a reusable theorem or write a local sketch. |
| Witnesses | witnessobtain | Supply values for an existential goal or extract witnesses from established existence. |
| Cases and contradiction | by casesby contraby enumerate | Prove all exhaustive cases, derive a contradiction or enumerate a finite carrier. |
| Induction and finite iteration | by inducby strong_inducby for | Use ordinary or strong induction, or iterate over a finite integer range. |
| Use definitions and theorems | by defrelease thmby thm … => factrelease obj defrelease struct def | Check a definition, publish theorem conclusions, select one conclusion or replay supported definitions. |
| Extensionality | by extensionby fn_extension | Establish set equality by membership or function equality by pointwise values. |
| Reusable reasoning | strategyregister reflexiveregister symmetricregister transitive | Define supported proof strategies or register checked predicate laws. |
| Evaluation and algorithms | evalalgo | Evaluate supported exact expressions or define executable functions. |
| Signatures and assumptions | abstract_propaxiomtrust | abstract_prop declares a predicate signature without defining clauses; axiom and trust explicitly introduce assumptions. |
See why each step holds.
Each verification record shows what happened to a statement, and which facts and rules were used to justify it.
A cited fact can come from anywhere in the current scope, not only the line above.
For a builtin rule, the record also lists its arguments and the proofs of its premises, so you can see why the rule applies here.