cert: certify non-empty List literals - #1447
Merged
Merged
Conversation
The plan grammar gains the two List patterns, `[]` and `[head, ..tail]`, and the two-arm List match the emitter lowers: both arms in either order, or either one first and `_` second. The wall ports `emit_mir_list_match` (stash the subject, `ref.is_null`, the `[]` arm in `then`, the head and tail read from the cons struct into the arm's binders in `else`) and proves the case in `agreement_step`, so a function that matches on a List, recursive ones included, is certified for the bytes already emitted. No helper, no new runtime contract, no schema change; the wall id rotates. The producer prints the patterns and carries the Rust twins of the arm pick, the typing and the lowering. Four hardening tests: the clean List certificate checks, and exchanged arm results, exchanged cons structs and exchanged head and tail slots decline. The ratchet records 54 gains and no loss; btc-listener goes from 632 to 765 certified exports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A type table long enough to be written in pieces (`types_records_0`, `types_records_1`, ...) left those pieces folded in the `simp` that proves a bridge's arguments well typed, so the step stopped on an unreduced record lookup and the bridge fell to `sorry`. btc-listener's records crossed that length once List matches were certified: 65 of its 494 bridges and one bridged law lost their credit. The typing step now unfolds every piece of the table but the string segments, which typing never reads, and btc-listener is back at 494 of 494 bridges and 16 of 17 bridged laws with 765 certified exports. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # docs/certification.md
…oofs The package's roles_ok and plans_ok unfolded carrierState, carrierConfirmed and typeSectionMatches with simp. Each is a match on the decoded type section, and simp reduced that match before the cut could rewrite the decode, evaluating the whole type-section decode in the elaborator. After the Vector version structs changed the type section, btc-listener's Artifact.lean ran past the 9000-second phase limit. Unfold these definitions by their unconditional equations with matcher reduction off, so the decode is replaced by the cut and read only in the kernel: roles_ok 13 s and plans_ok 68 s on that package, where each ran for over 10 minutes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
A non-empty literal pushes its items, then the empty list, and calls the per-type cons helper once per item. The plan grammar now admits that node: its typing needs the cons helper the type table declares for the element type, with the planned signature (T, List<T>) -> List<T>; its lowering is the items, ref.null and one call per item; its meaning is the cons cells of the items in order. The cons helper is offered as a planned internal function, and a new acceptance conjunct (consPinned) requires its plan to be the wall's own cons plan: one List.prepend of its two parameters. So the literal's calls reach a function whose meaning is proved, not assumed, and the agreement proof folds the calls over the reversed items. No schema change; the wall id rotates. The producer prints the items, declares the helper per element type, offers the helper with the literal's function, and carries the Rust twins of the typing and lowering. Bridges of functions that return a literal unfold it with the new simp lemmas. Hostile tests: the helper declared as a user function of the same signature, the helper's plan changed to return the tail, and the helpers of two instantiations exchanged, each refused. Ratchet: gains only. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
# Conflicts: # CHANGELOG.md # aver-cert/assets/wall/current/GrammarLower.lean # aver-cert/src/engine/plan.rs # aver-cert/src/format.rs # docs/certificate-format.md # docs/certification.md # src/codegen/cert/plan_from_mir.rs # tests/cert_certify_spec.rs # tests/cert_hardening_spec.rs # tests/snapshots/cert_certify_spec__add_one_certificate_package.snap # tests/snapshots/cert_certify_spec__wasip2_component_certificate_package.snap # tools/cert-baseline.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second List step for the certificate, stacked on #1445: non-empty List literals.
The first commit is #1446 (the acceptance proofs read the type section only through its cut). Without it, btc-listener's check runs past the 9000-second limit after #1444, so the measurements below need it. It drops out of this diff once #1446 is on main and this branch is rebased.
What changes
Grammar,GrammarLower,GrammarSound,TypeTable,SchemaCore,AcceptedArtifactCore,AcceptanceSoundness): the nodelist t itemsnow admits a non-empty literal. Its typing needs the cons helper the type table declares for the element type (TypeTable.listCons, the newMCtx.listCons), with the planned signature(t, List<t>) -> List<t>, and every item typed att. Its lowering is the items,ref.nullof the cons struct, and onecallof the helper per item. This is exactlyemit_mir_list_literal, and the last item is consed first. Its meaning is the cons cells of the items in order (consAll).consPinnedrequires every declared helper to be a planned function whose body is the wall's cons plan, oneList.prependof its two parameters (isConsPlan). The agreement proof takes the helper'sContractplus the model fact that its meaning isList.prepend(hConsF), and folds the calls over the reversed items (consCalls_run).fn_certified_groupdischarges that model fact from the plan (groupModel_consPlan), andfn_certified_totalthreads it through. The root theorems keep the axiomspropext, Classical.choice, Quot.sound. There is no schema change, and the wall id rotates.produce.rsoffers the helper with the literal's function, counts it as a call target, and keeps alistConsentry only when its helper is offered.plan_check.rshas the Rust twins of the typing and lowering.Plans.leanwriteslistConsonly when it is non-empty, so a module without literals renders as before, and the snapshots move only by the wall id. Bridge steps gained the simp lemmas that unfold a literal, so a function that returns a literal is now bridged.FnPlanfields as bound for every plan, andlint_flags_the_removed_code_entry_pincaught it.cert_hardening_spec, the clean literal certificate checks, and each of these is refused: theList<Int>helper declared as a user function of the same signature whose plan returns the tail, the helper's own plan changed to return the tail, and theList<Int>andList<String>helpers exchanged. The payment_ops count pin moves from 101 to 106. A strictaver-cert verifyof a seven-export literal probe returns CERTIFIED, with 6 of 6 bridges credited.--allow-dropnot used).certification.md, CHANGELOG.Measurements
aver-cert checkof btc-listener (commit 5698c8e), one Lean process,AVER_CERT_PHASE_TIMEOUT_SECS=9000:The census predicted +58 for btc, and all 58 arrive. Examples, projects and certificate fixtures (producer admission): 706 → 733.
Laws on bytes do not move yet. The laws over List functions need bridges for List arguments, which is the decoder PR that comes next.
Tests run
cargo test -p aver-cert --all-features, the printer unit tests, the certificate snapshots,cert_one_build_spec,cert_hardening_spec(42),cert_certify_spec(39, with the payment_ops pin moved), and thecert_verify_spectripwires (43). Alsocargo fmt --checkand clippy on both crates.