Skip to content

M2. Engine R #3

Open
Open

Description

@tamnd

This milestone writes engine R, the reference type checker. Engine R is a transcription of type_checker.cpp and inductive.cpp of the official kernel. After this milestone, rulean checks proofs. It gives the release v0.3.0.

Spec: docs/spec/14-milestones.md, M2. See also 05, 06 and 09.

Acceptance

  • All 235 Arena tests with a fixed outcome give the correct verdict.
  • The 30 Arena tests with the outcome "either" match the v4.35 profile. (Build the Arena either tests and check their verdicts in CI #39)
  • Mathlib is accepted, at any speed.
  • R1 and R2 are proved for engine R.
  • rulean is submitted to the Lean Kernel Arena.

Checklist

Activity

  1. added this to the M2 Engine R milestone on Nov 21, 2026
  2. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    PR #27 is merged. It adds the universe level functions of rulean-core: the normal form, equivalence, the is_geq order, instantiation and the check for undefined parameters. The functions follow level.cpp of the official kernel v4.35.0. The next PR is #28, the expression operations.

  3. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    PR #28 is merged. It adds the expression operations of engine R as a transcription of instantiate.cpp, abstract.cpp, expr.cpp and expr_eq_fn.cpp of the official kernel v4.35.0. The store hash of a binder node now does not mix the binder name or the binder info, so alpha-equivalent terms have equal hashes. The next PR is #30, which adds the environment and the type checker.

  4. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #30 is merged. It adds the environment and the type checker of engine R. The checker infers types, reduces terms to weak head normal form in the official order, and decides definitional equality with lazy delta reduction, eta, structure eta, proof irrelevance, unit-like types and the literal extensions. The three engine R items are ticked. The declaration checks in #31 come next.

  5. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #31 is merged. It adds the declaration checks of engine R: axioms, definitions, theorems, opaque constants, mutual blocks of unsafe or partial definitions and the quotient constants. A rejected declaration does not change the environment. The declarations item is ticked. The inductive checks in #32 come next.

  6. added a commit that references this issue on Nov 21, 2026
  7. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    PR #32 is merged. Engine R now has the inductive checks of spec 06.2, as a transcription of add_inductive in inductive.cpp of the official kernel v4.35.0. The checker checks the types and the constructors, the uniform parameters, strict positivity, the universe bound of the fields, the elimination level and the K flag. It makes the recursors and compares them with the export. The recursor item stays open until #33 adds the auxiliary recursors of nested types.

  8. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    Merged #33. Engine R now checks nested inductive types (spec 06.3). The checker builds the auxiliary mutual block, checks it with the rules of 06.2, generates the recursors and compares them with the recursors of the input (06.6). All 225 local Arena tests give the expected verdict, and the full Init prelude is accepted. The next step is #34, which adds primitive pinning (05.8).

  9. added a commit that references this issue on Nov 21, 2026
  10. 2 remaining items

  11. added a commit that references this issue on Nov 21, 2026
  12. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    Merged #37. It adds tests for the quarantine rules of spec 05.10: an unsafe inductive type skips strict positivity, and a theorem that refers to an unsafe or partial constant is rejected. The quarantine array of the report is in #35, so I will tick the quarantine item when #35 is merged.

  13. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    Release v0.0.3 is out: https://github.com/tamnd/rulean/releases/tag/v0.0.3. It has nested inductives (#33), primitive pinning (#34) and the quarantine tests (#37). The release workflow passed and attached 5 assets.

  14. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #35 is merged. rulean check now runs engine R on an export. It selects the semantics profile from the Lean version of the export, and --profile sets the profile. The exit codes are the codes of spec 09.3, and --report FILE writes the JSON report of docs/report.schema.json. Unsafe and partial constants go to the quarantine list of the report. The v4.35 profile covers Lean 4.35 and 4.36. An export from another Lean version gives decline.

  15. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #36 is merged. scripts/arena-run.sh is the Arena entry of rulean, and docs/arena/rulean.yaml is the draft of the entry. The arena CI job runs scripts/arena-check.sh on all tests of the Arena tarball. All 225 tests give the expected verdict. #39 adds the 30 tests with the outcome "either", which are not in the tarball.

  16. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #39 is merged. The new arena either CI job builds the 30 Arena tests that have the outcome "either" with Lean v4.36.0 and checks them with the v4.35 profile. The job builds 30 of 30 tests. 28 of 28 pinned tests give the expected verdict, and the 2 tests with no pinned verdict are not run. #39 also puts back the released 0.0.3 section of the CHANGELOG, which an earlier rebase changed.

  17. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #40 is merged. Engine R now checks axioms, definitions, theorems and opaque constants in the scratch tier of spec 04.8. The full Init prelude now takes 54 s and 964 MB, and before it took 93.5 s and 3.45 GB. Std now takes 60 s and 1.6 GB, and before it took 192 s and 4.55 GB. All 225 tests of the Arena tarball give the expected verdict. This is a step toward the Mathlib item, which needs the store to stay inside the memory of a normal machine.

  18. added a commit that references this issue on Nov 21, 2026
  19. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #41 is merged. rulean check now reads the export one line at a time and computes the SHA-256 digest at the same time, so the export is not in memory as a whole. All 225 tests of the Arena tarball give the expected verdict. The first url test also works on a local build: con-leche, built from its pinned commit and sent to rulean through a pipe, has the hash of the Arena results and is accepted. The check takes 198 s for 36747 declarations, but the peak memory is 7.7 GB, which is too much for Mathlib. I am looking at this now.

  20. tamnd commented on Nov 21, 2026

    @tamnd
    OwnerAuthor

    #42 is merged. scripts/arena-build.py now builds the six Arena tests with a url field, and --check RULEAN sends each export to rulean through a pipe. con-leche is accepted in this mode. The Mathlib export, built from commit fc4f59e5 with the Mathlib cache, has the hash of the Arena results. The Mathlib check is running now on a local build of main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    milestoneThe tracking issue of a milestone

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions