Repository navigation
Releases
v0.58.0
Finding a lemma to cite. prooflang find PATTERN lists the theorems
whose statement contains the pattern, a ProofLang proposition or term in
which each _ is a hole: find '_ ∣ _ * _', find '_ * _ > 0'.
- Matched on meaning, not text. The pattern, a proposition or a term
(_ × _), is elaborated in the scope of the searched modules and
matched against their elaborated IR, in a theorem's goal or in the type
of one of its context entries, insidematcharms too: a bound
variable's name does not matter, an operator matches at any carrier
(_ * _in a group and in ℕ), and a numeral at any type, with what it
fixes (_ ∈ {0, 1}matches a set of reals). Every_is a hole, even
under a binder named_. - Each match comes with its statement as a sequent, its obligation id
(whatsubmittakes), the last build's verdict, where it matched (the
goal, or which hypothesis, variable or instance), and how to cite it:
strategy simplify(using = [M.dvd_mul])for a project theorem,
qualified (two imported modules may share a name), whichsubmit --strategyaccepts as given. - Several projects are searched together: one whose scope lacks a name
the pattern uses is skipped; the pattern fails only when it elaborates in
none. --lean MODULEsearches a Lean module instead (find '_ < _ → _ ≤ _' --lean Mathlib.Order.Basic), asimport-lean --allimports it: only
what the importer can express (and self-checks) is searched; each match
carries its Lean name, cited asby: exact <name> ….--format jsonis one document for agents, pinned by a golden
(test/golden/cli/find.json).- Outside a pattern,
_is a name as before: a project'sa = _is an
unknown name, not a hole.
v0.57.0
The Lean importer reaches order theory. The round-trip suite gains
Mathlib.Order.Basic: 193 theorems imported, self-checked, and each
kernel-verified through the generated Lean (0.56.0 imported 33 of them).
Mathlib.Logic.Function.Basic rises to 154 (128 before). In all, the
suite covers 602 theorems across five modules.
- The front end:
- The prelude's classes at any universe.
Preorder,LinearOrder,
Monoid, … are(α: Type(u)) → Type(u), as Mathlib's are, theiru
flexible at each use, like any used constant's;Type → Typebefore,
soLinearOrder(β)atβ: Type(u)was a type mismatch. - Implicit and instance arguments after the explicit ones are
filled, as Lean fills them (an implicit by unification, an instance by
Lean's instance search):DecidableLE(α), whose[LE α]followsα,
is a type.
- The prelude's classes at any universe.
- The importer:
- η-expansion binders are named apart from the variables in scope
(λ x' ↦ …under a theorem's ownx, which it shadowed). - Refused, with the reason, three cases where the printed ProofLang
would mean something else in Lean although its hash matched (the
self-check compares hashes, which do not record instances):- an extern with a premise that has implicit binders (
le : ∀ ⦃x y⦄, …), as a theorem's has been since 0.52.0; - an operator two instances in scope may provide (
[Preorder α] [PartialOrder α]for≤; a topology, finiteness or decidable
equality provides none): ProofLang's operators take their instance by
search, so which one≤uses is not stated; - an operator (
≤,+,-x,|x|,↑n,∈, a numeral) at an
instance built from the declaration's arguments ((lift f inj).toLT, or an explicit(x : LE α)as inLE.ext), which
instance search does not find. A type family (β : ι → Type) and an
instance binder applied to indices (inst i) are not such
arguments.
- an extern with a premise that has implicit binders (
- η-expansion binders are named apart from the variables in scope
- Not done from the plan: structure projections on structures with
parents, non-concreteimaxlevels, and quoted Lean names. None of them
blockedMathlib.Order.Basic; its remaining refusals are mostly
instance parameters of classes ProofLang cannot name (StrongLT's).
v0.56.0
Nested types without Lean. A rose tree (a node's children are a sequence
of trees, node(label: ℕ, kids: Seq(Rose))) now has native definitions,
induction and cases, and links strictly offline. The new roses example
(example/lean_to_prooflang/roses) has 10 obligations, all verified by
Lean, natively and strictly offline.
- Mutual groups over a nested occurrence. A
mutual definitionor
mutual theoremmay be aboutSeq(Rose), a nested occurrence of the
block's type: the group has one member per motive of the type's
recursor (the block's types, then its nested occurrences).- The front end takes a group member's type with parameters (
Seq(Rose),
the parameters closed): its cases are the constructors at them
(more(head: Rose, tail: Seq(Rose))), a field of a type of the block
or of a nested occurrence having the theorem about it. - Without Lean, the definitions compile to the recursor at each
member's motive (Rose.rec,Rose.rec_1), and the native build adds
a nested type's auxiliary recursors. Mutual induction, mutualby:
blocks andcaseson a nested type use the same motives. - Offline, Lean's compilation (
brecOnthrough the nesting) is proved
equal to the native one, all members at once.
- The front end takes a group member's type with parameters (
- Not yet: nesting through ProofLang's
List, which has no
constructors to match on; nested types with parameters.
v0.55.0
Hand-written proofs over mutual types, without Lean. The forests example's
tactic module, whose proofs call each other, is now proved by ProofLang's
kernel: the example has all 16 obligations native (11 in 0.53.0), as
well as with Lean and strictly offline.
match x with | .c names => …in aby:block, on a project
inductive type, runs natively ascaseswith those alternatives (a
mutual type's recursor givenλ _, Truefor the block's other types). A
matchon anything else goes to the prover, as before.- A mutual group of
by:blocks (eachmatch x withover its
theorem's variable) is proved by the block recursor: the group's
statements are its motives, and each constructor case is the arm of its
theorem'smatchfor that constructor, run under the fields as the arm
names them. In an arm, a call of a theorem of the group on a field
(have ih := sizeF_doubleF f) is that field's induction hypothesis; any
other mention of a theorem of the group leaves it to Lean, since it
would cite what is being proved. Lean's code is unchanged (the blocks,
in theirmutual … end).
v0.54.0
Indexed families: the remaining native gaps. A written-out vector, a
match at an index of its own (head on Vec(ℕ, n + 1)) and cases at
a numeral index (v: Vec(ℕ, 1)) are proved without Lean and link
strictly offline. The families example grows to 15 obligations, all
proved with Lean, without it, and strictly offline.
- The front end:
- Numerals in unification. Closed arithmetic at ℕ is its value (`0
- 1
is1:cons(x, nil)has the typeVec(ℕ, 1)), and a numeral againstt + cunifiestwith the difference (?n + 1against1:?n := 0`), as Lean's unifier does.
- 1
- Numeral defaulting reaches a type variable a numeral's type was
unified with (cons(5, nil)'sα), so a written-out vector's element
type is ℕ before Lean, and its statement is no longer left with holes.
- Numerals in unification. Closed arithmetic at ℕ is its value (`0
- Without Lean:
- A
matchat an index of its own (one ℕ index, no recursive call)
compiles to the recursor with the motiveλ k t, k = I → RatEq.refl I. A constructor with no arm, whose index cannot beI, is closed by
Nat.noConfusion; a wrong one does not check and is left to Lean. cases x with | c names => …andcases xin the native tactics,
on a project inductive type, at a numeral index too. A constructor
whose index cannot be it is no case (Nat.noConfusion);m + c = k
fixes the fieldm := k − c(Nat.add_right_cancel, thenEq.rec).
The alternative's names go to the explicit fields, as Lean's do.- Linking. Lean's compilation of such a
match(a matcher over
casesOn) is proved equal to the native one: the motive carries the
index equation, the impossible cases byNat.noConfusion, the others
by injectingm + 1 = n + 1(Nat.succ.inj) andEq.rec, the cast
the identity by K.
- A
- Hashes. A declaration whose numerals' types were holes before (a
written-out vector's) now states ℕ, so its hash differs from 0.53.0's.
v0.53.0
Mutual definitions and theorems. Functions defined together on types
defined together (a tree's size calls its forest's, and back), and
theorems proved together by mutual induction, with Lean and without it.
The new forests example (example/lean_to_prooflang/forests) has 16
obligations: all verified by Lean and strictly by verify --offline, 11
by ProofLang's kernel without Lean (the automated module's 8 among them).
- The language:
mutual definitionandmutual theorem. A run of either in the
source is one group: any other declaration, aproofincluded, ends
it. A group's members may call each other, and each one declares its
result type. A group is one Leanmutual … endblock, whose recursion
Lean checks is structural.- Mutual induction.
strategy induction(on = t)on a theorem of a
group proves each constructor case with, for every field whose type
another theorem of the group is about, that theorem at the field. In
Lean it is amatch t withwhose arms state those hypotheses as calls
(have ih₁ := sizeF_doubleF children). A theorem so proved is about
one variable of a type without parameters or indices, and no two of a
group are about the same type: both are errors with the reason.
- Without Lean:
- Mutual definitions compile to the block recursor, one motive per
type, a call on a field being its induction hypothesis. Each set of
members that call each other (sizeandsizeF, notsumandsumF
written in the same run) is compiled on its own, and must define one
f(x: T) → R: match x:per type of the block,Rnot mentioningx. - Mutual induction is the block recursor into
Prop, the group's
statements its motives (λ _, Truefor a type no theorem is about).
It proves the whole group at once and cites none of it. - Linking. Lean's compilation of a mutual group (
brecOnover the
block) is proved equal to the native one, all members at once, by the
block recursor. So the forests example verifies strictly offline.
- Mutual definitions compile to the block recursor, one motive per
- Not yet: a hand-written recursive tactic proof (a
by:block that
calls its sibling) runs only in Lean; the native tactics run no
recursion, nor a tacticmatch. Nested types still have no native
matchor induction. - Hashes. A mutual definition group is hashed as one: each member's
hash depends on every member (a reference to one of them hashed as its
position), so editing one member changes all of theirs, and renaming
one changes none.
v0.52.0
The Lean importer reaches more of Mathlib. The round-trip suite gains
Mathlib.Logic.Relation: 163 theorems imported, self-checked, and each
kernel-verified through the generated Lean (0.51.0 imported 139 of them).
Mathlib.Logic.Function.Basic now imports 128 theorems (100 before). In
all, the suite covers 383 theorems across four modules.
- The front end's unifier:
- Pattern unification. A metavariable applied to distinct bound
variables (?φ(x, y)againstProp,Function.swap's dependent
codomain) is the other side abstracted over them, its λ binders typed
as those variables (the solved implicit argument is part of the
elaborated term, and its hash). A solutionλ x, g xisg, as
first-order unification found before. - Universe-polymorphic constants at another level. A used constant's
own universe variables are flexible at its use (Setoid(α: Sort(u))
atα: Type(v)), even when Mathlib names the using declaration's alike
(u_1): any level they can be (max(1, u)is neverProp). Lean
checks the instantiation; this checker may accept a level mismatch
Lean rejects (one variable used at two levels), never reject what Lean
accepts. A declaration whose stored IR would mention such a variable
(Id(Setoid)) is an error.
- Pattern unification. A metavariable applied to distinct bound
- The importer:
- Partially applied relations, connectives, set and arithmetic
operators (@Eq αinSubrelation r (@Eq α),And p) are
η-expanded toλ x y ↦ x = y, each side typed as the operator takes it
(HPow.hPow ℝ ℕ ℝ xisλ y: ℕ ↦ x ^ y); not a composition or a
product. - A Π whose domain is a proposition and whose body is not (an
inductive predicate's motive,(x: α) → q(x) → Prop) stays a function
type, not an implication, and a function type prints with its binder
named unless its domain is plainly a type:q(x) → Propwould read
back as an implication, andPropis no proposition. - Refused, with the reason:
- an eliminator (an implicit
motive:casesOn,recOn,below),
whose motive the generated Lean does not infer; - a theorem with a premise that has implicit binders of its own
(head : ∀ {a c}, …), which ProofLang cannot state and whose
citation meets Lean's implicit lambdas.
- an eliminator (an implicit
- Partially applied relations, connectives, set and arithmetic
v0.51.0
Obligations as data, and candidate proofs checked one at a time: what an
agent (or a person) needs to work on what a build left open, without
reading Lean.
-
prooflang obligations [paths]lists the obligations the last build
did not verify (--all: every one). Each entry has:- its declaration, module and file;
- its id (the semantic hash of the goal);
- its span;
- its context and goal, printed and as IR;
- its proof as given;
- its last verdict, with the reason: the newer of Lean's record and the
last native build's for this goal, elseunbuilt;edited(with the
previous verdict) when the source changed since, the id hashing the
goal alone.
--format jsonis one document, pinned by
test/golden/cli/obligations.json. -
prooflang submit <id|Module.theorem> (--strategy S | --by T)checks
one candidate for one theorem's obligation. The candidate replaces the
theorem'sproofblock, or is added after the theorem, in a copy of the
project's sources. The copy is built with Lean, or with--native
without it, and the obligation's verdict is reported (--format json
for agents). Nothing is trusted: only a kernel-checked verdict counts.--applywrites a verified candidate into the source file.- A
by:block checked natively is never applied: there, a block the
tactics do not run goes to the prover, which may prove the statement
though Lean rejects the block (the JSON says"tacticsChecked": false). - An id several theorems' goals share is refused, their names listed.
- The copy holds the project's modules, its
prooflang.tomland its
generated/caches; with Lean, the project's Mathlib is passed on
(--lean-packagestoo). A candidate that stops the build (one that
does not parse) is refused with its diagnostics.
-
Native records:
build --nativeandverify --offlinenow save
their records too, in.prooflang/verification-native.json, beside
Lean's, which they never replace.
v0.50.0
Mathlib's lemmas in strategy search. Before, the search was offered only
the project's own theorems (by the shape of their conclusion), so a goal
that one Mathlib lemma closes (φ(p) = p - 1 from Prime(p)) failed. The
automation benchmark's search module gains three such obligations: Lean
closes 10 of its 11 (7 of 8 before), and the native build all 11.
- With Lean: the library step. Once per search, on the goal as stated
(onlyintros before it, no∀left), the search runs Lean'sexact?.
It looks the goal up among every lemma the module imports and closes the
premises from the hypotheses.- It runs after the search has failed, on its own heartbeat budget
rather than the time limit: within the limit,exact?(whose first
call in a file indexes the imports) took the time a search needed for
what its other steps find (gauss_search,exists_gt_threeon CI).
A search that fails therefore takes longer than its limit. - What it found is stored for replay as
exact <term>: the proof term
printed on one line, β-reduced, its proofs shown (exact Nat.totient_prime hp,exact Nat.coprime_comm.mp h), when that
elaborates back (a heartbeat failure counts as not), else as
exact?. - A find that depends on
sorry(a project theorem with no proof, which
Lean adds withsorryAx) is no find.
- It runs after the search has failed, on its own heartbeat budget
- Natively: the snapshot's theorems by shape (
native_library.dart).
Each theorem of the native environment is keyed by its conclusion's
relation and the heads of its two sides (≥/>as≤/<, a
predicate by its first and last arguments, an↔by each direction).
One whose conclusion is variables only (Nat.Coprime.symm) is offered
when the goal's hypotheses have the heads of all its explicit premises,
and those are ranked first among the 8 tried. Each candidate is
applyd and its premises closed byassumptiononly, so the native
side finds no more thanexact?would: the ℝ facts of
NativeReal.lean, which Lean has not, and internal names (_simp_1,
match_1), whichexact?skips, are never offered. The index grows
with the build: each search indexes the theorems proved since the last,
so what it is offered does not depend on the native cache. - Benchmark:
totient_prime_search,prime_two_le_searchand
coprime_symm_search(none closed by v0.49.0, with Lean or natively).
The automation benchmark is 44 obligations, all of them proved natively. - Not done: the plan's Euler example rewrite. Its cited steps are
about its own definitions (Totient,Coprimebygcd), not Mathlib's,
or needapplywith a function argument (Nat.Coprime.prod_left),
whichexact?does not unify.
v0.49.0
Native proofs over reflexive types, and the native tactics' induction … with on parameterized and indexed types. A new example,
example/lean_to_prooflang/branching, has infinitely branching trees (a
node with one child per natural number): all 10 obligations are proved
with Lean and natively (v0.48.0 proved none of them natively), and
verify --offline links them strictly.
- Reflexive types natively:
- a
matchon one compiles to its recursor; a recursive call through
a function field (double(f(n))atlim(f)) is the field's
hypothesis applied; - induction's hypothesis for a function field is a function too (
∀ n, P(f(n))); - offline, Lean's compilation of such a definition (
brecOn) is
proved equal to the native one, a function field's case by
funext. Lean-made certificates now always carrycongrand
funext, which those proofs use (a certificate had them only when
Lean's own proofs did).
- a
induction … within the native tactics on a project type with
parameters (Tree(α),Le(a, b)) or indices (Vec(α, n)), as Lean's
inductionruns it: the indices must be distinct variables and are
generalized, the hypotheses depending on the variable or its indices
are reverted with it, and an implicit field (cons's{n}) takes no
case name (| cons x xs ih). The families example's tactic proofs now
run as written.simp only [f]on a recursive definition folds what its unfolding
leaves of a recursive call back intof(length(cons(x, xs))to
length(xs) + 1, not a recursor application), as Lean's equation lemma
states it, sorw [ih]finds it.- Prover:
- a hypothesis whose definition computes to
Falsecloses any goal; - arithmetic computes a recursor application whose major premise is a
constructor (size(succ(succ(x)))issize(x) + 2); - an induction case uses its hypothesis by modus ponens whenever the
motive generalizes a binder (the hypothesis is then an implication).
- a hypothesis whose definition computes to
- Limits: a function field whose arguments' types depend on other
fields, and a reflexive indexed family, are left to Lean; a function
field with several arguments compiles natively but does not link
offline. Mutual and nested types still have no nativematchor
induction: ProofLang has no mutual definitions, and Lean'sinduction
takes neither kind.