Skip to content

Releases

v0.58.0

Choose a tag to compare

@gmpassos gmpassos released this 02 Dec 06:32
eb36a0a

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, inside match arms 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
    (what submit takes), 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), which submit --strategy accepts 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 MODULE searches a Lean module instead (find '_ < _ → _ ≤ _' --lean Mathlib.Order.Basic), as import-lean --all imports it: only
    what the importer can express (and self-checks) is searched; each match
    carries its Lean name, cited as by: exact <name> ….
  • --format json is one document for agents, pinned by a golden
    (test/golden/cli/find.json).
  • Outside a pattern, _ is a name as before: a project's a = _ is an
    unknown name, not a hole.

v0.57.0

Choose a tag to compare

@gmpassos gmpassos released this 02 Dec 05:38
06e59cc

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, their u
      flexible at each use, like any used constant's; Type → Type before,
      so LinearOrder(β) 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 importer:
    • η-expansion binders are named apart from the variables in scope
      (λ x' ↦ … under a theorem's own x, 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 in LE.ext), which
        instance search does not find. A type family (β : ι → Type) and an
        instance binder applied to indices (inst i) are not such
        arguments.
  • Not done from the plan: structure projections on structures with
    parents, non-concrete imax levels, and quoted Lean names. None of them
    blocked Mathlib.Order.Basic; its remaining refusals are mostly
    instance parameters of classes ProofLang cannot name (StrongLT's).

v0.56.0

Choose a tag to compare

@gmpassos gmpassos released this 02 Dec 02:53
5ec57e7

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 definition or
    mutual theorem may be about Seq(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, mutual by:
      blocks and cases on a nested type use the same motives.
    • Offline, Lean's compilation (brecOn through the nesting) is proved
      equal to the native one, all members at once.
  • Not yet: nesting through ProofLang's List, which has no
    constructors to match on; nested types with parameters.

v0.55.0

Choose a tag to compare

@gmpassos gmpassos released this 02 Dec 01:52
d92171f

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 a by: block, on a project
    inductive type, runs natively as cases with those alternatives (a
    mutual type's recursor given λ _, True for the block's other types). A
    match on anything else goes to the prover, as before.
  • A mutual group of by: blocks (each match x with over 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's match for 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 their mutual … end).

v0.54.0

Choose a tag to compare

@gmpassos gmpassos released this 02 Dec 00:58
ee03c47

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
      • 1is1: cons(x, nil)has the typeVec(ℕ, 1)), and a numeral against t + cunifiest with the difference (?n + 1against1: ?n := 0`), as Lean's unifier does.
    • 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.
  • Without Lean:
    • A match at an index of its own (one ℕ index, no recursive call)
      compiles to the recursor with the motive λ k t, k = I → R at Eq.refl I. A constructor with no arm, whose index cannot be I, is closed by
      Nat.noConfusion; a wrong one does not check and is left to Lean.
    • cases x with | c names => … and cases x in 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 field m := k − c (Nat.add_right_cancel, then Eq.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 by Nat.noConfusion, the others
      by injecting m + 1 = n + 1 (Nat.succ.inj) and Eq.rec, the cast
      the identity by K.
  • 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

Choose a tag to compare

@gmpassos gmpassos released this 01 Dec 23:47
dc0ba4b

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 definition and mutual theorem. A run of either in the
      source is one group: any other declaration, a proof included, ends
      it. A group's members may call each other, and each one declares its
      result type. A group is one Lean mutual … end block, 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 a match t with whose 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 (size and sizeF, not sum and sumF
      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, R not mentioning x.
    • Mutual induction is the block recursor into Prop, the group's
      statements its motives (λ _, True for 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 (brecOn over the
      block) is proved equal to the native one, all members at once, by the
      block recursor. So the forests example verifies strictly offline.
  • 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 tactic match. Nested types still have no native
    match or 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

Choose a tag to compare

@gmpassos gmpassos released this 01 Dec 21:57
f14e44c

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) against Prop, 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 x is g, 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 never Prop). 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.
  • The importer:
    • Partially applied relations, connectives, set and arithmetic
      operators
      (@Eq α in Subrelation r (@Eq α), And p) are
      η-expanded to λ x y ↦ x = y, each side typed as the operator takes it
      (HPow.hPow ℝ ℕ ℝ x is λ 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) → Prop would read
      back as an implication, and Prop is 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.

v0.51.0

Choose a tag to compare

@gmpassos gmpassos released this 01 Dec 21:03
b15ac38

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, else unbuilt; edited (with the
      previous verdict) when the source changed since, the id hashing the
      goal alone.

    --format json is 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's proof block, 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.

    • --apply writes 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.toml and its
      generated/ caches; with Lean, the project's Mathlib is passed on
      (--lean-packages too). A candidate that stops the build (one that
      does not parse) is refused with its diagnostics.
  • Native records: build --native and verify --offline now save
    their records too, in .prooflang/verification-native.json, beside
    Lean's, which they never replace.

v0.50.0

Choose a tag to compare

@gmpassos gmpassos released this 01 Dec 20:30
a1e1c47

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
    (only intros before it, no ∀ left), the search runs Lean's exact?.
    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_three on 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 with sorryAx) is no find.
  • 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 by assumption only, so the native
    side finds no more than exact? would: the ℝ facts of
    NativeReal.lean, which Lean has not, and internal names (_simp_1,
    match_1), which exact? 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_search and
    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, Coprime by gcd), not Mathlib's,
    or need apply with a function argument (Nat.Coprime.prod_left),
    which exact? does not unify.

v0.49.0

Choose a tag to compare

@gmpassos gmpassos released this 01 Dec 10:24
b97659a

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 match on one compiles to its recursor; a recursive call through
      a function field (double(f(n)) at lim(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 carry congr and
      funext, which those proofs use (a certificate had them only when
      Lean's own proofs did).
  • induction … with in the native tactics on a project type with
    parameters (Tree(α), Le(a, b)) or indices (Vec(α, n)), as Lean's
    induction runs 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 into f (length(cons(x, xs)) to
    length(xs) + 1, not a recursor application), as Lean's equation lemma
    states it, so rw [ih] finds it.
  • Prover:
    • a hypothesis whose definition computes to False closes any goal;
    • arithmetic computes a recursor application whose major premise is a
      constructor (size(succ(succ(x))) is size(x) + 2);
    • an induction case uses its hypothesis by modus ponens whenever the
      motive generalizes a binder (the hypothesis is then an implication).
  • 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 native match or
    induction: ProofLang has no mutual definitions, and Lean's induction
    takes neither kind.