Skip to content

Self-hosting: GNAF certification and the target calculus's evaluator and realization library as language-1.2 source #275

Open

Description

@humuhumu33

Child of #92 (stage 8 of #27). Part of v0.4's objective: LexLean compiles itself.

Scope

Compiler code not covered by BS-04..BS-08: GNAF requests and certification (gnaf.rs, gnaf/; SPEC §17.15, §17.18), and the parts of calculus/ beyond the checker and the Rust backend: the evaluator, the realization library and the identity of calculus programs (§17.14).

Done when

  • Each is a certified production root whose package agrees with the Rust oracle byte for byte on every committed request, certificate, target program and fixture.

Each part follows the standing R3 discipline of #15: register rows in model/ids.toml and SPEC §31, one scenario and one conformance_<id> test per row, positive and negative fixtures, a planted defect recorded in VERIFICATION.md, and the Rust module kept as the stage-0 oracle (differential to the byte) until the fixed point of #273 removes it.


Generated by Claude Code

Activity

  1. added this to the LexLean v0.4 milestone on Oct 22, 2026
  2. added
    enhancementNew feature or request
    self-hostingLexLean compiling itself: compiler in .lex.tex, certified, built by its own pipeline
    on Oct 22, 2026
  3. humuhumu33 commented on Oct 22, 2026

    @humuhumu33
    ContributorAuthor

    Taking #275, starting with its GNAF part. Nothing is built yet; this is the shape, for correction before the first draft.

    Overlap checked. No open PR or branch touches gnaf.rs, gnaf/, compiler/gnaf, compiler/certificates, or calculus::{interp, realization}. The open drafts are BS-06/07 (#253, #258, #266), #91 stage 4 (#254, #255, #259, #262, #264, #265: runtime syntax and heap model, not GNAF), and #261, #256, #247 and the #115 series. claude/issue-22-gnaf-universe and claude/issue-23-gnaf-certification are the old v0.2 branches. Row numbers: BS-06/07 are in #253/#258, BS-08 is #272, BS-09 is in #259, so the GNAF rows start at BS-10. Each number is fixed when its row is claimed, in case another row lands first.

    What the GNAF part is. The oracle is crates/lexlean/src/gnaf.rs (1,781 lines) and gnaf/certification.rs (1,489). The kernel model compiler/src/Gnaf and Certification stay the normative definitions (§17.15, §17.18). The new roots are held to the Rust transcription to the byte, as #275 asks, and through it to the committed answers the kernel already confirms. The oracle splits into five parts. Four need no evaluator. The fifth is the premise facts, which evaluate systems and so wait on the evaluator part of this issue.

    Row Module, roots (rust-std) Oracle Lines Estimated largest part
    BS-10 GnafValidate: validateRequest (request : Request) : Option Rejection gnaf::validate and its checks, universe_size about 220 about 550 KB, 17% of the budget
    BS-11 GnafAnswer: answerOf, certifiesAnswer, minimaAttained, given the statuses evaluate_answer after statuses, argmin, frontier, dominates, componentwise_minimum, attains, certifies, minima_attained about 140 about 350 KB
    BS-12 GnafUniverse: expandCarrier, realizeSystem, programSize, systemCharge expand, well_formed, entry_body, realize, callees, reachable, expr_size, program_size, unit_charge, system_charge about 250 about 625 KB, plus the closure of CalculusCheck's program sorts
    BS-13 GnafCertify: certificateVerdict (request) (certificate) (facts) certification::check_inner with the premise facts as an argument; the certificate's capacity check about 700 about 1.75 MB, 56%; split by route if the first measure is over 60%
    later the premise facts (premise_fact, observations, preserves, is_normal) certification.rs about 350 after the evaluator row

    The estimates use BS-07's measured 2,500 bytes of certificate per oracle line (applyMoves). That figure comes from one recursive pass over Expr, so these are guesses until each first export. The first PR reports its measured parts, and each later row is measured before the next is built. load (spec tag, host capacity, grammar signature, thresholds, plan preparations) joins BS-12 or becomes its own row once universe_id can be source. That waits on #276's canonical JSON writer, and the check and evaluation it calls are BS-04's roots and the evaluator.

    BS-10 in detail (the first PR).

    • Arguments. validate reads no program and no value. It reads the domain's length, the carrier's kind, the plan count, each plan's preparations, the threshold count, the machine, the completeness evidence, the objective, the claim, and the scope. The root takes exactly that projection of the request: a record with the domain's length, the machine (fuel, capacity, operand size, actions, boundary, and each prepared artifact's action), and a carrier whose grammar keeps each plan's preparations and the thresholds. The reference program, the domain's values, the plans' functions, the argument and result types, the artifacts' digests, and the strings of profile_defined_comparison are not arguments. The row says this in its statement. The host projects each Request, and the oracle runs on the full Request.
    • Sorts. No recursive sort of the module's own. The one nesting is a list of plans, each holding a list of actions. A throwaway root first checks whether certificate A takes it. If it does not, the plans' preparations are carried flattened in plan order, with the plan count, which is all validate reads.
    • Oracle and corpus. gnaf::validate is public and outside the renderer's files, so no oracle change and no identity moves. The corpus is the 60 committed requests of compiler/gnaf/ (36 refused, 14 argmin, 5 frontier, 4 incomplete, 1 infeasible) and the requests the 73 certificate fixtures of compiler/certificates/ name. On top of those come hand-built requests that reach each of the 21 rejections, and each of the 10 action kinds for the six rejections that carry one where it is reachable, three times each. validate is total over Request values, so the vectors include requests that load would refuse. Field-level seeded mutants of the committed requests (every field above) can be large, because no program is evaluated.
    • Outcome compared. Acceptance, and the rejection as the oracle's serde_json bytes, to the byte.
    • Legs. As BS-04/05. On every host: the rendered package under the pinned rustc on the deterministic vectors. On the normative host: the lowered program under the calculus evaluator on the committed requests, the rule vectors, and a seeded corpus; the package on a larger seeded corpus; the plants; and the export equal to tests/production-export/bootstrap/. The case asserts that the largest certificate part is under 3,145,728 bytes.
    • Plants (candidates, about 12). The empty-domain check after the carrier; a constant charge of 0 accepted; a free preparation accepted under the complete boundary; a prepared artifact matched against steps instead of free; a duplicate counted at one occurrence; fallback missing from the performed kinds; the domain capacity compared with >=; the universe size as n + |T|·n for n + |T|·n²; restricted_universe_optimal refused as unsupported instead of an alias; the scalar and vector claim checks swapped; rust_programs scope admitted; the unit operand-size check before the capacity check. The case records each plant's first disagreement in VERIFICATION.md.
    • Records. The ids.toml and SPEC §31 rows, the §17.23 paragraph, the bootstrap.feature scenario, and a failing conformance_bs_10 are the first commit. Records bound to identities (lock, bootstrap/expected, the production export, the stack rows) are relocked locally to run the case and left to your regeneration, as for BS-04..07.

    After the GNAF part, the rest of #275 is the evaluator (calculus::interp, 729 lines, about 1.8 MB estimated, so likely one root per evaluation mode), the realization library (realization.rs, 1,466 lines, split by measurement), and the identity of calculus programs (§17.14, Program::id: the renamer and the canonical writer). The identity overlaps BS-08's module-local RustProgram writer, so it reuses that writer after BS-08 and #276 instead of writing a second one. I will post each part's shape here before building it.

    One question for you. compiler/src/Gnaf.validate, gnaf::validate, and GnafValidate.validateRequest will be three definitions of one function. Until #273 the Rust stays as the oracle. At the fixed point, should the bootstrap root also be tied to the kernel model, for example by the GNAF fixtures' expected answers? Or does the model stay the normative copy beside a certified one? This is a note for §17.23, not work for this PR.

    Branch claude/issue-275-gnaf-validate, draft PR to follow, based on release/v0.4.


    Generated by Claude Code

  4. changed the title [-][v0.4] Self-hosting: GNAF certification and the target calculus's evaluator and realization library as language-1.2 source[/-] [+]Self-hosting: GNAF certification and the target calculus's evaluator and realization library as language-1.2 source[/+] on Oct 22, 2026
  5. removed this from the LexLean v0.4 milestone on Oct 22, 2026
  6. humuhumu33 commented on Oct 29, 2026

    @humuhumu33
    ContributorAuthor

    Update to the claim of 2026-10-22. The shape of the GNAF part stands; the row numbers and the base have moved, so I fix them here before the first commit.

    Row numbers. BS-10 to BS-14 are now registered by the lowering stack (#315, register 461), and BS-15 is claimed by #272. The GNAF rows take the next four, fixed now:

    Row Module, roots Oracle
    BS-16 GnafValidate: validateRequest gnaf::validate, universe_size
    BS-17 GnafAnswer: answerOf, certifiesAnswer, minimaAttained evaluate_answer after statuses
    BS-18 GnafUniverse: expandCarrier, realizeSystem, programSize, systemCharge expand through system_charge
    BS-19 GnafCertify: certificateVerdict certification::check_inner with the premise facts as an argument

    The premise facts stay a later row, after the evaluator. If another row lands first, I renumber in this issue before my first commit, not after.

    Base. release/v0.4 at a1b925d. BS-16 reads no lowering root, so it does not stack on #315. The oracle is unchanged: gnaf.rs is 1,781 lines, gnaf/certification.rs 1,489, gnaf::validate is still public at line 836, and compiler/gnaf/ still holds the 60 committed requests and compiler/certificates/ the 73 fixtures.

    Overlap, re-checked on 2026-10-29. No open PR or branch touches gnaf.rs, gnaf/, compiler/src/Gnaf, compiler/src/Certification, compiler/gnaf or compiler/certificates. Two things matter for later parts only: #239 (claude/issue-115-lowering, base release/v0.5) changes 10 lines of calculus/interp.rs, which the evaluator part will have to follow; and the old branch issue-114-widening (no PR, last commit 2026-10-16) adds 24 lines to calculus/realization.rs. Neither touches BS-16.

    Shape of BS-16, unchanged. The root takes the projection of Request that validate reads (domain length, machine, carrier kind with each plan's preparations and the thresholds); the host projects, the oracle runs on the full Request. Compared to the byte: acceptance, and the rejection as serde_json bytes. Plants, corpus, records and legs are as in the first claim. The failing conformance_bs_16 is the first commit. Branch claude/issue-275-gnaf-validate; nothing is pushed.


    Generated by Claude Code

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

    enhancementNew feature or requestself-hostingLexLean compiling itself: compiler in .lex.tex, certified, built by its own pipeline

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions