Follow the evidence into Lean.
Start with Litex source: execution checks each statement and records why it holds. Below, inspect that record as JSON and follow how its rules and premises become Lean code.
01 · Litex source
Write definitions and proof steps.
02 · Execute & verify
Check each statement against its context.
03 · Verification record
Record rules, premises and citations; inspect them as JSON.
04 · Compiler replay
Use the recorded evidence to apply definitions and proved laws in Litex.lean.
05 · Lean code
Generate a proof that can be submitted to Lean for checking.
JSON is a readable view of the evidence, not the compiler's input. Compilation consumes the original typed results and Runtime context.
Every real square is nonnegative. Follow the recorded builtin rule into its Lean theorem, including the evidence that the base is real.
01 · Litex source
# Every real square is nonnegative in either written order orientation.
forall x R:
0 <= x^2
forall x R:
x^2 >= 0
Source on GitHub ↗02 · Execute and verify
The JSON below was recorded when Litex executed and verified the source above. Select a field to see how the compiler uses its recorded rule or premise in the generated Lean proof.
Replay the selected builtin rule
Try it: click a JSON field.
The explanation, Lean highlight and corresponding definition or theorem update together. You can also switch examples and proof steps above.
03 · Verification record · JSON
Click or tap an outlined field below ↓{ "base_in_real_proof": { "type": "atomic_except_equality", "verification_result": "accepted", "well_defined": { "well_defined_of_each_parameter": [ { "type": "by_def", "family": "Identifier", "kind": "Identifier", "obj": "x" }, { "type": "by_known", "obj": "R", "wd_id": "wd1" } ], "predicate_signature": { "type": "builtin" }, "predicate_domain": { "type": "by_known_fact_domain", "cite": { "type": "by_known_atomic", "cite_fact_id": "f15", "why_parameters_of_known_fact_are_equal_to_givens": [ { "type": "by_they_are_the_same", "kind": "same_ir" }, { "type": "by_they_are_the_same", "kind": "same_ir" } ] } } }, "searched_proof": { "type": "by_known_atomic", "why_parameters_of_known_fact_are_equal_to_givens": [ { "type": "by_they_are_the_same", "kind": "same_ir" }, { "type": "by_they_are_the_same", "kind": "same_ir" } ] } }}statement_results[0].verify.proved_then_facts[0].verify_result.searched_proof
04 · Compiler replay
Selected fieldrule
"EvenPowNonnegative"EvenPowNonnegative selects Litex.powStructuralNonnegativeOfEven. The compiler supplies the recorded real-base proof, the exact exponent and its evenness proof.
Compiler branch on GitHub ↗05 · Generated Lean · excerpt
Lines 13–14 have h_1 : Litex.Le (Litex.number (M := M) (0 : ℂ)) (Litex.powNatReal _value_i1 (Litex.number (M := M) (2 : ℂ)) (2 : ℕ) h_15 (Litex.NativeBridge.inOfDenoteNumber (Litex.number (M := M) (2 : ℂ)) (2 : ℂ) (Litex.N (M := M)) (Litex.NativeBridge.denoteNumber (M := M) (2 : ℂ)) (Litex.NativeBridge.numberInNOfEq (2 : ℂ) (2 : ℕ) (by norm_num))) (Litex.NativeBridge.sameOfDenoteNumber (Litex.number (M := M) (2 : ℂ)) (Litex.number (M := M) ((2 : ℕ) : ℂ)) (2 : ℂ) ((2 : ℕ) : ℂ) (Litex.NativeBridge.denoteNumber (M := M) (2 : ℂ)) (Litex.NativeBridge.denoteNumber (M := M) ((2 : ℕ) : ℂ)) (by norm_num))) :=
(Litex.powStructuralNonnegativeOfEven (Litex.powNatReal _value_i1 (Litex.number (M := M) (2 : ℂ)) (2 : ℕ) h_15 (Litex.NativeBridge.inOfDenoteNumber (Litex.number (M := M) (2 : ℂ)) (2 : ℂ) (Litex.N (M := M)) (Litex.NativeBridge.denoteNumber (M := M) (2 : ℂ)) (Litex.NativeBridge.numberInNOfEq (2 : ℂ) (2 : ℕ) (by norm_num))) (Litex.NativeBridge.sameOfDenoteNumber (Litex.number (M := M) (2 : ℂ)) (Litex.number (M := M) ((2 : ℕ) : ℂ)) (2 : ℂ) ((2 : ℕ) : ℂ) (Litex.NativeBridge.denoteNumber (M := M) (2 : ℂ)) (Litex.NativeBridge.denoteNumber (M := M) ((2 : ℕ) : ℂ)) (by norm_num))) h_15 (2 : ℕ) (Litex.NativeBridge.sameOfDenoteNumber (Litex.number (M := M) (2 : ℂ)) (Litex.number (M := M) ((2 : ℕ) : ℂ)) (2 : ℂ) ((2 : ℕ) : ℂ) (Litex.NativeBridge.denoteNumber (M := M) (2 : ℂ)) (Litex.NativeBridge.denoteNumber (M := M) ((2 : ℕ) : ℂ)) (by norm_num)) (by norm_num))The highlighted code is an excerpt from the actual generated file. Object construction and other required premises remain in the complete proof.
Complete Lean on GitHub ↗Definition or proved law in Litex.lean
theorem powStructuralNonnegativeOfEven {M : Semantics.{u}} {α : Type v} {β : Type w}
[Representation M α] [Representation M β]
(p : Obj (M := M) (PowObj (M := M) α β)) (haR : In p.val.base R)
(n : ℕ) (heValue : Same p.val.exponent (number (n : ℂ))) (hEven : Even n) :
Le (number 0) p := by
obtain ⟨r, hr⟩ := (M.real_members (denote p.val.base)).mp haR
refine ⟨0, r ^ n, ?_, ?_, hEven.pow_nonneg r⟩
· simp only [denote, number, Representation.denote, Complex.ofReal_zero]Inspect the complete recorded result
{
"kind": "run",
"run_result": "success",
"target": "file",
"path": "lean/examples/real_squares_nonnegative/statement.lit",
"detail": "detailed",
"language": "en",
"statement_results": [
{
"statement_result": "accepted",
"kind": "fact",
"statement": "forall x R:\n 0 <= (x ^ 2)",
"verify": {
"type": "forall",
"verification_result": "accepted",
"fact": "forall x R:\n 0 <= (x ^ 2)",
"introduced_params": {
"param_type_well_defined": [
{
"type": "obj",
"well_defined": {
"well_defined_result": "accepted",
"proof": {
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "R"
}
}
}
],
"defined_params": {
"stores": [
{
"fact_id": "f15"
}
],
"infers": [],
"store_and_infer_results": [
{
"stores": [
{
"fact_id": "f15"
}
],
"infers": []
}
]
},
"auto_opened_struct_layers": []
},
"assumed_dom_facts": [],
"proved_then_facts": [
{
"verify_result": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "0 <= (x ^ 2)",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
},
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd1"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": [
{
"requirement": "0 $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "0 $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd1"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "0"
},
"set": "R"
}
}
},
{
"requirement": "(x ^ 2) $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "(x ^ 2) $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd1"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd1"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_structural_membership",
"element": "(x ^ 2)",
"set": "R",
"base": {
"type": "by_structural_membership",
"element": "x",
"set": "R",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
},
"kind": "known"
},
"exponent": {
"type": "by_structural_membership",
"element": "2",
"set": "Z",
"calculation": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "Z"
},
"kind": "closed"
},
"domain_evidence": "enclosing_object_wd",
"kind": "pow"
}
}
}
]
},
"searched_proof": {
"type": "builtin_rule",
"family": "LessEqualFact",
"rule": "EvenPowNonnegative",
"base_in_real_proof": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd1"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f15",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
}
},
"store_and_infer": {
"stores": [
{
"fact_id": "f1"
}
],
"infers": []
}
}
]
},
"store_and_infer": {
"stores": [
{
"fact_id": "f2",
"fact": "forall x R:\n 0 <= (x ^ 2)"
}
],
"infers": []
}
},
{
"statement_result": "accepted",
"kind": "fact",
"statement": "forall x R:\n (x ^ 2) >= 0",
"verify": {
"type": "forall",
"verification_result": "accepted",
"fact": "forall x R:\n (x ^ 2) >= 0",
"introduced_params": {
"param_type_well_defined": [
{
"type": "obj",
"well_defined": {
"well_defined_result": "accepted",
"proof": {
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "R"
}
}
}
],
"defined_params": {
"stores": [
{
"fact_id": "f279"
}
],
"infers": [],
"store_and_infer_results": [
{
"stores": [
{
"fact_id": "f279"
}
],
"infers": []
}
]
},
"auto_opened_struct_layers": []
},
"assumed_dom_facts": [],
"proved_then_facts": [
{
"verify_result": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "(x ^ 2) >= 0",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": [
{
"requirement": "(x ^ 2) $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "(x ^ 2) $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_structural_membership",
"element": "(x ^ 2)",
"set": "R",
"base": {
"type": "by_structural_membership",
"element": "x",
"set": "R",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
},
"kind": "known"
},
"exponent": {
"type": "by_structural_membership",
"element": "2",
"set": "Z",
"calculation": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "Z"
},
"kind": "closed"
},
"domain_evidence": "enclosing_object_wd",
"kind": "pow"
}
}
},
{
"requirement": "0 $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "0 $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "0"
},
"set": "R"
}
}
}
]
},
"searched_proof": {
"type": "by_builtin_rewrite",
"rule": "OrderDual",
"alternate_fact": "0 <= (x ^ 2)",
"proof_of_alternate_fact": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "0 <= (x ^ 2)",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
},
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": [
{
"requirement": "0 $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "0 $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "0"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "0"
},
"set": "R"
}
}
},
{
"requirement": "(x ^ 2) $in R",
"verify": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "(x ^ 2) $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "ArithmeticOperator",
"kind": "Pow",
"obj": "(x ^ 2)",
"child_obj_well_defined": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
}
],
"requirement_fact_verified": [
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
},
{
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "2 $in N",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Literal",
"kind": "Number",
"obj": "2"
},
{
"type": "by_def",
"family": "StandardSet",
"kind": "StandardSet",
"obj": "N"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "N"
}
}
]
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": []
},
"searched_proof": {
"type": "by_structural_membership",
"element": "(x ^ 2)",
"set": "R",
"base": {
"type": "by_structural_membership",
"element": "x",
"set": "R",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
},
"kind": "known"
},
"exponent": {
"type": "by_structural_membership",
"element": "2",
"set": "Z",
"calculation": {
"type": "by_closed_calculation",
"kind": "in",
"value": {
"representation": "decimal",
"normal": "2"
},
"set": "Z"
},
"kind": "closed"
},
"domain_evidence": "enclosing_object_wd",
"kind": "pow"
}
}
}
]
},
"searched_proof": {
"type": "builtin_rule",
"family": "LessEqualFact",
"rule": "EvenPowNonnegative",
"base_in_real_proof": {
"type": "atomic_except_equality",
"verification_result": "accepted",
"fact": "x $in R",
"well_defined": {
"well_defined_of_each_parameter": [
{
"type": "by_def",
"family": "Identifier",
"kind": "Identifier",
"obj": "x"
},
{
"type": "by_known",
"obj": "R",
"wd_id": "wd4"
}
],
"predicate_signature": {
"type": "builtin"
},
"predicate_domain": {
"type": "by_known_fact_domain",
"cite": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
},
"searched_proof": {
"type": "by_known_atomic",
"cite_fact_id": "f279",
"why_parameters_of_known_fact_are_equal_to_givens": [
{
"type": "by_they_are_the_same",
"kind": "same_ir"
},
{
"type": "by_they_are_the_same",
"kind": "same_ir"
}
]
}
}
}
}
}
},
"store_and_infer": {
"stores": [
{
"fact_id": "f264"
}
],
"infers": []
}
}
]
},
"store_and_infer": {
"stores": [
{
"fact_id": "f265",
"fact": "forall x R:\n (x ^ 2) >= 0"
}
],
"infers": []
}
}
],
"session_terminated": false,
"termination": null
}Check details
A Lean kernel check is not recorded for this new example; the Litex run, actual compilation and canonical output match passed.
Generated theorems explicitly quantify over M : Litex.Semantics. Function examples also require Litex.FunctionSemantics M. Lean checks the proof under these interfaces; using the result as an ordinary Mathlib theorem requires a corresponding interpretation and bridge.
Support depends on the recorded rule, object and scope. An unsupported route rejects the complete compilation even when Litex can verify the source.
Links use the example's recorded source revision. fd62f2afa5e91e12178126a3a0cf85edceb76c80
Litex: An Easy-To-Learn Frontend Language For Lean?
Both systems check mathematical proofs, but their usual ways of writing a proof differ. Lean lets authors write proof terms or construct them with tactics. Litex lets authors state the next fact, then looks for supporting evidence in the current context.
GitHub: Litex → Lean compiler source
Here, Litex's verification kernel means its broader verification and execution implementation. Lean's kernel means the component that checks the final proof term. The comparison below explains which checks each performs.
| Responsibility | Lean | Litex |
|---|---|---|
| Mathematical representation | Dependent type theory with inductive types. Mathematical terms inhabit types. | Sets, elements, functions, and membership facts organize the mathematical interface. |
| Default authoring interface | Write a proof term or use tactics and automation to construct it. | State the next fact; supply explicit proof structures for meaningful intermediate reasoning. |
| Automatic proof work | Elaboration and tactics construct core terms outside the small kernel. | The verifier combines known facts, builtin mathematics, definitions, and bounded local search. |
| What acceptance trusts | The kernel checks the elaborated term against the core rules and declared assumptions. | Current acceptance relies on the verifier, builtin and inference rules, and scoped knowledge handling. |
Litex exposes set-theoretic and ZFC-side construction and axiom interfaces. Its current builtin mathematical background is supplied by the implementation; its full correspondence to foundational theory still needs specification and audit.
The same statement, two default interfaces
For every natural number x, if x = 2, then x + 1 = 3. These are independently written examples, not compiler output.
Handwritten Lean example
example (x : Nat) (h : x = 2) : x + 1 = 3 := by
rw [h]Litex facts in a local context
forall x N:
x = 2
=>:
x + 1 = 3Lean's rw uses the assumption to construct an equality proof; its kernel checks the resulting term. Litex receives the desired consequence and supplies the matching, substitution, and arithmetic checks. Both systems can also use other proof styles.
Three fundamental differences
Lean is based on dependent type theory. Litex organizes mathematics through objects, sets, and facts in first-order logic. This leads to three differences in how authors express mathematics and how the verifier checks it.
1. Litex has no type system
Lean terms have types, and those types can depend on values. Litex's mathematical language has no type system: N, Z, and R are sets, and an object's membership is a fact to establish. For example, x $in N and x $in R can describe the same object; establishing another membership fact does not change its type or create a new object.
2. Well-definedness is a prerequisite
Before accepting a fact, Litex must establish that its expressions are well-defined. For 1 / x, this includes x != 0. The verifier finds or proves that condition in the current context; the author does not pass a proof as an extra argument each time the expression is used. Every use must still satisfy the condition.
Thus Litex rejects 1 / 0 at the well-definedness check, whereas Lean/Mathlib's real division satisfies (1 : ℝ) / 0 = 0. Mathlib defines division as a total function; laws such as x / x = 1 require a nonzero hypothesis. The linked FAQ explains this convention and the alternative of passing domain proofs as arguments. Division by zero in type theory: a FAQ
3. Propositions are not parameters
Litex uses first-order logic: a prop declaration introduces a predicate, not an object that can be passed to a function or bound by forall. Lean can take P : Prop as a parameter or quantify over propositions with ∀ P : Prop. Litex does not support these forms.
This restriction supports Litex's proof search: it uses the fixed predicate of a goal as an index key to find candidate facts and rules, then matches arguments and checks premises. If the predicate itself were a variable, the current search could no longer look up candidates by that fixed key; supporting this would require a different search mechanism.
For Lean users, a useful way to picture the authoring experience is a Lean macro with one big tactic: you write the next fact, and that tactic handles well-definedness, matching known facts, and routine inference.