Skip to content

Add the environment and the type checker of engine R - #30

Open
tamnd wants to merge 3 commits into
mainfrom
m2/tc
Open

tamnd wants to merge 3 commits into
mainfrom
m2/tc

Conversation

@tamnd

@tamnd tamnd commented Nov 21, 2026

Copy link
Copy Markdown
Owner

Refers to #3.

Summary

This PR adds the environment and the type checker of engine R to rulean-core. The code is a transcription of type_checker.cpp, of inductive_reduce_rec and its helpers in inductive.h and inductive.cpp, and of quot_reduce_rec in quot.h, of the official kernel v4.35.0.

Changes

  • env.rs: the constant records of declaration.h and the environment. A lookup returns a slot number and not a reference, because subset rule S10 forbids Option<&T>.
  • tc.rs: the checker state, the local context, the caches, the sticky fault, the depth bound and type inference in the infer-only mode and in the check mode.
  • whnf.rs: whnf_core and whnf in the official order. This includes beta, zeta, projections, recursor iota with K and structure eta for the major premise, Quot.lift and Quot.ind, the 15 Nat operations with the size bound, and delta.
  • defeq.rs: is_def_eq_core with the official order of steps: the quick check, the Bool.true reflection step, proof irrelevance, lazy delta reduction with the offset rule, projections, application congruence, eta, structure eta, the String literal expansion and unit-like types.
  • tests/tc.rs: 14 tests on small environments that are built by hand.

Notes

  • The builtin constants are found by name in this PR. Primitive pinning (spec 05.8, D1) comes in a later PR.
  • Declarations, inductive types and the rulean check command come in the next PRs.

Test plan

  • cargo test -p rulean-core
  • cargo clippy --workspace --all-targets -- -D warnings
  • cargo xtask all, which includes the subset check
  • The extract job in CI

@tamnd tamnd added this to the M2 Engine R milestone Nov 21, 2026
@tamnd tamnd added area/core The type checker: engines F and R, declarations, profiles type/feature New function labels Nov 21, 2026
Base automatically changed from m2/expr to main November 21, 2026 16:42
The checker infers types, reduces terms to weak head normal form and decides definitional equality. The code is a transcription of type_checker.cpp, inductive_reduce_rec and quot_reduce_rec of the official kernel v4.35.0, in the Aeneas subset.
@tamnd tamnd mentioned this pull request Nov 21, 2026
2 of 20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core The type checker: engines F and R, declarations, profiles type/feature New function

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant