From 5907068df01b33346cc2a35f48363ab9bd3bef5c Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 07:04:20 +0000 Subject: [PATCH 01/21] R3 skeleton for #115: register rows TC-08, RB-15, SP-21, MD-14 with scenarios and failing named tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rows, SPEC.md §31 rows, scenarios, and conformance_ tests only; the four tests fail because no case is wired. No implementation, no identity moves. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 4 ++++ SPEC.md | 6 +++++- crates/conformance/src/cases/repository.rs | 2 +- crates/conformance/tests/conformance.rs | 20 ++++++++++++++++++ features/suites/calculus.feature | 6 ++++++ features/suites/models.feature | 6 ++++++ features/suites/preservation.feature | 6 ++++++ features/suites/rust-backend.feature | 6 ++++++ model/ids.toml | 24 ++++++++++++++++++++++ xtask/src/spec_links.rs | 4 ++-- 10 files changed, 80 insertions(+), 4 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index a601b74d91..196d468ced 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -77,6 +77,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `TC-05` | `build` | Every realization library template has a fixture whose outcome the kernel proves equal to the value LexLean's own collection primitive computes, committed instances equal their templates, and a mutated template is rejected by Lean. | | `TC-06` | `build` | Every runtime construct of the production registry has exactly one realization row naming existing calculus elements and requires allocation and implies recursion exactly when its realization does, and the fixtures exercise every calculus type, literal, expression, shape, primitive, and template, and every fixed-width primitive at every width it admits. | | `TC-07` | `build` | Every fixture with an observable outcome renders to a safe Rust library crate in rust-std, and in rust-core exactly when it needs no heap, that the pinned rustc compiles with warnings denied, that prints exactly the denotation's value or overflow, and whose counted work never exceeds the denotation's steps; planted value and work discrepancies are detected. | +| `TC-08` | `build` | The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. | ## cli-api @@ -331,6 +332,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `MD-11` | `build` | Model constructs have production dispositions under which artifacts, realizations, models, validators, and checked applications are realized through their elaborations while contracts and evidence are erased, the realization table covers every new runtime construct, and production roots applying an artifact-backed model, directly and through its checks, are eligible and extract the same closure through Lean. | | `MD-12` | `build` | The committed models example verifies nontrivial deterministic stateful, rule, statistical, artifact-backed neural, and composite models with every claim kernel-checked, and planting a contract and realization mismatch in it is refused by verification. | | `MD-13` | `build` | IEEE-754 binary32 and binary64 bit patterns decode in LexLean to exact dyadic rationals (sign, integer mantissa, exponent) for zero, subnormal, and normal values while rejecting non-finite and out-of-range patterns, and the models corpus derives round(a * b / c * 2^32) from three binary32 patterns by exact integer arithmetic that agrees with an independent exact rational computation under Lean and refuses a planted rounding or exponent mutation. | +| `MD-14` | `build` | The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. | ## oracle @@ -379,6 +381,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `SP-18` | `build` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | | `SP-19` | `build` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | | `SP-20` | `build` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | +| `SP-21` | `build` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | ## production @@ -506,6 +509,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `RB-12` | `build` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | | `RB-13` | `build` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | | `RB-14` | `build` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | +| `RB-15` | `build` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | ## security diff --git a/SPEC.md b/SPEC.md index 0235f315f8..c451c8ee37 100644 --- a/SPEC.md +++ b/SPEC.md @@ -10219,6 +10219,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `TC-05` | `calculus` | Every realization library template has a fixture whose outcome the kernel proves equal to the value LexLean's own collection primitive computes, committed instances equal their templates, and a mutated template is rejected by Lean. | §17.12, §17.14 | | `TC-06` | `calculus` | Every runtime construct of the production registry has exactly one realization row naming existing calculus elements and requires allocation and implies recursion exactly when its realization does, and the fixtures exercise every calculus type, literal, expression, shape, primitive, and template, and every fixed-width primitive at every width it admits. | §17.13, §17.14 | | `TC-07` | `calculus` | Every fixture with an observable outcome renders to a safe Rust library crate in rust-std, and in rust-core exactly when it needs no heap, that the pinned rustc compiles with warnings denied, that prints exactly the denotation's value or overflow, and whose counted work never exceeds the denotation's steps; planted value and work discrepancies are detected. | §17.14 | +| `TC-08` | `calculus` | The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. | §17.14 | | `RB-01` | `rust-backend` | Every Rust rendering is built as a closed AST each of whose constructs carries the calculus element it realizes, every correspondence row and every AST node is exercised by a run package, and a construct whose row, width, or program does not justify its element is refused. | §17.16 | | `RB-02` | `rust-backend` | An exported name that is not a lowercase snake-case identifier, is a Rust keyword, imitates a generated name, or is declared by the runtime, a name exported twice, and an unavailable crate name each fail with LLB6005, and a crate binding one name twice in a function is refused. | §17.16, §26.3 | | `RB-03` | `rust-backend` | An export that copies a parameter whose type is not Copy fails with LLB6005, and a crate that moves a value twice or reads it after moving it is refused. | §17.16, §26.3 | @@ -10233,6 +10234,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `RB-12` | `rust-backend` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | §17.16, §21.2 | | `RB-13` | `rust-backend` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | §17.13, §17.16 | | `RB-14` | `rust-backend` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | §17.13, §17.14, §17.16 | +| `RB-15` | `rust-backend` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | §17.16 | | `GN-01` | `gnaf` | Every committed GNAF request and fixture is canonical, validates against the GNAF schemas whose calculus definitions are the target program schema's, and states its components' universe identity; a malformed request, an invalid reference, plan, or realized program, a reference without a value on a domain argument, or a wrong universe identity fails closed with LLB6006, and a machine or request beyond the host's capacity fails closed with LLS8002. | §17.15, §26.3 | | `GN-02` | `gnaf` | The GNAF model is a kernel-checked LexLean definition, Lean's kernel reduces the universe, the system statuses, and the answer of every committed request to what the host transcription computes, and a wrong answer, an answer computed from a universe with a system omitted, a tie with a member dropped, and a universe with a system omitted are rejected by Lean. | §17.15 | | `GN-03` | `gnaf` | Candidate membership is the grammar's expansion, which a kernel-checked theorem proves equal to the grammar's well-formed selectors for every grammar, independent of evaluation and fixed by a universe identity before any optimizer, and optimizer-defined, discovered, cached, and internal-plan universes and missing, self-referential, or optimizer-citing completeness evidence are rejected. | §17.15 | @@ -10272,6 +10274,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `SP-18` | `preservation` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-19` | `preservation` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-20` | `preservation` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | §17.16, §17.17 | +| `SP-21` | `preservation` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | §17.17 | | `MD-01` | `models` | Language 1.2 artifact, contract, realization, evidence, and model declarations, the checked_apply term, the contract_violation type, and the less_than primitive belong to the closed lexlean/semantic-module/2 schema and its snapshot schema, are rejected under language 1.1 before either backend runs, and admit no member outside the closed schema, such as prompt text, a free-form description, or raw model configuration. | §17.12 | | `MD-02` | `models` | A model artifact is admitted only from a configured, content-addressed, confined project file whose SHA-256 and byte length equal its declaration and whose bytes decode under its declared closed schema to its declared type and role; a missing artifact or a digest or length mismatch fails with LLR3007, a schema, type, or role violation fails with LLR3008, and the generated Lean embeds the exact bytes with a kernel-checked theorem that the typed value is their decoding. | §17.12, §10.1, §26.3 | | `MD-03` | `models` | A contract names typed input, output, and optional state interfaces and prior proposition-valued predicates of exactly those interface signatures, and each runtime validator is an executable Boolean definition of the same signature linked to its predicate by a statement-exact soundness theorem and an optional completeness theorem that Lean restates against the fixed model semantics; any mismatch fails with LLT4006. | §17.12 | @@ -10285,6 +10288,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `MD-11` | `models` | Model constructs have production dispositions under which artifacts, realizations, models, validators, and checked applications are realized through their elaborations while contracts and evidence are erased, the realization table covers every new runtime construct, and production roots applying an artifact-backed model, directly and through its checks, are eligible and extract the same closure through Lean. | §17.13, §17.14, §22.10 | | `MD-12` | `models` | The committed models example verifies nontrivial deterministic stateful, rule, statistical, artifact-backed neural, and composite models with every claim kernel-checked, and planting a contract and realization mismatch in it is refused by verification. | §17.12, §28.6 | | `MD-13` | `models` | IEEE-754 binary32 and binary64 bit patterns decode in LexLean to exact dyadic rationals (sign, integer mantissa, exponent) for zero, subnormal, and normal values while rejecting non-finite and out-of-range patterns, and the models corpus derives round(a * b / c * 2^32) from three binary32 patterns by exact integer arithmetic that agrees with an independent exact rational computation under Lean and refuses a planted rounding or exponent mutation. | §17.12, §28.6 | +| `MD-14` | `models` | The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. | §17.12 | | `RS-01` | `reasoning` | Language 1.2 logic, inference_rule, verifier, and reasoner declarations, the forward, search, and generate_and_verify strategies, the initial_invariant, terminates, observation_invariant, and answer_correct claims, and the reasoning_failure type belong to the closed lexlean/semantic-module/2 schema and its snapshot schema, are rejected under language 1.1 before either backend runs, and admit no member, strategy, or claim outside the closed schema, such as an opaque oracle, a prompt, an unregistered strategy, or an unregistered claim, which fail with LLT4001. | §17.12 | | `RS-02` | `reasoning` | A logic names a prior state relation and an optional invariant with a statement-exact preservation theorem and an optional ranking, each of exactly its state type, and an inference rule over a logic is a typed guard, conclusion, and optional binding with a candidate list whose soundness theorem states exactly that the guard implies the relation and whose progress theorem states exactly that the ranking decreases; logics, rules, verifiers, and reasoners may be generic, and a predicate of the wrong signature, an inexact theorem, a rule over another logic than its reasoner's, or a use with the wrong number of type arguments fails with LLT4010. | §17.12 | | `RS-03` | `reasoning` | A verifier links an executable Boolean check over a subject and a candidate to a prior proposition-valued specification by statement-exact soundness and optional completeness theorems that Lean restates against the fixed reasoning semantics; an inexact statement or a verifier whose subject or candidate type differs from its reasoner's fails with LLT4010, and a false soundness theorem is refused by verification with LLV7002. | §17.12, §22.6 | @@ -10369,7 +10373,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `LM-06` | `language-models` | Nondeterminism is an explicit contract: a `text_generator` under the `sample` policy draws through the closed `xorshift32` generator and `proportional` distribution only, takes its seed as an explicit `uint32` input and returns the next seed as an explicit output, so the same prompt and seed give the same output, which the kernel computes; it has the same generated and kernel-checked laws as a greedy generator, `xorshift32` agrees with the reference sequence, and a generator or distribution outside the closed members, a sample policy without one, or a seed stated on a policy is a schema violation (`LLT4001`). | §17.12 | | `LM-13` | `language-models` | The text laws a tokenizer elaborates through are LexLean source and not authored text: the module that states them is one language-1.2 native core module of the embedded `language/text-1.2` project, the project holds no file of Lean source, no independently authored Lean file anywhere in the release tree declares the `LexLeanText` namespace or lies under its module root, and the one-time migration input is absent; the registry lists only that module, the declarations and their exact axiom policies are read from its native data, which the compiler embeds and hashes into the language-1.2 semantics, and a module that declares a text component imports the generated module rather than splicing any Lean text. | §17.10, §17.12 | -**Total required capability IDs:** 430. +**Total required capability IDs:** 434. No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors. diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index 2bb5b5a6d0..df6d6d314f 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -756,7 +756,7 @@ pub(crate) fn run(id: &str) { let model = repo_model::Model::load(&root.join("model").into_std_path_buf()) .expect("the model loads"); let table = spec_table(); - assert_eq!(table.len(), 430, "§31 has 430 rows"); + assert_eq!(table.len(), 434, "§31 has 434 rows"); assert_eq!(model.ids.id.len(), table.len(), "register row count"); for ((spec_id, spec_suite, spec_statement), row) in table.iter().zip(model.ids.id.iter()) diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 32e726461a..5738586cab 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2154,3 +2154,23 @@ fn conformance_lm_06() { fn conformance_lm_13() { repo_conformance::cases::run("LM-13"); } + +#[test] +fn conformance_tc_08() { + repo_conformance::cases::run("TC-08"); +} + +#[test] +fn conformance_rb_15() { + repo_conformance::cases::run("RB-15"); +} + +#[test] +fn conformance_sp_21() { + repo_conformance::cases::run("SP-21"); +} + +#[test] +fn conformance_md_14() { + repo_conformance::cases::run("MD-14"); +} diff --git a/features/suites/calculus.feature b/features/suites/calculus.feature index 5a5837c3af..1eae31a3a9 100644 --- a/features/suites/calculus.feature +++ b/features/suites/calculus.feature @@ -50,3 +50,9 @@ Feature: calculus When each is rendered as a library crate in both profiles where it can be, compiled with its harness by rustc with warnings denied, and run Then rust-core renders exactly the fixtures that need no heap, and each run prints the denotation's observable outcome and a work count no greater than its steps And a wrapping addition or a Euclidean quotient planted in a rendering changes the printed outcome, and a quadratic append exceeds the steps + + @TC-08 @build + Scenario: The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. + Given a calculus program that holds a decoded constant as a data literal, and copies that plant a mistyped literal, a malformed member, and a noncanonical spelling + When it is loaded, evaluated by the denotation, and rendered + Then the literal has its type, its canonical form, and the denotation's value, the cost is its weight per read, and each copy fails with LLB6005 diff --git a/features/suites/models.feature b/features/suites/models.feature index 52e500215c..0b3c403c78 100644 --- a/features/suites/models.feature +++ b/features/suites/models.feature @@ -92,3 +92,9 @@ Feature: models When they are decoded to exact dyadic rationals and round(a * b / c * 2^32) is derived in LexLean Then the decoded rationals and rounded scale ratios equal the independent exact rational computation under Lean And non-finite and out-of-range patterns are rejected and a planted rounding or exponent mutation is refused by verification + + @MD-14 @build + Scenario: The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. + Given the committed models example, whose production roots read artifacts, and a copy whose lowered program builds an artifact per call + When it is built and verified + Then every artifact read is a data literal equal to its decoding, no function body builds an artifact value, and the copy is detected diff --git a/features/suites/preservation.feature b/features/suites/preservation.feature index 0d80b10441..7dde17293d 100644 --- a/features/suites/preservation.feature +++ b/features/suites/preservation.feature @@ -143,3 +143,9 @@ Feature: preservation When every loop of every rendering is read back into the recursive body it is the loop form of, the loop form of that body is computed by the library's form transliterated, and certificate B of the fixtures rendered as loops is compiled by the pinned Lean over the shipped library Then the loop form of each recovered body is the crate's function, and each certificate B compiles with exactly the axioms the audit states And a loop that is not the loop form of any recursive body is refused for each way it may differ + + @SP-21 @build + Scenario: A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. + Given every committed production root that reads an artifact, and a copy that lowers the artifact to a nullary function + When it is lowered and certified + Then each lowered program holds the decoded value as data, certificates A, B, and E check, and the copy is refused diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index 7cb0d10a62..dc0001e6ac 100644 --- a/features/suites/rust-backend.feature +++ b/features/suites/rust-backend.feature @@ -93,3 +93,9 @@ Feature: rust-backend When each is rendered in both profiles and its self calls are classified as tail calls or not Then every template whose self calls are all tail calls renders as a loop that breaks with its result, and its primitives' registry rows say `recursion = false` And every other template renders as a call and keeps `recursion = true`, and a template rendered with a self call it could have as a loop, or a row that disagrees with its rendering, is refused + + @RB-15 @build + Scenario: The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. + Given the calculus fixtures that read a data literal, and a copy whose rendering rebuilds the literal at each read + When it is rendered as rust-std packages and run under the pinned rustc + Then each package prints the denotation's value with counted work no greater than its steps, the literal is constructed once per thread, and the rebuilding copy is detected diff --git a/model/ids.toml b/model/ids.toml index 6e62580190..f6c72fcc59 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1699,6 +1699,12 @@ level = "build" suite = "calculus" statement = "Every fixture with an observable outcome renders to a safe Rust library crate in rust-std, and in rust-core exactly when it needs no heap, that the pinned rustc compiles with warnings denied, that prints exactly the denotation's value or overflow, and whose counted work never exceeds the denotation's steps; planted value and work discrepancies are detected." +[[id]] +id = "TC-08" +level = "build" +suite = "calculus" +statement = "The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005." + [[id]] id = "RB-01" level = "build" @@ -1783,6 +1789,12 @@ level = "build" suite = "rust-backend" statement = "A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused." +[[id]] +id = "RB-15" +level = "build" +suite = "rust-backend" +statement = "The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate." + [[id]] id = "GN-01" level = "build" @@ -2017,6 +2029,12 @@ level = "build" suite = "preservation" statement = "Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have." +[[id]] +id = "SP-21" +level = "build" +suite = "preservation" +statement = "A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused." + [[id]] id = "MD-01" level = "build" @@ -2095,6 +2113,12 @@ level = "build" suite = "models" statement = "IEEE-754 binary32 and binary64 bit patterns decode in LexLean to exact dyadic rationals (sign, integer mantissa, exponent) for zero, subnormal, and normal values while rejecting non-finite and out-of-range patterns, and the models corpus derives round(a * b / c * 2^32) from three binary32 patterns by exact integer arithmetic that agrees with an independent exact rational computation under Lean and refuses a planted rounding or exponent mutation." +[[id]] +id = "MD-14" +level = "build" +suite = "models" +statement = "The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected." + [[id]] id = "RS-01" level = "build" diff --git a/xtask/src/spec_links.rs b/xtask/src/spec_links.rs index 6e4e5c0aa3..1fb5cc0b96 100644 --- a/xtask/src/spec_links.rs +++ b/xtask/src/spec_links.rs @@ -61,8 +61,8 @@ fn parse_table(spec: &str) -> Result, Fail> { pub fn validate(root: &Path) -> Result<(), Fail> { let spec = std::fs::read_to_string(root.join("SPEC.md"))?; let rows = parse_table(&spec)?; - if rows.len() != 430 { - return Err(format!("RP-07: the §31 table has {} rows, not 430", rows.len()).into()); + if rows.len() != 434 { + return Err(format!("RP-07: the §31 table has {} rows, not 434", rows.len()).into()); } // The prose total under the table is part of the contract a reader // relies on; a row added without it would leave §31 contradicting itself. From 8c5345bcb2d308a1c00d074291d8a3a4b7efd7b4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 07:05:46 +0000 Subject: [PATCH 02/21] R3 skeleton for #115: take RB-18 and SP-24 (RB-15..17 and SP-21..23 are #91 stage 4's) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 4 ++-- SPEC.md | 4 ++-- crates/conformance/tests/conformance.rs | 8 ++++---- features/suites/preservation.feature | 2 +- features/suites/rust-backend.feature | 2 +- model/ids.toml | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 196d468ced..0142f195b5 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -381,7 +381,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `SP-18` | `build` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | | `SP-19` | `build` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | | `SP-20` | `build` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | -| `SP-21` | `build` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | +| `SP-24` | `build` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | ## production @@ -509,7 +509,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `RB-12` | `build` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | | `RB-13` | `build` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | | `RB-14` | `build` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | -| `RB-15` | `build` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | +| `RB-18` | `build` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | ## security diff --git a/SPEC.md b/SPEC.md index c451c8ee37..ab43e05d7f 100644 --- a/SPEC.md +++ b/SPEC.md @@ -10234,7 +10234,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `RB-12` | `rust-backend` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | §17.16, §21.2 | | `RB-13` | `rust-backend` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | §17.13, §17.16 | | `RB-14` | `rust-backend` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | §17.13, §17.14, §17.16 | -| `RB-15` | `rust-backend` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | §17.16 | +| `RB-18` | `rust-backend` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | §17.16 | | `GN-01` | `gnaf` | Every committed GNAF request and fixture is canonical, validates against the GNAF schemas whose calculus definitions are the target program schema's, and states its components' universe identity; a malformed request, an invalid reference, plan, or realized program, a reference without a value on a domain argument, or a wrong universe identity fails closed with LLB6006, and a machine or request beyond the host's capacity fails closed with LLS8002. | §17.15, §26.3 | | `GN-02` | `gnaf` | The GNAF model is a kernel-checked LexLean definition, Lean's kernel reduces the universe, the system statuses, and the answer of every committed request to what the host transcription computes, and a wrong answer, an answer computed from a universe with a system omitted, a tie with a member dropped, and a universe with a system omitted are rejected by Lean. | §17.15 | | `GN-03` | `gnaf` | Candidate membership is the grammar's expansion, which a kernel-checked theorem proves equal to the grammar's well-formed selectors for every grammar, independent of evaluation and fixed by a universe identity before any optimizer, and optimizer-defined, discovered, cached, and internal-plan universes and missing, self-referential, or optimizer-citing completeness evidence are rejected. | §17.15 | @@ -10274,7 +10274,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `SP-18` | `preservation` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-19` | `preservation` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-20` | `preservation` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | §17.16, §17.17 | -| `SP-21` | `preservation` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | §17.17 | +| `SP-24` | `preservation` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | §17.17 | | `MD-01` | `models` | Language 1.2 artifact, contract, realization, evidence, and model declarations, the checked_apply term, the contract_violation type, and the less_than primitive belong to the closed lexlean/semantic-module/2 schema and its snapshot schema, are rejected under language 1.1 before either backend runs, and admit no member outside the closed schema, such as prompt text, a free-form description, or raw model configuration. | §17.12 | | `MD-02` | `models` | A model artifact is admitted only from a configured, content-addressed, confined project file whose SHA-256 and byte length equal its declaration and whose bytes decode under its declared closed schema to its declared type and role; a missing artifact or a digest or length mismatch fails with LLR3007, a schema, type, or role violation fails with LLR3008, and the generated Lean embeds the exact bytes with a kernel-checked theorem that the typed value is their decoding. | §17.12, §10.1, §26.3 | | `MD-03` | `models` | A contract names typed input, output, and optional state interfaces and prior proposition-valued predicates of exactly those interface signatures, and each runtime validator is an executable Boolean definition of the same signature linked to its predicate by a statement-exact soundness theorem and an optional completeness theorem that Lean restates against the fixed model semantics; any mismatch fails with LLT4006. | §17.12 | diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 5738586cab..bcafc4df2e 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2161,13 +2161,13 @@ fn conformance_tc_08() { } #[test] -fn conformance_rb_15() { - repo_conformance::cases::run("RB-15"); +fn conformance_rb_18() { + repo_conformance::cases::run("RB-18"); } #[test] -fn conformance_sp_21() { - repo_conformance::cases::run("SP-21"); +fn conformance_sp_24() { + repo_conformance::cases::run("SP-24"); } #[test] diff --git a/features/suites/preservation.feature b/features/suites/preservation.feature index 7dde17293d..d165c29f09 100644 --- a/features/suites/preservation.feature +++ b/features/suites/preservation.feature @@ -144,7 +144,7 @@ Feature: preservation Then the loop form of each recovered body is the crate's function, and each certificate B compiles with exactly the axioms the audit states And a loop that is not the loop form of any recursive body is refused for each way it may differ - @SP-21 @build + @SP-24 @build Scenario: A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. Given every committed production root that reads an artifact, and a copy that lowers the artifact to a nullary function When it is lowered and certified diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index dc0001e6ac..384cc7012c 100644 --- a/features/suites/rust-backend.feature +++ b/features/suites/rust-backend.feature @@ -94,7 +94,7 @@ Feature: rust-backend Then every template whose self calls are all tail calls renders as a loop that breaks with its result, and its primitives' registry rows say `recursion = false` And every other template renders as a call and keeps `recursion = true`, and a template rendered with a self call it could have as a loop, or a row that disagrees with its rendering, is refused - @RB-15 @build + @RB-18 @build Scenario: The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. Given the calculus fixtures that read a data literal, and a copy whose rendering rebuilds the literal at each read When it is rendered as rust-std packages and run under the pinned rustc diff --git a/model/ids.toml b/model/ids.toml index f6c72fcc59..290b17221d 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1790,7 +1790,7 @@ suite = "rust-backend" statement = "A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused." [[id]] -id = "RB-15" +id = "RB-18" level = "build" suite = "rust-backend" statement = "The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate." @@ -2030,7 +2030,7 @@ suite = "preservation" statement = "Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have." [[id]] -id = "SP-21" +id = "SP-24" level = "build" suite = "preservation" statement = "A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused." From 2023063898c31c87f3766cbad3943c82a2111a21 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 07:24:25 +0000 Subject: [PATCH 03/21] TC-08: a calculus literal is charged its weight once per read The reference interpreter, the TargetSemantics denotation, and the SPEC.md 17.14 cost rules charge Expr.value its weight (one for a scalar). The case conformance_tc_08 passes; the 14 fixtures with a literal heavier than one node, their generated statements, and compiler/lexlean.lock are not regenerated, so conformance_tc_01/03/04/05 fail on this tree until the maintainer sequences it. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 2 +- SPEC.md | 8 +- VERIFICATION.md | 26 ++++ compiler/src/TargetSemantics.lex.tex | 2 +- crates/conformance/src/cases/calculus.rs | 149 +++++++++++++++++++++++ crates/lexlean/src/calculus/interp.rs | 10 +- features/suites/calculus.feature | 8 +- model/ids.toml | 2 +- 8 files changed, 195 insertions(+), 12 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 0142f195b5..3bf70089fc 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -77,7 +77,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `TC-05` | `build` | Every realization library template has a fixture whose outcome the kernel proves equal to the value LexLean's own collection primitive computes, committed instances equal their templates, and a mutated template is rejected by Lean. | | `TC-06` | `build` | Every runtime construct of the production registry has exactly one realization row naming existing calculus elements and requires allocation and implies recursion exactly when its realization does, and the fixtures exercise every calculus type, literal, expression, shape, primitive, and template, and every fixed-width primitive at every width it admits. | | `TC-07` | `build` | Every fixture with an observable outcome renders to a safe Rust library crate in rust-std, and in rust-core exactly when it needs no heap, that the pinned rustc compiles with warnings denied, that prints exactly the denotation's value or overflow, and whose counted work never exceeds the denotation's steps; planted value and work discrepancies are detected. | -| `TC-08` | `build` | The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. | +| `TC-08` | `build` | A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005. | ## cli-api diff --git a/SPEC.md b/SPEC.md index ab43e05d7f..10bac18cb8 100644 --- a/SPEC.md +++ b/SPEC.md @@ -4313,7 +4313,11 @@ map key order. The result is an `Outcome`: a value with its exact step count, **Cost.** The step count charges every operation the evaluator performs, so no runtime operation is free: -- each evaluated node is one step, on top of the steps of its operands; +- each evaluated node is one step, on top of the steps of its operands, except + a literal, which is charged its *weight* each time it is read, so that a + scalar costs one step and a decoded constant held as a list, pair, option, + result, or algebraic-data literal is accounted by its size and never by a + single step (`TC-08`); - reading a local is one step more per binding the lookup examines before it finds the local's; - a `match` is one step more per arm it tries, the taken arm included; @@ -10219,7 +10223,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `TC-05` | `calculus` | Every realization library template has a fixture whose outcome the kernel proves equal to the value LexLean's own collection primitive computes, committed instances equal their templates, and a mutated template is rejected by Lean. | §17.12, §17.14 | | `TC-06` | `calculus` | Every runtime construct of the production registry has exactly one realization row naming existing calculus elements and requires allocation and implies recursion exactly when its realization does, and the fixtures exercise every calculus type, literal, expression, shape, primitive, and template, and every fixed-width primitive at every width it admits. | §17.13, §17.14 | | `TC-07` | `calculus` | Every fixture with an observable outcome renders to a safe Rust library crate in rust-std, and in rust-core exactly when it needs no heap, that the pinned rustc compiles with warnings denied, that prints exactly the denotation's value or overflow, and whose counted work never exceeds the denotation's steps; planted value and work discrepancies are detected. | §17.14 | -| `TC-08` | `calculus` | The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. | §17.14 | +| `TC-08` | `calculus` | A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005. | §17.14 | | `RB-01` | `rust-backend` | Every Rust rendering is built as a closed AST each of whose constructs carries the calculus element it realizes, every correspondence row and every AST node is exercised by a run package, and a construct whose row, width, or program does not justify its element is refused. | §17.16 | | `RB-02` | `rust-backend` | An exported name that is not a lowercase snake-case identifier, is a Rust keyword, imitates a generated name, or is declared by the runtime, a name exported twice, and an unavailable crate name each fail with LLB6005, and a crate binding one name twice in a function is refused. | §17.16, §26.3 | | `RB-03` | `rust-backend` | An export that copies a parameter whose type is not Copy fails with LLB6005, and a crate that moves a value twice or reads it after moving it is refused. | §17.16, §26.3 | diff --git a/VERIFICATION.md b/VERIFICATION.md index e74fbc975a..82d8a55ae1 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4009,6 +4009,32 @@ A second plant dropped the result weight from a primitive's charge; the kernel refused the same theorem, stated with 50 steps. Removed: the interpreter was restored and the fixtures regenerated; `compiler/` verifies. +### calculus literal weight can fail (TC-08) + +Planted, in two steps. First the reference interpreter charged a literal one +step (the rule before TC-08); `conformance_tc_08` refused it at the string +literal, whose weight is 4 for `"h\u{e9}\u{e9}"`: + +```text +assertion `left == right` failed: string read 1 time(s) is charged its weight 4 + left: 1 + right: 4 +``` + +Second, with the interpreter correct, `TargetSemantics.lex.tex` was restored to +`(ctor Outcome.value literal 1)`; the same case refused it: + +```text +the denotation charges a literal its weight +``` + +Removed: the weight charge was restored in both. The kernel's own check of +the rule, a fixture whose `rfl` theorem states the weighted step count, needs +`cargo xtask check-calculus --write` and is not exercised here: the 14 fixtures +with a literal heavier than one node (and `compiler/lexlean.lock`) are not yet +regenerated, so `conformance_tc_01`, `conformance_tc_03`, `conformance_tc_04`, +and `conformance_tc_05` fail on this tree until they are. + ### kernel-opaque classification is observed Probe: `compare_bytes` and byte equality were both treated as reducible, and diff --git a/compiler/src/TargetSemantics.lex.tex b/compiler/src/TargetSemantics.lex.tex index ed4b2a2062..6a32a6b79c 100644 --- a/compiler/src/TargetSemantics.lex.tex +++ b/compiler/src/TargetSemantics.lex.tex @@ -5257,7 +5257,7 @@ body: (match fuel | Nat.zero => (ctor Outcome.exhausted) | Nat.succ remaining => (match expression - | TargetSyntax::Expr.value literalType literal => (ctor Outcome.value literal 1) + | TargetSyntax::Expr.value literalType literal => (ctor Outcome.value literal (weight literal)) | TargetSyntax::Expr.var name => (match (lookup environment name) | Option.none => (ctor Outcome.stuck) | Option.some found => (ctor Outcome.value found (1 + (depth environment name)))) diff --git a/crates/conformance/src/cases/calculus.rs b/crates/conformance/src/cases/calculus.rs index 9f82d64e1a..e4b4c98ee4 100644 --- a/crates/conformance/src/cases/calculus.rs +++ b/crates/conformance/src/cases/calculus.rs @@ -1518,6 +1518,155 @@ pub fn run(id: &str) { } } } + // §17.14 *Cost*: a literal is charged its weight once per read. + "TC-08" => literal_weight(), other => panic!("no calculus case is wired for {other}"), } } + +/// The weight of a literal, spelled from its JSON form so the expectation +/// does not borrow the interpreter's own function. +fn literal_nodes(value: &Json) -> u64 { + let all = |items: &Json| { + items + .as_array() + .expect("items") + .iter() + .map(literal_nodes) + .sum::() + }; + match value["kind"].as_str().expect("kind") { + "string" => 1 + value["value"].as_str().expect("text").chars().count() as u64, + "bytes" => 1 + value["hex"].as_str().expect("hex").len() as u64 / 2, + "some" | "ok" | "error" => 1 + literal_nodes(&value["value"]), + "list" => 1 + all(&value["items"]), + "adt" => 1 + all(&value["fields"]), + "pair" => 1 + literal_nodes(&value["left"]) + literal_nodes(&value["right"]), + _ => 1, + } +} + +fn literal_program(ty: &Json, value: &Json, reads: usize) -> Json { + let literal = json!({"kind": "value", "type": ty, "value": value}); + let (body, result) = if reads == 1 { + (literal, ty.clone()) + } else { + let pair = json!({"kind": "pair", "left": ty, "right": ty}); + ( + json!({"kind": "build", "operands": [literal.clone(), literal], + "shape": {"kind": "pair"}, "type": pair}), + pair, + ) + }; + json!({ + "adts": [{"constructors": [[], [{"kind": "nat"}]]}], + "functions": [{"body": body, "parameters": [], "result": result, "types": []}], + "spec": "lexlean/target-program/1" + }) +} + +fn literal_weight() { + let nat = |n: &str| json!({"kind": "nat", "value": n}); + let nat_ty = json!({"kind": "nat"}); + let list_ty = json!({"kind": "list", "element": nat_ty}); + let cases: Vec<(&str, Json, Json)> = vec![ + ("nat", nat_ty.clone(), nat("5")), + ( + "string", + json!({"kind": "string"}), + json!({"kind": "string", "value": "h\u{e9}\u{e9}"}), + ), + ( + "bytes", + json!({"kind": "bytes"}), + json!({"kind": "bytes", "hex": "0102"}), + ), + ( + "list", + list_ty.clone(), + json!({"kind": "list", "items": [nat("1"), nat("2"), nat("3")]}), + ), + ( + "pair", + json!({"kind": "pair", "left": list_ty, "right": {"kind": "option", "value": {"kind": "string"}}}), + json!({"kind": "pair", + "left": {"kind": "list", "items": [nat("1"), nat("2")]}, + "right": {"kind": "some", "value": {"kind": "string", "value": "a"}}}), + ), + ( + "adt", + json!({"kind": "adt", "index": 0}), + json!({"kind": "adt", "constructor": 1, "fields": [nat("7")]}), + ), + ]; + let mut heavier = 0; + for (name, ty, value) in &cases { + let weight = literal_nodes(value); + heavier += usize::from(weight > 1); + for reads in [1usize, 2] { + let program = target::load(literal_program(ty, value, reads).to_string().as_bytes()) + .unwrap_or_else(|error| panic!("{name}: the program loads: {error:?}")); + // One read is the literal's weight. Two reads are the build node + // and the weight of each, so the cost is per read, not per program. + let expected = if reads == 1 { weight } else { 1 + 2 * weight }; + match interp::run(&program, 1000, 0, &[]) { + Outcome::Value { steps, .. } => assert_eq!( + steps, expected, + "{name} read {reads} time(s) is charged its weight {weight}" + ), + other => panic!("{name}: {other:?}"), + } + } + } + assert!( + heavier >= 4, + "the cases cover literals heavier than one node" + ); + // The denotation is the same rule: the Lean evaluator charges `weight`. + let semantics = + std::fs::read_to_string(repo_root().join("compiler/src/TargetSemantics.lex.tex")) + .expect("TargetSemantics"); + assert!( + semantics.contains("TargetSyntax::Expr.value literalType literal => (ctor Outcome.value literal (weight literal))"), + "the denotation charges a literal its weight" + ); + // Planted: the defects the static rules refuse, each LLB6005. + let base = literal_program( + &list_ty_of_nat(), + &json!({"kind": "list", "items": [nat("1")]}), + 1, + ); + for (what, edit) in [ + ( + "a mistyped element", + json!({"kind": "list", "items": [{"kind": "bool", "value": true}]}), + ), + ( + "a noncanonical byte spelling", + json!({"kind": "bytes", "hex": "0A"}), + ), + ( + "an unknown member", + json!({"kind": "list", "items": [{"kind": "closure", "function": 0, "captures": []}]}), + ), + ] { + let mut planted = base.clone(); + let ty = if what == "a noncanonical byte spelling" { + json!({"kind": "bytes"}) + } else { + list_ty_of_nat() + }; + planted["functions"][0]["body"]["value"] = edit; + planted["functions"][0]["body"]["type"] = ty.clone(); + planted["functions"][0]["result"] = ty; + let error = target::load(planted.to_string().as_bytes()).expect_err(what); + assert!( + format!("{error:?}").contains("LLB6005"), + "{what} is LLB6005: {error:?}" + ); + } +} + +fn list_ty_of_nat() -> Json { + json!({"kind": "list", "element": {"kind": "nat"}}) +} diff --git a/crates/lexlean/src/calculus/interp.rs b/crates/lexlean/src/calculus/interp.rs index 7329da1340..d6eaedd1d4 100644 --- a/crates/lexlean/src/calculus/interp.rs +++ b/crates/lexlean/src/calculus/interp.rs @@ -442,9 +442,13 @@ impl Interp<'_> { return Out::Exhausted; }; match expr { - Expr::Value { value, .. } => { - to_runtime(value).map_or(Out::Stuck, |value| Out::Value(value, 1)) - } + // A literal is charged its weight each time it is read, as a + // primitive's operands are, so a decoded constant is accounted + // by its size; a scalar still costs one step (§17.14 *Cost*). + Expr::Value { value, .. } => to_runtime(value).map_or(Out::Stuck, |value| { + let steps = weight(&value); + Out::Value(value, steps) + }), Expr::Var { name } => { lookup(env, *name).map_or(Out::Stuck, |(value, depth)| Out::Value(value, 1 + depth)) } diff --git a/features/suites/calculus.feature b/features/suites/calculus.feature index 1eae31a3a9..58c87f0a88 100644 --- a/features/suites/calculus.feature +++ b/features/suites/calculus.feature @@ -52,7 +52,7 @@ Feature: calculus And a wrapping addition or a Euclidean quotient planted in a rendering changes the printed outcome, and a quadratic append exceeds the steps @TC-08 @build - Scenario: The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005. - Given a calculus program that holds a decoded constant as a data literal, and copies that plant a mistyped literal, a malformed member, and a noncanonical spelling - When it is loaded, evaluated by the denotation, and rendered - Then the literal has its type, its canonical form, and the denotation's value, the cost is its weight per read, and each copy fails with LLB6005 + Scenario: A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005. + Given calculus programs that read scalar, string, byte-string, list, pair, option, and algebraic-data literals once and twice, and copies that plant a mistyped literal, a malformed member, and a noncanonical spelling + When they are loaded and evaluated by the reference interpreter, and the denotation's source is read + Then each read costs the literal's weight and a scalar costs one step, the denotation charges the same weight, and each copy fails with LLB6005 diff --git a/model/ids.toml b/model/ids.toml index 290b17221d..73edf3d8a1 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1703,7 +1703,7 @@ statement = "Every fixture with an observable outcome renders to a safe Rust lib id = "TC-08" level = "build" suite = "calculus" -statement = "The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005." +statement = "A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005." [[id]] id = "RB-01" From f3376f52f5d2f25a07c859a855cbafd6b19c8b46 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 07:26:25 +0000 Subject: [PATCH 04/21] VERIFICATION: reword the TC-08 record for the R4 gate Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- VERIFICATION.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 82d8a55ae1..eab7c282e1 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4031,9 +4031,9 @@ the denotation charges a literal its weight Removed: the weight charge was restored in both. The kernel's own check of the rule, a fixture whose `rfl` theorem states the weighted step count, needs `cargo xtask check-calculus --write` and is not exercised here: the 14 fixtures -with a literal heavier than one node (and `compiler/lexlean.lock`) are not yet -regenerated, so `conformance_tc_01`, `conformance_tc_03`, `conformance_tc_04`, -and `conformance_tc_05` fail on this tree until they are. +with a literal heavier than one node (and `compiler/lexlean.lock`) still hold +the bytes written before TC-08, so `conformance_tc_01`, `conformance_tc_03`, `conformance_tc_04`, +and `conformance_tc_05` fail on this tree until they are rewritten. ### kernel-opaque classification is observed From ae0d10f9b2ef0db9da64f0864ef6ec97ab541e58 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 09:00:38 +0000 Subject: [PATCH 05/21] RB-18: a heap literal read from a function of no parameters is a once-per-thread constant ItemDef::Constant (a thread-local cell and a clone per call) is lowered for a nullary, infallible function whose body is a closed literal with a heap type in rust-std; validate refuses a constant that calls or can fail; the machine reads it as the function it caches. conformance_rb_18 counts allocations under the pinned rustc, with the rebuilding rendering as a plant, and the calculus fixture cached-literal puts a constant in TC-07's differential. rb_01 and rb_07 wait on the maintainer's regeneration of the committed packages and the rust_renderer record. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 2 +- SPEC.md | 19 +- VERIFICATION.md | 23 +++ crates/conformance/src/calculus.rs | 30 +++ .../src/cases/bootstrap/rust_validate.rs | 37 +++- crates/conformance/src/cases/rust_backend.rs | 193 +++++++++++++++++- crates/conformance/src/preservation.rs | 8 +- crates/lexlean/src/calculus/rust/ast.rs | 59 ++++++ crates/lexlean/src/calculus/rust/lower.rs | 30 ++- crates/lexlean/src/calculus/rust/validate.rs | 46 +++++ .../src/production/certificate/data_b.rs | 25 +-- .../production/certificate/data_b/align.rs | 2 +- .../production/certificate/data_b/syntax.rs | 14 ++ features/suites/rust-backend.feature | 8 +- model/ids.toml | 2 +- 15 files changed, 462 insertions(+), 36 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 3bf70089fc..da3a863c26 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -509,7 +509,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `RB-12` | `build` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | | `RB-13` | `build` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | | `RB-14` | `build` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | -| `RB-18` | `build` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | +| `RB-18` | `build` | A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | ## security diff --git a/SPEC.md b/SPEC.md index 10bac18cb8..340b14dcfc 100644 --- a/SPEC.md +++ b/SPEC.md @@ -4769,6 +4769,23 @@ writes differently are fixed: Each of these renders the same denotation with no more work than the plain rendering. +**Constants.** A function of no parameters that cannot fail, whose body is a +closed literal (scalars, constructors, pairs, and boxes of literals only) whose +result holds heap storage, is rendered in `rust-std` as a *constant*: a +`thread_local!` cell initialised once per thread by the literal, and a function +whose every call is `CELL.with(|cell| cell.clone())`. A clone of a list, a +string, or a byte string shares its storage, so a read allocates nothing, where +a rebuilt literal allocates at each read (`RB-18`). A constant is not a new +construct of the calculus: its row in `validate::CORRESPONDENCE` is `constant`, +realizing `function`, and calls to it are ordinary calls. The machine of §17.17 +reads a constant as the function of no parameters it caches, whose value is the +body's; when the value is computed is not part of the denotation, so the work +the machine counts and the steps of §17.14 are unchanged. `rust::validate` +refuses, as `LLB6005`, a constant whose result can fail or whose body is not a +closed literal: a thread-local initializer cannot propagate a failure, and a +body that calls could reach the constant it initializes. `rust-core` renders no +constant, because the literal holds heap storage. + **Failure typing.** A function can overflow exactly when its body reaches a primitive or successor that can (`nat_add`, `nat_mul`, `int_add`, `int_sub`, `int_mul`, `int_neg`, `int_quot`, `parse_decimal` at `int`, `succ`), a call to @@ -10238,7 +10255,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `RB-12` | `rust-backend` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | §17.16, §21.2 | | `RB-13` | `rust-backend` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | §17.13, §17.16 | | `RB-14` | `rust-backend` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | §17.13, §17.14, §17.16 | -| `RB-18` | `rust-backend` | The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. | §17.16 | +| `RB-18` | `rust-backend` | A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | §17.16 | | `GN-01` | `gnaf` | Every committed GNAF request and fixture is canonical, validates against the GNAF schemas whose calculus definitions are the target program schema's, and states its components' universe identity; a malformed request, an invalid reference, plan, or realized program, a reference without a value on a domain argument, or a wrong universe identity fails closed with LLB6006, and a machine or request beyond the host's capacity fails closed with LLS8002. | §17.15, §26.3 | | `GN-02` | `gnaf` | The GNAF model is a kernel-checked LexLean definition, Lean's kernel reduces the universe, the system statuses, and the answer of every committed request to what the host transcription computes, and a wrong answer, an answer computed from a universe with a system omitted, a tie with a member dropped, and a universe with a system omitted are rejected by Lean. | §17.15 | | `GN-03` | `gnaf` | Candidate membership is the grammar's expansion, which a kernel-checked theorem proves equal to the grammar's well-formed selectors for every grammar, independent of evaluation and fixed by a universe identity before any optimizer, and optimizer-defined, discovered, cached, and internal-plan universes and missing, self-referential, or optimizer-citing completeness evidence are rejected. | §17.15 | diff --git a/VERIFICATION.md b/VERIFICATION.md index eab7c282e1..37dee37db3 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4035,6 +4035,29 @@ with a literal heavier than one node (and `compiler/lexlean.lock`) still hold the bytes written before TC-08, so `conformance_tc_01`, `conformance_tc_03`, `conformance_tc_04`, and `conformance_tc_05` fail on this tree until they are rewritten. +### rust constants can fail (RB-18) + +Planted, three ways, all observed by `conformance_rb_18`. The oracle is the +pinned rustc, a counting global allocator in the harness, and `validate`. + +1. The same program with its constant rebuilt at each read (the crate's + `Constant` item printed as a `Function`): two reads allocate 4 times, + where the cached rendering allocates 0. The harness counts, so the + rebuilding rendering is detected by behavior, not by its text. +2. A constant whose body is a call: `validate` refuses it + (`constant: ... is not an infallible closed literal`). +3. A constant whose result is `R`: the same refusal. + +Removed: the crate was restored to the lowering's own output. `rust-core` +has no rendering of the heap literal at all (`lower` refuses it). + +`conformance_tc_07` passes with the new fixture `cached-literal`, whose +function 1 renders as a constant read twice. On this tree +`conformance_rb_01` fails with `correspondence rows no run package exercises: +["constant"]` until the committed packages are rewritten from the fixtures, +and `conformance_rb_07` fails with `the renderer changed without its record +`rust_renderer``: both are records of the renderer's bytes. + ### kernel-opaque classification is observed Probe: `compare_bytes` and byte equality were both treated as reducible, and diff --git a/crates/conformance/src/calculus.rs b/crates/conformance/src/calculus.rs index 68770961e2..697903df95 100644 --- a/crates/conformance/src/calculus.rs +++ b/crates/conformance/src/calculus.rs @@ -2079,6 +2079,36 @@ fn renderer_cases() -> Vec { vec![natv(1)], 100, )); + // A list literal read from a function of no parameters, twice: the + // `rust-std` rendering holds it as a constant built once (§17.16). + out.push(case( + "cached-literal", + program( + Vec::new(), + vec![ + function( + Vec::new(), + pair_t(list_t(nat_t()), nat_t()), + build( + Shape::Pair, + pair_t(list_t(nat_t()), nat_t()), + vec![ + call(1, Vec::new()), + p(Prim::Length, vec![call(1, Vec::new())]), + ], + ), + ), + function( + Vec::new(), + list_t(nat_t()), + lit(list_t(nat_t()), listv(vec![natv(3), natv(1), natv(2)])), + ), + ], + ), + 0, + Vec::new(), + 100, + )); // Units: computed, passed, bound, matched, returned by a function that // can overflow, and chosen by a conditional without an alternative. out.push(case( diff --git a/crates/conformance/src/cases/bootstrap/rust_validate.rs b/crates/conformance/src/cases/bootstrap/rust_validate.rs index ccec03b409..c3b39084b1 100644 --- a/crates/conformance/src/cases/bootstrap/rust_validate.rs +++ b/crates/conformance/src/cases/bootstrap/rust_validate.rs @@ -472,6 +472,24 @@ fn enc_item_def(item: &ItemDef) -> Value { enc_origin(at), ], ), + // The bootstrap validator reads a constant as the function of no + // parameters it caches; the rule that its body is a literal is + // `validate.rs`'s alone. + ItemDef::Constant { + name, + result, + body, + at, + } => adt( + 2, + vec![ + enc_ident(name), + enc_params(&[]), + enc_type(result), + enc_block(body), + enc_origin(at), + ], + ), ItemDef::Function { name, parameters, @@ -859,6 +877,17 @@ fn visit_crate(krate: &mut Crate, f: &mut Visitor<'_>) { arms.iter_mut().for_each(|arm| f(Node::Dispatch(arm))); f(Node::Origin(at)); } + ItemDef::Constant { + name, + result, + body, + at, + } => { + f(Node::Ident(name)); + visit_ty(result, f); + visit_block(body, f); + f(Node::Origin(at)); + } ItemDef::Function { name, parameters, @@ -1261,12 +1290,16 @@ fn mutate_once(krate: &mut Crate, seeded: &mut Seeded, pool: &Pool) -> bool { }; } ItemDef::Apply { fn_type, .. } => *fn_type += number + 1, - ItemDef::Function { name, .. } => *name = Ident::Function(number), + ItemDef::Function { name, .. } | ItemDef::Constant { name, .. } => { + *name = Ident::Function(number); + } }, 4 => { if let ItemDef::Apply { fallible, .. } = &mut krate.items[at] { *fallible = !*fallible; - } else if let ItemDef::Function { result, .. } = &mut krate.items[at] { + } else if let ItemDef::Function { result, .. } + | ItemDef::Constant { result, .. } = &mut krate.items[at] + { *result = match result.clone() { Type::Fallible(inner) => *inner, other => Type::Fallible(Box::new(other)), diff --git a/crates/conformance/src/cases/rust_backend.rs b/crates/conformance/src/cases/rust_backend.rs index e02a664834..1217d439df 100644 --- a/crates/conformance/src/cases/rust_backend.rs +++ b/crates/conformance/src/cases/rust_backend.rs @@ -372,7 +372,7 @@ fn ast_shapes(krate: &Crate, out: &mut BTreeSet<&'static str>) { }); } } - ItemDef::Function { body, .. } => block(body, out), + ItemDef::Function { body, .. } | ItemDef::Constant { body, .. } => block(body, out), ItemDef::Enum { .. } => {} } } @@ -1599,6 +1599,197 @@ pub fn run(id: &str) { "the primitive `checked_pow` is cited by no row", ); } + // §17.16 *Constants*: a literal that holds heap storage is built once + // per thread and each read is a clone of it. + "RB-18" => cached_literal(), other => panic!("no Rust backend case is wired for {other}"), } } + +/// A program whose function 0 is the list literal `[7, 8, 9, 10, 11]` over +/// `int`, the shape an artifact read lowers to. +fn literal_list_program() -> target::Program { + let int = |n: i64| serde_json::json!({"kind": "int", "value": n.to_string()}); + let ty = serde_json::json!({"kind": "list", "element": {"kind": "int"}}); + let program = serde_json::json!({ + "adts": [], + "functions": [{ + "body": {"kind": "value", "type": ty, + "value": {"kind": "list", "items": [int(7), int(8), int(9), int(10), int(11)]}}, + "parameters": [], "result": ty, "types": [] + }], + "spec": "lexlean/target-program/1" + }); + target::load(program.to_string().as_bytes()).expect("the literal program loads") +} + +/// Build `library` with the pinned rustc and run a harness that reads function +/// 0 once to warm it, then counts the allocations of the next two reads. +fn allocations_of_reads(library: &str, dir: &Path) -> (String, u64) { + let harness = r#"use std::alloc::{GlobalAlloc, Layout, System}; +use std::sync::atomic::{AtomicU64, Ordering}; +struct Counting; +static ALLOCATIONS: AtomicU64 = AtomicU64::new(0); +unsafe impl GlobalAlloc for Counting { + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + ALLOCATIONS.fetch_add(1, Ordering::Relaxed); + unsafe { System.alloc(layout) } + } + unsafe fn dealloc(&self, pointer: *mut u8, layout: Layout) { + unsafe { System.dealloc(pointer, layout) } + } +} +#[global_allocator] +static COUNTING: Counting = Counting; +fn main() { + let warm = program::f0(); + let before = ALLOCATIONS.load(Ordering::Relaxed); + let second = program::f0(); + let third = program::f0(); + let after = ALLOCATIONS.load(Ordering::Relaxed); + let head = second.uncons().map(|(head, _)| head); + println!("{:?} {} {}", head, program::length_list(third), program::length_list(warm)); + println!("allocations {}", after - before); +} +"#; + std::fs::write(dir.join("library.rs"), library).expect("library"); + std::fs::write(dir.join("harness.rs"), harness).expect("harness"); + let rustc = std::env::var("RUSTC").unwrap_or_else(|_| "rustc".to_owned()); + let compile = |arguments: &[&str]| { + let compiled = std::process::Command::new(&rustc) + .args(["--edition", "2021", "-D", "warnings", "-C", "opt-level=0"]) + .args(arguments) + .current_dir(dir) + .output() + .expect("rustc runs"); + assert!( + compiled.status.success(), + "rustc rejects the program:\n{}", + String::from_utf8_lossy(&compiled.stderr) + ); + }; + compile(&[ + "--crate-type", + "rlib", + "--crate-name", + "program", + "-o", + "libprogram.rlib", + "library.rs", + ]); + compile(&[ + "--crate-name", + "harness", + "--extern", + "program=libprogram.rlib", + "-o", + "harness", + "harness.rs", + ]); + let ran = std::process::Command::new(dir.join("harness")) + .output() + .expect("runs"); + assert!( + ran.status.success(), + "{}", + String::from_utf8_lossy(&ran.stderr) + ); + let stdout = String::from_utf8(ran.stdout).expect("utf8"); + let mut lines = stdout.lines(); + let value = lines.next().expect("the value line").to_owned(); + let count = lines + .next() + .and_then(|line| line.strip_prefix("allocations ")) + .and_then(|count| count.parse().ok()) + .expect("the allocation line"); + (value, count) +} + +fn cached_literal() { + let program = literal_list_program(); + let cached = rust::lower(&program, Profile::Std).expect("the literal program lowers"); + assert!( + matches!(cached.items.as_slice(), [ItemDef::Constant { .. }]), + "a nullary heap literal is a constant: {:?}", + cached.items + ); + let text = rust::ast::print(&cached).expect("prints"); + assert_eq!( + text.matches("thread_local!").count(), + 1, + "one cell per constant" + ); + assert!( + text.contains("CELL.with(|cell| cell.clone())"), + "a read is a clone" + ); + // The profile with no heap has no rendering of the literal at all. + assert!( + rust::lower(&program, Profile::Core).is_err(), + "rust-core does not render a heap literal" + ); + let dir = tempfile::Builder::new() + .prefix("lexlean-cached-literal-") + .tempdir() + .expect("tempdir"); + let read = |library: &str, name: &str| { + let sub = dir.path().join(name); + std::fs::create_dir(&sub).expect("dir"); + allocations_of_reads(library, &sub) + }; + let (value, allocations) = read(&text, "cached"); + assert_eq!(value, "Some(7) 5 5", "a read is the denotation's value"); + assert_eq!( + allocations, 0, + "a read of a cached literal allocates nothing" + ); + + // Planted: the same program with its constant rebuilt at each read + // allocates on every read, which the harness counts. + let mut rebuilt = cached.clone(); + for item in &mut rebuilt.items { + if let ItemDef::Constant { + name, + result, + body, + at, + } = item.clone() + { + *item = ItemDef::Function { + name, + parameters: Vec::new(), + result, + body, + at, + }; + } + } + let (value, allocations) = read(&rust::ast::print(&rebuilt).expect("prints"), "rebuilt"); + assert_eq!( + value, "Some(7) 5 5", + "the rebuilding rendering has the same value" + ); + assert!(allocations > 0, "a rebuilt literal allocates at each read"); + + // Planted: a constant whose body calls, or that can fail, is refused + // before printing. + let mut called = cached.clone(); + if let ItemDef::Constant { body, .. } = &mut called.items[0] { + body.tail = Expr::Call { + callee: Callee::Function(0), + args: Vec::new(), + propagate: false, + at: Origin::of("function"), + }; + } + let error = validate::validate(&called).expect_err("a constant that calls is refused"); + assert!(error.contains("constant"), "{error}"); + let mut failing = cached; + if let ItemDef::Constant { result, .. } = &mut failing.items[0] { + *result = Type::Fallible(Box::new(result.clone())); + } + assert!( + validate::validate(&failing).is_err(), + "a fallible constant is refused" + ); +} diff --git a/crates/conformance/src/preservation.rs b/crates/conformance/src/preservation.rs index f247f5aae2..0692c74446 100644 --- a/crates/conformance/src/preservation.rs +++ b/crates/conformance/src/preservation.rs @@ -2381,18 +2381,20 @@ fn crate_function( let functions = krate .items .iter() - .filter(|item| matches!(item, ItemDef::Function { .. })) + .filter(|item| matches!(item, ItemDef::Function { .. } | ItemDef::Constant { .. })) .count() as u64; let last = krate .items .iter() .filter_map(|item| match item { - ItemDef::Function { name, .. } => function_number(name), + ItemDef::Function { name, .. } | ItemDef::Constant { name, .. } => { + function_number(name) + } _ => None, }) .max(); for item in &mut krate.items { - if let ItemDef::Function { name, body, .. } = item { + if let ItemDef::Function { name, body, .. } | ItemDef::Constant { name, body, .. } = item { let Some(number) = function_number(name) else { continue; }; diff --git a/crates/lexlean/src/calculus/rust/ast.rs b/crates/lexlean/src/calculus/rust/ast.rs index 5908d0016b..2e26d9bcd1 100644 --- a/crates/lexlean/src/calculus/rust/ast.rs +++ b/crates/lexlean/src/calculus/rust/ast.rs @@ -425,6 +425,52 @@ pub enum ItemDef { body: Block, at: Origin, }, + /// A function of no parameters that cannot fail and whose body is a + /// closed literal: the rendering evaluates the body once per thread and + /// each call returns a clone of that value. A clone of a persistent value + /// shares its cells, so the call allocates nothing, while a rebuilt + /// literal allocates on every call (SPEC.md §17.16 *Constants*). The + /// machine reads it as the function it caches: the value is the body's, + /// and when it is computed is not part of the denotation. + Constant { + name: Ident, + result: Type, + body: Block, + at: Origin, + }, +} + +/// The name, parameters, result, body, and origin of a function. +pub type FunctionParts<'a> = ( + &'a Ident, + &'a [(Pat, Type)], + &'a Type, + &'a Block, + &'a Origin, +); + +impl ItemDef { + /// The function an item denotes, when it denotes one: a function is + /// itself and a constant is the function of no parameters it caches. + #[must_use] + pub fn function(&self) -> Option> { + match self { + Self::Function { + name, + parameters, + result, + body, + at, + } => Some((name, parameters, result, body, at)), + Self::Constant { + name, + result, + body, + at, + } => Some((name, &[], result, body, at)), + Self::Enum { .. } | Self::Apply { .. } => None, + } + } } /// A rendered library crate. @@ -831,6 +877,19 @@ impl Printer { ), ); } + ItemDef::Constant { + name, result, body, .. + } => { + let ty = result.text(); + let value = self.block_inline(body, 1); + self.line(0, &format!("pub fn {}() -> {ty} {{", name.text())); + self.line( + 1, + &format!("thread_local! {{ static CELL: {ty} = {value}; }}"), + ); + self.line(1, "CELL.with(|cell| cell.clone())"); + self.line(0, "}"); + } } } } diff --git a/crates/lexlean/src/calculus/rust/lower.rs b/crates/lexlean/src/calculus/rust/lower.rs index 05102d6faa..e677f67a56 100644 --- a/crates/lexlean/src/calculus/rust/lower.rs +++ b/crates/lexlean/src/calculus/rust/lower.rs @@ -2379,12 +2379,30 @@ impl<'a> Lowering<'a> { super::moves::apply(&mut body); (parameters, body) }; - items.push(ItemDef::Function { - name: Ident::Function(position as u64), - parameters, - result, - body, - at: Origin::of("function"), + // A function of no parameters whose body is a literal that holds + // heap storage is evaluated once per thread, so a constant read + // from many calls is built once, not at each (§17.16 *Constants*). + let cached = parameters.is_empty() + && !fallible + && result.heap() + && matches!(function.body, Term::Value { .. }) + && body.lets.is_empty() + && super::validate::literal(&body.tail); + items.push(if cached { + ItemDef::Constant { + name: Ident::Function(position as u64), + result, + body, + at: Origin::of("function"), + } + } else { + ItemDef::Function { + name: Ident::Function(position as u64), + parameters, + result, + body, + at: Origin::of("function"), + } }); } Ok(Crate { diff --git a/crates/lexlean/src/calculus/rust/validate.rs b/crates/lexlean/src/calculus/rust/validate.rs index e0a90a4050..4ccb6d8b85 100644 --- a/crates/lexlean/src/calculus/rust/validate.rs +++ b/crates/lexlean/src/calculus/rust/validate.rs @@ -56,6 +56,13 @@ fn declared(krate: &Crate) -> Result { return fail(format!("hygiene: Fn{fn_type}::apply is declared twice")); } } + ItemDef::Constant { name, .. } => { + if let Ident::Function(n) = name { + if out.functions.insert(*n, false).is_some() { + return fail(format!("hygiene: f{n} is declared twice")); + } + } + } ItemDef::Function { name, result, .. } => { if let Ident::Function(n) = name { if out @@ -761,6 +768,25 @@ pub fn validate(krate: &Crate) -> Result<(), String> { } } } + ItemDef::Constant { + name, result, body, .. + } => { + checker.ty(result)?; + // A thread-local initializer cannot propagate a failure, and + // a body that calls could reach the constant it initializes, + // which Rust refuses at run time, so the body is a literal. + if matches!(result, Type::Fallible(_)) + || !body.lets.is_empty() + || !literal(&body.tail) + { + return fail(format!( + "constant: `{}` is not an infallible closed literal", + ident_text(name) + )); + } + checker.fallible = false; + checker.block(body, true)?; + } ItemDef::Function { name, parameters, @@ -836,6 +862,13 @@ pub fn instances(krate: &Crate) -> (Vec, BTreeSet) { found.ty(ty); } } + ItemDef::Constant { + result, body, at, .. + } => { + found.at("constant", at); + found.ty(result); + found.block(body); + } ItemDef::Function { parameters, result, @@ -1078,6 +1111,18 @@ impl Found { } } +/// Whether an expression is built from literals alone: scalars, constructors, +/// pairs, and boxes of literals. +pub(super) fn literal(expr: &Expr) -> bool { + match expr { + Expr::Lit(..) => true, + Expr::Construct { args, .. } => args.iter().all(literal), + Expr::Pair(left, right, _) => literal(left) && literal(right), + Expr::Box(inner, _) => literal(inner), + _ => false, + } +} + /// The calculus primitive a runtime function realizes, by its path's last /// segment: fixed-width paths share one name per operation. fn runtime_kind(base: &str) -> String { @@ -1106,6 +1151,7 @@ fn runtime_kind(base: &str) -> String { /// the realized program uses that element. pub const CORRESPONDENCE: &[(&str, &[&str])] = &[ ("function", &["function", "export"]), + ("constant", &["function"]), ("enum:adt", &["type:adt"]), ("enum:closures", &["type:fn", "expr:closure"]), ("apply:dispatch", &["type:fn", "expr:closure"]), diff --git a/crates/lexlean/src/production/certificate/data_b.rs b/crates/lexlean/src/production/certificate/data_b.rs index a9b4276c72..c8f6bae1f8 100644 --- a/crates/lexlean/src/production/certificate/data_b.rs +++ b/crates/lexlean/src/production/certificate/data_b.rs @@ -43,7 +43,7 @@ pub use align::RULES; use super::data_a::{RowKind, Writer}; use super::{Gen, Source}; -use crate::calculus::rust::ast::{Crate, ItemDef}; +use crate::calculus::rust::ast::Crate; use crate::calculus::{Function, Program}; use crate::ir::core::{CoreBinderInfo, CoreLevel, CoreModule, CoreNode}; use crate::production::kernel::Term as K; @@ -189,14 +189,10 @@ impl<'g, 'a> Aligner<'g, 'a> { .krate() .items .iter() - .find_map(|item| match item { - ItemDef::Function { - name: crate::calculus::rust::ast::Ident::Function(found), - parameters, - body, - .. - } if *found == index => Some((parameters, body)), - _ => None, + .find_map(|item| { + let (name, parameters, _, body, _) = item.function()?; + matches!(name, crate::calculus::rust::ast::Ident::Function(found) if *found == index) + .then_some((parameters, body)) }) .ok_or_else(|| format!("the crate does not render function {index}"))?; let (direct, looping) = self.fun_ok_halves(index)?; @@ -402,13 +398,10 @@ impl<'g, 'a> Aligner<'g, 'a> { .krate() .items .iter() - .find_map(|item| match item { - ItemDef::Function { - name: crate::calculus::rust::ast::Ident::Function(found), - result, - .. - } if *found == index => Some(result), - _ => None, + .find_map(|item| { + let (name, _, result, _, _) = item.function()?; + matches!(name, crate::calculus::rust::ast::Ident::Function(found) if *found == index) + .then_some(result) }) .ok_or_else(|| format!("the crate does not render function {index}"))?; Ok(self.w.rs_type(result)) diff --git a/crates/lexlean/src/production/certificate/data_b/align.rs b/crates/lexlean/src/production/certificate/data_b/align.rs index 6f501277ec..bc903a0b8f 100644 --- a/crates/lexlean/src/production/certificate/data_b/align.rs +++ b/crates/lexlean/src/production/certificate/data_b/align.rs @@ -537,7 +537,7 @@ impl<'g, 'a> Aligner<'g, 'a> { && function.result == *result) }) }), - ItemDef::Enum { .. } | ItemDef::Function { .. } => true, + ItemDef::Enum { .. } | ItemDef::Function { .. } | ItemDef::Constant { .. } => true, }) } diff --git a/crates/lexlean/src/production/certificate/data_b/syntax.rs b/crates/lexlean/src/production/certificate/data_b/syntax.rs index 6433292681..c759c2ba89 100644 --- a/crates/lexlean/src/production/certificate/data_b/syntax.rs +++ b/crates/lexlean/src/production/certificate/data_b/syntax.rs @@ -606,6 +606,20 @@ impl Writer<'_, '_> { &[fn_type, parameters, result, fallible, arms], ) } + // The machine reads a constant as the function of no parameters + // it caches: its value is the body's, whenever it is computed. + ItemDef::Constant { + name, + result, + body, + at: _, + } => { + let name = self.rs_ident(name); + let parameters = self.rs_parameters(&[]); + let result = self.rs_type(result); + let body = self.rs_block(body); + self.rs_apply("ItemDef.function", &[name, parameters, result, body]) + } ItemDef::Function { name, parameters, diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index 384cc7012c..29d00b96e9 100644 --- a/features/suites/rust-backend.feature +++ b/features/suites/rust-backend.feature @@ -95,7 +95,7 @@ Feature: rust-backend And every other template renders as a call and keeps `recursion = true`, and a template rendered with a self call it could have as a loop, or a row that disagrees with its rendering, is refused @RB-18 @build - Scenario: The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate. - Given the calculus fixtures that read a data literal, and a copy whose rendering rebuilds the literal at each read - When it is rendered as rust-std packages and run under the pinned rustc - Then each package prints the denotation's value with counted work no greater than its steps, the literal is constructed once per thread, and the rebuilding copy is detected + Scenario: A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. + Given a program whose function of no parameters is a list literal over int, rendered in both profiles, and copies that rebuild the literal at each read, call from a constant's body, or make a constant fallible + When the rust-std rendering is compiled by the pinned rustc with warnings denied and read three times under a counting allocator + Then the constant is one thread-local cell, a read returns the denotation's value and allocates nothing, rust-core refuses the literal, and each copy is detected or refused diff --git a/model/ids.toml b/model/ids.toml index 73edf3d8a1..41b31e46fb 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1793,7 +1793,7 @@ statement = "A library template whose self calls are all tail calls is rendered id = "RB-18" level = "build" suite = "rust-backend" -statement = "The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate." +statement = "A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations." [[id]] id = "GN-01" From 3d7365156897cf5a8f09f2197a0f750784756b82 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 10:36:08 +0000 Subject: [PATCH 06/21] SP-24, MD-14: an artifact's decoded value is one literal of the lowered program The lowering folds an artifact definition's Nil/Cons-of-literals body to one Expr::Value, keyed on the declaration. Certificate A relates the source's cons chain to the literal by conv_value (stated for every Value), so the library does not grow. conformance_md_14 decodes each artifact file from its bytes and compares; conformance_sp_24 certifies and Lean-checks the models example and plants a wrong lemma. The committed models records (programs, crates, certificates) are not regenerated. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 4 +- SPEC.md | 18 +- VERIFICATION.md | 27 +++ crates/conformance/src/cases/models.rs | 213 ++++++++++++++++++ crates/conformance/src/cases/preservation.rs | 96 ++++++++ .../production/certificate/data_a/prove.rs | 16 ++ crates/lexlean/src/production/lower.rs | 115 +++++++++- crates/lexlean/src/production/source.rs | 12 + features/suites/models.feature | 8 +- features/suites/preservation.feature | 8 +- model/ids.toml | 4 +- 11 files changed, 506 insertions(+), 15 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index da3a863c26..f74e7e75bb 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -332,7 +332,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `MD-11` | `build` | Model constructs have production dispositions under which artifacts, realizations, models, validators, and checked applications are realized through their elaborations while contracts and evidence are erased, the realization table covers every new runtime construct, and production roots applying an artifact-backed model, directly and through its checks, are eligible and extract the same closure through Lean. | | `MD-12` | `build` | The committed models example verifies nontrivial deterministic stateful, rule, statistical, artifact-backed neural, and composite models with every claim kernel-checked, and planting a contract and realization mismatch in it is refused by verification. | | `MD-13` | `build` | IEEE-754 binary32 and binary64 bit patterns decode in LexLean to exact dyadic rationals (sign, integer mantissa, exponent) for zero, subnormal, and normal values while rejecting non-finite and out-of-range patterns, and the models corpus derives round(a * b / c * 2^32) from three binary32 patterns by exact integer arithmetic that agrees with an independent exact rational computation under Lean and refuses a planted rounding or exponent mutation. | -| `MD-14` | `build` | The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. | +| `MD-14` | `build` | The lowered program of a production root reading an artifact holds the artifact's decoded value as a literal equal to the decoding of its bytes by the closed schemas, and no function of no parameters builds a list with constructors on a call; a literal turned back into its chain, or with one element changed, is detected, and a lowering that stops folding artifacts is refused by the case. | ## oracle @@ -381,7 +381,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `SP-18` | `build` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | | `SP-19` | `build` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | | `SP-20` | `build` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | -| `SP-24` | `build` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | +| `SP-24` | `build` | A production root that reads a content-addressed artifact holds the artifact's decoded value as one literal in its lowered program, recognised by the artifact declaration and not by the shape of a term, and certificates A, B, and E verify for every root of the committed models example, certificate A relating the source's construction of the list to the literal by the lemma that relates any literal to its value, so that the preservation library does not grow; a wrong lemma for the literal is refused by Lean. | ## production diff --git a/SPEC.md b/SPEC.md index 340b14dcfc..9ffe3b30a7 100644 --- a/SPEC.md +++ b/SPEC.md @@ -5934,6 +5934,20 @@ reads each record back, verifies the production example under the pinned Lean, and plants a wrong lemma application, a changed statement, a forged program literal, an added axiom, and a row whose policy lies, each refused. +**Artifacts as data** (`SP-24`, `MD-14`). An artifact declaration (§17.12 rule +2) elaborates to a definition of its decoded value, which the lowering holds as +one literal of the target program when the definition's body is a list built +from `Nil` and `Cons` of literals: the declaration, and not the shape of a +term, decides which definitions fold, so an ordinary definition that builds the +same list keeps its construction. The literal is charged its weight on each read +(§17.14 *Cost*) where the chain it replaces was evaluated, node by node, at each +call, and the `rust-std` rendering holds it as a constant built once per thread +(§17.16 *Constants*). Certificate A relates the source's construction of the +list to the literal by the lemma that relates any literal to its value +(`conv_value`, stated for every `Value`), so the preservation library has no +new lemma and `Corr` no new constructor; certificate B reads the constant as +the function of no parameters it caches. + **A function rendered as a loop** (`SP-20`). The renderer writes a function whose self calls are all tail calls as a loop (§17.16), so the crate no longer holds the recursive body that the calculus function corresponds to. `FunOK` is @@ -10295,7 +10309,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `SP-18` | `preservation` | The declared Rust machine states a machine primitive as a callee and the overflow value as a literal: RustSyntax declares eight machine primitives (checked add, subtract, multiply, quotient, negation, shift left, and shift right of a width, and try-from to a width), the callee that names one, and the literal Overflow, and RustSemantics evaluates a call of a machine callee as the calculus primitive of the same name, with the Option value the calculus states, stuck on an operand of another width (the amount of a shift excepted), and the literal Overflow as the unit value that an Err(Overflow) carries, which the pinned Lean evaluates on the boundary values of the widths and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-19` | `preservation` | The declared Rust machine states a loop over a state with a break value: RustSyntax declares the expression Loop of a state binding and a body block, and RustSemantics evaluates it by running the body in the environment of the state, rebinding the state to the payload of an Ok result and running the loop again, ending with the payload of an Err result as the value of the loop, stuck on a body whose value is neither, and exhausted rather than wrong when the fuel runs out, which the pinned Lean evaluates on a countdown and refuses to evaluate to a wrong value. | §17.14, §17.16 | | `SP-20` | `preservation` | Certificate B certifies a function the renderer writes as a loop: the library's FunOK states a function either by the correspondence for the body the crate holds or by FunLoop, that the crate's body is the loop form of an ordinary recursive body (the library's loopOf, with its Boolean checks of the renamed parameters, the kept parameters, and the freshness of the renamed names decided by evaluation) together with the correspondence for that recursive body, which funSem_of turns into the simulation through funSem_loop with the correspondence, its recursor, and the soundness theorem unchanged, and the aligner recovers the recursive body by inverting the rendering of loops (the renamed parameters, the destructuring of the state, and the Ok and Err wraps), so that for every loop of every renderer fixture in each profile and of every production root of the committed examples in each of its targets the loop form of the recovered body, computed by the library's form transliterated, is the crate's function, certificate B of the fixtures rendered as loops compiles under the pinned Lean with exactly the axioms Classical.choice, Quot.sound, and propext, and a loop that is not the loop form of any recursive body is refused, whether its state has another type, its body does not take the state apart, an end is not an Err, a renamed parameter is read by the body, a pattern rebinds a kept parameter, or the state holds a parameter the function does not have. | §17.16, §17.17 | -| `SP-24` | `preservation` | A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. | §17.17 | +| `SP-24` | `preservation` | A production root that reads a content-addressed artifact holds the artifact's decoded value as one literal in its lowered program, recognised by the artifact declaration and not by the shape of a term, and certificates A, B, and E verify for every root of the committed models example, certificate A relating the source's construction of the list to the literal by the lemma that relates any literal to its value, so that the preservation library does not grow; a wrong lemma for the literal is refused by Lean. | §17.17 | | `MD-01` | `models` | Language 1.2 artifact, contract, realization, evidence, and model declarations, the checked_apply term, the contract_violation type, and the less_than primitive belong to the closed lexlean/semantic-module/2 schema and its snapshot schema, are rejected under language 1.1 before either backend runs, and admit no member outside the closed schema, such as prompt text, a free-form description, or raw model configuration. | §17.12 | | `MD-02` | `models` | A model artifact is admitted only from a configured, content-addressed, confined project file whose SHA-256 and byte length equal its declaration and whose bytes decode under its declared closed schema to its declared type and role; a missing artifact or a digest or length mismatch fails with LLR3007, a schema, type, or role violation fails with LLR3008, and the generated Lean embeds the exact bytes with a kernel-checked theorem that the typed value is their decoding. | §17.12, §10.1, §26.3 | | `MD-03` | `models` | A contract names typed input, output, and optional state interfaces and prior proposition-valued predicates of exactly those interface signatures, and each runtime validator is an executable Boolean definition of the same signature linked to its predicate by a statement-exact soundness theorem and an optional completeness theorem that Lean restates against the fixed model semantics; any mismatch fails with LLT4006. | §17.12 | @@ -10309,7 +10323,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `MD-11` | `models` | Model constructs have production dispositions under which artifacts, realizations, models, validators, and checked applications are realized through their elaborations while contracts and evidence are erased, the realization table covers every new runtime construct, and production roots applying an artifact-backed model, directly and through its checks, are eligible and extract the same closure through Lean. | §17.13, §17.14, §22.10 | | `MD-12` | `models` | The committed models example verifies nontrivial deterministic stateful, rule, statistical, artifact-backed neural, and composite models with every claim kernel-checked, and planting a contract and realization mismatch in it is refused by verification. | §17.12, §28.6 | | `MD-13` | `models` | IEEE-754 binary32 and binary64 bit patterns decode in LexLean to exact dyadic rationals (sign, integer mantissa, exponent) for zero, subnormal, and normal values while rejecting non-finite and out-of-range patterns, and the models corpus derives round(a * b / c * 2^32) from three binary32 patterns by exact integer arithmetic that agrees with an independent exact rational computation under Lean and refuses a planted rounding or exponent mutation. | §17.12, §28.6 | -| `MD-14` | `models` | The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. | §17.12 | +| `MD-14` | `models` | The lowered program of a production root reading an artifact holds the artifact's decoded value as a literal equal to the decoding of its bytes by the closed schemas, and no function of no parameters builds a list with constructors on a call; a literal turned back into its chain, or with one element changed, is detected, and a lowering that stops folding artifacts is refused by the case. | §17.12 | | `RS-01` | `reasoning` | Language 1.2 logic, inference_rule, verifier, and reasoner declarations, the forward, search, and generate_and_verify strategies, the initial_invariant, terminates, observation_invariant, and answer_correct claims, and the reasoning_failure type belong to the closed lexlean/semantic-module/2 schema and its snapshot schema, are rejected under language 1.1 before either backend runs, and admit no member, strategy, or claim outside the closed schema, such as an opaque oracle, a prompt, an unregistered strategy, or an unregistered claim, which fail with LLT4001. | §17.12 | | `RS-02` | `reasoning` | A logic names a prior state relation and an optional invariant with a statement-exact preservation theorem and an optional ranking, each of exactly its state type, and an inference rule over a logic is a typed guard, conclusion, and optional binding with a candidate list whose soundness theorem states exactly that the guard implies the relation and whose progress theorem states exactly that the ranking decreases; logics, rules, verifiers, and reasoners may be generic, and a predicate of the wrong signature, an inexact theorem, a rule over another logic than its reasoner's, or a use with the wrong number of type arguments fails with LLT4010. | §17.12 | | `RS-03` | `reasoning` | A verifier links an executable Boolean check over a subject and a candidate to a prior proposition-valued specification by statement-exact soundness and optional completeness theorems that Lean restates against the fixed reasoning semantics; an inexact statement or a verifier whose subject or candidate type differs from its reasoner's fails with LLT4010, and a false soundness theorem is refused by verification with LLV7002. | §17.12, §22.6 | diff --git a/VERIFICATION.md b/VERIFICATION.md index 37dee37db3..7ba3576c6d 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4058,6 +4058,33 @@ function 1 renders as a constant read twice. On this tree and `conformance_rb_07` fails with `the renderer changed without its record `rust_renderer``: both are records of the renderer's bytes. +### artifacts as data can fail (SP-24, MD-14) + +Planted, three ways. + +1. The lowering stopped folding artifacts (`is_artifact` replaced by `false`). + `conformance_md_14` refused it at the first artifact read: + +```text +Models.Main.classify: `Recognizer.outputBias` is built on each call, not held as data: Build { shape: Cons, ty: List { element: Int }, operands: [Value { ty: Int, value: Int { value: "-6" } }, Build { shape: Cons, ... +``` + +2. A literal turned back into its construction chain, and a literal with one + element changed: the first is a `Build` of constructors, which the + per-call check names; the second is unequal to the closed schemas' + decoding of the artifact's bytes, which the case computes from the file + alone. +3. In certificate A of a root that holds a literal, every `conv_value` was + replaced by `conv_var`. `conformance_sp_24` compiles the planted module + under the pinned Lean and requires it to be refused. + +Before the aligner learned the case, the same run printed +`LLI9001 phase preservation: the lowering of a cons is not a build of two`: +certificate A had no derivation for a source list lowered to one literal. The +fix is one branch in `data_a/prove.rs` using the lemma that relates any +literal to its value; `git diff -- language/` is empty, so the preservation +library did not grow. Removed: each plant was reverted. + ### kernel-opaque classification is observed Probe: `compare_bytes` and byte equality were both treated as reducible, and diff --git a/crates/conformance/src/cases/models.rs b/crates/conformance/src/cases/models.rs index 17f035b6ce..f2c25b1455 100644 --- a/crates/conformance/src/cases/models.rs +++ b/crates/conformance/src/cases/models.rs @@ -286,6 +286,7 @@ pub fn run(id: &str) { "MD-11" => md_11(), "MD-12" => md_12(), "MD-13" => md_13(), + "MD-14" => md_14(), _ => panic!("no models case {id}"), } } @@ -3774,3 +3775,215 @@ fn md_13() { planted_round.verify_fails_with("LLV7002"); } } + +/// An artifact's bytes decoded by the closed schemas of §17.12 rule 2, from +/// the bytes alone: the value a lowered program must hold as data. +fn decoded_artifact( + schema: &lexlean::ir::semantic::ArtifactSchema, + bytes: &[u8], +) -> lexlean::calculus::Value { + use lexlean::calculus::Value; + use lexlean::ir::semantic::{ArtifactSchema, TensorElement}; + match schema { + ArtifactSchema::Bytes => Value::Bytes { + hex: bytes.iter().map(|byte| format!("{byte:02x}")).collect(), + }, + ArtifactSchema::Utf8Lines => Value::List { + items: std::str::from_utf8(bytes) + .expect("UTF-8 lines") + .split_terminator('\n') + .map(|line| Value::String { + value: line.to_owned(), + }) + .collect(), + }, + ArtifactSchema::IntTensor { element, shape } => { + let (width, signed) = match element { + TensorElement::Int8 => (1, true), + TensorElement::Int16 => (2, true), + TensorElement::Int32 => (4, true), + TensorElement::Int64 => (8, true), + TensorElement::UInt8 => (1, false), + TensorElement::UInt16 => (2, false), + TensorElement::UInt32 => (4, false), + TensorElement::UInt64 => (8, false), + }; + let numbers: Vec = bytes + .chunks(width) + .map(|chunk| { + let mut wide = [0_u8; 16]; + wide[..width].copy_from_slice(chunk); + if signed && chunk[width - 1] & 0x80 != 0 { + wide[width..].fill(0xff); + } + i128::from_le_bytes(wide).to_string() + }) + .collect(); + fn nest(numbers: &[String], shape: &[u64]) -> Value { + match shape { + [] => Value::Int { + value: numbers[0].clone(), + }, + [extent, rest @ ..] => { + let stride = numbers.len() / usize::try_from(*extent).expect("extent"); + Value::List { + items: numbers.chunks(stride).map(|row| nest(row, rest)).collect(), + } + } + } + } + nest(&numbers, shape) + } + } +} + +/// The artifact definitions of one lowered program, with each one's body. +fn artifact_literals<'a>( + lowered: &'a lexlean::production::lower::Lowered, + artifacts: &BTreeSet, +) -> Vec<(String, &'a lexlean::calculus::Expr)> { + use lexlean::production::lower::Origin; + lowered + .layout + .functions + .iter() + .zip(&lowered.program.functions) + .filter_map(|(origin, function)| { + let Origin::Definition { module, name, .. } = origin else { + return None; + }; + let full = format!("{module}.{name}"); + artifacts.contains(&full).then_some((full, &function.body)) + }) + .collect() +} + +/// Whether a function body builds its value with constructor expressions, +/// the per-call construction of a decoded constant. +fn builds_per_call(body: &lexlean::calculus::Expr) -> bool { + matches!(body, lexlean::calculus::Expr::Build { .. }) +} + +fn md_14() { + use lexlean::calculus::{Expr, Shape, Value}; + use lexlean::ir::semantic::SemanticDeclaration; + use lexlean::production::lower::{linked_modules, lower_root, roots}; + + let project = P::copy_example(EXAMPLE); + let checked = support::checked_project(&project); + let modules = linked_modules(&checked); + let limits = support::limits(&project); + // Every configured artifact file by its digest, decoded from its bytes. + let files: std::collections::BTreeMap> = + std::fs::read_dir(project.root.join("artifacts").as_std_path()) + .expect("artifacts") + .map(|entry| { + let bytes = std::fs::read(entry.expect("entry").path()).expect("artifact bytes"); + (Sha256Digest::of(&bytes).to_hex(), bytes) + }) + .collect(); + let mut schemas = std::collections::BTreeMap::new(); + for (module, linked) in &modules { + for declaration in &linked.semantic.declarations { + if let SemanticDeclaration::Artifact { + name, + schema, + sha256, + .. + } = declaration + { + schemas.insert(format!("{module}.{name}"), (schema.clone(), sha256.clone())); + } + } + } + assert_eq!(schemas.len(), 8, "the example declares eight artifacts"); + let artifacts: BTreeSet = schemas.keys().cloned().collect(); + let mut literals = 0; + for report in roots(&checked).expect("the eligibility reports") { + let lowered = lower_root( + &modules, + &report.module, + &report.name, + report.report, + &limits, + ) + .unwrap_or_else(|diagnostic| panic!("{}: {diagnostic:?}", report.report.root)); + for (name, body) in artifact_literals(&lowered, &artifacts) { + let Expr::Value { value, .. } = body else { + panic!( + "{}: `{name}` is built on each call, not held as data: {body:?}", + report.report.root + ); + }; + let (schema, sha256) = &schemas[&name]; + let bytes = files + .get(sha256) + .unwrap_or_else(|| panic!("{name}: no file has digest {sha256}")); + assert_eq!( + value, + &decoded_artifact(schema, bytes), + "{name}: the literal is the decoding of the artifact's bytes" + ); + literals += 1; + } + // No function of no parameters builds a constant with constructors: + // the shape of the per-call construction this removes. + for function in &lowered.program.functions { + assert!( + !(function.parameters.is_empty() + && builds_per_call(&function.body) + && matches!( + function.body, + Expr::Build { + shape: Shape::Cons, + .. + } + )), + "{}: a list is built on each call", + report.report.root + ); + } + // Planted: a literal turned back into its chain, and a literal with + // one element changed, are each detected by the same checks. + if let Some(( + _, + Expr::Value { + value: Value::List { items }, + ty, + }, + )) = artifact_literals(&lowered, &artifacts).into_iter().next() + { + let chain = items.iter().rev().fold( + Expr::Build { + shape: Shape::Nil, + ty: ty.clone(), + operands: Vec::new(), + }, + |tail, item| Expr::Build { + shape: Shape::Cons, + ty: ty.clone(), + operands: vec![ + Expr::Value { + ty: ty.clone(), + value: item.clone(), + }, + tail, + ], + }, + ); + assert!(builds_per_call(&chain), "a rebuilt constant is detected"); + let mut changed = items.clone(); + changed[0] = Value::Int { + value: "424242".to_owned(), + }; + assert_ne!( + Value::List { items: changed }, + Value::List { + items: items.clone() + }, + "a changed element is detected by the equality with the decoding" + ); + } + } + assert_eq!(literals, 10, "R0, R1, and R2 hold ten artifact literals"); +} diff --git a/crates/conformance/src/cases/preservation.rs b/crates/conformance/src/cases/preservation.rs index 972a76014e..bb28886478 100644 --- a/crates/conformance/src/cases/preservation.rs +++ b/crates/conformance/src/cases/preservation.rs @@ -5272,6 +5272,102 @@ pub fn run(id: &str) { ); } } + // §17.17 *Artifacts as data*: an artifact lowered as one literal is + // certified like any other root. + "SP-24" => artifacts_as_data(), _ => panic!("no preservation case is wired for {id}"), } } + +fn artifacts_as_data() { + use lexlean::calculus::rust::ast::ItemDef; + use lexlean::calculus::{Expr, Value}; + let project = P::copy_example("models"); + let certified = preservation::certificates(&project); + let held = |function: &lexlean::calculus::Function| { + function.parameters.is_empty() + && matches!( + &function.body, + Expr::Value { + value: Value::List { .. }, + .. + } + ) + }; + let literals: usize = certified + .iter() + .map(|entry| entry.program.functions.iter().filter(|f| held(f)).count()) + .sum(); + assert_eq!(literals, 10, "R0, R1, and R2 hold ten artifact literals"); + let mut constants = 0; + for entry in &certified { + assert!(!entry.targets.is_empty(), "{}: a target", entry.root); + assert_eq!( + entry.renderings.len(), + entry.targets.len(), + "{}: certificate B in each target", + entry.root + ); + assert_eq!( + entry.composed.len(), + entry.targets.len(), + "{}: certificate E in each target", + entry.root + ); + let krate = + lexlean::calculus::rust::lower(&entry.program, lexlean::calculus::rust::Profile::Std) + .expect("the program renders in rust-std"); + constants += krate + .items + .iter() + .filter(|item| matches!(item, ItemDef::Constant { .. })) + .count(); + } + assert_eq!(constants, 10, "each literal renders as a constant"); + if !support::lean_backed("SP-24") { + return; + } + let workspace = preservation::staged(&project, &certified); + let root = tempfile::Builder::new() + .prefix("lexlean-sp24-") + .tempdir() + .expect("tempdir"); + let checked = preservation::check(&workspace, root.path()); + assert!( + checked.failure.is_none(), + "every certificate of the models example verifies under the pinned Lean: {:?}", + checked.failure + ); + let all: Vec = certified + .iter() + .flat_map(preservation::Certified::all) + .collect(); + audit(&checked.audit_output, &all).expect("the audit, every row's axioms included"); + // Planted: the lemma that relates a literal to its value, replaced in the + // certificate A of a root that holds one, is refused by Lean. + let entry = certified + .iter() + .find(|entry| entry.program.functions.iter().any(held)) + .expect("a root that holds a literal"); + let certificate = &entry.certificate; + let data = certificate.data.as_ref().expect("certificate A is data"); + let mut planted = data.clone(); + let mut renamed = 0; + for node in &mut planted.nodes { + if let lexlean::ir::core::CoreNode::Const { n, .. } = node { + if n == "LexLeanPreservation.conv_value" { + *n = "LexLeanPreservation.conv_var".to_owned(); + renamed += 1; + } + } + } + assert!(renamed > 0, "the certificate uses `conv_value`"); + let module = format!("{}PlantWrongLemma", certificate.module); + let text = lexlean::backend::core::lean_text_legacy(&planted, &module) + .expect("the planted module renders"); + let output = preservation::compile_text(root.path(), &module, &text); + assert!( + !output.status.success(), + "the wrong lemma for a literal is refused by Lean" + ); +} diff --git a/crates/lexlean/src/production/certificate/data_a/prove.rs b/crates/lexlean/src/production/certificate/data_a/prove.rs index f83bdc689e..27f1705383 100644 --- a/crates/lexlean/src/production/certificate/data_a/prove.rs +++ b/crates/lexlean/src/production/certificate/data_a/prove.rs @@ -182,6 +182,22 @@ impl<'a> Writer<'_, 'a> { ) -> Result { let site = scope.ctx.site.clone(); let (p, env) = (self.prog, scope.env); + // An artifact's list, held by the lowering as one literal, is related + // to the source's construction of it by the lemma that relates any + // literal to its value (§17.17 *Artifacts as data*). + if let ( + SemanticTerm::Nil { element: _ } | SemanticTerm::Cons { head: _, tail: _ }, + Expr::Value { ty, value }, + ) = (term, expr) + { + let ty = self.ty_term(ty); + let value = self.value_term(value)?; + return self.apply( + "conv_value", + &[("p", p), ("env", env), ("t", ty), ("v", value)], + &[], + ); + } match term { SemanticTerm::Var { name } => { let number = match expr { diff --git a/crates/lexlean/src/production/lower.rs b/crates/lexlean/src/production/lower.rs index 7858fd36d6..914cba5f99 100644 --- a/crates/lexlean/src/production/lower.rs +++ b/crates/lexlean/src/production/lower.rs @@ -277,6 +277,107 @@ pub fn json_depth(text: &str) -> usize { deepest } +/// What a lowered term is, for the folding of an artifact's list to a literal. +enum Folding<'a> { + Literal(&'a Value), + Nil, + Cons(&'a Expr, &'a Expr), + Other, +} + +/// Every construct of the calculus classified, so a new one is a decision here. +fn folding(expr: &Expr) -> Folding<'_> { + match expr { + Expr::Value { ty: _, value } => Folding::Literal(value), + Expr::Build { + shape, + ty: _, + operands, + } => match shape { + Shape::Nil if operands.is_empty() => Folding::Nil, + Shape::Cons => <&[Expr; 2]>::try_from(operands.as_slice()) + .map_or(Folding::Other, |pair| Folding::Cons(&pair[0], &pair[1])), + Shape::Nil + | Shape::None + | Shape::Some + | Shape::Ok + | Shape::Error + | Shape::Zero + | Shape::Succ + | Shape::Pair + | Shape::True + | Shape::False + | Shape::Unit + | Shape::Lt + | Shape::Eq + | Shape::Gt + | Shape::Adt { constructor: _ } => Folding::Other, + }, + Expr::Var { name: _ } + | Expr::Let { + name: _, + ty: _, + bound: _, + body: _, + } + | Expr::Cond { + condition: _, + then_branch: _, + else_branch: _, + } + | Expr::Match { + ty: _, + scrutinee: _, + arms: _, + } + | Expr::Call { + function: _, + operands: _, + } + | Expr::Closure { + function: _, + captures: _, + } + | Expr::Apply { + target: _, + operands: _, + } + | Expr::Prim { + operation: _, + operands: _, + } + | Expr::First { value: _ } + | Expr::Second { value: _ } + | Expr::Field { value: _, index: _ } => Folding::Other, + } +} + +/// The calculus value a lowered term of constructions and literals denotes, +/// when it is one: a list built from `Nil` and `Cons` whose elements are +/// literals or such lists. A cons spine is walked in a loop, so the length of +/// a tensor does not deepen the recursion; only its rank does. +fn literal_of(expr: &Expr) -> Option { + match folding(expr) { + Folding::Literal(value) => Some(value.clone()), + Folding::Nil => Some(Value::List { items: Vec::new() }), + Folding::Cons(_, _) => { + let mut items = Vec::new(); + let mut rest = expr; + loop { + match folding(rest) { + Folding::Cons(head, tail) => { + items.push(literal_of(head)?); + rest = tail; + } + Folding::Nil => return Some(Value::List { items }), + Folding::Literal(_) | Folding::Other => return None, + } + } + } + Folding::Other => None, + } +} + /// Lower one eligible root. A failure is a compiler defect: eligibility /// already admitted every construct the closure reaches. /// @@ -2408,7 +2509,19 @@ impl Lowerer<'_> { })); } let result = self.ty(&self.source.close(result, &site))?; - let body = self.term(body, &mut scope, &site, index)?; + let mut body = self.term(body, &mut scope, &site, index)?; + // An artifact's decoded value is data, not a chain of + // constructions evaluated at each read (§17.14 *Cost*, the + // weight of a literal; §17.17 *Artifacts as data*). + let folded = self + .source + .is_artifact(&module, &name) + .then(|| literal_of(&body)) + .flatten(); + body = folded.map_or(body, |value| Expr::Value { + ty: result.clone(), + value, + }); self.functions[index as usize] = Some(Function { parameters: names, types, diff --git a/crates/lexlean/src/production/source.rs b/crates/lexlean/src/production/source.rs index 8a9a969b2b..b67b554236 100644 --- a/crates/lexlean/src/production/source.rs +++ b/crates/lexlean/src/production/source.rs @@ -132,6 +132,18 @@ impl<'a> Source<'a> { }) } + /// Whether `name` of `module` is an artifact declaration (§17.12 rule 2): + /// its elaborated definition is the constant its bytes decode to. + pub(crate) fn is_artifact(&self, module: &str, name: &str) -> bool { + self.modules.get(module).is_some_and(|linked| { + linked + .semantic + .declarations + .iter() + .any(|declaration| declaration.kind() == "artifact" && declaration.name() == name) + }) + } + /// The generated Lean module of a source module. pub(crate) fn lean_module(&self, module: &str) -> Result<&'a str, String> { self.modules diff --git a/features/suites/models.feature b/features/suites/models.feature index 0b3c403c78..99dcee04a8 100644 --- a/features/suites/models.feature +++ b/features/suites/models.feature @@ -94,7 +94,7 @@ Feature: models And non-finite and out-of-range patterns are rejected and a planted rounding or exponent mutation is refused by verification @MD-14 @build - Scenario: The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected. - Given the committed models example, whose production roots read artifacts, and a copy whose lowered program builds an artifact per call - When it is built and verified - Then every artifact read is a data literal equal to its decoding, no function body builds an artifact value, and the copy is detected + Scenario: The lowered program of a production root reading an artifact holds the artifact's decoded value as a literal equal to the decoding of its bytes by the closed schemas, and no function of no parameters builds a list with constructors on a call; a literal turned back into its chain, or with one element changed, is detected, and a lowering that stops folding artifacts is refused by the case. + Given the committed models example, whose production roots read eight artifacts, and copies that turn a literal back into its chain or change one element + When every root is lowered and each artifact's file is decoded by the closed schemas from its bytes alone + Then each artifact definition is a literal equal to that decoding, no function of no parameters builds a list on a call, and each copy is detected diff --git a/features/suites/preservation.feature b/features/suites/preservation.feature index d165c29f09..578c17729f 100644 --- a/features/suites/preservation.feature +++ b/features/suites/preservation.feature @@ -145,7 +145,7 @@ Feature: preservation And a loop that is not the loop form of any recursive body is refused for each way it may differ @SP-24 @build - Scenario: A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused. - Given every committed production root that reads an artifact, and a copy that lowers the artifact to a nullary function - When it is lowered and certified - Then each lowered program holds the decoded value as data, certificates A, B, and E check, and the copy is refused + Scenario: A production root that reads a content-addressed artifact holds the artifact's decoded value as one literal in its lowered program, recognised by the artifact declaration and not by the shape of a term, and certificates A, B, and E verify for every root of the committed models example, certificate A relating the source's construction of the list to the literal by the lemma that relates any literal to its value, so that the preservation library does not grow; a wrong lemma for the literal is refused by Lean. + Given the committed models example, whose roots read artifacts, lowered, certified, and checked under the pinned Lean + When its certificates A, B, and E are staged and compiled, replayed, and audited, and the certificate A of a root that holds a literal has the lemma for a literal replaced + Then ten artifact literals are held as data and rendered as constants, every certificate verifies with its exact axioms, and the wrong lemma is refused diff --git a/model/ids.toml b/model/ids.toml index 41b31e46fb..af85eeb4e3 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -2033,7 +2033,7 @@ statement = "Certificate B certifies a function the renderer writes as a loop: t id = "SP-24" level = "build" suite = "preservation" -statement = "A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused." +statement = "A production root that reads a content-addressed artifact holds the artifact's decoded value as one literal in its lowered program, recognised by the artifact declaration and not by the shape of a term, and certificates A, B, and E verify for every root of the committed models example, certificate A relating the source's construction of the list to the literal by the lemma that relates any literal to its value, so that the preservation library does not grow; a wrong lemma for the literal is refused by Lean." [[id]] id = "MD-01" @@ -2117,7 +2117,7 @@ statement = "IEEE-754 binary32 and binary64 bit patterns decode in LexLean to ex id = "MD-14" level = "build" suite = "models" -statement = "The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected." +statement = "The lowered program of a production root reading an artifact holds the artifact's decoded value as a literal equal to the decoding of its bytes by the closed schemas, and no function of no parameters builds a list with constructors on a call; a literal turned back into its chain, or with one element changed, is detected, and a lowering that stops folding artifacts is refused by the case." [[id]] id = "RS-01" From 22df8de7d4a416d0889badcd8e32744dd5ffd461 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 13:50:57 +0000 Subject: [PATCH 07/21] Merge the skeleton; TC-08 row in spec/src; VERIFICATION names its command and the limit of the text check Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- VERIFICATION.md | 6 ++++++ spec/src/IdsTC.lex.tex | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 16d3406830..4baa867090 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4011,6 +4011,7 @@ interpreter was restored and the fixtures regenerated; `compiler/` verifies. ### calculus literal weight can fail (TC-08) +Command: `cargo test -p repo-conformance --test conformance conformance_tc_08`. Planted, in two steps. First the reference interpreter charged a literal one step (the rule before TC-08); `conformance_tc_08` refused it at the string literal, whose weight is 4 for `"h\u{e9}\u{e9}"`: @@ -4028,6 +4029,11 @@ Second, with the interpreter correct, `TargetSemantics.lex.tex` was restored to the denotation charges a literal its weight ``` +The second plant is a text check: the case reads `TargetSemantics.lex.tex` and +requires the line that charges `weight literal`. It shows the source was not +restored to the old charge; it does not show the kernel's reduction agrees +with the interpreter, which needs the regenerated fixtures. + Removed: the weight charge was restored in both. The kernel's own check of the rule, a fixture whose `rfl` theorem states the weighted step count, needs `cargo xtask check-calculus --write` and is not exercised here: the 14 fixtures diff --git a/spec/src/IdsTC.lex.tex b/spec/src/IdsTC.lex.tex index dc7fac223a..d9ceaf0911 100644 --- a/spec/src/IdsTC.lex.tex +++ b/spec/src/IdsTC.lex.tex @@ -64,7 +64,7 @@ name: tc08, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "TC-08", level := "build", suite := "calculus", statement := "The production calculus has a closed data literal, a list, pair, option, or algebraic-data value spelled by literals of its element types, that has a type rule, a canonical form with one spelling per value, a kernel-checked denotation equal to the value it spells, and a stated cost that charges its weight once per read, so that a decoded constant is data in a program and never a chain of build expressions evaluated on each call; a literal of the wrong type, a malformed member, or a literal that is not canonical is refused with LLB6005.", sections := "§17.14"}), + body: (record Rows::IdRow {id := "TC-08", level := "build", suite := "calculus", statement := "A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005.", sections := "§17.14"}), executable: true } \end{semanticmodule} From 4d774802845e64d620c7a23033a9ebb041c60474 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 16:10:43 +0000 Subject: [PATCH 08/21] RB-18 round two: constant is a construct of the machine ItemDef.constant in RustSyntax with arms in RustSemantics; certificate B encodes it as itself; the rule (infallible, closed literal, no binding) is stated by validate and by the bootstrap RustValidate, held by five committed crates in the BS-05 differential; the library repairs its one lemma that eliminates ItemDef (findDispatch_some._f). A declared algebraic type is not a constant. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 4 +- SPEC.md | 46 +- VERIFICATION.md | 75 ++- bootstrap/src/RustValidate.lex.tex | 117 +++- compiler/src/RustSemantics.lex.tex | 6 +- compiler/src/RustSyntax.lex.tex | 3 +- .../src/cases/bootstrap/rust_validate.rs | 96 ++- crates/conformance/src/cases/rust_backend.rs | 42 ++ crates/lexlean/src/calculus/rust/validate.rs | 2 +- .../production/certificate/data_b/syntax.rs | 5 +- features/suites/bootstrap.feature | 2 +- features/suites/rust-backend.feature | 8 +- .../library/src/RustMatches.lex.tex | 581 +++++++++++++++--- model/ids.toml | 4 +- spec/src/IdsBS.lex.tex | 2 +- spec/src/IdsRB.lex.tex | 2 +- 16 files changed, 840 insertions(+), 155 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 5883259b57..1a390fc6bd 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -64,7 +64,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `BS-02` | `build` | The preservation lexer and token audit of SPEC.md §17.17 are language-1.2 source in the `bootstrap/` project: `lex` and `auditTokens` of `TokenAudit` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `production::preserve::{lex, audit_tokens}` on every lexeme, position, and rejection message for the first 1,500 characters of every module of the shipped preservation library and calculus modules, the number-lexing corpus, and every token-audit unit vector; on the normative host, both roots' lowered programs under the calculus evaluator agree with the Rust oracle on those vectors and a seeded corpus, the rendered packages under the pinned rustc agree with the oracle on the large seeded corpus of generated and mutated Lean texts with no disagreement, a planted defect in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | | `BS-03` | `build` | The primitive scanner of SPEC.md §12.2 is language-1.2 source in the `bootstrap/` project: `scanSource` and `rejectAtoms` of `PrimitiveScan` are production roots eligible for `rust-std` with exactly their declared effects; on every host of the matrix, both roots' rendered `rust-std` packages under that host's pinned rustc agree with the Rust oracle `source::scan::{scan, reject_forbidden_atoms}` on every atom with its class, text, and byte, line, and column spans and on every rejection with its code, message, span, and help, for the deterministic vectors (the oracle's unit inputs, the atom limit at N and N+1, atom lists with gaps, payload strings, and notation bodies), a 128-byte window and a 2,048-byte prefix of every committed `.lex.tex` source, and the whole of each such source up to 8,192 bytes (up to 1,024 bytes, one source in four, for `rejectAtoms`); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the vectors and the 128-byte windows and on 80 seeded texts, the packages agree on 2,500 seeded texts, each of ten planted defects in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | | `BS-04` | `build` | The target calculus's checker of SPEC.md §17.14 (`lexlean::calculus::check`), for a program given as calculus data, each list of a recursive type carried as a chain of that type's own `Nil` and `Cons` constructors and decoded back to the program on every vector (reading a program from its canonical JSON is not part of this row), is language-1.2 source in the `bootstrap/` project: `checkProgram` and `checkArguments` of `CalculusCheck` are production roots eligible for `rust-std` with exactly their declared effects; on the normative host the lowered programs of both roots under the calculus evaluator agree with the Rust checker on acceptance and on the rejection message to the byte for every committed target program and the refusal edits of `TC-02` and for a seeded corpus of data-level mutations, and each planted defect in the source is detected; on every host the rendered `rust-std` packages of both roots under the pinned rustc agree with the Rust checker on the deterministic vectors, and on the normative host also on a larger seeded corpus with no disagreement; strings whose Rust `Debug` spelling escapes a non-ASCII scalar other than `U+0080`..`U+009F` are outside the claim; and the certified packages the production export publishes for the project are the committed ones. | -| `BS-05` | `build` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, and for 34 hand-built crates of the loop rules (406 `validateCrate` runs, 165 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | +| `BS-05` | `build` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | ## calculus @@ -518,7 +518,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `RB-12` | `build` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | | `RB-13` | `build` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | | `RB-14` | `build` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | -| `RB-18` | `build` | A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | +| `RB-18` | `build` | A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | ## security diff --git a/SPEC.md b/SPEC.md index cdb713695b..23b58071fd 100644 --- a/SPEC.md +++ b/SPEC.md @@ -4776,21 +4776,28 @@ Each of these renders the same denotation with no more work than the plain rendering. **Constants.** A function of no parameters that cannot fail, whose body is a -closed literal (scalars, constructors, pairs, and boxes of literals only) whose -result holds heap storage, is rendered in `rust-std` as a *constant*: a -`thread_local!` cell initialised once per thread by the literal, and a function -whose every call is `CELL.with(|cell| cell.clone())`. A clone of a list, a -string, or a byte string shares its storage, so a read allocates nothing, where -a rebuilt literal allocates at each read (`RB-18`). A constant is not a new -construct of the calculus: its row in `validate::CORRESPONDENCE` is `constant`, -realizing `function`, and calls to it are ordinary calls. The machine of §17.17 -reads a constant as the function of no parameters it caches, whose value is the -body's; when the value is computed is not part of the denotation, so the work -the machine counts and the steps of §17.14 are unchanged. `rust::validate` -refuses, as `LLB6005`, a constant whose result can fail or whose body is not a -closed literal: a thread-local initializer cannot propagate a failure, and a -body that calls could reach the constant it initializes. `rust-core` renders no -constant, because the literal holds heap storage. +closed literal (scalars, constructors, pairs, and boxes of literals only) and +whose result is a list, a string, or a byte string (a type with heap storage +by `Type::heap`), is a *constant* in `rust-std`: the item `ItemDef::Constant` +of the AST and `ItemDef.constant` of `RustSyntax`, printed as a `thread_local!` +cell initialised once per thread by the literal and a function whose every call +is `CELL.with(|cell| cell.clone())`. A clone of a list, a string, or a byte +string shares its storage, so a read allocates nothing, where a rebuilt literal +allocates at each read (`RB-18`). A literal whose type is a declared algebraic +type is not a constant, whatever it holds: its type says no heap, so it stays a +function that builds the value on each call. `RustSemantics` gives a call of a +constant the value of its body, as `findFunction` returns it as a function of no +parameters; the machine counts no work, so a read adds none to the counted work +the differentials measure (§17.16 *Checks*, `TC-07`), and when the value is +computed is not part of the denotation. Certificate B encodes the item as +itself (§17.17), so the crate it states is the crate printed. `rust::validate` +and the bootstrap `RustValidate` refuse, as `LLB6005`, a constant whose result +can fail or whose body has a binding or is not a closed literal, ``constant: `f` +is not an infallible closed literal``: a thread-local initializer cannot propagate +a failure, and a body that calls could reach the constant it initializes. No +lowering builds such a constant, so the refusal is held by committed crates in +the differential of `BS-05`. `rust-core` renders no constant, because the +literal holds heap storage. **Failure typing.** A function can overflow exactly when its body reaches a primitive or successor that can (`nat_add`, `nat_mul`, `int_add`, `int_sub`, @@ -7510,8 +7517,9 @@ the `elements` the renderer realizes), a rule corpus that reaches each of the runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run out first; the refusal that a construct has no row of the table cannot be reached), 17 crates by hand for the merge of moved sets at an `if` and a -`match`, and 34 by hand for the loop rules; that is 406 runs of `validateCrate` -(165 refused) and 269 of `correspondCrate` (46 refused), and the case asserts +`match`, 34 by hand for the loop rules, and 5 by hand for the rule of a constant +(§17.16 *Constants*); that is 411 runs of `validateCrate` +(169 refused) and 269 of `correspondCrate` (46 refused), and the case asserts these counts. On every host, the rendered `rust-std` packages of both roots (§17.16), compiled by the pinned rustc, are run on all of them. On the normative host, the lowered programs of both roots are run under the calculus @@ -10286,7 +10294,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `RB-12` | `rust-backend` | The language-1.2 compiler-semantics ID covers the package scaffold: changing a lint row, the edition, or a gate of a copy of the embedded tree changes it, writing the module in its data form or reformatting its notation does not, and the module is outside the identities of languages 1.0 and 1.1. | §17.16, §21.2 | | `RB-13` | `rust-backend` | A package states the effects of its realization: `package.json` and `provenance.json` record them, ascending and registered, the production registry says that exhausting the stack aborts the process, and an unregistered or unordered list, or one that states allocation on `rust-core`, is refused. | §17.13, §17.16 | | `RB-14` | `rust-backend` | A library template whose self calls are all tail calls is rendered as a loop over its accumulator that breaks with its result, so that the production rows of the primitives it realizes carry no `recursion`, while a template with a call that is not a tail call is rendered as a call and keeps the effect; a rendering that states a self call where a loop is possible, and a row whose `recursion` differs from its rendering, are refused. | §17.13, §17.14, §17.16 | -| `RB-18` | `rust-backend` | A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | §17.16 | +| `RB-18` | `rust-backend` | A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations. | §17.16 | | `GN-01` | `gnaf` | Every committed GNAF request and fixture is canonical, validates against the GNAF schemas whose calculus definitions are the target program schema's, and states its components' universe identity; a malformed request, an invalid reference, plan, or realized program, a reference without a value on a domain argument, or a wrong universe identity fails closed with LLB6006, and a machine or request beyond the host's capacity fails closed with LLS8002. | §17.15, §26.3 | | `GN-02` | `gnaf` | The GNAF model is a kernel-checked LexLean definition, Lean's kernel reduces the universe, the system statuses, and the answer of every committed request to what the host transcription computes, and a wrong answer, an answer computed from a universe with a system omitted, a tie with a member dropped, and a universe with a system omitted are rejected by Lean. | §17.15 | | `GN-03` | `gnaf` | Candidate membership is the grammar's expansion, which a kernel-checked theorem proves equal to the grammar's well-formed selectors for every grammar, independent of evaluation and fixed by a universe identity before any optimizer, and optimizer-defined, discovered, cached, and internal-plan universes and missing, self-referential, or optimizer-citing completeness evidence are rejected. | §17.15 | @@ -10411,7 +10419,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `BS-02` | `bootstrap` | The preservation lexer and token audit of SPEC.md §17.17 are language-1.2 source in the `bootstrap/` project: `lex` and `auditTokens` of `TokenAudit` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `production::preserve::{lex, audit_tokens}` on every lexeme, position, and rejection message for the first 1,500 characters of every module of the shipped preservation library and calculus modules, the number-lexing corpus, and every token-audit unit vector; on the normative host, both roots' lowered programs under the calculus evaluator agree with the Rust oracle on those vectors and a seeded corpus, the rendered packages under the pinned rustc agree with the oracle on the large seeded corpus of generated and mutated Lean texts with no disagreement, a planted defect in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | §17.17, §17.23 | | `BS-03` | `bootstrap` | The primitive scanner of SPEC.md §12.2 is language-1.2 source in the `bootstrap/` project: `scanSource` and `rejectAtoms` of `PrimitiveScan` are production roots eligible for `rust-std` with exactly their declared effects; on every host of the matrix, both roots' rendered `rust-std` packages under that host's pinned rustc agree with the Rust oracle `source::scan::{scan, reject_forbidden_atoms}` on every atom with its class, text, and byte, line, and column spans and on every rejection with its code, message, span, and help, for the deterministic vectors (the oracle's unit inputs, the atom limit at N and N+1, atom lists with gaps, payload strings, and notation bodies), a 128-byte window and a 2,048-byte prefix of every committed `.lex.tex` source, and the whole of each such source up to 8,192 bytes (up to 1,024 bytes, one source in four, for `rejectAtoms`); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the vectors and the 128-byte windows and on 80 seeded texts, the packages agree on 2,500 seeded texts, each of ten planted defects in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | §12.2, §17.23 | | `BS-04` | `bootstrap` | The target calculus's checker of SPEC.md §17.14 (`lexlean::calculus::check`), for a program given as calculus data, each list of a recursive type carried as a chain of that type's own `Nil` and `Cons` constructors and decoded back to the program on every vector (reading a program from its canonical JSON is not part of this row), is language-1.2 source in the `bootstrap/` project: `checkProgram` and `checkArguments` of `CalculusCheck` are production roots eligible for `rust-std` with exactly their declared effects; on the normative host the lowered programs of both roots under the calculus evaluator agree with the Rust checker on acceptance and on the rejection message to the byte for every committed target program and the refusal edits of `TC-02` and for a seeded corpus of data-level mutations, and each planted defect in the source is detected; on every host the rendered `rust-std` packages of both roots under the pinned rustc agree with the Rust checker on the deterministic vectors, and on the normative host also on a larger seeded corpus with no disagreement; strings whose Rust `Debug` spelling escapes a non-ASCII scalar other than `U+0080`..`U+009F` are outside the claim; and the certified packages the production export publishes for the project are the committed ones. | §17.14, §17.23 | -| `BS-05` | `bootstrap` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, and for 34 hand-built crates of the loop rules (406 `validateCrate` runs, 165 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | §17.16, §17.23 | +| `BS-05` | `bootstrap` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | §17.16, §17.23 | | `PK-01` | `packages` | A language-1.2 project that declares a source package by its identifier, version, kind `path`, and the member directory a `lexlean-workspace.toml` lists locks it by the tree digest of its manifest and source files, its manifest digest, its version, its module prefix, and its own packages, and the configuration and the lock read back to the bytes written; a project without a source package keeps its bytes, and a package of another kind, a source package in another language, a changed byte or version (LLC0105), an undeclared package (LLC0106), a module prefix claimed twice (LLC0107), a project or a package outside the workspace (LLC0108), a path that escapes it, and a symlink (LLS8001) are each refused with the named code. | §10.5, §11.1, §25.1 | | `PK-02` | `packages` | A module of a project imports only modules of its own project and modules of the packages the project declares, and a module of a package only modules of itself and of the packages its own manifest declares: a package module is a module of the importing project under its own module prefix, a module of a package the project does not declare fails with LLR3009, and an import cycle through a package fails with LLR3003. | §10.5, §15.1 | | `PK-03` | `packages` | An importing project builds and verifies under the pinned Lean offline, and its package modules are generated, elaborated, replayed with `leanchecker`, and audited for their exact axioms under the package's module prefix with the package as their origin in the records; the source ID of the project changes with the pins, and no file of the package is written by `fmt`, `build`, or `verify`. | §10.5, §21.3, §22 | diff --git a/VERIFICATION.md b/VERIFICATION.md index eee89c8563..61b6e0d3f6 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4043,25 +4043,60 @@ and `conformance_tc_05` fail on this tree until they are rewritten. ### rust constants can fail (RB-18) -Planted, three ways, all observed by `conformance_rb_18`. The oracle is the -pinned rustc, a counting global allocator in the harness, and `validate`. - -1. The same program with its constant rebuilt at each read (the crate's - `Constant` item printed as a `Function`): two reads allocate 4 times, - where the cached rendering allocates 0. The harness counts, so the - rebuilding rendering is detected by behavior, not by its text. -2. A constant whose body is a call: `validate` refuses it - (`constant: ... is not an infallible closed literal`). -3. A constant whose result is `R`: the same refusal. - -Removed: the crate was restored to the lowering's own output. `rust-core` -has no rendering of the heap literal at all (`lower` refuses it). - -`conformance_tc_07` passes with the new fixture `cached-literal`, whose -function 1 renders as a constant read twice. On this tree -`conformance_rb_01` fails with `correspondence rows no run package exercises: -["constant"]` until the committed packages are rewritten from the fixtures, -and `conformance_rb_07` fails with `the renderer changed without its record +Command: `cargo test -p repo-conformance --test conformance conformance_rb_18`. +The oracles are the pinned rustc, a counting global allocator in the harness, +`validate`, and the bootstrap validator. + +Planted, five ways. + +1. The lowering stopped hoisting (`let cached = false && ...`). The case + refused it: + +```text +thread 'conformance_rb_18' panicked at crates/conformance/src/cases/rust_backend.rs:1711:5: +a nullary heap literal is a constant: [Function { name: Function(0), parameters: [], result: List(Int), body: Block { lets: [], tail: Construct { ctor: Cons, args: [Lit(Int(7), ... +``` + +2. The same program with its constant printed as a function that rebuilds at + each read: two reads allocate 4 times where the cached rendering allocates + 0 (counted by the harness; observed by printing the count once, the case + asserts `> 0` and `== 0`). The reviewer's variant, a rebuild behind the + cell, fails the same equality (`left: 4`, `right: 0`). +3. A constant whose body is a call, one whose result can fail, and one with a + binding before the literal: `validate` refuses each with + ``constant: `f0` is not an infallible closed literal``. The bootstrap + validator refuses the same three crates with the same message (committed in + `constant_crates` of the BS-05 differential, with a literal it accepts and a + name declared twice by constants), so the differential holds the rule. +4. A literal of a declared algebraic type holding a list is not a constant: the + case requires the lowering to leave it a function. +5. `rust-core` has no rendering of the heap literal (`lower` refuses it). + +The expectation `Some(7) 5 5` of the harness is written by hand. That the +rendering and the evaluator agree on a constant rests on `conformance_tc_07`, +whose fixture `cached-literal` is generated and has no committed file until the +fixtures are regenerated, so until then it is the case's own program and not +the committed fixture that the differential runs. + +**The machine and the library.** `RustSyntax.ItemDef` grows by `constant` and +`RustSemantics` gains an arm in each of its two matches over it (`findFunction` +returns a constant as a function of no parameters, `findDispatch` skips it). +With the regenerated `RustSyntax`/`RustSemantics` modules in place, the library +refused the grown `ItemDef` at the first break the #91 stage-4 walk predicted, +`LexLeanPreservation.Rust.findDispatch_some._f` in `RustMatches` +(`(kernel) application type mismatch ... ItemDef.casesOn`). The repair is the +fourth minor premise of that `casesOn`: the `function` minor with its parameters +field removed and the constructor replaced, rewritten on the module's data and +written back in the notation (the module round-trips byte for byte before the +edit). After it `conformance_sp_13`, which compiles all 13 library modules +over the machine modules, passes (299 s); no other declaration needed a repair. +`lexlean verify` of `bootstrap/` with the grown `RustValidate` passes +(`verified 6 modules`). Both runs used regenerated machine modules held in the +working tree only; the committed ones are left for the regeneration. + +Removed: each plant was reverted. `conformance_rb_01` fails on this tree with +`correspondence rows no run package exercises: ["constant"]` and +`conformance_rb_07` with `the renderer changed without its record `rust_renderer``: both are records of the renderer's bytes. ### kernel-opaque classification is observed @@ -9743,7 +9778,7 @@ Authoring found four shapes certificate A and certificate B do not accept, each ### the bootstrap Rust crate validator can fail its oracle (SPEC.md §17.23, §17.16) -`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, and 34 hand-built crates of the loop rules, that is 406 `validateCrate` vectors (165 refused) and 269 `correspondCrate` vectors (46 refused), 675 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 675. On the normative host the evaluator agrees on the 200 crates of at most 400 expressions, the rule runs, and the hand-built crates (383 + 246 vectors), and on 500 seeded mutants (271 and 244 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. +`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, and 34 hand-built crates of the loop rules, that is 406 `validateCrate` vectors (165 refused) and 269 `correspondCrate` vectors (46 refused), 675 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 675. On the normative host the evaluator agrees on the 200 crates of at most 400 expressions, the rule runs, and the hand-built crates (388 + 246 vectors), and on 500 seeded mutants (271 and 244 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. The loop rules (the oracle's `Expr::Loop`, SP-19 and RB-14) are `ELoop [Id, Expr]` of the module: ownership of the state across a body that runs again (two refusals, for a name and for a component, naming the least offender in the oracle's order of names), the fallible-tail rule, `apply_types` with `tail = false` for the body, and the correspondence traversal treating the body as a block. The correspondence table was re-diffed against the oracle's `CORRESPONDENCE` after SP-19: 97 rows, and the six that gained `expr:call` (`destructure:pair`, `type:result`, `type:pair`, `construct:ok`, `construct:err`, `construct:pair`) are the only difference from the table first transcribed; the module's table and the oracle's are equal row for row and element for element. diff --git a/bootstrap/src/RustValidate.lex.tex b/bootstrap/src/RustValidate.lex.tex index e231bb718a..81fbd8bfb7 100644 --- a/bootstrap/src/RustValidate.lex.tex +++ b/bootstrap/src/RustValidate.lex.tex @@ -285,7 +285,8 @@ {name: DApply, fields: [Nat, Ty, Ty, Bool, Dis, Origin]}, {name: DFunction, fields: [Id, Par, Ty, Expr, Origin]}, {name: DNil, fields: []}, - {name: DCons, fields: [Def, Def]} + {name: DCons, fields: [Def, Def]}, + {name: DConstant, fields: [Id, Ty, Expr, Origin]} ] } @@ -958,6 +959,7 @@ | Def.DEnum d0 d1 d2 => (ctor Result.ok [Decl, Bytes] decl) | Def.DApply d0 d1 d2 d3 d4 d5 => (ctor Result.ok [Decl, Bytes] decl) | Def.DFunction d0 d1 d2 d3 d4 => (ctor Result.ok [Decl, Bytes] decl) + | Def.DConstant d0 d1 d2 d3 => (ctor Result.ok [Decl, Bytes] decl) | Def.DNil => (ctor Result.ok [Decl, Bytes] decl) | Def.DCons head tail => (match head | Def.DEnum name variants origin => (match name @@ -990,6 +992,19 @@ | Bool.true => (ctor Result.error [Decl, Bytes] (cat (text "hygiene: f") (cat (decimal n) (text " is declared twice")))) | Bool.false => (declareDefs (record Decl {adts := (project decl adts), closures := (project decl closures), applies := (project decl applies), functions := (cons (n, (tyIsFallible result)) (project decl functions))}) tail)) | Id.IdExport d0 => (declareDefs decl tail)) + | Def.DConstant name result body origin => (match name + | Id.IdLocal d0 => (declareDefs decl tail) + | Id.IdHolder d0 => (declareDefs decl tail) + | Id.IdOperand d0 => (declareDefs decl tail) + | Id.IdCallee d0 => (declareDefs decl tail) + | Id.IdBoxed d0 => (declareDefs decl tail) + | Id.IdPart d0 => (declareDefs decl tail) + | Id.IdCapture d0 => (declareDefs decl tail) + | Id.IdParam d0 => (declareDefs decl tail) + | Id.IdFunction n => (match (hasFlag (project decl functions) n) + | Bool.true => (ctor Result.error [Decl, Bytes] (cat (text "hygiene: f") (cat (decimal n) (text " is declared twice")))) + | Bool.false => (declareDefs (record Decl {adts := (project decl adts), closures := (project decl closures), applies := (project decl applies), functions := (cons (n, false) (project decl functions))}) tail)) + | Id.IdExport d0 => (declareDefs decl tail)) | Def.DNil => (declareDefs decl tail) | Def.DCons d0 d1 => (declareDefs decl tail))), executable: true, @@ -2659,6 +2674,95 @@ recursive_argument: arms } +definition{ + name: literalOk, + parameters: [e : Expr], + result: Bool, + body: (match e + | Expr.ELit d0 d1 => true + | Expr.ERead d0 d1 d2 => false + | Expr.EWrap kind inner d2 => (match kind + | WrapKind.WkNot => false + | WrapKind.WkBox => (literalOk inner) + | WrapKind.WkWiden => false + | WrapKind.WkSucceed => false) + | Expr.ECall d0 d1 d2 d3 => false + | Expr.EApply d0 d1 d2 d3 => false + | Expr.EConstruct d0 args d2 => (literalOk args) + | Expr.EPair left right d2 => (match (literalOk left) + | Bool.true => (literalOk right) + | Bool.false => false) + | Expr.EIf d0 d1 d2 d3 => false + | Expr.EMatch d0 d1 d2 => false + | Expr.EBlockE d0 => false + | Expr.EProbe d0 d1 d2 => false + | Expr.EBlock d0 d1 => false + | Expr.ENil => true + | Expr.ECons head tail => (match (literalOk head) + | Bool.true => (literalOk tail) + | Bool.false => false) + | Expr.ELet d0 d1 d2 d3 d4 d5 => false + | Expr.EArm d0 d1 d2 => false + | Expr.ELoop d0 d1 => false), + axioms: [], + executable: true, + recursive_argument: e +} + +definition{ + name: noLets, + parameters: [e : Expr], + result: Bool, + body: (match e + | Expr.ELit d0 d1 => false + | Expr.ERead d0 d1 d2 => false + | Expr.EWrap d0 d1 d2 => false + | Expr.ECall d0 d1 d2 d3 => false + | Expr.EApply d0 d1 d2 d3 => false + | Expr.EConstruct d0 d1 d2 => false + | Expr.EPair d0 d1 d2 => false + | Expr.EIf d0 d1 d2 d3 => false + | Expr.EMatch d0 d1 d2 => false + | Expr.EBlockE d0 => false + | Expr.EProbe d0 d1 d2 => false + | Expr.EBlock d0 d1 => false + | Expr.ENil => true + | Expr.ECons d0 d1 => false + | Expr.ELet d0 d1 d2 d3 d4 d5 => false + | Expr.EArm d0 d1 d2 => false + | Expr.ELoop d0 d1 => false), + axioms: [], + executable: true +} + +definition{ + name: constantShape, + parameters: [result : Ty, body : Expr], + result: Bool, + body: (match body + | Expr.ELit d0 d1 => false + | Expr.ERead d0 d1 d2 => false + | Expr.EWrap d0 d1 d2 => false + | Expr.ECall d0 d1 d2 d3 => false + | Expr.EApply d0 d1 d2 d3 => false + | Expr.EConstruct d0 d1 d2 => false + | Expr.EPair d0 d1 d2 => false + | Expr.EIf d0 d1 d2 d3 => false + | Expr.EMatch d0 d1 d2 => false + | Expr.EBlockE d0 => false + | Expr.EProbe d0 d1 d2 => false + | Expr.EBlock lets tail => (match (tyIsFallible result) + | Bool.true => false + | Bool.false => (match (noLets lets) | Bool.true => (literalOk tail) | Bool.false => false)) + | Expr.ENil => false + | Expr.ECons d0 d1 => false + | Expr.ELet d0 d1 d2 d3 d4 d5 => false + | Expr.EArm d0 d1 d2 => false + | Expr.ELoop d0 d1 => false), + axioms: [], + executable: true +} + definition{ name: validateItem, parameters: [core : Bool, decl : Decl, rows : (List ItemRow), item : Def], @@ -2681,6 +2785,13 @@ | Result.error problem55 => (ctor Result.error [Unit, Bytes] problem55)) | Result.error problem56 => (ctor Result.error [Unit, Bytes] problem56)) | Result.error problem57 => (ctor Result.error [Unit, Bytes] problem57)))) + | Def.DConstant name result body org => (let cx : Cx := (record Cx {core := core, decl := decl, fallible := false, items := rows}); (match (tyOk cx result) + | Result.ok done => (match (constantShape result body) + | Bool.false => (ctor Result.error [Unit, Bytes] (cat (text "constant: ") (cat (tick (idText name)) (text " is not an infallible closed literal")))) + | Bool.true => (match (blockC (record St {bound := (nil Id), scope := (nil Id), moved := (nil Id), parted := (nil (Id * (List Nat))), propagates := false}) cx body true) + | Result.ok s2 => (ctor Result.ok [Unit, Bytes] ()) + | Result.error problem90 => (ctor Result.error [Unit, Bytes] problem90))) + | Result.error problem91 => (ctor Result.error [Unit, Bytes] problem91))) | Def.DNil => (ctor Result.ok [Unit, Bytes] ()) | Def.DCons d0 d1 => (ctor Result.ok [Unit, Bytes] ())), axioms: [propext], @@ -2695,6 +2806,7 @@ | Def.DEnum d0 d1 d2 => (ctor Result.ok [Unit, Bytes] ()) | Def.DApply d0 d1 d2 d3 d4 d5 => (ctor Result.ok [Unit, Bytes] ()) | Def.DFunction d0 d1 d2 d3 d4 => (ctor Result.ok [Unit, Bytes] ()) + | Def.DConstant d0 d1 d2 d3 => (ctor Result.ok [Unit, Bytes] ()) | Def.DNil => (ctor Result.ok [Unit, Bytes] ()) | Def.DCons head tail => (match (validateItem core decl rows head) | Result.ok done => (validateItems core decl rows tail) @@ -2765,6 +2877,7 @@ | Bool.false => (text "enum:adt")) org) variants) | Def.DApply fnType parameters result fallible arms org => (foundTy (foundTy (foundAt found (text "apply:dispatch") org) parameters) result) | Def.DFunction name parameters result body org => (foundExpr (foundTy (foundParTys (foundAt found (text "function") org) parameters) result) body) + | Def.DConstant name result body org => (foundExpr (foundTy (foundAt found (text "constant") org) result) body) | Def.DNil => found | Def.DCons head tail => (let f1 : Found := (foundDefs found head); (foundDefs f1 tail))), axioms: [propext], @@ -2840,7 +2953,7 @@ name: correspondTable, parameters: [unit : Unit], result: (List (Bytes * (List Bytes))), - body: (let rows0 : (List (Bytes * (List Bytes))) := (cons ((text "function"), (cons (text "function") (cons (text "export") (nil Bytes)))) (cons ((text "enum:adt"), (cons (text "type:adt") (nil Bytes))) (cons ((text "enum:closures"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "apply:dispatch"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "let"), (cons (text "expr:let") (cons (text "expr:match") (cons (text "expr:prim") (cons (text "expr:apply") (cons (text "expr:call") (cons (text "expr:closure") (cons (text "expr:cond") (cons (text "expr:field") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "shape:succ") (cons (text "shape:zero") (cons (text "shape:unit") (cons (text "shape:true") (cons (text "indirection") (cons (text "overflow") (nil Bytes))))))))))))))))))))) (cons ((text "read"), (cons (text "expr:var") (cons (text "expr:match") (cons (text "expr:prim") (cons (text "expr:call") (cons (text "expr:apply") (cons (text "expr:closure") (cons (text "expr:first") (cons (text "expr:second") (cons (text "expr:field") (cons (text "expr:cond") (cons (text "shape:true") (cons (text "shape:zero") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "export") (cons (text "type:fn") (cons (text "type:adt") (cons (text "type:pair") (cons (text "type:result") (nil Bytes)))))))))))))))))))))))) (nil (Bytes * (List Bytes))))))))); (let rows1 : (List (Bytes * (List Bytes))) := (cons ((text "box"), (cons (text "indirection") (nil Bytes))) (cons ((text "destructure:pair"), (cons (text "expr:first") (cons (text "expr:second") (cons (text "shape:pair") (cons (text "expr:call") (nil Bytes)))))) (cons ((text "type:unit"), (cons (text "type:unit") (nil Bytes))) (cons ((text "type:bool"), (cons (text "type:bool") (nil Bytes))) (cons ((text "type:nat"), (cons (text "type:nat") (cons (text "type:fixed") (nil Bytes)))) (cons ((text "type:int"), (cons (text "type:int") (cons (text "type:fixed") (nil Bytes)))) rows0)))))); (let rows2 : (List (Bytes * (List Bytes))) := (cons ((text "type:fixed"), (cons (text "type:fixed") (nil Bytes))) (cons ((text "type:ordering"), (cons (text "type:ordering") (nil Bytes))) (cons ((text "type:string"), (cons (text "type:string") (nil Bytes))) (cons ((text "type:bytes"), (cons (text "type:bytes") (nil Bytes))) (cons ((text "type:option"), (cons (text "type:option") (nil Bytes))) (cons ((text "type:result"), (cons (text "type:result") (cons (text "expr:call") (nil Bytes)))) rows1)))))); (let rows3 : (List (Bytes * (List Bytes))) := (cons ((text "type:list"), (cons (text "type:list") (nil Bytes))) (cons ((text "type:pair"), (cons (text "type:pair") (cons (text "expr:call") (nil Bytes)))) (cons ((text "type:adt"), (cons (text "type:adt") (nil Bytes))) (cons ((text "type:fn"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "type:rc"), (cons (text "indirection") (nil Bytes))) (cons ((text "type:fallible"), (cons (text "overflow") (nil Bytes))) rows2)))))); (let rows4 : (List (Bytes * (List Bytes))) := (cons ((text "type:ref"), (cons (text "export") (nil Bytes))) (cons ((text "lit:unit"), (cons (text "value:unit") (cons (text "shape:unit") (cons (text "expr:var") (cons (text "expr:call") (cons (text "expr:apply") (cons (text "expr:closure") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "export") (cons (text "overflow") (nil Bytes))))))))))))))) (cons ((text "lit:bool"), (cons (text "value:bool") (cons (text "shape:true") (cons (text "shape:false") (cons (text "expr:cond") (nil Bytes)))))) (cons ((text "lit:nat"), (cons (text "value:nat") (cons (text "shape:zero") (nil Bytes)))) (cons ((text "lit:int"), (cons (text "value:int") (nil Bytes))) (cons ((text "lit:fixed"), (cons (text "value:u8") (cons (text "value:u16") (cons (text "value:u32") (cons (text "value:u64") (cons (text "value:i8") (cons (text "value:i16") (cons (text "value:i32") (cons (text "value:i64") (nil Bytes)))))))))) rows3)))))); (let rows5 : (List (Bytes * (List Bytes))) := (cons ((text "lit:string"), (cons (text "value:string") (nil Bytes))) (cons ((text "lit:bytes"), (cons (text "value:bytes") (nil Bytes))) (cons ((text "lit:ordering"), (cons (text "value:ordering") (cons (text "shape:lt") (cons (text "shape:eq") (cons (text "shape:gt") (nil Bytes)))))) (cons ((text "construct:none"), (cons (text "value:none") (cons (text "shape:none") (nil Bytes)))) (cons ((text "construct:some"), (cons (text "value:some") (cons (text "shape:some") (nil Bytes)))) (cons ((text "construct:ok"), (cons (text "value:ok") (cons (text "shape:ok") (cons (text "expr:call") (nil Bytes))))) rows4)))))); (let rows6 : (List (Bytes * (List Bytes))) := (cons ((text "construct:err"), (cons (text "value:error") (cons (text "shape:error") (cons (text "expr:call") (nil Bytes))))) (cons ((text "construct:adt"), (cons (text "value:adt") (cons (text "shape:adt") (nil Bytes)))) (cons ((text "construct:closure"), (cons (text "expr:closure") (nil Bytes))) (cons ((text "construct:cons"), (cons (text "value:list") (cons (text "shape:cons") (nil Bytes)))) (cons ((text "construct:nil"), (cons (text "value:list") (cons (text "shape:nil") (nil Bytes)))) (cons ((text "construct:pair"), (cons (text "value:pair") (cons (text "shape:pair") (cons (text "expr:call") (nil Bytes))))) rows5)))))); (let rows7 : (List (Bytes * (List Bytes))) := (cons ((text "if"), (cons (text "expr:cond") (cons (text "shape:true") (cons (text "shape:zero") (nil Bytes))))) (cons ((text "match:nat"), (cons (text "shape:zero") (nil Bytes))) (cons ((text "match:list"), (cons (text "shape:nil") (nil Bytes))) (cons ((text "match:option"), (cons (text "shape:none") (nil Bytes))) (cons ((text "match:result"), (cons (text "shape:ok") (nil Bytes))) (cons ((text "match:ordering"), (cons (text "shape:lt") (nil Bytes))) rows6)))))); (let rows8 : (List (Bytes * (List Bytes))) := (cons ((text "match:adt"), (cons (text "shape:adt") (cons (text "expr:field") (nil Bytes)))) (cons ((text "match:empty"), (cons (text "type:fn") (cons (text "type:adt") (cons (text "type:pair") (cons (text "type:result") (nil Bytes)))))) (cons ((text "call:function"), (cons (text "expr:call") (cons (text "export") (nil Bytes)))) (cons ((text "apply"), (cons (text "expr:apply") (nil Bytes))) (cons ((text "widen"), (cons (text "prim:convert") (nil Bytes))) (cons ((text "succeed"), (cons (text "overflow") (nil Bytes))) rows7)))))); (let rows9 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:succ"), (cons (text "shape:succ") (nil Bytes))) (cons ((text "call:runtime:nat_add"), (cons (text "prim:nat_add") (nil Bytes))) (cons ((text "call:runtime:nat_sub"), (cons (text "prim:nat_sub") (nil Bytes))) (cons ((text "call:runtime:nat_mul"), (cons (text "prim:nat_mul") (nil Bytes))) (cons ((text "call:runtime:nat_quot"), (cons (text "prim:nat_quot") (nil Bytes))) (cons ((text "call:runtime:nat_rem"), (cons (text "prim:nat_rem") (nil Bytes))) rows8)))))); (let rows10 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:nat_eq"), (cons (text "prim:nat_eq") (nil Bytes))) (cons ((text "call:runtime:nat_le"), (cons (text "prim:nat_le") (nil Bytes))) (cons ((text "call:runtime:nat_lt"), (cons (text "prim:nat_lt") (nil Bytes))) (cons ((text "call:runtime:int_add"), (cons (text "prim:int_add") (nil Bytes))) (cons ((text "call:runtime:int_sub"), (cons (text "prim:int_sub") (nil Bytes))) (cons ((text "call:runtime:int_mul"), (cons (text "prim:int_mul") (nil Bytes))) rows9)))))); (let rows11 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:int_neg"), (cons (text "prim:int_neg") (nil Bytes))) (cons ((text "call:runtime:int_quot"), (cons (text "prim:int_quot") (nil Bytes))) (cons ((text "call:runtime:int_rem"), (cons (text "prim:int_rem") (nil Bytes))) (cons ((text "call:runtime:bool_not"), (cons (text "prim:bool_not") (nil Bytes))) (cons ((text "call:runtime:bool_and"), (cons (text "prim:bool_and") (nil Bytes))) (cons ((text "call:runtime:bool_or"), (cons (text "prim:bool_or") (nil Bytes))) rows10)))))); (let rows12 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:equal"), (cons (text "prim:equal") (nil Bytes))) (cons ((text "call:runtime:compare"), (cons (text "prim:compare") (nil Bytes))) (cons ((text "call:runtime:checked_add"), (cons (text "prim:checked_add") (nil Bytes))) (cons ((text "call:runtime:checked_sub"), (cons (text "prim:checked_sub") (nil Bytes))) (cons ((text "call:runtime:checked_mul"), (cons (text "prim:checked_mul") (nil Bytes))) (cons ((text "call:runtime:checked_quot"), (cons (text "prim:checked_quot") (nil Bytes))) rows11)))))); (let rows13 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:checked_neg"), (cons (text "prim:checked_neg") (nil Bytes))) (cons ((text "call:runtime:bit_and"), (cons (text "prim:bit_and") (nil Bytes))) (cons ((text "call:runtime:bit_or"), (cons (text "prim:bit_or") (nil Bytes))) (cons ((text "call:runtime:bit_xor"), (cons (text "prim:bit_xor") (nil Bytes))) (cons ((text "call:runtime:bit_not"), (cons (text "prim:bit_not") (nil Bytes))) (cons ((text "call:runtime:shift_left"), (cons (text "prim:shift_left") (nil Bytes))) rows12)))))); (let rows14 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:shift_right"), (cons (text "prim:shift_right") (nil Bytes))) (cons ((text "call:runtime:convert"), (cons (text "prim:convert") (nil Bytes))) (cons ((text "call:runtime:append"), (cons (text "prim:append") (nil Bytes))) (cons ((text "call:runtime:length"), (cons (text "prim:length") (nil Bytes))) (cons ((text "call:runtime:index"), (cons (text "prim:index") (nil Bytes))) (cons ((text "call:runtime:slice"), (cons (text "prim:slice") (nil Bytes))) rows13)))))); (let rows15 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:utf8_encode"), (cons (text "prim:utf8_encode") (nil Bytes))) (cons ((text "call:runtime:utf8_decode"), (cons (text "prim:utf8_decode") (nil Bytes))) (cons ((text "call:runtime:compare_bytes"), (cons (text "prim:compare_bytes") (nil Bytes))) (cons ((text "call:runtime:split_exact"), (cons (text "prim:split_exact") (nil Bytes))) (cons ((text "call:runtime:join"), (cons (text "prim:join") (nil Bytes))) (cons ((text "call:runtime:format_decimal"), (cons (text "prim:format_decimal") (nil Bytes))) rows14)))))); (let rows16 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:parse_decimal"), (cons (text "prim:parse_decimal") (nil Bytes))) rows15); rows16))))))))))))))))), + body: (let rows0 : (List (Bytes * (List Bytes))) := (cons ((text "function"), (cons (text "function") (cons (text "export") (nil Bytes)))) (cons ((text "enum:adt"), (cons (text "type:adt") (nil Bytes))) (cons ((text "enum:closures"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "apply:dispatch"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "let"), (cons (text "expr:let") (cons (text "expr:match") (cons (text "expr:prim") (cons (text "expr:apply") (cons (text "expr:call") (cons (text "expr:closure") (cons (text "expr:cond") (cons (text "expr:field") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "shape:succ") (cons (text "shape:zero") (cons (text "shape:unit") (cons (text "shape:true") (cons (text "indirection") (cons (text "overflow") (nil Bytes))))))))))))))))))))) (cons ((text "read"), (cons (text "expr:var") (cons (text "expr:match") (cons (text "expr:prim") (cons (text "expr:call") (cons (text "expr:apply") (cons (text "expr:closure") (cons (text "expr:first") (cons (text "expr:second") (cons (text "expr:field") (cons (text "expr:cond") (cons (text "shape:true") (cons (text "shape:zero") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "export") (cons (text "type:fn") (cons (text "type:adt") (cons (text "type:pair") (cons (text "type:result") (nil Bytes)))))))))))))))))))))))) (nil (Bytes * (List Bytes))))))))); (let rows1 : (List (Bytes * (List Bytes))) := (cons ((text "box"), (cons (text "indirection") (nil Bytes))) (cons ((text "destructure:pair"), (cons (text "expr:first") (cons (text "expr:second") (cons (text "shape:pair") (cons (text "expr:call") (nil Bytes)))))) (cons ((text "type:unit"), (cons (text "type:unit") (nil Bytes))) (cons ((text "type:bool"), (cons (text "type:bool") (nil Bytes))) (cons ((text "type:nat"), (cons (text "type:nat") (cons (text "type:fixed") (nil Bytes)))) (cons ((text "type:int"), (cons (text "type:int") (cons (text "type:fixed") (nil Bytes)))) rows0)))))); (let rows2 : (List (Bytes * (List Bytes))) := (cons ((text "type:fixed"), (cons (text "type:fixed") (nil Bytes))) (cons ((text "type:ordering"), (cons (text "type:ordering") (nil Bytes))) (cons ((text "type:string"), (cons (text "type:string") (nil Bytes))) (cons ((text "type:bytes"), (cons (text "type:bytes") (nil Bytes))) (cons ((text "type:option"), (cons (text "type:option") (nil Bytes))) (cons ((text "type:result"), (cons (text "type:result") (cons (text "expr:call") (nil Bytes)))) rows1)))))); (let rows3 : (List (Bytes * (List Bytes))) := (cons ((text "type:list"), (cons (text "type:list") (nil Bytes))) (cons ((text "type:pair"), (cons (text "type:pair") (cons (text "expr:call") (nil Bytes)))) (cons ((text "type:adt"), (cons (text "type:adt") (nil Bytes))) (cons ((text "type:fn"), (cons (text "type:fn") (cons (text "expr:closure") (nil Bytes)))) (cons ((text "type:rc"), (cons (text "indirection") (nil Bytes))) (cons ((text "type:fallible"), (cons (text "overflow") (nil Bytes))) rows2)))))); (let rows4 : (List (Bytes * (List Bytes))) := (cons ((text "type:ref"), (cons (text "export") (nil Bytes))) (cons ((text "lit:unit"), (cons (text "value:unit") (cons (text "shape:unit") (cons (text "expr:var") (cons (text "expr:call") (cons (text "expr:apply") (cons (text "expr:closure") (cons (text "shape:some") (cons (text "shape:ok") (cons (text "shape:error") (cons (text "shape:cons") (cons (text "shape:adt") (cons (text "export") (cons (text "overflow") (nil Bytes))))))))))))))) (cons ((text "lit:bool"), (cons (text "value:bool") (cons (text "shape:true") (cons (text "shape:false") (cons (text "expr:cond") (nil Bytes)))))) (cons ((text "lit:nat"), (cons (text "value:nat") (cons (text "shape:zero") (nil Bytes)))) (cons ((text "lit:int"), (cons (text "value:int") (nil Bytes))) (cons ((text "lit:fixed"), (cons (text "value:u8") (cons (text "value:u16") (cons (text "value:u32") (cons (text "value:u64") (cons (text "value:i8") (cons (text "value:i16") (cons (text "value:i32") (cons (text "value:i64") (nil Bytes)))))))))) rows3)))))); (let rows5 : (List (Bytes * (List Bytes))) := (cons ((text "lit:string"), (cons (text "value:string") (nil Bytes))) (cons ((text "lit:bytes"), (cons (text "value:bytes") (nil Bytes))) (cons ((text "lit:ordering"), (cons (text "value:ordering") (cons (text "shape:lt") (cons (text "shape:eq") (cons (text "shape:gt") (nil Bytes)))))) (cons ((text "construct:none"), (cons (text "value:none") (cons (text "shape:none") (nil Bytes)))) (cons ((text "construct:some"), (cons (text "value:some") (cons (text "shape:some") (nil Bytes)))) (cons ((text "construct:ok"), (cons (text "value:ok") (cons (text "shape:ok") (cons (text "expr:call") (nil Bytes))))) rows4)))))); (let rows6 : (List (Bytes * (List Bytes))) := (cons ((text "construct:err"), (cons (text "value:error") (cons (text "shape:error") (cons (text "expr:call") (nil Bytes))))) (cons ((text "construct:adt"), (cons (text "value:adt") (cons (text "shape:adt") (nil Bytes)))) (cons ((text "construct:closure"), (cons (text "expr:closure") (nil Bytes))) (cons ((text "construct:cons"), (cons (text "value:list") (cons (text "shape:cons") (nil Bytes)))) (cons ((text "construct:nil"), (cons (text "value:list") (cons (text "shape:nil") (nil Bytes)))) (cons ((text "construct:pair"), (cons (text "value:pair") (cons (text "shape:pair") (cons (text "expr:call") (nil Bytes))))) rows5)))))); (let rows7 : (List (Bytes * (List Bytes))) := (cons ((text "if"), (cons (text "expr:cond") (cons (text "shape:true") (cons (text "shape:zero") (nil Bytes))))) (cons ((text "match:nat"), (cons (text "shape:zero") (nil Bytes))) (cons ((text "match:list"), (cons (text "shape:nil") (nil Bytes))) (cons ((text "match:option"), (cons (text "shape:none") (nil Bytes))) (cons ((text "match:result"), (cons (text "shape:ok") (nil Bytes))) (cons ((text "match:ordering"), (cons (text "shape:lt") (nil Bytes))) rows6)))))); (let rows8 : (List (Bytes * (List Bytes))) := (cons ((text "match:adt"), (cons (text "shape:adt") (cons (text "expr:field") (nil Bytes)))) (cons ((text "match:empty"), (cons (text "type:fn") (cons (text "type:adt") (cons (text "type:pair") (cons (text "type:result") (nil Bytes)))))) (cons ((text "call:function"), (cons (text "expr:call") (cons (text "export") (nil Bytes)))) (cons ((text "apply"), (cons (text "expr:apply") (nil Bytes))) (cons ((text "widen"), (cons (text "prim:convert") (nil Bytes))) (cons ((text "succeed"), (cons (text "overflow") (nil Bytes))) rows7)))))); (let rows9 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:succ"), (cons (text "shape:succ") (nil Bytes))) (cons ((text "call:runtime:nat_add"), (cons (text "prim:nat_add") (nil Bytes))) (cons ((text "call:runtime:nat_sub"), (cons (text "prim:nat_sub") (nil Bytes))) (cons ((text "call:runtime:nat_mul"), (cons (text "prim:nat_mul") (nil Bytes))) (cons ((text "call:runtime:nat_quot"), (cons (text "prim:nat_quot") (nil Bytes))) (cons ((text "call:runtime:nat_rem"), (cons (text "prim:nat_rem") (nil Bytes))) rows8)))))); (let rows10 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:nat_eq"), (cons (text "prim:nat_eq") (nil Bytes))) (cons ((text "call:runtime:nat_le"), (cons (text "prim:nat_le") (nil Bytes))) (cons ((text "call:runtime:nat_lt"), (cons (text "prim:nat_lt") (nil Bytes))) (cons ((text "call:runtime:int_add"), (cons (text "prim:int_add") (nil Bytes))) (cons ((text "call:runtime:int_sub"), (cons (text "prim:int_sub") (nil Bytes))) (cons ((text "call:runtime:int_mul"), (cons (text "prim:int_mul") (nil Bytes))) rows9)))))); (let rows11 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:int_neg"), (cons (text "prim:int_neg") (nil Bytes))) (cons ((text "call:runtime:int_quot"), (cons (text "prim:int_quot") (nil Bytes))) (cons ((text "call:runtime:int_rem"), (cons (text "prim:int_rem") (nil Bytes))) (cons ((text "call:runtime:bool_not"), (cons (text "prim:bool_not") (nil Bytes))) (cons ((text "call:runtime:bool_and"), (cons (text "prim:bool_and") (nil Bytes))) (cons ((text "call:runtime:bool_or"), (cons (text "prim:bool_or") (nil Bytes))) rows10)))))); (let rows12 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:equal"), (cons (text "prim:equal") (nil Bytes))) (cons ((text "call:runtime:compare"), (cons (text "prim:compare") (nil Bytes))) (cons ((text "call:runtime:checked_add"), (cons (text "prim:checked_add") (nil Bytes))) (cons ((text "call:runtime:checked_sub"), (cons (text "prim:checked_sub") (nil Bytes))) (cons ((text "call:runtime:checked_mul"), (cons (text "prim:checked_mul") (nil Bytes))) (cons ((text "call:runtime:checked_quot"), (cons (text "prim:checked_quot") (nil Bytes))) rows11)))))); (let rows13 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:checked_neg"), (cons (text "prim:checked_neg") (nil Bytes))) (cons ((text "call:runtime:bit_and"), (cons (text "prim:bit_and") (nil Bytes))) (cons ((text "call:runtime:bit_or"), (cons (text "prim:bit_or") (nil Bytes))) (cons ((text "call:runtime:bit_xor"), (cons (text "prim:bit_xor") (nil Bytes))) (cons ((text "call:runtime:bit_not"), (cons (text "prim:bit_not") (nil Bytes))) (cons ((text "call:runtime:shift_left"), (cons (text "prim:shift_left") (nil Bytes))) rows12)))))); (let rows14 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:shift_right"), (cons (text "prim:shift_right") (nil Bytes))) (cons ((text "call:runtime:convert"), (cons (text "prim:convert") (nil Bytes))) (cons ((text "call:runtime:append"), (cons (text "prim:append") (nil Bytes))) (cons ((text "call:runtime:length"), (cons (text "prim:length") (nil Bytes))) (cons ((text "call:runtime:index"), (cons (text "prim:index") (nil Bytes))) (cons ((text "call:runtime:slice"), (cons (text "prim:slice") (nil Bytes))) rows13)))))); (let rows15 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:utf8_encode"), (cons (text "prim:utf8_encode") (nil Bytes))) (cons ((text "call:runtime:utf8_decode"), (cons (text "prim:utf8_decode") (nil Bytes))) (cons ((text "call:runtime:compare_bytes"), (cons (text "prim:compare_bytes") (nil Bytes))) (cons ((text "call:runtime:split_exact"), (cons (text "prim:split_exact") (nil Bytes))) (cons ((text "call:runtime:join"), (cons (text "prim:join") (nil Bytes))) (cons ((text "call:runtime:format_decimal"), (cons (text "prim:format_decimal") (nil Bytes))) rows14)))))); (let rows16 : (List (Bytes * (List Bytes))) := (cons ((text "call:runtime:parse_decimal"), (cons (text "prim:parse_decimal") (nil Bytes))) rows15); (let rows17 : (List (Bytes * (List Bytes))) := (cons ((text "constant"), (cons (text "function") (nil Bytes))) rows16); rows17)))))))))))))))))), executable: true } diff --git a/compiler/src/RustSemantics.lex.tex b/compiler/src/RustSemantics.lex.tex index 6cec2f276d..2d30bd6c42 100644 --- a/compiler/src/RustSemantics.lex.tex +++ b/compiler/src/RustSemantics.lex.tex @@ -1316,7 +1316,8 @@ | List.cons item rest => (match item | RustSyntax::ItemDef.enum ignored533 ignored534 => (findFunction rest wanted) | RustSyntax::ItemDef.apply ignored535 ignored536 ignored537 ignored538 ignored539 => (findFunction rest wanted) - | RustSyntax::ItemDef.function name parameters result body => (if (sameIdent name wanted) then (ctor Option.some [((List RustSyntax::Parameter) * (RustSyntax::RustType * RustSyntax::Block))] (parameters, (result, body))) else (findFunction rest wanted)))), + | RustSyntax::ItemDef.function name parameters result body => (if (sameIdent name wanted) then (ctor Option.some [((List RustSyntax::Parameter) * (RustSyntax::RustType * RustSyntax::Block))] (parameters, (result, body))) else (findFunction rest wanted)) + | RustSyntax::ItemDef.constant constantName constantResult constantBody => (if (sameIdent constantName wanted) then (ctor Option.some [((List RustSyntax::Parameter) * (RustSyntax::RustType * RustSyntax::Block))] ((ctor List.nil [RustSyntax::Parameter]), (constantResult, constantBody))) else (findFunction rest wanted)))), recursive_argument: items } @@ -1341,7 +1342,8 @@ | RustSyntax::ItemDef.apply ignoredFnType ignoredParameters ignoredResult fallible arms => (match (findArm arms function count) | Option.none => (findDispatch rest function count) | Option.some armFallible => (ctor Option.some [(Bool * Bool)] (fallible, armFallible))) - | RustSyntax::ItemDef.function ignored542 ignored543 ignored544 ignored545 => (findDispatch rest function count))), + | RustSyntax::ItemDef.function ignored542 ignored543 ignored544 ignored545 => (findDispatch rest function count) + | RustSyntax::ItemDef.constant ignoredConstantName ignoredConstantResult ignoredConstantBody => (findDispatch rest function count))), recursive_argument: items } diff --git a/compiler/src/RustSyntax.lex.tex b/compiler/src/RustSyntax.lex.tex index f72bfd689d..13ec7b0ebd 100644 --- a/compiler/src/RustSyntax.lex.tex +++ b/compiler/src/RustSyntax.lex.tex @@ -287,7 +287,8 @@ constructors: [ {name: enum, fields: [RustType, (List Variant)]}, {name: apply, fields: [Nat, (List RustType), RustType, Bool, (List Dispatch)]}, - {name: function, fields: [Ident, (List Parameter), RustType, Block]} + {name: function, fields: [Ident, (List Parameter), RustType, Block]}, + {name: constant, fields: [Ident, RustType, Block]} ] } diff --git a/crates/conformance/src/cases/bootstrap/rust_validate.rs b/crates/conformance/src/cases/bootstrap/rust_validate.rs index c3b39084b1..2948e2f9b3 100644 --- a/crates/conformance/src/cases/bootstrap/rust_validate.rs +++ b/crates/conformance/src/cases/bootstrap/rust_validate.rs @@ -448,7 +448,7 @@ fn enc_params(parameters: &[(Pat, Type)]) -> Value { }) } -/// `Def`: enum, apply, function, nil, cons. +/// `Def`: enum, apply, function, nil, cons, constant. fn enc_item_def(item: &ItemDef) -> Value { match item { ItemDef::Enum { name, variants, at } => { @@ -472,19 +472,15 @@ fn enc_item_def(item: &ItemDef) -> Value { enc_origin(at), ], ), - // The bootstrap validator reads a constant as the function of no - // parameters it caches; the rule that its body is a literal is - // `validate.rs`'s alone. ItemDef::Constant { name, result, body, at, } => adt( - 2, + 5, vec![ enc_ident(name), - enc_params(&[]), enc_type(result), enc_block(body), enc_origin(at), @@ -1732,6 +1728,8 @@ fn classify(message: &str) -> &'static str { "dispatch-misstated" } else if has("propagates a failure its result type does not carry") { "propagates-undeclared" + } else if has(" is not an infallible closed literal") { + "constant-shape" } else if has("has no target-semantics correspondence") { "no-row" } else if has("the element it was lowered from") { @@ -1901,6 +1899,71 @@ fn rule_vectors(bases: &[&Rendered], each: usize) -> (Vec, Vec) { (validated, corresponded) } +/// Crates by hand for the rule of a constant (SPEC.md §17.16 *Constants*): a +/// literal the rule accepts, then a call in its body, a result that can fail, +/// and a binding before the literal, each refused by the rule, and a name +/// declared by a constant twice. No lowering builds a constant that breaks the +/// rule, so the mutants never reach it; these make it a vector the validators +/// are held to. +fn constant_crates() -> Vec { + let at = Origin::of; + let literal = || Expr::Construct { + ctor: Ctor::Cons, + args: vec![ + Expr::Lit(Lit::Nat(1), at("value:nat")), + Expr::Construct { + ctor: Ctor::Nil(Type::Nat), + args: Vec::new(), + at: at("construct:nil"), + }, + ], + at: at("construct:cons"), + }; + let constant = |result: Type, body: Block| ItemDef::Constant { + name: Ident::Function(0), + result, + body, + at: at("function"), + }; + let list = || Type::List(Box::new(Type::Nat)); + let crate_of = |items: Vec| Crate { + profile: Profile::Std, + items, + }; + vec![ + crate_of(vec![constant(list(), Block::of(literal()))]), + crate_of(vec![constant( + list(), + Block::of(Expr::Call { + callee: Callee::Function(0), + args: Vec::new(), + propagate: false, + at: at("expr:call"), + }), + )]), + crate_of(vec![constant( + Type::Fallible(Box::new(list())), + Block::of(literal()), + )]), + crate_of(vec![constant( + list(), + Block { + lets: vec![Let { + pat: Pat::Wild, + ty: None, + value: Expr::Lit(Lit::Unit, at("value:unit")), + at: at("let"), + }], + tail: literal(), + }, + )]), + crate_of(vec![ + constant(list(), Block::of(literal())), + constant(list(), Block::of(literal())), + ]), + ] +} + /// Crates by hand for the merge of moved sets at a branch: a name moved on /// one arm of a match, or one branch of an `if`, and used after it. The /// mutants reach this rarely, so these make it a vector. @@ -2840,12 +2903,13 @@ const RULE_VALIDATE_RUNS: usize = 132; const RULE_CORRESPOND_RUNS: usize = 12; const BRANCH_CRATES: usize = 17; const LOOP_CRATES: usize = 34; -const VECTORS_VALIDATE: usize = 406; -const REFUSED_VALIDATE: usize = 165; +const CONSTANT_CRATES: usize = 5; +const VECTORS_VALIDATE: usize = 411; +const REFUSED_VALIDATE: usize = 169; const VECTORS_CORRESPOND: usize = 269; const REFUSED_CORRESPOND: usize = 46; const EVALUATOR_CRATES: usize = 200; -const EVALUATOR_VALIDATE: usize = 383; +const EVALUATOR_VALIDATE: usize = 388; const EVALUATOR_CORRESPOND: usize = 246; const SEEDED_REFUSED_VALIDATE: usize = 271; const SEEDED_REFUSED_CORRESPOND: usize = 244; @@ -2878,15 +2942,23 @@ pub(super) fn case() { ); let bases = small(&all, BASE_CAP); let (mut rule_validate, rule_correspond) = rule_vectors(&bases, RULES_EACH); - let by_hand: Vec = branch_crates().into_iter().chain(loop_crates()).collect(); + let by_hand: Vec = branch_crates() + .into_iter() + .chain(loop_crates()) + .chain(constant_crates()) + .collect(); assert_eq!( (rule_validate.len(), rule_correspond.len()), (RULE_VALIDATE_RUNS, RULE_CORRESPOND_RUNS), "the rule runs: each reachable refusal {RULES_EACH} times" ); assert_eq!( - (branch_crates().len(), loop_crates().len()), - (BRANCH_CRATES, LOOP_CRATES), + ( + branch_crates().len(), + loop_crates().len(), + constant_crates().len(), + ), + (BRANCH_CRATES, LOOP_CRATES, CONSTANT_CRATES), "the hand-built crates" ); rule_validate.extend(by_hand.iter().map(validate_run)); diff --git a/crates/conformance/src/cases/rust_backend.rs b/crates/conformance/src/cases/rust_backend.rs index 1217d439df..441ade8b05 100644 --- a/crates/conformance/src/cases/rust_backend.rs +++ b/crates/conformance/src/cases/rust_backend.rs @@ -1771,6 +1771,34 @@ fn cached_literal() { ); assert!(allocations > 0, "a rebuilt literal allocates at each read"); + // A literal whose type is a declared algebraic type is not a constant, + // although it holds a list: the type says no heap (`Type::heap`), so it + // stays a function that builds the value at each call (SPEC.md §17.16). + { + let int = |n: &str| serde_json::json!({"kind": "int", "value": n}); + let ty = serde_json::json!({"kind": "adt", "index": 0}); + let program = serde_json::json!({ + "adts": [{"constructors": [[{"kind": "list", "element": {"kind": "int"}}]]}], + "functions": [{ + "body": {"kind": "value", "type": ty, "value": { + "kind": "adt", "constructor": 0, + "fields": [{"kind": "list", "items": [int("1"), int("2")]}]}}, + "parameters": [], "result": ty, "types": [] + }], + "spec": "lexlean/target-program/1" + }); + let program = target::load(program.to_string().as_bytes()).expect("the program loads"); + let krate = rust::lower(&program, Profile::Std).expect("the program lowers"); + assert!( + matches!(krate.items.as_slice(), [.., ItemDef::Function { .. }]) + && !krate + .items + .iter() + .any(|item| matches!(item, ItemDef::Constant { .. })), + "a literal of a declared type is a function: {:?}", + krate.items + ); + } // Planted: a constant whose body calls, or that can fail, is refused // before printing. let mut called = cached.clone(); @@ -1784,6 +1812,20 @@ fn cached_literal() { } let error = validate::validate(&called).expect_err("a constant that calls is refused"); assert!(error.contains("constant"), "{error}"); + let mut bound = cached.clone(); + if let ItemDef::Constant { body, .. } = &mut bound.items[0] { + body.lets.push(Let { + pat: Pat::Wild, + ty: None, + value: Expr::Lit(Lit::Unit, Origin::of("value:unit")), + at: Origin::of("let"), + }); + } + let error = validate::validate(&bound).expect_err("a constant with a binding is refused"); + assert!( + error.contains("not an infallible closed literal"), + "{error}" + ); let mut failing = cached; if let ItemDef::Constant { result, .. } = &mut failing.items[0] { *result = Type::Fallible(Box::new(result.clone())); diff --git a/crates/lexlean/src/calculus/rust/validate.rs b/crates/lexlean/src/calculus/rust/validate.rs index 4ccb6d8b85..16ecb71641 100644 --- a/crates/lexlean/src/calculus/rust/validate.rs +++ b/crates/lexlean/src/calculus/rust/validate.rs @@ -1151,7 +1151,6 @@ fn runtime_kind(base: &str) -> String { /// the realized program uses that element. pub const CORRESPONDENCE: &[(&str, &[&str])] = &[ ("function", &["function", "export"]), - ("constant", &["function"]), ("enum:adt", &["type:adt"]), ("enum:closures", &["type:fn", "expr:closure"]), ("apply:dispatch", &["type:fn", "expr:closure"]), @@ -1341,6 +1340,7 @@ pub const CORRESPONDENCE: &[(&str, &[&str])] = &[ ("call:runtime:join", &["prim:join"]), ("call:runtime:format_decimal", &["prim:format_decimal"]), ("call:runtime:parse_decimal", &["prim:parse_decimal"]), + ("constant", &["function"]), ]; fn row(construct: &str) -> Result<&'static [&'static str], String> { diff --git a/crates/lexlean/src/production/certificate/data_b/syntax.rs b/crates/lexlean/src/production/certificate/data_b/syntax.rs index c759c2ba89..11b9b54ca7 100644 --- a/crates/lexlean/src/production/certificate/data_b/syntax.rs +++ b/crates/lexlean/src/production/certificate/data_b/syntax.rs @@ -606,8 +606,6 @@ impl Writer<'_, '_> { &[fn_type, parameters, result, fallible, arms], ) } - // The machine reads a constant as the function of no parameters - // it caches: its value is the body's, whenever it is computed. ItemDef::Constant { name, result, @@ -615,10 +613,9 @@ impl Writer<'_, '_> { at: _, } => { let name = self.rs_ident(name); - let parameters = self.rs_parameters(&[]); let result = self.rs_type(result); let body = self.rs_block(body); - self.rs_apply("ItemDef.function", &[name, parameters, result, body]) + self.rs_apply("ItemDef.constant", &[name, result, body]) } ItemDef::Function { name, diff --git a/features/suites/bootstrap.feature b/features/suites/bootstrap.feature index 39ee8de1f1..625f346111 100644 --- a/features/suites/bootstrap.feature +++ b/features/suites/bootstrap.feature @@ -31,7 +31,7 @@ Feature: bootstrap And every planted defect is detected, and every exported package is byte-identical to its committed package and realizes the lowered program @BS-05 @build - Scenario: The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, and for 34 hand-built crates of the loop rules (406 `validateCrate` runs, 165 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. + Scenario: The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. Given the committed `bootstrap` project, the crates the Rust renderer lowers from every committed target program, the refusals the seeded rule runs and the hand-built crates give, and the Rust validator `calculus::rust::validate` as the oracle When the project is checked and built, both roots' lowered programs are run by the evaluator on those crates and a seeded mutation corpus, both roots' rendered rust-std packages are run on those crates and the large seeded corpus, a defect is planted in the source, and the project is exported through the production pipeline Then both roots are eligible for rust-std with exactly their declared effects and no run disagrees with the oracle diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index 29d00b96e9..66d18f151a 100644 --- a/features/suites/rust-backend.feature +++ b/features/suites/rust-backend.feature @@ -95,7 +95,7 @@ Feature: rust-backend And every other template renders as a call and keeps `recursion = true`, and a template rendered with a self call it could have as a loop, or a row that disagrees with its rendering, is refused @RB-18 @build - Scenario: A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations. - Given a program whose function of no parameters is a list literal over int, rendered in both profiles, and copies that rebuild the literal at each read, call from a constant's body, or make a constant fallible - When the rust-std rendering is compiled by the pinned rustc with warnings denied and read three times under a counting allocator - Then the constant is one thread-local cell, a read returns the denotation's value and allocates nothing, rust-core refuses the literal, and each copy is detected or refused + Scenario: A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations. + Given a program whose function of no parameters is a list literal over int, one whose literal has a declared algebraic type, rendered in both profiles, copies that rebuild the literal at each read, and committed crates that give a constant a call, a failing result, or a binding + When the rust-std rendering is compiled by the pinned rustc with warnings denied, read once to warm and then twice under a counting allocator, and the crates are validated by the oracle and by the bootstrap validator + Then the literal is one thread-local cell, a read returns the denotation's value and allocates nothing, the algebraic literal stays a function, rust-core refuses the heap literal, certificate B states the constant, and the rebuilding copy and each committed crate are detected or refused by both validators diff --git a/language/preservation-1.2/library/src/RustMatches.lex.tex b/language/preservation-1.2/library/src/RustMatches.lex.tex index 65f96c098e..001a8618b1 100644 --- a/language/preservation-1.2/library/src/RustMatches.lex.tex +++ b/language/preservation-1.2/library/src/RustMatches.lex.tex @@ -2049,7 +2049,7 @@ reducibility: abbrev{}, transparency: implicit-reducible } -abbrev LexLeanPreservation.Rust.findDispatch_some._f : @80202 := @82034 { +abbrev LexLeanPreservation.Rust.findDispatch_some._f : @80202 := @161967 { all: [LexLeanPreservation.Rust.findDispatch_some._f], class: false, generated: false, @@ -56615,7 +56615,9 @@ @80317 := proof(proof(@80311 @10) @11) @80318 := @80315 @80317 @80319 := @80067 @12 -@80326 := @80038 (@80039 (@80319 @80) @72 @70) (@80044 @66) +@80324 := @80038 (@80039 (@80319 @80) @72 @70) +@80325 := @80044 @66 +@80326 := @80324 @80325 @80327 := @80067 @66 @80331 := @2647 (@80144 (@80327 @133) @80151) @80335 := @2647 (@79546 @133) (@79554 @124) @@ -57001,7 +57003,8 @@ (fun (arms : @79436) => @2647 (@80144 (@80067 (@81083 @338 @397 @133 @124) @377) @80151) @80713)))))) @12 -@81112 := @80140 (fun (arms : @79436) => @2647 (@80144 @370 @80510) @80755) +@81107 := @80144 @370 +@81112 := @80140 (fun (arms : @79436) => @2647 (@81107 @80510) @80755) @81113 := fun (fal : @114) => @81112 @81114 := @80504 @81113 @81115 := @80139 @81113 @@ -57272,29 +57275,32 @@ @81617 := LexLeanTarget.RustSyntax.ItemDef.function @81622 := @81616 (@81617 @61 @10 @11 @12) @81626 := proof(proof(proof(proof(@81617 @57) @61) @10) @11) -@81651 := @80315 - @81626 - (fun (item : @80033) => - (h : @80038 (@80039 (@80319 @83) @76 @80) @80898) -> - @4921 - (fun (ft : @1) => - @80137 - (fun (ps : @80136) => - @80138 - (fun (r : @4699) => - @80139 - (fun (fal : @114) => - @80140 (fun (arms : @79436) => @2647 (@80144 (@80327 @338) @80151) @80437)))))) -@81659 := @80038 (@80039 (@80067 @81626 @76) @80 @72) (@80044 @70) +@81627 := @80315 @81626 +@81650 := fun (item : @80033) => + (h : @80038 (@80039 (@80319 @83) @76 @80) @80898) -> + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 (fun (arms : @79436) => @2647 (@80144 (@80327 @338) @80151) @80437))))) +@81651 := @81627 @81650 +@81657 := @80038 (@80039 (@80067 @81626 @76) @80 @72) +@81658 := @80044 @70 +@81659 := @81657 @81658 @81670 := @80137 (fun (ps : @80136) => @80138 (fun (r : @4699) => @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80453 @80151) @80467)))) @81671 := fun (ft : @1) => @81670 -@81701 := @9397 - @81671 - (fun (x : @4921 @81671) => +@81672 := @9397 @81671 +@81673 := @4921 @81671 +@81695 := @81672 + (fun (x : @81673) => @4921 (fun (ft : @1) => @80137 @@ -57306,14 +57312,16 @@ @80140 (fun (arms : @79436) => @2647 (@80144 (@80067 (@81617 @83 @76 @80 @72) @338) @80151) @80437)))))) - (proof(proj PProd PProd.fst 0 @66) @76 @80 @72 @12) +@81700 := proof(proj PProd PProd.fst 0 @66) @76 @80 @72 @12 +@81701 := @81695 @81700 @81710 := @80138 (fun (r : @4699) => @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80505 @80411) @80437))) @81711 := fun (ps : @80136) => @81710 -@81736 := @80405 - @81711 - (fun (x : @80137 @81711) => +@81712 := @80405 @81711 +@81713 := @80137 @81711 +@81736 := @81712 + (fun (x : @81713) => @4921 (fun (ft : @1) => @80137 @@ -57328,9 +57336,10 @@ @12 @81743 := @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80548 @80458) @80562)) @81744 := fun (r : @4699) => @81743 -@81769 := @80452 - @81744 - (fun (x : @80138 @81744) => +@81745 := @80452 @81744 +@81746 := @80138 @81744 +@81769 := @81745 + (fun (x : @81746) => @4921 (fun (ft : @1) => @80137 @@ -57426,72 +57435,60 @@ @81925 := @81617 @326 @338 @397 @133 @81934 := @80736 (fun (arms : @79436) => @2647 (@80144 (@80067 @81925 @377) @80746) @80713) @61 @81935 := @81784 @80764 -@81940 := @6085 @81935 (@79536 (fun (d : @79435) => @80769 @80577)) +@81936 := @6085 @81935 +@81939 := @79536 (fun (d : @79435) => @80769 @80577) +@81940 := @81936 @81939 @81941 := @2283 @81935 @81942 := @1134 @81935 @81943 := @80776 @81781 @81944 := @2621 @81943 @81945 := @81140 @80764 @81946 := @81944 @81945 +@81952 := @81942 @81946 @2760 (@80784 @81781 @395 @80764) +@81955 := @1134 @81946 @80791 @2760 +@81970 := @3283 + @81944 + @80790 + @81945 + @2760 + (@2663 @81943 @337 @2621 (@1246 @81943 (fun (h : @81943) => @1248 (@80806 @81925 @12)))) +@81972 := @18024 @81945 @11 +@82005 := @81651 + (fun (h : @81659) => + @81701 + (fun (ft : @1) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#276 : @81670) => + @81736 + (fun (ps : @80136) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#277 : @81710) => + @81769 + (fun (r : @4699) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#278 : @81743) => + @81800 + (fun (fal : @114) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#279 : @81774) => + @81829 + (fun (arms : @79436) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#280 : @81803) => + @81860 + (fun (hm : @81830) => + fun (hd : @81863) => + @81884 + (@81896 + (@81913 + (@81921 + (@81934 + (@81940 (@81941 (@81952 (@81955 (@81970 @81972) @80818))) @12)))))))))))) + @83 +@82006 := @80850 @83 @82016 := @81613 (fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#26.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#257 : @182) => fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#28.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#258 : @81615) => fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#33.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#259 : @4699) => fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#35.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#260 : @4867) => fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#261 : @81622) => - @81651 - (fun (h : @81659) => - @81701 - (fun (ft : @1) => - fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#276 : @81670) => - @81736 - (fun (ps : @80136) => - fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#277 : @81710) => - @81769 - (fun (r : @4699) => - fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#278 : @81743) => - @81800 - (fun (fal : @114) => - fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#279 : @81774) => - @81829 - (fun (arms : @79436) => - fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#280 : @81803) => - @81860 - (fun (hm : @81830) => - fun (hd : @81863) => - @81884 - (@81896 - (@81913 - (@81921 - (@81934 - (@81940 - (@81941 - (@81942 - @81946 - @2760 - (@80784 @81781 @395 @80764) - (@1134 - @81946 - @80791 - @2760 - (@3283 - @81944 - @80790 - @81945 - @2760 - (@2663 - @81943 - @337 - @2621 - (@1246 - @81943 - (fun (h : @81943) => @1248 (@80806 @81925 @12)))) - (@18024 @81945 @11)) - @80818))) - @12)))))))))))) - @83 - (@80850 @83 @81626 @12) - @66) + @82005 (@82006 @81626 @12) @66) +@82018 := proof(@53 @80033) @66 @82034 := fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#90 : @80034) => fun (f : @80177) => fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#91 : @1) => @@ -57506,7 +57503,7 @@ fun (x : @80036) => fun (h : @80074) => fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#407 : @80280) => - @82016 (proof(@53 @80033) @66)) + @82016 @82018) @57 @82039 := {items : @80034} -> {f : @1} -> {k : @1} -> {x : @80036} -> (a._@._internal._hyg.#0 : @80046) -> @80170 @@ -75910,7 +75907,8 @@ (fun (x._@.LexLeanPreservation.RustMatches.#3797461251._hygCtx._hyg.#301 : @2530) => (hb : @111524) -> @2621 (@111525 @111054) (@111525 @79084)) @111533 := @111506 @2784 -@111535 := (proj PProd PProd.fst 0 @63) @83 +@111534 := proj PProd PProd.fst 0 @63 +@111535 := @111534 @83 @111537 := @110474 @401 @395 @111539 := @107151 @124 @99 @111540 := @111537 @111539 @@ -106560,5 +106558,422 @@ proof(proof(@148337 @147817) @147845)) proof(proof(@148337 @147816) @147830)) @147860))))))))))))) +@161285 := LexLeanTarget.RustSyntax.ItemDef.constant +@161286 := @161285 @61 +@161289 := @81616 (@161286 @11 @12) +@161292 := @161285 @57 @10 @11 +@161294 := @80315 @161292 @81650 +@161301 := @80038 (@80039 (@80067 @161292 @76) @80 @72) @81658 +@161323 := @81672 + (fun (x : @81673) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @83 @80 @72) @338) @80151) @80437)))))) + @81700 +@161345 := @81712 + (fun (x : @81713) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @99 @83 @76) @346) @80151) @80489)))))) + @12 +@161367 := @81745 + (fun (x : @81746) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @133 @99 @79) @396) @80151) @80532)))))) + @12 +@161368 := @161285 @338 +@161370 := @161368 @133 @124 +@161373 := @80144 (@80067 @161370 @395) +@161389 := @81776 + (fun (x : @81777) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161373 @80151) @80580)))))) + @12 +@161390 := @161285 @346 +@161395 := @80144 (@80067 (@161390 @338 @397) @393) +@161411 := @81805 + (fun (x : @81806) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161395 @80151) @80625)))))) + @12 +@161412 := @161285 @396 +@161417 := @80144 (@80067 (@161412 @346 @326) @469) +@161433 := @81835 + (fun (x : @81837) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161417 @80151) @81311)))))) + @12 +@161453 := @6082 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @370 @353 @346) @385) @80151) @81163))))) + @83 +@161465 := @80676 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161417 @80681) @81311)))) + @80 +@161466 := @161285 @353 +@161481 := @80694 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => @2647 (@80144 (@80067 (@161466 @326 @338) @401) @80704) @80663))) + @70 +@161489 := @80722 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161395 @80727) @80625)) + @63 +@161490 := @161285 @326 +@161492 := @161490 @397 @133 +@161501 := @80736 (fun (arms : @79436) => @2647 (@80144 (@80067 @161492 @377) @80746) @80713) @61 +@161502 := @161373 @80764 +@161504 := @6085 @161502 @81939 +@161505 := @2283 @161502 +@161506 := @1134 @161502 +@161507 := @80776 @161370 +@161508 := @2621 @161507 +@161509 := @161508 @81945 +@161571 := fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#261 : @161289) => + @161294 + (fun (h : @161301) => + @161323 + (fun (ft : @1) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#276 : @81670) => + @161345 + (fun (ps : @80136) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#277 : @81710) => + @161367 + (fun (r : @4699) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#278 : @81743) => + @161389 + (fun (fal : @114) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#279 : @81774) => + @161411 + (fun (arms : @79436) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#280 : @81803) => + @161433 + (fun (hm : @81830) => + fun (hd : @81863) => + @161453 + (@161465 + (@161481 + (@161489 + (@161501 + (@161504 + (@161505 + (@161506 + @161509 + @2760 + (@80784 @161370 @395 @80764) + (@1134 + @161509 + @80791 + @2760 + (@3283 + @161508 + @80790 + @81945 + @2760 + (@2663 + @161507 + @337 + @2621 + (@1246 + @161507 + (fun (h : @161507) => @1248 (@80806 @161492 @12)))) + @81972) + @80818))) + @12)))))))))))) + @83 + (@82006 @161292 @12) + @66 +@161576 := @80282 @80 (@161285 @10 @11 @12) +@161578 := @161286 @10 @11 +@161603 := @80315 + @161578 + (fun (item : @80033) => + (h : @80038 (@80039 (@80319 @76) @80 @72) @81658) -> + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 (fun (arms : @79436) => @2647 (@80144 (@80327 @397) @80151) @80467)))))) +@161610 := @80038 (@80039 (@80067 @161578 @80) @72 @70) @80325 +@161621 := @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80406 @80151) @80338)))) +@161622 := fun (ft : @1) => @161621 +@161650 := @9397 + @161622 + (fun (x : @4921 @161622) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @76 @80 @72) @397) @80151) @80467)))))) + (@111534 @80 @72 @70 @12) +@161659 := @80138 + (fun (r : @4699) => + @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80453 @80411) @80467))) +@161660 := fun (ps : @80136) => @161659 +@161684 := @80405 + @161660 + (fun (x : @80137 @161660) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @79 @83 @76) @326) @80151) @80562)))))) + @12 +@161691 := @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@80505 @80458) @80437)) +@161692 := fun (r : @4699) => @161691 +@161716 := @80452 + @161692 + (fun (x : @80138 @161692) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161285 @124 @99 @79) @353) @80151) @80951)))))) + @12 +@161721 := @80140 (fun (arms : @79436) => @2647 (@80548 @80510) @80562) +@161722 := fun (fal : @114) => @161721 +@161723 := @80504 @161722 +@161724 := @80139 @161722 +@161727 := @161285 @397 @133 @124 +@161730 := @80144 (@80067 @161727 @370) +@161746 := @161723 + (fun (x : @161724) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161730 @80151) @80755)))))) + @12 +@161749 := @2647 (@80595 @80553) @80489 +@161750 := fun (arms : @79436) => @161749 +@161751 := @80547 @161750 +@161752 := @80140 @161750 +@161757 := @80144 (@80067 (@161490 @338 @397) @377) +@161773 := @161751 + (fun (x : @161752) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161757 @80151) @80713)))))) + @12 +@161774 := @81036 @80600 +@161775 := @4846 @161774 +@161778 := @79536 (fun (d : @79435) => @80605 @80646) +@161779 := @161775 @161778 +@161781 := @2647 @161774 @161778 +@161786 := @80144 (@80067 (@161466 @346 @326) @401) +@161802 := @161779 + (fun (x : @161781) => + @4921 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161786 @80151) @80663)))))) + @12 +@161805 := @79536 (fun (d : @79435) => @80642 @80529) +@161824 := @6082 + (fun (ft : @1) => + @80137 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => + @2647 (@80144 (@80067 (@161412 @353 @346) @469) @80151) @81311))))) + @83 +@161836 := @80676 + (fun (ps : @80136) => + @80138 + (fun (r : @4699) => + @80139 (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161786 @80681) @80663)))) + @80 +@161851 := @80694 + (fun (r : @4699) => + @80139 + (fun (fal : @114) => + @80140 + (fun (arms : @79436) => @2647 (@80144 (@80067 (@161390 @326 @338) @393) @80704) @80625))) + @70 +@161859 := @80722 + (fun (fal : @114) => @80140 (fun (arms : @79436) => @2647 (@161757 @80727) @80713)) + @63 +@161861 := @161368 @397 @133 +@161870 := @80736 (fun (arms : @79436) => @2647 (@80144 (@80067 @161861 @395) @80746) @80580) @61 +@161871 := @161730 @80764 +@161876 := @6085 @161871 (@79536 (fun (d : @79435) => @80769 @80752)) +@161877 := @2283 @161871 +@161878 := @1134 @161871 +@161879 := @80776 @161727 +@161880 := @2621 @161879 +@161881 := @81107 @80764 +@161882 := @161880 @161881 +@161952 := @82016 + (fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#26.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#257 : @182) => + fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#33.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#259 : @4699) => + fun (x._@.LexLeanTarget.RustSyntax.#3179855659._hygCtx.#35.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#260 : @4867) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#261 : @161576) => + @161603 + (fun (h : @161610) => + @161650 + (fun (ft : @1) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#276 : @161621) => + @161684 + (fun (ps : @80136) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#277 : @161659) => + @161716 + (fun (r : @4699) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#278 : @161691) => + @161746 + (fun (fal : @114) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#279 : @161721) => + @161773 + (fun (arms : @79436) => + fun (h._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#280 : @161749) => + @161802 + (fun (hm : @161774) => + fun (hd : @161805) => + @161824 + (@161836 + (@161851 + (@161859 + (@161870 + (@161876 + (@161877 + (@161878 + @161882 + @2760 + (@80784 @161727 @370 @80764) + (@1134 + @161882 + @80791 + @2760 + (@3283 + @161880 + @80790 + @161881 + @2760 + (@2663 + @161879 + @337 + @2621 + (@1246 + @161879 + (fun (h : @161879) => @1248 (@80806 @161861 @12)))) + (@18024 @161881 @11)) + @80818))) + @12)))))))))))) + @76 + (@80850 @76 @161578 @12) + @63) + @82018 +@161967 := fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#90 : @80034) => + fun (f : @80177) => + fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#91 : @1) => + fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#92 : @1) => + fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#93 : @80036) => + fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#94 : @80182) => + @80279 + (fun (item : @80033) => + fun (rest : @80034) => + fun (f : @1) => + fun (k : @1) => + fun (x : @80036) => + fun (h : @80074) => + fun (x._@.LexLeanPreservation.RustMatches.#3727410275._hygCtx._hyg.#407 : @80280) => @161952) + @57 \end{coremodule} \end{lexlean} diff --git a/model/ids.toml b/model/ids.toml index 80b45b5da3..57ac766d25 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1796,7 +1796,7 @@ statement = "A library template whose self calls are all tail calls is rendered id = "RB-18" level = "build" suite = "rust-backend" -statement = "A function of no parameters that cannot fail and whose body is a closed literal holding heap storage is a constant in rust-std, a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a production root reads a decoded constant without rebuilding it and a read allocates nothing; the machine reads a constant as the function it caches, rust-core has no rendering of it, and a constant whose body calls, or that can fail, is refused before printing, while a rendering that rebuilds the literal at each read is detected by counting its allocations." +statement = "A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations." [[id]] id = "GN-01" @@ -2540,7 +2540,7 @@ statement = "The target calculus's checker of SPEC.md §17.14 (`lexlean::calculu id = "BS-05" level = "build" suite = "bootstrap" -statement = "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, and for 34 hand-built crates of the loop rules (406 `validateCrate` runs, 165 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim." +statement = "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim." [[id]] id = "PK-01" diff --git a/spec/src/IdsBS.lex.tex b/spec/src/IdsBS.lex.tex index 5a437e539d..b93bd64beb 100644 --- a/spec/src/IdsBS.lex.tex +++ b/spec/src/IdsBS.lex.tex @@ -40,7 +40,7 @@ name: bs05, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "BS-05", level := "build", suite := "bootstrap", statement := "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, and for 34 hand-built crates of the loop rules (406 `validateCrate` runs, 165 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim.", sections := "§17.16, §17.23"}), + body: (record Rows::IdRow {id := "BS-05", level := "build", suite := "bootstrap", statement := "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim.", sections := "§17.16, §17.23"}), executable: true } \end{semanticmodule} diff --git a/spec/src/IdsRB.lex.tex b/spec/src/IdsRB.lex.tex index a957646668..27d3b83a3c 100644 --- a/spec/src/IdsRB.lex.tex +++ b/spec/src/IdsRB.lex.tex @@ -120,7 +120,7 @@ name: rb18, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "RB-18", level := "build", suite := "rust-backend", statement := "The Rust backend renders each closed data literal of a program once per thread and a read of it as a clone of that value, so that a production root reads a constant without rebuilding it, and the counted work of a read never exceeds the denotation's steps; a rendering that rebuilds the literal at each read is detected by the work gate.", sections := "§17.16"}), + body: (record Rows::IdRow {id := "RB-18", level := "build", suite := "rust-backend", statement := "A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations.", sections := "§17.16"}), executable: true } \end{semanticmodule} From 775bba06525f676557463a13c2d4900bf450873b Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 16:20:20 +0000 Subject: [PATCH 09/21] Merge the reworked RB-18 into the lowering; SP-24 and MD-14 rows in spec/src; certificate B states the machine's constant Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- SPEC.md | 6 ++++-- VERIFICATION.md | 3 ++- spec/src/IdsMD.lex.tex | 2 +- spec/src/IdsSP.lex.tex | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/SPEC.md b/SPEC.md index db0016fdcc..f1878d30ab 100644 --- a/SPEC.md +++ b/SPEC.md @@ -5958,8 +5958,10 @@ call, and the `rust-std` rendering holds it as a constant built once per thread (§17.16 *Constants*). Certificate A relates the source's construction of the list to the literal by the lemma that relates any literal to its value (`conv_value`, stated for every `Value`), so the preservation library has no -new lemma and `Corr` no new constructor; certificate B reads the constant as -the function of no parameters it caches. +new lemma and `Corr` no new constructor; certificate B encodes the constant as +the machine's `ItemDef.constant` (§17.16 *Constants*), whose function the +machine finds by the same lookup as any function, so the derivation of a +constant is the derivation of a function of no parameters over its literal. **A function rendered as a loop** (`SP-20`). The renderer writes a function whose self calls are all tail calls as a loop (§17.16), so the crate no longer holds diff --git a/VERIFICATION.md b/VERIFICATION.md index efebeceb01..b2c88fd7ae 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4115,7 +4115,8 @@ Models.Main.classify: `Recognizer.outputBias` is built on each call, not held as per-call check names; the second is unequal to the closed schemas' decoding of the artifact's bytes, which the case computes from the file alone. -3. In certificate A of a root that holds a literal, every `conv_value` was +3. Certificate B and E: `conformance_sp_24` stages and compiles the certificates of every root of the models example with the crate's ten constants encoded as `ItemDef.constant`, over the regenerated machine modules and the repaired library held in the working tree only (289 s, with `conformance_md_14`). +4. In certificate A of a root that holds a literal, every `conv_value` was replaced by `conv_var`. `conformance_sp_24` compiles the planted module under the pinned Lean and requires it to be refused. diff --git a/spec/src/IdsMD.lex.tex b/spec/src/IdsMD.lex.tex index 17b604eb32..544b8977b9 100644 --- a/spec/src/IdsMD.lex.tex +++ b/spec/src/IdsMD.lex.tex @@ -112,7 +112,7 @@ name: md14, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "MD-14", level := "build", suite := "models", statement := "The lowered program of a production root reading an artifact contains the artifact's decoded value as data equal to the decoding of its bytes and no per-call construction of it, and a root whose lowered program decodes or builds the value on a call is detected.", sections := "§17.12"}), + body: (record Rows::IdRow {id := "MD-14", level := "build", suite := "models", statement := "The lowered program of a production root reading an artifact holds the artifact's decoded value as a literal equal to the decoding of its bytes by the closed schemas, and no function of no parameters builds a list with constructors on a call; a literal turned back into its chain, or with one element changed, is detected, and a lowering that stops folding artifacts is refused by the case.", sections := "§17.12"}), executable: true } \end{semanticmodule} diff --git a/spec/src/IdsSP.lex.tex b/spec/src/IdsSP.lex.tex index c310b53b8b..dfb82383bd 100644 --- a/spec/src/IdsSP.lex.tex +++ b/spec/src/IdsSP.lex.tex @@ -168,7 +168,7 @@ name: sp24, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "SP-24", level := "build", suite := "preservation", statement := "A production root that reads a content-addressed artifact lowers the artifact's decoded value as a data literal and not as a nullary function whose body builds it, and certificates A, B, and E cover the data literal on every committed root, so that no lowered program evaluates a build chain for an artifact on any call; a lowering that rebuilds the value per call is refused.", sections := "§17.17"}), + body: (record Rows::IdRow {id := "SP-24", level := "build", suite := "preservation", statement := "A production root that reads a content-addressed artifact holds the artifact's decoded value as one literal in its lowered program, recognised by the artifact declaration and not by the shape of a term, and certificates A, B, and E verify for every root of the committed models example, certificate A relating the source's construction of the list to the literal by the lemma that relates any literal to its value, so that the preservation library does not grow; a wrong lemma for the literal is refused by Lean.", sections := "§17.17"}), executable: true } \end{semanticmodule} From ae95b28087476f1cfc88f7a144d81d72723440e1 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 17:01:55 +0000 Subject: [PATCH 10/21] TC-08: the library follows the denotation (sem_value spells Outcome.value v (weight v)) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- VERIFICATION.md | 16 +++++ .../library/src/RustLemmas.lex.tex | 66 +++++++++++-------- 2 files changed, 55 insertions(+), 27 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 4baa867090..9677be0a78 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4041,6 +4041,22 @@ with a literal heavier than one node (and `compiler/lexlean.lock`) still hold the bytes written before TC-08, so `conformance_tc_01`, `conformance_tc_03`, `conformance_tc_04`, and `conformance_tc_05` fail on this tree until they are rewritten. + +**The library follows the denotation.** With `TargetSemantics.lean` regenerated +from the changed source (held in the working tree only) `conformance_sp_13`, +which compiles the 13 library modules over the machine modules, refused +`RustLemmas` at `LexLeanPreservation.Rust.sem_value`: the term applies +`congrArg` to `eval.eq_2` with the explicit argument `Outcome.value v 1`, which +the new equation lemma no longer states. The repair rewrites that argument to +`Outcome.value v (weight v)` (one occurrence, on the module's data, written back +in the notation). The loader stops at the first refusal, so the count was found +by iteration: after the one repair `conformance_sp_13` passes over all 13 +modules (no second refusal), and `conformance_sp_14`, `conformance_sp_15` (the +four corpora's certificates A as data and the production example verified under +Lean) and `conformance_sp_16` pass over the same regenerated module. The +examples' and `compiler/`'s locks were refreshed locally for these runs and are +not committed. + ### kernel-opaque classification is observed Probe: `compare_bytes` and byte equality were both treated as reducible, and diff --git a/language/preservation-1.2/library/src/RustLemmas.lex.tex b/language/preservation-1.2/library/src/RustLemmas.lex.tex index 68296d249d..ec0e052d85 100644 --- a/language/preservation-1.2/library/src/RustLemmas.lex.tex +++ b/language/preservation-1.2/library/src/RustLemmas.lex.tex @@ -6637,7 +6637,7 @@ tags: [recursive], transparency: semireducible } -theorem LexLeanPreservation.Rust.sem_value : @364016 := @364223 { +theorem LexLeanPreservation.Rust.sem_value : @364016 := @397055 { all: [LexLeanPreservation.Rust.sem_value], class: false, generated: false, @@ -294552,6 +294552,17 @@ @364170 := proof(@1093 @364166) @364171 := proof(@23840 @638) @364172 := proof(@23828 @364171) +@364175 := proof(proof(@364170 proof(@364172 @130388)) @364168) +@364177 := proof(proof(@37899 @364165) @364172) +@364180 := proof(proof(proof(@37904 @364164) @364171) @23828) +@364185 := proof(@37910 proof(proof(proof(proof(@23830 @40758) @618) @53) @364162)) +@364188 := proof(proof(@364185 proof(@48773 @311)) @37931) +@364194 := proof(proof(proof(proof(proof(proof(LexLeanTarget.TargetSemantics.eval.eq_2) @618) @53) + @610) + @51) + @203) +@364199 := proof(@364175 proof(proof(@364177 proof(@364180 proof(@364188 @364194))) @130388)) +@364201 := proof(proof(@38106 @638) @21) @364223 := proof(fun {p : @847} => proof(fun {c : @13} => proof(fun {A : @848} => @@ -294570,32 +294581,7 @@ proof(fun (ho : @364023) => proof(fun (hs : @24323) => proof(proof(@364159 - proof(proof(@364169 - proof(proof(proof(proof(@364170 - proof(@364172 @130388)) - @364168) - proof(proof(proof(proof(@37899 @364165) - @364172) - proof(proof(proof(proof(@37904 @364164) - @364171) - @23828) - proof(proof(proof(proof(@37910 - proof(proof(proof(proof(@23830 - @40758) - @618) - @53) - @364162)) - proof(@48773 @311)) - @37931) - proof(proof(proof(proof(proof(proof(LexLeanTarget.TargetSemantics.eval.eq_2) - @618) - @53) - @610) - @51) - @203)))) - @130388)) - proof(proof(@38106 @638) @21))) - @23)) + proof(proof(@364169 proof(@364199 @364201)) @23)) @5)))))))))))))))))) @364241 := {p : @847} -> {c : @13} -> @@ -317260,5 +317246,31 @@ @396824 @396989 @395839 +@397055 := fun {p : @847} => + fun {c : @13} => + fun {A : @848} => + fun {n : @145} => + fun {Γ : @109198} => + fun {fl : @549} => + fun {t : @852} => + fun {v : @69} => + fun {r : @49} => + fun (hl : @143499) => + fun (ht : @363996) => + fun (env : @23751) => + fun (renv : @28457) => + fun (he : @230630) => + fun (o : @528) => + fun (ho : @364023) => + fun (hs : @24323) => + @364159 + (@364169 + (@364175 + (@364177 + (@364180 (@364185 (@48773 (LexLeanTarget.TargetSemantics.weight @203)) @37931 @364194)) + @130388) + @364201) + @23) + @5 \end{coremodule} \end{lexlean} From b1ec3d6ed9b3b0eb4336cf29c19b89ed81a21069 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 17:16:40 +0000 Subject: [PATCH 11/21] TC-08: the case reads a result literal, as its statement names one Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- crates/conformance/src/cases/calculus.rs | 5 +++++ features/suites/calculus.feature | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/conformance/src/cases/calculus.rs b/crates/conformance/src/cases/calculus.rs index e4b4c98ee4..d1a97435c0 100644 --- a/crates/conformance/src/cases/calculus.rs +++ b/crates/conformance/src/cases/calculus.rs @@ -1593,6 +1593,11 @@ fn literal_weight() { "left": {"kind": "list", "items": [nat("1"), nat("2")]}, "right": {"kind": "some", "value": {"kind": "string", "value": "a"}}}), ), + ( + "result", + json!({"kind": "result", "ok": {"kind": "nat"}, "error": {"kind": "string"}}), + json!({"kind": "ok", "value": nat("3")}), + ), ( "adt", json!({"kind": "adt", "index": 0}), diff --git a/features/suites/calculus.feature b/features/suites/calculus.feature index 58c87f0a88..efe745883d 100644 --- a/features/suites/calculus.feature +++ b/features/suites/calculus.feature @@ -53,6 +53,6 @@ Feature: calculus @TC-08 @build Scenario: A literal of the production calculus, a scalar or a list, pair, option, result, or algebraic-data value of literals, is charged its weight, one per node plus a string's characters and a byte string's bytes, once each time it is read, in the kernel-checked denotation, in the reference interpreter, and in the cost rules of §17.14, so that a scalar literal still costs one step and a decoded constant is data whose read is accounted by its size and never by a single step; a literal of the wrong type, a malformed member, or a noncanonical spelling is refused with LLB6005. - Given calculus programs that read scalar, string, byte-string, list, pair, option, and algebraic-data literals once and twice, and copies that plant a mistyped literal, a malformed member, and a noncanonical spelling + Given calculus programs that read scalar, string, byte-string, list, pair, option, result, and algebraic-data literals once and twice, and copies that plant a mistyped literal, a malformed member, and a noncanonical spelling When they are loaded and evaluated by the reference interpreter, and the denotation's source is read Then each read costs the literal's weight and a scalar costs one step, the denotation charges the same weight, and each copy fails with LLB6005 From c82e5fd5c9ad641c85e22067cc422d9fa41432dd Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 17:22:10 +0000 Subject: [PATCH 12/21] RB-18 review: stale BS-05 counts, certificate B asserted, plant 2 quoted, Then clause points at BS-05 and SP-24 Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- SPEC.md | 2 +- VERIFICATION.md | 27 +++++++---- crates/conformance/src/cases/rust_backend.rs | 47 ++++++++++++++++++++ features/suites/rust-backend.feature | 4 +- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/SPEC.md b/SPEC.md index 23b58071fd..3111d2007c 100644 --- a/SPEC.md +++ b/SPEC.md @@ -7501,7 +7501,7 @@ ends with, at each `Err` of its body, must be a fallible value; the body is checked as a block that is not a tail, for its applications as for its moves, and the correspondence traversal treats it as a block. `correspondCrate` lists the constructs a crate emits instance by instance and -checks each against the 97 rows of the correspondence table, the element it was +checks each against the 98 rows of the correspondence table, the element it was lowered from, its width, and the elements the program uses; a repeated instance is kept once, which does not change which one the oracle reports first. Lowering, printing, packaging, and the choice of profile are not part of diff --git a/VERIFICATION.md b/VERIFICATION.md index be1520ea3a..99eec9ae7d 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4062,7 +4062,7 @@ Command: `cargo test -p repo-conformance --test conformance conformance_rb_18`. The oracles are the pinned rustc, a counting global allocator in the harness, `validate`, and the bootstrap validator. -Planted, five ways. +Planted, six ways. 1. The lowering stopped hoisting (`let cached = false && ...`). The case refused it: @@ -4072,11 +4072,19 @@ thread 'conformance_rb_18' panicked at crates/conformance/src/cases/rust_backend a nullary heap literal is a constant: [Function { name: Function(0), parameters: [], result: List(Int), body: Block { lets: [], tail: Construct { ctor: Cons, args: [Lit(Int(7), ... ``` -2. The same program with its constant printed as a function that rebuilds at - each read: two reads allocate 4 times where the cached rendering allocates - 0 (counted by the harness; observed by printing the count once, the case - asserts `> 0` and `== 0`). The reviewer's variant, a rebuild behind the - cell, fails the same equality (`left: 4`, `right: 0`). +2. The printer returning the rebuilt literal behind the cell (the cell read + into `let _`, then the literal's block as the tail), which keeps every text + the case looks for. The harness counted the allocations of the two reads: + +```text +thread 'conformance_rb_18' panicked at crates/conformance/src/cases/rust_backend.rs:1742:5: +assertion `left == right` failed: a read of a cached literal allocates nothing + left: 4 + right: 0 +``` + + The same program with its constant printed as a plain function allocates 4 + as well, and the case requires `> 0` of that copy. 3. A constant whose body is a call, one whose result can fail, and one with a binding before the literal: `validate` refuses each with ``constant: `f0` is not an infallible closed literal``. The bootstrap @@ -4086,6 +4094,7 @@ a nullary heap literal is a constant: [Function { name: Function(0), parameters: 4. A literal of a declared algebraic type holding a list is not a constant: the case requires the lowering to leave it a function. 5. `rust-core` has no rendering of the heap literal (`lower` refuses it). +6. Certificate B of the cached crate states `LexLeanTarget.RustSyntax.ItemDef.constant` in its text and its data, and that of the copy printed as a function does not; the case asserts both, so a certificate B that regressed to encoding a constant as a function is refused. The expectation `Some(7) 5 5` of the harness is written by hand. That the rendering and the evaluator agree on a constant rests on `conformance_tc_07`, @@ -9667,7 +9676,7 @@ among the ones before it is not a tail call, the two calculus checkers, which recurse with the depth of the program they check, and the two Rust crate validators (`BS-05`, `validate_crate` and `correspond_crate`), which recurse with the depth of the crate they check. The validators were measured with -`LEXLEAN_MEASURE_STACK=all` on `conformance_bs_05` alone, over the 675 vectors +`LEXLEAN_MEASURE_STACK=all` on `conformance_bs_05` alone, over the 680 vectors and the 4,000 seeded mutants of its rustc differentials, the largest need of all of them being the row. The scans, the token roots and the standard library's text and SHA-256 roots are loops and need no @@ -9793,9 +9802,9 @@ Authoring found four shapes certificate A and certificate B do not accept, each ### the bootstrap Rust crate validator can fail its oracle (SPEC.md §17.23, §17.16) -`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, and 34 hand-built crates of the loop rules, that is 406 `validateCrate` vectors (165 refused) and 269 `correspondCrate` vectors (46 refused), 675 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 675. On the normative host the evaluator agrees on the 200 crates of at most 400 expressions, the rule runs, and the hand-built crates (388 + 246 vectors), and on 500 seeded mutants (271 and 244 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. +`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, 34 hand-built crates of the loop rules, and 5 hand-built crates of the rule of a constant, that is 411 `validateCrate` vectors (169 refused) and 269 `correspondCrate` vectors (46 refused), 680 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 680. On the normative host the evaluator agrees on the 200 crates of at most 400 expressions, the rule runs, and the hand-built crates (388 + 246 vectors), and on 500 seeded mutants (271 and 244 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. -The loop rules (the oracle's `Expr::Loop`, SP-19 and RB-14) are `ELoop [Id, Expr]` of the module: ownership of the state across a body that runs again (two refusals, for a name and for a component, naming the least offender in the oracle's order of names), the fallible-tail rule, `apply_types` with `tail = false` for the body, and the correspondence traversal treating the body as a block. The correspondence table was re-diffed against the oracle's `CORRESPONDENCE` after SP-19: 97 rows, and the six that gained `expr:call` (`destructure:pair`, `type:result`, `type:pair`, `construct:ok`, `construct:err`, `construct:pair`) are the only difference from the table first transcribed; the module's table and the oracle's are equal row for row and element for element. +The loop rules (the oracle's `Expr::Loop`, SP-19 and RB-14) are `ELoop [Id, Expr]` of the module: ownership of the state across a body that runs again (two refusals, for a name and for a component, naming the least offender in the oracle's order of names), the fallible-tail rule, `apply_types` with `tail = false` for the body, and the correspondence traversal treating the body as a block. The correspondence table was re-diffed against the oracle's `CORRESPONDENCE` after SP-19: 97 rows (98 with the `constant` row of RB-18), and the six that gained `expr:call` (`destructure:pair`, `type:result`, `type:pair`, `construct:ok`, `construct:err`, `construct:pair`) are the only difference from the table first transcribed; the module's table and the oracle's are equal row for row and element for element. The refusal that a construct has no row of the correspondence table cannot be reached by any crate of the closed AST (every construct it emits has a row), so no vector reaches it and the module's transcription of it is held by reading, not by a run. A crate whose exported name or origin element holds a non-ASCII or non-printable scalar is outside the claim. diff --git a/crates/conformance/src/cases/rust_backend.rs b/crates/conformance/src/cases/rust_backend.rs index 441ade8b05..ed5eeccaed 100644 --- a/crates/conformance/src/cases/rust_backend.rs +++ b/crates/conformance/src/cases/rust_backend.rs @@ -1771,6 +1771,53 @@ fn cached_literal() { ); assert!(allocations > 0, "a rebuilt literal allocates at each read"); + // Certificate B states the constant as the machine's `ItemDef.constant` + // (SPEC.md §17.17), not as a function: the text and the data of the + // certificate of the cached crate name it, and the certificate of the + // rebuilding copy, a function, does not. + { + let module = + lexlean::production::rust_cert::module_for("LexLeanPreserve.C0.R0", "rust-std") + .expect("a Rust target"); + let constant = "LexLeanTarget.RustSyntax.ItemDef.constant"; + let states = |krate: &Crate| { + let b = + lexlean::production::rust_cert::certificate_b(&program, krate, &module, u64::MAX) + .expect("certificate B builds"); + let in_data = b.data.nodes.iter().any(|node| { + matches!(node, lexlean::ir::core::CoreNode::Const { n, .. } if n == constant) + }); + (b.text.contains("ItemDef.constant"), in_data) + }; + assert_eq!( + states(&cached), + (true, true), + "certificate B states the constant" + ); + let mut as_function = cached.clone(); + for item in &mut as_function.items { + if let ItemDef::Constant { + name, + result, + body, + at, + } = item.clone() + { + *item = ItemDef::Function { + name, + parameters: Vec::new(), + result, + body, + at, + }; + } + } + assert_eq!( + states(&as_function), + (false, false), + "a function is not stated as a constant" + ); + } // A literal whose type is a declared algebraic type is not a constant, // although it holds a list: the type says no heap (`Type::heap`), so it // stays a function that builds the value at each call (SPEC.md §17.16). diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index 66d18f151a..5200343f95 100644 --- a/features/suites/rust-backend.feature +++ b/features/suites/rust-backend.feature @@ -97,5 +97,5 @@ Feature: rust-backend @RB-18 @build Scenario: A function of no parameters that cannot fail and whose body is a closed literal of a list, string, or byte string is a constant of the Rust machine, an `ItemDef.constant` of `RustSyntax` whose value in `RustSemantics` is its body's, rendered in rust-std as a thread-local cell evaluated once per thread whose every call returns a clone of the value, so that a read allocates nothing and a decoded constant is not rebuilt on each call; certificate B encodes the item as itself, rust-core has no rendering of it, a literal whose type is a declared algebraic type is not a constant, and the rule that a constant cannot fail and that its body is a closed literal is stated by `validate` and by the bootstrap `RustValidate`, whose differential is held to it by committed crates that break it, while a rendering that rebuilds the literal at each read is detected by counting its allocations. Given a program whose function of no parameters is a list literal over int, one whose literal has a declared algebraic type, rendered in both profiles, copies that rebuild the literal at each read, and committed crates that give a constant a call, a failing result, or a binding - When the rust-std rendering is compiled by the pinned rustc with warnings denied, read once to warm and then twice under a counting allocator, and the crates are validated by the oracle and by the bootstrap validator - Then the literal is one thread-local cell, a read returns the denotation's value and allocates nothing, the algebraic literal stays a function, rust-core refuses the heap literal, certificate B states the constant, and the rebuilding copy and each committed crate are detected or refused by both validators + When the rust-std rendering is compiled by the pinned rustc with warnings denied, read once to warm and then twice under a counting allocator, and certificate B of the crate is built + Then the literal is one thread-local cell, a read returns the denotation's value and allocates nothing, the algebraic literal stays a function, rust-core refuses the heap literal, certificate B states the constant as `ItemDef.constant`, and the rebuilding copy is detected; the committed crates that break the rule are held by both validators in BS-05, and the certificates of the models example by SP-24 From e8bcf13135123c1029ec9bea49757b3fe035f5a6 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 17:28:26 +0000 Subject: [PATCH 13/21] SP-24, MD-14 review: plants run the case's checks on mutated programs, certificate B asserted, record has its command Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- VERIFICATION.md | 36 +++- crates/conformance/src/cases/models.rs | 194 +++++++++++------- crates/conformance/src/cases/preservation.rs | 24 ++- .../production/certificate/data_a/prove.rs | 3 + 4 files changed, 172 insertions(+), 85 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 3e6f2c592a..d3da329f2f 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4125,7 +4125,11 @@ Removed: each plant was reverted. `conformance_rb_01` fails on this tree with ### artifacts as data can fail (SP-24, MD-14) -Planted, three ways. +Command: `cargo test -p repo-conformance --test conformance -- conformance_md_14 conformance_sp_24` +(`conformance_md_14` needs the models lock rewritten and `conformance_sp_24` +the regenerated machine modules; both were held in the working tree only). + +Planted, five ways. 1. The lowering stopped folding artifacts (`is_artifact` replaced by `false`). `conformance_md_14` refused it at the first artifact read: @@ -4134,22 +4138,34 @@ Planted, three ways. Models.Main.classify: `Recognizer.outputBias` is built on each call, not held as data: Build { shape: Cons, ty: List { element: Int }, operands: [Value { ty: Int, value: Int { value: "-6" } }, Build { shape: Cons, ... ``` -2. A literal turned back into its construction chain, and a literal with one - element changed: the first is a `Build` of constructors, which the - per-call check names; the second is unequal to the closed schemas' - decoding of the artifact's bytes, which the case computes from the file - alone. -3. Certificate B and E: `conformance_sp_24` stages and compiles the certificates of every root of the models example with the crate's ten constants encoded as `ItemDef.constant`, over the regenerated machine modules and the repaired library held in the working tree only (289 s, with `conformance_md_14`). -4. In certificate A of a root that holds a literal, every `conv_value` was +2. A lowered program of a root that reads an artifact with one literal turned + back into the chain a lowering that stopped folding would leave: the + case's own check (`check_artifacts_as_data`, the function it runs on every + root) returns the defect ``... is built on each call``. +3. The same program with one element of a literal changed: the check returns + ``the literal of `...` is not the decoding of the artifact's bytes``, the + decoding being computed from the file by the closed schemas alone. +4. Certificate B: `conformance_sp_24` requires a certificate B text and data + to name `LexLeanTarget.RustSyntax.ItemDef.constant` exactly for the roots + whose crate has a constant, and stages and compiles the certificates A, B, + and E of every root of the models example with its ten constants, over the + regenerated machine modules and the repaired library (108 s with + `conformance_md_14`). +5. In certificate A of a root that holds a literal, every `conv_value` was replaced by `conv_var`. `conformance_sp_24` compiles the planted module under the pinned Lean and requires it to be refused. +Certificate A relates the lowered literal to its own value (`conv_value` has no +source argument, as the existing path for a scalar literal); that the literal +is the decoding of the artifact's bytes is established by MD-14's independent +decoding and by nothing else. + Before the aligner learned the case, the same run printed `LLI9001 phase preservation: the lowering of a cons is not a build of two`: certificate A had no derivation for a source list lowered to one literal. The fix is one branch in `data_a/prove.rs` using the lemma that relates any -literal to its value; `git diff -- language/` is empty, so the preservation -library did not grow. Removed: each plant was reverted. +literal to its value; this PR changes nothing under `language/`, so the +preservation library did not grow for it. Removed: each plant was reverted. ### kernel-opaque classification is observed diff --git a/crates/conformance/src/cases/models.rs b/crates/conformance/src/cases/models.rs index f2c25b1455..35ae96f7d0 100644 --- a/crates/conformance/src/cases/models.rs +++ b/crates/conformance/src/cases/models.rs @@ -3864,6 +3864,53 @@ fn builds_per_call(body: &lexlean::calculus::Expr) -> bool { matches!(body, lexlean::calculus::Expr::Build { .. }) } +/// The checks of MD-14 on one lowered root: every artifact definition is a +/// literal equal to the decoding of its file, and no function of no +/// parameters builds a list with constructors. Returns the number of literals +/// checked, or the first defect. +fn check_artifacts_as_data( + lowered: &lexlean::production::lower::Lowered, + root: &str, + artifacts: &BTreeSet, + schemas: &std::collections::BTreeMap, + files: &std::collections::BTreeMap>, +) -> Result { + use lexlean::calculus::{Expr, Shape}; + let mut literals = 0; + for (name, body) in artifact_literals(lowered, artifacts) { + let Expr::Value { value, .. } = body else { + return Err(format!( + "{root}: `{name}` is built on each call, not held as data" + )); + }; + let (schema, sha256) = &schemas[&name]; + let bytes = files + .get(sha256) + .ok_or_else(|| format!("{name}: no file has digest {sha256}"))?; + if value != &decoded_artifact(schema, bytes) { + return Err(format!( + "{root}: the literal of `{name}` is not the decoding of the artifact's bytes" + )); + } + literals += 1; + } + for function in &lowered.program.functions { + if function.parameters.is_empty() + && builds_per_call(&function.body) + && matches!( + function.body, + Expr::Build { + shape: Shape::Cons, + .. + } + ) + { + return Err(format!("{root}: a list is built on each call")); + } + } + Ok(literals) +} + fn md_14() { use lexlean::calculus::{Expr, Shape, Value}; use lexlean::ir::semantic::SemanticDeclaration; @@ -3899,6 +3946,7 @@ fn md_14() { assert_eq!(schemas.len(), 8, "the example declares eight artifacts"); let artifacts: BTreeSet = schemas.keys().cloned().collect(); let mut literals = 0; + let mut planted = None; for report in roots(&checked).expect("the eligibility reports") { let lowered = lower_root( &modules, @@ -3908,82 +3956,80 @@ fn md_14() { &limits, ) .unwrap_or_else(|diagnostic| panic!("{}: {diagnostic:?}", report.report.root)); - for (name, body) in artifact_literals(&lowered, &artifacts) { - let Expr::Value { value, .. } = body else { - panic!( - "{}: `{name}` is built on each call, not held as data: {body:?}", - report.report.root - ); - }; - let (schema, sha256) = &schemas[&name]; - let bytes = files - .get(sha256) - .unwrap_or_else(|| panic!("{name}: no file has digest {sha256}")); - assert_eq!( - value, - &decoded_artifact(schema, bytes), - "{name}: the literal is the decoding of the artifact's bytes" - ); - literals += 1; + literals += + check_artifacts_as_data(&lowered, &report.report.root, &artifacts, &schemas, &files) + .unwrap_or_else(|defect| panic!("{defect}")); + if planted.is_none() && !artifact_literals(&lowered, &artifacts).is_empty() { + planted = Some((lowered, report.report.root.clone())); } - // No function of no parameters builds a constant with constructors: - // the shape of the per-call construction this removes. - for function in &lowered.program.functions { - assert!( - !(function.parameters.is_empty() - && builds_per_call(&function.body) - && matches!( - function.body, - Expr::Build { - shape: Shape::Cons, - .. - } - )), - "{}: a list is built on each call", - report.report.root - ); - } - // Planted: a literal turned back into its chain, and a literal with - // one element changed, are each detected by the same checks. - if let Some(( - _, - Expr::Value { - value: Value::List { items }, - ty, - }, - )) = artifact_literals(&lowered, &artifacts).into_iter().next() - { - let chain = items.iter().rev().fold( - Expr::Build { - shape: Shape::Nil, - ty: ty.clone(), - operands: Vec::new(), - }, - |tail, item| Expr::Build { - shape: Shape::Cons, + } + assert_eq!(literals, 10, "R0, R1, and R2 hold ten artifact literals"); + + // Planted: the same checks, run on a lowered program of a root that reads + // an artifact after its literal is turned back into the chain a lowering + // that stopped folding would leave, and after one element is changed. + let (lowered, root) = planted.expect("a root reads an artifact"); + let target = lowered + .layout + .functions + .iter() + .zip(&lowered.program.functions) + .position(|(origin, function)| { + matches!( + (&function.body, origin), + ( + Expr::Value { + value: Value::List { .. }, + .. + }, + lexlean::production::lower::Origin::Definition { .. } + ) + ) + }) + .expect("a literal-bodied definition"); + let Expr::Value { + value: Value::List { items }, + ty, + } = lowered.program.functions[target].body.clone() + else { + panic!("the target is a list literal"); + }; + let mut chained = lowered.clone(); + chained.program.functions[target].body = items.iter().rev().fold( + Expr::Build { + shape: Shape::Nil, + ty: ty.clone(), + operands: Vec::new(), + }, + |tail, item| Expr::Build { + shape: Shape::Cons, + ty: ty.clone(), + operands: vec![ + Expr::Value { ty: ty.clone(), - operands: vec![ - Expr::Value { - ty: ty.clone(), - value: item.clone(), - }, - tail, - ], - }, - ); - assert!(builds_per_call(&chain), "a rebuilt constant is detected"); - let mut changed = items.clone(); - changed[0] = Value::Int { - value: "424242".to_owned(), - }; - assert_ne!( - Value::List { items: changed }, - Value::List { - items: items.clone() + value: item.clone(), }, - "a changed element is detected by the equality with the decoding" - ); - } + tail, + ], + }, + ); + let defect = check_artifacts_as_data(&chained, &root, &artifacts, &schemas, &files) + .expect_err("a rebuilt constant is refused"); + assert!(defect.contains("is built on each call"), "{defect}"); + let mut changed = lowered.clone(); + if let Expr::Value { + value: Value::List { items }, + .. + } = &mut changed.program.functions[target].body + { + items[0] = Value::Int { + value: "424242".to_owned(), + }; } - assert_eq!(literals, 10, "R0, R1, and R2 hold ten artifact literals"); + let defect = check_artifacts_as_data(&changed, &root, &artifacts, &schemas, &files) + .expect_err("a changed element is refused"); + assert!( + defect.contains("is not the decoding of the artifact's bytes"), + "{defect}" + ); } diff --git a/crates/conformance/src/cases/preservation.rs b/crates/conformance/src/cases/preservation.rs index bb28886478..8e5b4c5cae 100644 --- a/crates/conformance/src/cases/preservation.rs +++ b/crates/conformance/src/cases/preservation.rs @@ -5317,11 +5317,33 @@ fn artifacts_as_data() { let krate = lexlean::calculus::rust::lower(&entry.program, lexlean::calculus::rust::Profile::Std) .expect("the program renders in rust-std"); - constants += krate + let here = krate .items .iter() .filter(|item| matches!(item, ItemDef::Constant { .. })) .count(); + constants += here; + // Certificate B states a constant as the machine's `ItemDef.constant`, + // in its text and in its data, exactly for the roots that have one: a + // certificate that compiled but encoded the constant as a function + // would not name it. + for (target, certificate) in &entry.renderings { + let in_data = certificate.data.as_ref().is_some_and(|data| { + data.nodes.iter().any(|node| { + matches!(node, lexlean::ir::core::CoreNode::Const { n, .. } + if n == "LexLeanTarget.RustSyntax.ItemDef.constant") + }) + }); + assert_eq!( + (certificate.text.contains("ItemDef.constant"), in_data), + ( + here > 0 && target == "rust-std", + here > 0 && target == "rust-std" + ), + "{} on {target}: certificate B states the constant exactly when the crate has one", + entry.root + ); + } } assert_eq!(constants, 10, "each literal renders as a constant"); if !support::lean_backed("SP-24") { diff --git a/crates/lexlean/src/production/certificate/data_a/prove.rs b/crates/lexlean/src/production/certificate/data_a/prove.rs index 27f1705383..2f9b94c4df 100644 --- a/crates/lexlean/src/production/certificate/data_a/prove.rs +++ b/crates/lexlean/src/production/certificate/data_a/prove.rs @@ -182,6 +182,9 @@ impl<'a> Writer<'_, 'a> { ) -> Result { let site = scope.ctx.site.clone(); let (p, env) = (self.prog, scope.env); + // Keyed on the shape, not on the artifact declaration: only an artifact's + // list folds today (`production::lower`), so no other definition meets + // this branch, and a second folding construct would need its own check. // An artifact's list, held by the lowering as one literal, is related // to the source's construction of it by the lemma that relates any // literal to its value (§17.17 *Artifacts as data*). From 5ec86d43685a66c95d39eb1d0a95bd1b512965a5 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 18:55:47 +0000 Subject: [PATCH 14/21] Merge release/v0.5 (65f7168d9) into the #115 skeleton; SPEC.md is the projection Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- SPEC.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SPEC.md b/SPEC.md index b7c421cce7..922045f697 100644 --- a/SPEC.md +++ b/SPEC.md @@ -10462,7 +10462,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `NS-04` | `normative-source` | The projector fails closed on a module of the specification project that holds a declaration kind, a term kind, a field, a name, a file, or a family it does not read, and on a duplicate identifier or code, and a plant of each is refused naming the file and, for a declaration, its position. | §17.21, §24.8 | | `NS-05` | `normative-source` | SPEC.md regenerates byte-identically from the chapter modules of the specification project, its conformance-ID table, its diagnostic-code table, its authority table, and its stated total being derived from the register, registry, and authority modules and never typed, and the projector refuses a chapter item it does not read. | §26.3, §27.5, §31 | -**Total required capability IDs:** 438. +**Total required capability IDs:** 442. No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors. From 4d1120fa4022128e201225503fb044b77e6b6a9a Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 18:59:26 +0000 Subject: [PATCH 15/21] TC-08: the cost rule is a chapter item of spec/src (SPEC.md is its projection) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- spec/src/Chapter17.lex.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/src/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index dbbd0728e5..501655ed0a 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -1988,7 +1988,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "- each evaluated node is one step, on top of the steps of its operands;" (cons "- reading a local is one step more per binding the lookup examines before" (cons " it finds the local's;" (cons "- a `match` is one step more per arm it tries, the taken arm included;" (cons "- `apply` is one step more per capture it passes;" (cons "- `field` is one step more per field it skips;" (cons "- a primitive is one step more per unit of *weight* of its operands and of" (cons " its result. A value's weight is one per node, plus a string's characters" (cons " and a byte string's bytes, so every primitive whose work grows with its" (cons " operands (append, length, index, slice, encoding, decoding, comparison," (cons " split, join, formatting, parsing) is charged in proportion." (nil String)))))))))))) + (cons "- each evaluated node is one step, on top of the steps of its operands, except" (cons " a literal, which is charged its *weight* each time it is read, so that a" (cons " scalar costs one step and a decoded constant held as a list, pair, option," (cons " result, or algebraic-data literal is accounted by its size and never by a" (cons " single step (`TC-08`);" (cons "- reading a local is one step more per binding the lookup examines before" (cons " it finds the local's;" (cons "- a `match` is one step more per arm it tries, the taken arm included;" (cons "- `apply` is one step more per capture it passes;" (cons "- `field` is one step more per field it skips;" (cons "- a primitive is one step more per unit of *weight* of its operands and of" (cons " its result. A value's weight is one per node, plus a string's characters" (cons " and a byte string's bytes, so every primitive whose work grows with its" (cons " operands (append, length, index, slice, encoding, decoding, comparison," (cons " split, join, formatting, parsing) is charged in proportion." (nil String)))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] From 9b338a0ba868a773d1d0d6562924bcccb6c31d49 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 19:04:33 +0000 Subject: [PATCH 16/21] RB-18: the constants and BS-05 prose are chapter items of spec/src (SPEC.md is their projection) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- spec/src/Chapter17.lex.tex | 406 +++++++++++++++++++------------------ 1 file changed, 210 insertions(+), 196 deletions(-) diff --git a/spec/src/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index 501655ed0a..b7e52355bb 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -2362,7 +2362,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Failure typing.** A function can overflow exactly when its body reaches a" (cons "primitive or successor that can (`nat_add`, `nat_mul`, `int_add`, `int_sub`," (cons "`int_mul`, `int_neg`, `int_quot`, `parse_decimal` at `int`, `succ`), a call to" (cons "a function that can, or an application of a function type one of whose" (cons "closures can: the least fixed point of these rules, computed by a worklist" (cons "over the reverse call and application edges. A function that can overflow" (cons "returns `R` and every call to it ends in `?`, except in tail position," (cons "where its result is returned as it is; any other function returns its value" (cons "and no call to it propagates. The length of a sequence cannot exceed" (cons "`2^64 - 1` on any machine that holds it, so `length` cannot overflow." (nil String))))))))))) + (cons "**Constants.** A function of no parameters that cannot fail, whose body is a" (cons "closed literal (scalars, constructors, pairs, and boxes of literals only) and" (cons "whose result is a list, a string, or a byte string (a type with heap storage" (cons "by `Type::heap`), is a *constant* in `rust-std`: the item `ItemDef::Constant`" (cons "of the AST and `ItemDef.constant` of `RustSyntax`, printed as a `thread_local!`" (cons "cell initialised once per thread by the literal and a function whose every call" (cons "is `CELL.with(|cell| cell.clone())`. A clone of a list, a string, or a byte" (cons "string shares its storage, so a read allocates nothing, where a rebuilt literal" (cons "allocates at each read (`RB-18`). A literal whose type is a declared algebraic" (cons "type is not a constant, whatever it holds: its type says no heap, so it stays a" (cons "function that builds the value on each call. `RustSemantics` gives a call of a" (cons "constant the value of its body, as `findFunction` returns it as a function of no" (cons "parameters; the machine counts no work, so a read adds none to the counted work" (cons "the differentials measure (§17.16 *Checks*, `TC-07`), and when the value is" (cons "computed is not part of the denotation. Certificate B encodes the item as" (cons "itself (§17.17), so the crate it states is the crate printed. `rust::validate`" (cons "and the bootstrap `RustValidate` refuse, as `LLB6005`, a constant whose result" (cons "can fail or whose body has a binding or is not a closed literal, ``constant: `f`" (cons "is not an infallible closed literal``: a thread-local initializer cannot propagate" (cons "a failure, and a body that calls could reach the constant it initializes. No" (cons "lowering builds such a constant, so the refusal is held by committed crates in" (cons "the differential of `BS-05`. `rust-core` renders no constant, because the" (cons "literal holds heap storage." (nil String)))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2376,7 +2376,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Checks.** Before printing, `rust::validate` refuses, as `LLB6005`:" (nil String)) + (cons "**Failure typing.** A function can overflow exactly when its body reaches a" (cons "primitive or successor that can (`nat_add`, `nat_mul`, `int_add`, `int_sub`," (cons "`int_mul`, `int_neg`, `int_quot`, `parse_decimal` at `int`, `succ`), a call to" (cons "a function that can, or an application of a function type one of whose" (cons "closures can: the least fixed point of these rules, computed by a worklist" (cons "over the reverse call and application edges. A function that can overflow" (cons "returns `R` and every call to it ends in `?`, except in tail position," (cons "where its result is returned as it is; any other function returns its value" (cons "and no call to it propagates. The length of a sequence cannot exceed" (cons "`2^64 - 1` on any machine that holds it, so `length` cannot overflow." (nil String))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2390,7 +2390,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "1. *hygiene*: a name used but not bound, or bound twice in one function," (cons " and an item declared twice;" (cons "2. *ownership*: a value moved twice, or read after it was moved, on any" (cons " path; a pair component moved out twice, or a binding read or moved" (cons " whole after a component was moved out of it; branches are alternatives;" (cons "3. *hidden allocation*: in `rust-core`, any heap type, heap runtime" (cons " function, string or byte string literal, list construction or match, or" (cons " box;" (cons "4. *arithmetic*: a fallible call that does not propagate outside tail" (cons " position, an infallible call that propagates, a fallible function's tail" (cons " that is not a fallible value, and a function that propagates a failure" (cons " its result type does not carry;" (cons "5. *correspondence*, instance by instance: an emitted construct with no row" (cons " in `validate::CORRESPONDENCE`, whose row does not name the element of its" (cons " own origin, whose width (a fixed-width runtime function's or literal's)" (cons " differs from its origin's, or whose origin the program does not use; and" (cons " a type the crate names whose row names no element the program uses. The" (cons " pair and result constructs that a loop's state and break carry (`type:pair`," (cons " `type:result`, `destructure:pair`, `construct:pair`, `construct:ok`," (cons " `construct:err`) name `expr:call` among their origins, so they are admitted" (cons " in any program that calls, not only where a self tail call is rendered as" (cons " a loop: the rule is coarser there by that much. The" (cons " origin is derived from the term being lowered, independently of the" (cons " construct chosen for it, so a call of `nat_mul` lowered from a `nat_add`" (cons " term, or a `u16` addition lowered from a `u8` one, is refused even in a" (cons " program that uses both. Types are checked against the program's elements" (cons " as a whole. That the parts of a construct are composed faithfully (which" (cons " arm is which, which function a call names, the order of captures and" (cons " fields) is not a check of the AST: it is established by the conformance" (cons " differential below, against which planted lowering mutations are" (cons " recorded. A negated zero test or predecessor is refused as well: a zero" (cons " test is negated as its complement, and the printer parenthesizes any" (cons " comparison under `!`." (nil String)))))))))))))))))))))))))))))))))) + (cons "**Checks.** Before printing, `rust::validate` refuses, as `LLB6005`:" (nil String)) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2404,7 +2404,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Runtime boundary.** The runtime both profiles carry is a closed text" (cons "(`rust::runtime`), and what it may take from Rust's library is closed too." (cons "`rust_library::PRIMITIVES` lists the *machine primitives*: the checked" (cons "integer operations at each width (`checked_add`, `checked_sub`," (cons "`checked_mul`, `checked_div`, `checked_rem`, `checked_neg`, `checked_shl`," (cons "`checked_shr`), conversion between integer widths, the order of two" (cons "scalars, the work counter, a growable buffer (creation with a capacity," (cons "`push` and `truncate` by its only holder, length), a shared immutable copy of" (cons "a slice, the unique-holder test and release of a shared value, replacement" (cons "of a place's value, and the UTF-8 view and check of a text. Each is stated" (cons "by its meaning, and these, with Rust's integer and Boolean operators, are" (cons "the only operations the runtime may use that no runtime source defines." (cons "`rust_library::LIBRARY` lists every name the runtime text takes from the" (cons "library (an import, a path, a method, a macro, or a capitalized type, trait," (cons "or constructor; an integer type in a path is written ``), each with its" (cons "role: part of a primitive; *stated*, meaning the closed AST states what it" (cons "computes over the primitives the row cites, or over its own constructs" (cons "alone when it cites none; or a construct of the closed AST. The audit" (cons "(`rust_library::audit`) reads the text as tokens and refuses a name the" (cons "table does not list, a row the text does not use or lists twice, a row" (cons "citing a name that is not a primitive, and a primitive no row cites." (nil String)))))))))))))))))))))) + (cons "1. *hygiene*: a name used but not bound, or bound twice in one function," (cons " and an item declared twice;" (cons "2. *ownership*: a value moved twice, or read after it was moved, on any" (cons " path; a pair component moved out twice, or a binding read or moved" (cons " whole after a component was moved out of it; branches are alternatives;" (cons "3. *hidden allocation*: in `rust-core`, any heap type, heap runtime" (cons " function, string or byte string literal, list construction or match, or" (cons " box;" (cons "4. *arithmetic*: a fallible call that does not propagate outside tail" (cons " position, an infallible call that propagates, a fallible function's tail" (cons " that is not a fallible value, and a function that propagates a failure" (cons " its result type does not carry;" (cons "5. *correspondence*, instance by instance: an emitted construct with no row" (cons " in `validate::CORRESPONDENCE`, whose row does not name the element of its" (cons " own origin, whose width (a fixed-width runtime function's or literal's)" (cons " differs from its origin's, or whose origin the program does not use; and" (cons " a type the crate names whose row names no element the program uses. The" (cons " pair and result constructs that a loop's state and break carry (`type:pair`," (cons " `type:result`, `destructure:pair`, `construct:pair`, `construct:ok`," (cons " `construct:err`) name `expr:call` among their origins, so they are admitted" (cons " in any program that calls, not only where a self tail call is rendered as" (cons " a loop: the rule is coarser there by that much. The" (cons " origin is derived from the term being lowered, independently of the" (cons " construct chosen for it, so a call of `nat_mul` lowered from a `nat_add`" (cons " term, or a `u16` addition lowered from a `u8` one, is refused even in a" (cons " program that uses both. Types are checked against the program's elements" (cons " as a whole. That the parts of a construct are composed faithfully (which" (cons " arm is which, which function a call names, the order of captures and" (cons " fields) is not a check of the AST: it is established by the conformance" (cons " differential below, against which planted lowering mutations are" (cons " recorded. A negated zero test or predecessor is refused as well: a zero" (cons " test is negated as its complement, and the printer parenthesizes any" (cons " comparison under `!`." (nil String)))))))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2418,7 +2418,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Packages.** A package manifest (`lexlean/rust-package/1`," (cons "`schemas/rust-package.schema.json`) names a crate and its version (three" (cons "canonical decimals, each at most `2^64 - 1`, as Cargo reads them; the schema" (cons "pattern and the renderer agree), a profile, a target program, the exported" (cons "functions, and its `sources`: the semantic IDs (§21.4) of the LexLean builds" (cons "whose linked IR states the program, as lowercase SHA-256 hex, strictly" (cons "ascending, and empty for a program no LexLean build states. The renderer" (cons "checks their form and records them; that they name the build stating the" (cons "program is established by the conformance suite against the verified build" (cons "(below). That the program faithfully realizes the semantic objects of that" (cons "build (realization-to-source preservation) is the obligation of the" (cons "production pipeline that derives target programs from LexLean roots, not of" (cons "this backend: `sources` binds a package to the build that states its program," (cons "and the backend never derives a program from a build. Its `effects` are effects" (cons "of §17.13, strictly ascending and registered, that the package states of" (cons "itself. For a package a production root exports they are the set eligibility" (cons "requires of the root on the profile, which eligibility decides and the renderer" (cons "does not derive; for a package no root exports (a fixture) they are the effects" (cons "its program shows, `overflow` for an export that can fail and `recursion` for a" (cons "function that reaches itself, never `allocation`. They are not the effects the" (cons "realization can exhibit: the argument check an entry carries recurses over a" (cons "recursive argument type, and the graph templates' `nat_add` fuel bound can" (cons "overflow, and neither is among a root's required effects (issue 105). The" (cons "renderer refuses a list that is unregistered, unordered, or states `allocation`" (cons "on `rust-core`. Each export names a" (cons "program function, its Rust name, how it takes each parameter (`own`;" (cons "`borrow`, by shared reference; or `copy`, only for a `Copy` type: a scalar," (cons "or an option, result, or pair of `Copy` types), and whether it can fail" (cons "(`none` or `overflow`). A package is refused, as `LLB6005`, when:" (nil String)))))))))))))))))))))))))))))) + (cons "**Runtime boundary.** The runtime both profiles carry is a closed text" (cons "(`rust::runtime`), and what it may take from Rust's library is closed too." (cons "`rust_library::PRIMITIVES` lists the *machine primitives*: the checked" (cons "integer operations at each width (`checked_add`, `checked_sub`," (cons "`checked_mul`, `checked_div`, `checked_rem`, `checked_neg`, `checked_shl`," (cons "`checked_shr`), conversion between integer widths, the order of two" (cons "scalars, the work counter, a growable buffer (creation with a capacity," (cons "`push` and `truncate` by its only holder, length), a shared immutable copy of" (cons "a slice, the unique-holder test and release of a shared value, replacement" (cons "of a place's value, and the UTF-8 view and check of a text. Each is stated" (cons "by its meaning, and these, with Rust's integer and Boolean operators, are" (cons "the only operations the runtime may use that no runtime source defines." (cons "`rust_library::LIBRARY` lists every name the runtime text takes from the" (cons "library (an import, a path, a method, a macro, or a capitalized type, trait," (cons "or constructor; an integer type in a path is written ``), each with its" (cons "role: part of a primitive; *stated*, meaning the closed AST states what it" (cons "computes over the primitives the row cites, or over its own constructs" (cons "alone when it cites none; or a construct of the closed AST. The audit" (cons "(`rust_library::audit`) reads the text as tokens and refuses a name the" (cons "table does not list, a row the text does not use or lists twice, a row" (cons "citing a name that is not a primitive, and a primitive no row cites." (nil String)))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2432,7 +2432,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "- an exported name is not a lowercase snake-case identifier of at most 64" (cons " characters, is a Rust keyword, has the shape of a generated name, or is" (cons " declared by the runtime; a name is exported twice; or the crate name is a" (cons " sysroot crate or `harness` (*identifier collision*);" (cons "- an export copies a parameter whose type is not `Copy` (*ownership" (cons " mismatch*);" (cons "- an export's boundary holds a function value, directly or inside the fields" (cons " of a named type at any depth: the boundary is first-order (§17.13)" (cons " (*unsupported type*);" (cons "- an export's declared errors differ from its function's (*arithmetic" (cons " mismatch*);" (cons "- the profile is `rust-core` and the program needs heap allocation, or its" (cons " effects state `allocation` (*hidden allocation*);" (cons "- its effects are not registered or not strictly ascending (*effects" (cons " mismatch*); or" (cons "- the manifest is malformed, its version not canonical, its sources not" (cons " canonical, its program invalid or without a faithful rendering, or an" (cons " export's arity wrong." (nil String))))))))))))))))))) + (cons "**Packages.** A package manifest (`lexlean/rust-package/1`," (cons "`schemas/rust-package.schema.json`) names a crate and its version (three" (cons "canonical decimals, each at most `2^64 - 1`, as Cargo reads them; the schema" (cons "pattern and the renderer agree), a profile, a target program, the exported" (cons "functions, and its `sources`: the semantic IDs (§21.4) of the LexLean builds" (cons "whose linked IR states the program, as lowercase SHA-256 hex, strictly" (cons "ascending, and empty for a program no LexLean build states. The renderer" (cons "checks their form and records them; that they name the build stating the" (cons "program is established by the conformance suite against the verified build" (cons "(below). That the program faithfully realizes the semantic objects of that" (cons "build (realization-to-source preservation) is the obligation of the" (cons "production pipeline that derives target programs from LexLean roots, not of" (cons "this backend: `sources` binds a package to the build that states its program," (cons "and the backend never derives a program from a build. Its `effects` are effects" (cons "of §17.13, strictly ascending and registered, that the package states of" (cons "itself. For a package a production root exports they are the set eligibility" (cons "requires of the root on the profile, which eligibility decides and the renderer" (cons "does not derive; for a package no root exports (a fixture) they are the effects" (cons "its program shows, `overflow` for an export that can fail and `recursion` for a" (cons "function that reaches itself, never `allocation`. They are not the effects the" (cons "realization can exhibit: the argument check an entry carries recurses over a" (cons "recursive argument type, and the graph templates' `nat_add` fuel bound can" (cons "overflow, and neither is among a root's required effects (issue 105). The" (cons "renderer refuses a list that is unregistered, unordered, or states `allocation`" (cons "on `rust-core`. Each export names a" (cons "program function, its Rust name, how it takes each parameter (`own`;" (cons "`borrow`, by shared reference; or `copy`, only for a `Copy` type: a scalar," (cons "or an option, result, or pair of `Copy` types), and whether it can fail" (cons "(`none` or `overflow`). A package is refused, as `LLB6005`, when:" (nil String)))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2446,7 +2446,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "A package is three files. `src/lib.rs` is the rendering with one public" (cons "wrapper per export. `Cargo.toml` declares the crate, its edition, no" (cons "dependencies, and its lint gate: `unsafe_code` forbidden, rustc warnings" (cons "denied, and every Clippy lint of the default set denied except the ten of the" (cons "table below, each because its advice would make the rendering depart from the" (cons "calculus." (nil String))))))) + (cons "- an exported name is not a lowercase snake-case identifier of at most 64" (cons " characters, is a Rust keyword, has the shape of a generated name, or is" (cons " declared by the runtime; a name is exported twice; or the crate name is a" (cons " sysroot crate or `harness` (*identifier collision*);" (cons "- an export copies a parameter whose type is not `Copy` (*ownership" (cons " mismatch*);" (cons "- an export's boundary holds a function value, directly or inside the fields" (cons " of a named type at any depth: the boundary is first-order (§17.13)" (cons " (*unsupported type*);" (cons "- an export's declared errors differ from its function's (*arithmetic" (cons " mismatch*);" (cons "- the profile is `rust-core` and the program needs heap allocation, or its" (cons " effects state `allocation` (*hidden allocation*);" (cons "- its effects are not registered or not strictly ascending (*effects" (cons " mismatch*); or" (cons "- the manifest is malformed, its version not canonical, its sources not" (cons " canonical, its program invalid or without a faithful rendering, or an" (cons " export's arity wrong." (nil String))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2460,7 +2460,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Scaffolding.** What a package says of itself beside its program is data, not" (cons "renderer text. The edition (2021), that the crate is not published, the gate" (cons "on rustc's lints, the Clippy group the gate starts from, and the" (cons "allowed lints, each with its Clippy group and its reason, are the declarations" (cons "of one language-1.2 semantic module, `RustPackage`, written in the authoring" (cons "notation at `language/package-1.2/library/src/RustPackage.lex.tex`. It is under `language/`," (cons "so the language-1.2 compiler-semantics ID (§21.2) covers it, and a changed" (cons "lint, edition, or gate changes LexLean's identity. The renderer reads it, and" (cons "neither evaluates it nor splices it into a rendering (the library's path is" (cons "not in it: `src/lib.rs` is the package's layout, `package::LIBRARY_PATH`, which" (cons "the provenance schema also fixes): `rust::scaffold` decodes" (cons "the module's semantic data, accepting exactly the shapes the module uses and" (cons "the declarations it names, and `package.rs` prints `Cargo.toml` over the" (cons "record. The crate attributes are derived, not stored: `#![no_std]` is the" (cons "target row of `language/production-1.2.toml` with `allocation = false`, and" (cons "`#![forbid(lint)]` restates each gate on rustc's lints at level `forbid` (so" (cons "`#![forbid(unsafe_code)]` and `unsafe_code = \"forbid\"` come from one row, and" (cons "a `lib.rs` built outside Cargo still forbids unsafe code). No source of the" (cons "renderer holds a string the module states (`scaffold::audit`). The module" (cons "states that no allowed lint is in Clippy's `correctness` group as a theorem" (cons "over the same list. The reader refuses a lint in that group and checks the" (cons "theorem by its shape (the predicate is false exactly on `correctness`, and the" (cons "theorem equates it over the list with `true`); the module is the project" (cons "`language/package-1.2/library`, whose check types it, and the kernel's replay" (cons "of the theorem's proof is that of `verify`, which no gate of this repository" (cons "runs on it." (nil String))))))))))))))))))))))))))) + (cons "A package is three files. `src/lib.rs` is the rendering with one public" (cons "wrapper per export. `Cargo.toml` declares the crate, its edition, no" (cons "dependencies, and its lint gate: `unsafe_code` forbidden, rustc warnings" (cons "denied, and every Clippy lint of the default set denied except the ten of the" (cons "table below, each because its advice would make the rendering depart from the" (cons "calculus." (nil String))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -2472,6 +2472,20 @@ name: i0182, parameters: [], result: DocRows::Item, + body: constructor{ + arguments: [ + (cons "**Scaffolding.** What a package says of itself beside its program is data, not" (cons "renderer text. The edition (2021), that the crate is not published, the gate" (cons "on rustc's lints, the Clippy group the gate starts from, and the" (cons "allowed lints, each with its Clippy group and its reason, are the declarations" (cons "of one language-1.2 semantic module, `RustPackage`, written in the authoring" (cons "notation at `language/package-1.2/library/src/RustPackage.lex.tex`. It is under `language/`," (cons "so the language-1.2 compiler-semantics ID (§21.2) covers it, and a changed" (cons "lint, edition, or gate changes LexLean's identity. The renderer reads it, and" (cons "neither evaluates it nor splices it into a rendering (the library's path is" (cons "not in it: `src/lib.rs` is the package's layout, `package::LIBRARY_PATH`, which" (cons "the provenance schema also fixes): `rust::scaffold` decodes" (cons "the module's semantic data, accepting exactly the shapes the module uses and" (cons "the declarations it names, and `package.rs` prints `Cargo.toml` over the" (cons "record. The crate attributes are derived, not stored: `#![no_std]` is the" (cons "target row of `language/production-1.2.toml` with `allocation = false`, and" (cons "`#![forbid(lint)]` restates each gate on rustc's lints at level `forbid` (so" (cons "`#![forbid(unsafe_code)]` and `unsafe_code = \"forbid\"` come from one row, and" (cons "a `lib.rs` built outside Cargo still forbids unsafe code). No source of the" (cons "renderer holds a string the module states (`scaffold::audit`). The module" (cons "states that no allowed lint is in Clippy's `correctness` group as a theorem" (cons "over the same list. The reader refuses a lint in that group and checks the" (cons "theorem by its shape (the predicate is false exactly on `correctness`, and the" (cons "theorem equates it over the list with `true`); the module is the project" (cons "`language/package-1.2/library`, whose check types it, and the kernel's replay" (cons "of the theorem's proof is that of `verify`, which no gate of this repository" (cons "runs on it." (nil String))))))))))))))))))))))))))) + ], + constructor: DocRows::Item.para, + type_arguments: [] + }, + executable: true +} + +definition{ + name: i0183, + parameters: [], + result: DocRows::Item, body: constructor{ arguments: [ (cons "| Lint | Clippy group | Reason |" (cons "| --- | --- | --- |" (cons "| `type_complexity` | complexity | asks for a type alias: a generated type is exactly its calculus type, and an alias is a name with no calculus counterpart |" (cons "| `too_many_arguments` | complexity | asks to group parameters into a struct: a function takes exactly its calculus parameters, and the struct is a type with no calculus counterpart |" (cons "| `large_enum_variant` | perf | asks to box a large variant: boxing changes the representation and allocates, which rust-core cannot and the calculus does not |" (cons "| `result_large_err` | perf | asks to box a large error: boxing changes the representation and allocates, which rust-core cannot and the calculus does not |" (cons "| `result_unit_err` | style | asks for an error type in place of unit: a function returns exactly its calculus result type, and the error type has no calculus counterpart |" (cons "| `single_match` | style | asks for `if let` or `if` in place of a match with an empty arm: every calculus match states an arm for every shape, and `if let` leaves one implicit |" (cons "| `manual_unwrap_or` | complexity | asks for a library combinator in place of the program's own match: the combinator is outside the closed runtime |" (cons "| `manual_unwrap_or_default` | suspicious | asks for a library combinator in place of the program's own match: the combinator is outside the closed runtime, and its advice is a rewrite that preserves the match's meaning, so allowing it masks no defect |" (cons "| `manual_map` | style | asks for `Option::map` and a Rust closure in place of the program's own match: a calculus closure is defunctionalized, never a Rust closure |" (cons "| `manual_ok_err` | complexity | asks for a library combinator in place of the program's own match: the combinator is outside the closed runtime |" (nil String))))))))))))) @@ -2483,7 +2497,7 @@ } definition{ - name: i0183, + name: i0184, parameters: [], result: DocRows::Item, body: constructor{ @@ -2497,7 +2511,7 @@ } definition{ - name: i0184, + name: i0185, parameters: [], result: DocRows::Item, body: constructor{ @@ -2511,7 +2525,7 @@ } definition{ - name: i0185, + name: i0186, parameters: [], result: DocRows::Item, body: constructor{ @@ -2525,7 +2539,7 @@ } definition{ - name: i0186, + name: i0187, parameters: [], result: DocRows::Item, body: constructor{ @@ -2539,7 +2553,7 @@ } definition{ - name: i0187, + name: i0188, parameters: [], result: DocRows::Item, body: constructor{ @@ -2551,7 +2565,7 @@ } definition{ - name: i0188, + name: i0189, parameters: [], result: DocRows::Item, body: constructor{ @@ -2565,7 +2579,7 @@ } definition{ - name: i0189, + name: i0190, parameters: [], result: DocRows::Item, body: constructor{ @@ -2579,7 +2593,7 @@ } definition{ - name: i0190, + name: i0191, parameters: [], result: DocRows::Item, body: constructor{ @@ -2593,7 +2607,7 @@ } definition{ - name: i0191, + name: i0192, parameters: [], result: DocRows::Item, body: constructor{ @@ -2608,7 +2622,7 @@ } definition{ - name: i0192, + name: i0193, parameters: [], result: DocRows::Item, body: constructor{ @@ -2622,7 +2636,7 @@ } definition{ - name: i0193, + name: i0194, parameters: [], result: DocRows::Item, body: constructor{ @@ -2636,7 +2650,7 @@ } definition{ - name: i0194, + name: i0195, parameters: [], result: DocRows::Item, body: constructor{ @@ -2650,7 +2664,7 @@ } definition{ - name: i0195, + name: i0196, parameters: [], result: DocRows::Item, body: constructor{ @@ -2664,7 +2678,7 @@ } definition{ - name: i0196, + name: i0197, parameters: [], result: DocRows::Item, body: constructor{ @@ -2678,7 +2692,7 @@ } definition{ - name: i0197, + name: i0198, parameters: [], result: DocRows::Item, body: constructor{ @@ -2692,7 +2706,7 @@ } definition{ - name: i0198, + name: i0199, parameters: [], result: DocRows::Item, body: constructor{ @@ -2706,7 +2720,7 @@ } definition{ - name: i0199, + name: i0200, parameters: [], result: DocRows::Item, body: constructor{ @@ -2720,7 +2734,7 @@ } definition{ - name: i0200, + name: i0201, parameters: [], result: DocRows::Item, body: constructor{ @@ -2734,7 +2748,7 @@ } definition{ - name: i0201, + name: i0202, parameters: [], result: DocRows::Item, body: constructor{ @@ -2748,7 +2762,7 @@ } definition{ - name: i0202, + name: i0203, parameters: [], result: DocRows::Item, body: constructor{ @@ -2762,7 +2776,7 @@ } definition{ - name: i0203, + name: i0204, parameters: [], result: DocRows::Item, body: constructor{ @@ -2776,7 +2790,7 @@ } definition{ - name: i0204, + name: i0205, parameters: [], result: DocRows::Item, body: constructor{ @@ -2790,7 +2804,7 @@ } definition{ - name: i0205, + name: i0206, parameters: [], result: DocRows::Item, body: constructor{ @@ -2804,7 +2818,7 @@ } definition{ - name: i0206, + name: i0207, parameters: [], result: DocRows::Item, body: constructor{ @@ -2818,7 +2832,7 @@ } definition{ - name: i0207, + name: i0208, parameters: [], result: DocRows::Item, body: constructor{ @@ -2832,7 +2846,7 @@ } definition{ - name: i0208, + name: i0209, parameters: [], result: DocRows::Item, body: constructor{ @@ -2847,7 +2861,7 @@ } definition{ - name: i0209, + name: i0210, parameters: [], result: DocRows::Item, body: constructor{ @@ -2861,7 +2875,7 @@ } definition{ - name: i0210, + name: i0211, parameters: [], result: DocRows::Item, body: constructor{ @@ -2875,7 +2889,7 @@ } definition{ - name: i0211, + name: i0212, parameters: [], result: DocRows::Item, body: constructor{ @@ -2889,7 +2903,7 @@ } definition{ - name: i0212, + name: i0213, parameters: [], result: DocRows::Item, body: constructor{ @@ -2904,7 +2918,7 @@ } definition{ - name: i0213, + name: i0214, parameters: [], result: DocRows::Item, body: constructor{ @@ -2919,7 +2933,7 @@ } definition{ - name: i0214, + name: i0215, parameters: [], result: DocRows::Item, body: constructor{ @@ -2934,7 +2948,7 @@ } definition{ - name: i0215, + name: i0216, parameters: [], result: DocRows::Item, body: constructor{ @@ -2949,7 +2963,7 @@ } definition{ - name: i0216, + name: i0217, parameters: [], result: DocRows::Item, body: constructor{ @@ -2964,7 +2978,7 @@ } definition{ - name: i0217, + name: i0218, parameters: [], result: DocRows::Item, body: constructor{ @@ -2978,7 +2992,7 @@ } definition{ - name: i0218, + name: i0219, parameters: [], result: DocRows::Item, body: constructor{ @@ -2992,7 +3006,7 @@ } definition{ - name: i0219, + name: i0220, parameters: [], result: DocRows::Item, body: constructor{ @@ -3006,7 +3020,7 @@ } definition{ - name: i0220, + name: i0221, parameters: [], result: DocRows::Item, body: constructor{ @@ -3020,7 +3034,7 @@ } definition{ - name: i0221, + name: i0222, parameters: [], result: DocRows::Item, body: constructor{ @@ -3034,7 +3048,7 @@ } definition{ - name: i0222, + name: i0223, parameters: [], result: DocRows::Item, body: constructor{ @@ -3048,7 +3062,7 @@ } definition{ - name: i0223, + name: i0224, parameters: [], result: DocRows::Item, body: constructor{ @@ -3062,7 +3076,7 @@ } definition{ - name: i0224, + name: i0225, parameters: [], result: DocRows::Item, body: constructor{ @@ -3076,7 +3090,7 @@ } definition{ - name: i0225, + name: i0226, parameters: [], result: DocRows::Item, body: constructor{ @@ -3088,7 +3102,7 @@ } definition{ - name: i0226, + name: i0227, parameters: [], result: DocRows::Item, body: constructor{ @@ -3102,7 +3116,7 @@ } definition{ - name: i0227, + name: i0228, parameters: [], result: DocRows::Item, body: constructor{ @@ -3116,7 +3130,7 @@ } definition{ - name: i0228, + name: i0229, parameters: [], result: DocRows::Item, body: constructor{ @@ -3130,7 +3144,7 @@ } definition{ - name: i0229, + name: i0230, parameters: [], result: DocRows::Item, body: constructor{ @@ -3145,7 +3159,7 @@ } definition{ - name: i0230, + name: i0231, parameters: [], result: DocRows::Item, body: constructor{ @@ -3159,7 +3173,7 @@ } definition{ - name: i0231, + name: i0232, parameters: [], result: DocRows::Item, body: constructor{ @@ -3174,7 +3188,7 @@ } definition{ - name: i0232, + name: i0233, parameters: [], result: DocRows::Item, body: constructor{ @@ -3188,7 +3202,7 @@ } definition{ - name: i0233, + name: i0234, parameters: [], result: DocRows::Item, body: constructor{ @@ -3202,7 +3216,7 @@ } definition{ - name: i0234, + name: i0235, parameters: [], result: DocRows::Item, body: constructor{ @@ -3216,7 +3230,7 @@ } definition{ - name: i0235, + name: i0236, parameters: [], result: DocRows::Item, body: constructor{ @@ -3230,7 +3244,7 @@ } definition{ - name: i0236, + name: i0237, parameters: [], result: DocRows::Item, body: constructor{ @@ -3244,7 +3258,7 @@ } definition{ - name: i0237, + name: i0238, parameters: [], result: DocRows::Item, body: constructor{ @@ -3258,7 +3272,7 @@ } definition{ - name: i0238, + name: i0239, parameters: [], result: DocRows::Item, body: constructor{ @@ -3272,7 +3286,7 @@ } definition{ - name: i0239, + name: i0240, parameters: [], result: DocRows::Item, body: constructor{ @@ -3286,7 +3300,7 @@ } definition{ - name: i0240, + name: i0241, parameters: [], result: DocRows::Item, body: constructor{ @@ -3300,7 +3314,7 @@ } definition{ - name: i0241, + name: i0242, parameters: [], result: DocRows::Item, body: constructor{ @@ -3315,7 +3329,7 @@ } definition{ - name: i0242, + name: i0243, parameters: [], result: DocRows::Item, body: constructor{ @@ -3329,7 +3343,7 @@ } definition{ - name: i0243, + name: i0244, parameters: [], result: DocRows::Item, body: constructor{ @@ -3341,7 +3355,7 @@ } definition{ - name: i0244, + name: i0245, parameters: [], result: DocRows::Item, body: constructor{ @@ -3355,7 +3369,7 @@ } definition{ - name: i0245, + name: i0246, parameters: [], result: DocRows::Item, body: constructor{ @@ -3369,7 +3383,7 @@ } definition{ - name: i0246, + name: i0247, parameters: [], result: DocRows::Item, body: constructor{ @@ -3383,7 +3397,7 @@ } definition{ - name: i0247, + name: i0248, parameters: [], result: DocRows::Item, body: constructor{ @@ -3397,7 +3411,7 @@ } definition{ - name: i0248, + name: i0249, parameters: [], result: DocRows::Item, body: constructor{ @@ -3411,7 +3425,7 @@ } definition{ - name: i0249, + name: i0250, parameters: [], result: DocRows::Item, body: constructor{ @@ -3425,7 +3439,7 @@ } definition{ - name: i0250, + name: i0251, parameters: [], result: DocRows::Item, body: constructor{ @@ -3439,7 +3453,7 @@ } definition{ - name: i0251, + name: i0252, parameters: [], result: DocRows::Item, body: constructor{ @@ -3453,7 +3467,7 @@ } definition{ - name: i0252, + name: i0253, parameters: [], result: DocRows::Item, body: constructor{ @@ -3467,7 +3481,7 @@ } definition{ - name: i0253, + name: i0254, parameters: [], result: DocRows::Item, body: constructor{ @@ -3481,7 +3495,7 @@ } definition{ - name: i0254, + name: i0255, parameters: [], result: DocRows::Item, body: constructor{ @@ -3495,7 +3509,7 @@ } definition{ - name: i0255, + name: i0256, parameters: [], result: DocRows::Item, body: constructor{ @@ -3509,7 +3523,7 @@ } definition{ - name: i0256, + name: i0257, parameters: [], result: DocRows::Item, body: constructor{ @@ -3523,7 +3537,7 @@ } definition{ - name: i0257, + name: i0258, parameters: [], result: DocRows::Item, body: constructor{ @@ -3537,7 +3551,7 @@ } definition{ - name: i0258, + name: i0259, parameters: [], result: DocRows::Item, body: constructor{ @@ -3551,7 +3565,7 @@ } definition{ - name: i0259, + name: i0260, parameters: [], result: DocRows::Item, body: constructor{ @@ -3565,7 +3579,7 @@ } definition{ - name: i0260, + name: i0261, parameters: [], result: DocRows::Item, body: constructor{ @@ -3579,7 +3593,7 @@ } definition{ - name: i0261, + name: i0262, parameters: [], result: DocRows::Item, body: constructor{ @@ -3591,7 +3605,7 @@ } definition{ - name: i0262, + name: i0263, parameters: [], result: DocRows::Item, body: constructor{ @@ -3605,7 +3619,7 @@ } definition{ - name: i0263, + name: i0264, parameters: [], result: DocRows::Item, body: constructor{ @@ -3619,7 +3633,7 @@ } definition{ - name: i0264, + name: i0265, parameters: [], result: DocRows::Item, body: constructor{ @@ -3633,7 +3647,7 @@ } definition{ - name: i0265, + name: i0266, parameters: [], result: DocRows::Item, body: constructor{ @@ -3647,7 +3661,7 @@ } definition{ - name: i0266, + name: i0267, parameters: [], result: DocRows::Item, body: constructor{ @@ -3661,7 +3675,7 @@ } definition{ - name: i0267, + name: i0268, parameters: [], result: DocRows::Item, body: constructor{ @@ -3675,7 +3689,7 @@ } definition{ - name: i0268, + name: i0269, parameters: [], result: DocRows::Item, body: constructor{ @@ -3689,7 +3703,7 @@ } definition{ - name: i0269, + name: i0270, parameters: [], result: DocRows::Item, body: constructor{ @@ -3703,7 +3717,7 @@ } definition{ - name: i0270, + name: i0271, parameters: [], result: DocRows::Item, body: constructor{ @@ -3717,7 +3731,7 @@ } definition{ - name: i0271, + name: i0272, parameters: [], result: DocRows::Item, body: constructor{ @@ -3731,7 +3745,7 @@ } definition{ - name: i0272, + name: i0273, parameters: [], result: DocRows::Item, body: constructor{ @@ -3745,7 +3759,7 @@ } definition{ - name: i0273, + name: i0274, parameters: [], result: DocRows::Item, body: constructor{ @@ -3759,7 +3773,7 @@ } definition{ - name: i0274, + name: i0275, parameters: [], result: DocRows::Item, body: constructor{ @@ -3773,7 +3787,7 @@ } definition{ - name: i0275, + name: i0276, parameters: [], result: DocRows::Item, body: constructor{ @@ -3787,7 +3801,7 @@ } definition{ - name: i0276, + name: i0277, parameters: [], result: DocRows::Item, body: constructor{ @@ -3801,7 +3815,7 @@ } definition{ - name: i0277, + name: i0278, parameters: [], result: DocRows::Item, body: constructor{ @@ -3815,7 +3829,7 @@ } definition{ - name: i0278, + name: i0279, parameters: [], result: DocRows::Item, body: constructor{ @@ -3829,7 +3843,7 @@ } definition{ - name: i0279, + name: i0280, parameters: [], result: DocRows::Item, body: constructor{ @@ -3843,7 +3857,7 @@ } definition{ - name: i0280, + name: i0281, parameters: [], result: DocRows::Item, body: constructor{ @@ -3857,7 +3871,7 @@ } definition{ - name: i0281, + name: i0282, parameters: [], result: DocRows::Item, body: constructor{ @@ -3869,7 +3883,7 @@ } definition{ - name: i0282, + name: i0283, parameters: [], result: DocRows::Item, body: constructor{ @@ -3883,7 +3897,7 @@ } definition{ - name: i0283, + name: i0284, parameters: [], result: DocRows::Item, body: constructor{ @@ -3897,7 +3911,7 @@ } definition{ - name: i0284, + name: i0285, parameters: [], result: DocRows::Item, body: constructor{ @@ -3911,7 +3925,7 @@ } definition{ - name: i0285, + name: i0286, parameters: [], result: DocRows::Item, body: constructor{ @@ -3925,7 +3939,7 @@ } definition{ - name: i0286, + name: i0287, parameters: [], result: DocRows::Item, body: constructor{ @@ -3939,7 +3953,7 @@ } definition{ - name: i0287, + name: i0288, parameters: [], result: DocRows::Item, body: constructor{ @@ -3953,7 +3967,7 @@ } definition{ - name: i0288, + name: i0289, parameters: [], result: DocRows::Item, body: constructor{ @@ -3967,7 +3981,7 @@ } definition{ - name: i0289, + name: i0290, parameters: [], result: DocRows::Item, body: constructor{ @@ -3981,7 +3995,7 @@ } definition{ - name: i0290, + name: i0291, parameters: [], result: DocRows::Item, body: constructor{ @@ -3995,7 +4009,7 @@ } definition{ - name: i0291, + name: i0292, parameters: [], result: DocRows::Item, body: constructor{ @@ -4009,7 +4023,7 @@ } definition{ - name: i0292, + name: i0293, parameters: [], result: DocRows::Item, body: constructor{ @@ -4023,7 +4037,7 @@ } definition{ - name: i0293, + name: i0294, parameters: [], result: DocRows::Item, body: constructor{ @@ -4037,7 +4051,7 @@ } definition{ - name: i0294, + name: i0295, parameters: [], result: DocRows::Item, body: constructor{ @@ -4051,7 +4065,7 @@ } definition{ - name: i0295, + name: i0296, parameters: [], result: DocRows::Item, body: constructor{ @@ -4065,7 +4079,7 @@ } definition{ - name: i0296, + name: i0297, parameters: [], result: DocRows::Item, body: constructor{ @@ -4077,7 +4091,7 @@ } definition{ - name: i0297, + name: i0298, parameters: [], result: DocRows::Item, body: constructor{ @@ -4091,7 +4105,7 @@ } definition{ - name: i0298, + name: i0299, parameters: [], result: DocRows::Item, body: constructor{ @@ -4103,7 +4117,7 @@ } definition{ - name: i0299, + name: i0300, parameters: [], result: DocRows::Item, body: constructor{ @@ -4117,7 +4131,7 @@ } definition{ - name: i0300, + name: i0301, parameters: [], result: DocRows::Item, body: constructor{ @@ -4131,7 +4145,7 @@ } definition{ - name: i0301, + name: i0302, parameters: [], result: DocRows::Item, body: constructor{ @@ -4143,7 +4157,7 @@ } definition{ - name: i0302, + name: i0303, parameters: [], result: DocRows::Item, body: constructor{ @@ -4157,7 +4171,7 @@ } definition{ - name: i0303, + name: i0304, parameters: [], result: DocRows::Item, body: constructor{ @@ -4172,7 +4186,7 @@ } definition{ - name: i0304, + name: i0305, parameters: [], result: DocRows::Item, body: constructor{ @@ -4186,7 +4200,7 @@ } definition{ - name: i0305, + name: i0306, parameters: [], result: DocRows::Item, body: constructor{ @@ -4198,7 +4212,7 @@ } definition{ - name: i0306, + name: i0307, parameters: [], result: DocRows::Item, body: constructor{ @@ -4212,7 +4226,7 @@ } definition{ - name: i0307, + name: i0308, parameters: [], result: DocRows::Item, body: constructor{ @@ -4227,7 +4241,7 @@ } definition{ - name: i0308, + name: i0309, parameters: [], result: DocRows::Item, body: constructor{ @@ -4241,7 +4255,7 @@ } definition{ - name: i0309, + name: i0310, parameters: [], result: DocRows::Item, body: constructor{ @@ -4253,7 +4267,7 @@ } definition{ - name: i0310, + name: i0311, parameters: [], result: DocRows::Item, body: constructor{ @@ -4267,7 +4281,7 @@ } definition{ - name: i0311, + name: i0312, parameters: [], result: DocRows::Item, body: constructor{ @@ -4281,7 +4295,7 @@ } definition{ - name: i0312, + name: i0313, parameters: [], result: DocRows::Item, body: constructor{ @@ -4293,7 +4307,7 @@ } definition{ - name: i0313, + name: i0314, parameters: [], result: DocRows::Item, body: constructor{ @@ -4307,7 +4321,7 @@ } definition{ - name: i0314, + name: i0315, parameters: [], result: DocRows::Item, body: constructor{ @@ -4321,7 +4335,7 @@ } definition{ - name: i0315, + name: i0316, parameters: [], result: DocRows::Item, body: constructor{ @@ -4335,7 +4349,7 @@ } definition{ - name: i0316, + name: i0317, parameters: [], result: DocRows::Item, body: constructor{ @@ -4349,7 +4363,7 @@ } definition{ - name: i0317, + name: i0318, parameters: [], result: DocRows::Item, body: constructor{ @@ -4363,7 +4377,7 @@ } definition{ - name: i0318, + name: i0319, parameters: [], result: DocRows::Item, body: constructor{ @@ -4375,7 +4389,7 @@ } definition{ - name: i0319, + name: i0320, parameters: [], result: DocRows::Item, body: constructor{ @@ -4389,7 +4403,7 @@ } definition{ - name: i0320, + name: i0321, parameters: [], result: DocRows::Item, body: constructor{ @@ -4403,7 +4417,7 @@ } definition{ - name: i0321, + name: i0322, parameters: [], result: DocRows::Item, body: constructor{ @@ -4415,7 +4429,7 @@ } definition{ - name: i0322, + name: i0323, parameters: [], result: DocRows::Item, body: constructor{ @@ -4429,7 +4443,7 @@ } definition{ - name: i0323, + name: i0324, parameters: [], result: DocRows::Item, body: constructor{ @@ -4443,7 +4457,7 @@ } definition{ - name: i0324, + name: i0325, parameters: [], result: DocRows::Item, body: constructor{ @@ -4455,7 +4469,7 @@ } definition{ - name: i0325, + name: i0326, parameters: [], result: DocRows::Item, body: constructor{ @@ -4469,7 +4483,7 @@ } definition{ - name: i0326, + name: i0327, parameters: [], result: DocRows::Item, body: constructor{ @@ -4481,7 +4495,7 @@ } definition{ - name: i0327, + name: i0328, parameters: [], result: DocRows::Item, body: constructor{ @@ -4495,7 +4509,7 @@ } definition{ - name: i0328, + name: i0329, parameters: [], result: DocRows::Item, body: constructor{ @@ -4509,7 +4523,7 @@ } definition{ - name: i0329, + name: i0330, parameters: [], result: DocRows::Item, body: constructor{ @@ -4524,7 +4538,7 @@ } definition{ - name: i0330, + name: i0331, parameters: [], result: DocRows::Item, body: constructor{ @@ -4538,7 +4552,7 @@ } definition{ - name: i0331, + name: i0332, parameters: [], result: DocRows::Item, body: constructor{ @@ -4552,7 +4566,7 @@ } definition{ - name: i0332, + name: i0333, parameters: [], result: DocRows::Item, body: constructor{ @@ -4566,7 +4580,7 @@ } definition{ - name: i0333, + name: i0334, parameters: [], result: DocRows::Item, body: constructor{ @@ -4580,7 +4594,7 @@ } definition{ - name: i0334, + name: i0335, parameters: [], result: DocRows::Item, body: constructor{ @@ -4594,7 +4608,7 @@ } definition{ - name: i0335, + name: i0336, parameters: [], result: DocRows::Item, body: constructor{ @@ -4606,7 +4620,7 @@ } definition{ - name: i0336, + name: i0337, parameters: [], result: DocRows::Item, body: constructor{ @@ -4620,7 +4634,7 @@ } definition{ - name: i0337, + name: i0338, parameters: [], result: DocRows::Item, body: constructor{ @@ -4634,7 +4648,7 @@ } definition{ - name: i0338, + name: i0339, parameters: [], result: DocRows::Item, body: constructor{ @@ -4648,7 +4662,7 @@ } definition{ - name: i0339, + name: i0340, parameters: [], result: DocRows::Item, body: constructor{ @@ -4662,7 +4676,7 @@ } definition{ - name: i0340, + name: i0341, parameters: [], result: DocRows::Item, body: constructor{ @@ -4676,7 +4690,7 @@ } definition{ - name: i0341, + name: i0342, parameters: [], result: DocRows::Item, body: constructor{ @@ -4690,7 +4704,7 @@ } definition{ - name: i0342, + name: i0343, parameters: [], result: DocRows::Item, body: constructor{ @@ -4704,7 +4718,7 @@ } definition{ - name: i0343, + name: i0344, parameters: [], result: DocRows::Item, body: constructor{ @@ -4716,7 +4730,7 @@ } definition{ - name: i0344, + name: i0345, parameters: [], result: DocRows::Item, body: constructor{ @@ -4730,7 +4744,7 @@ } definition{ - name: i0345, + name: i0346, parameters: [], result: DocRows::Item, body: constructor{ @@ -4744,7 +4758,7 @@ } definition{ - name: i0346, + name: i0347, parameters: [], result: DocRows::Item, body: constructor{ @@ -4758,7 +4772,7 @@ } definition{ - name: i0347, + name: i0348, parameters: [], result: DocRows::Item, body: constructor{ @@ -4772,7 +4786,7 @@ } definition{ - name: i0348, + name: i0349, parameters: [], result: DocRows::Item, body: constructor{ @@ -4786,7 +4800,7 @@ } definition{ - name: i0349, + name: i0350, parameters: [], result: DocRows::Item, body: constructor{ @@ -4800,7 +4814,7 @@ } definition{ - name: i0350, + name: i0351, parameters: [], result: DocRows::Item, body: constructor{ @@ -4814,7 +4828,7 @@ } definition{ - name: i0351, + name: i0352, parameters: [], result: DocRows::Item, body: constructor{ @@ -4828,7 +4842,7 @@ } definition{ - name: i0352, + name: i0353, parameters: [], result: DocRows::Item, body: constructor{ @@ -4842,7 +4856,7 @@ } definition{ - name: i0353, + name: i0354, parameters: [], result: DocRows::Item, body: constructor{ @@ -4856,7 +4870,7 @@ } definition{ - name: i0354, + name: i0355, parameters: [], result: DocRows::Item, body: constructor{ @@ -4870,7 +4884,7 @@ } definition{ - name: i0355, + name: i0356, parameters: [], result: DocRows::Item, body: constructor{ @@ -4884,7 +4898,7 @@ } definition{ - name: i0356, + name: i0357, parameters: [], result: DocRows::Item, body: constructor{ @@ -4898,7 +4912,7 @@ } definition{ - name: i0357, + name: i0358, parameters: [], result: DocRows::Item, body: constructor{ @@ -4912,7 +4926,7 @@ } definition{ - name: i0358, + name: i0359, parameters: [], result: DocRows::Item, body: constructor{ @@ -4926,7 +4940,7 @@ } definition{ - name: i0359, + name: i0360, parameters: [], result: DocRows::Item, body: constructor{ @@ -4940,7 +4954,7 @@ } definition{ - name: i0360, + name: i0361, parameters: [], result: DocRows::Item, body: constructor{ @@ -4954,7 +4968,7 @@ } definition{ - name: i0361, + name: i0362, parameters: [], result: DocRows::Item, body: constructor{ @@ -4968,7 +4982,7 @@ } definition{ - name: i0362, + name: i0363, parameters: [], result: DocRows::Item, body: constructor{ @@ -4982,7 +4996,7 @@ } definition{ - name: i0363, + name: i0364, parameters: [], result: DocRows::Item, body: constructor{ @@ -4996,7 +5010,7 @@ } definition{ - name: i0364, + name: i0365, parameters: [], result: DocRows::Item, body: constructor{ @@ -5010,7 +5024,7 @@ } definition{ - name: i0365, + name: i0366, parameters: [], result: DocRows::Item, body: constructor{ @@ -5024,7 +5038,7 @@ } definition{ - name: i0366, + name: i0367, parameters: [], result: DocRows::Item, body: constructor{ @@ -5038,12 +5052,12 @@ } definition{ - name: i0367, + name: i0368, parameters: [], result: DocRows::Item, body: constructor{ arguments: [ - (cons "A `Crate` is the closed Rust AST (`calculus::rust::ast`) as first-order data" (cons "(§17.13 rule 1): whether the profile is `rust-core`, and the items as a chain," (cons "each sort carrying its lists as its own `Nil`/`Cons` chain. A literal is" (cons "read for its kind and width and a runtime function for its row of the table" (cons "the module transcribes from `runtime::Item` (path, failure, heap use, width)," (cons "so the payload of a literal is not data. `Result.error` carries the oracle's" (cons "message to the byte, including the `{:?}` of a `Type`, of an `Option`," (cons "and of a slice of strings. `validateCrate` checks, in the order of the oracle," (cons "that each enum, `apply`, and function is declared once, that every type a crate" (cons "names is declared and, in `rust-core`, has no heap component (and no heap" (cons "construct or runtime function appears), that every name is bound once per" (cons "function and in scope, that a value is moved at most once on every path" (cons "(including the components of a pair, and the alternatives of an `if` and a" (cons "`match`), that a fallible call propagates exactly where its function is" (cons "fallible, and that each `apply` arm states the failure of the function it calls." (cons "A loop over a state (`Loop`, the constructor `ELoop` of the module) moves its" (cons "state into the loop's own binding and runs its body again after each `Ok`, so a" (cons "body that moves a name outside it, or a component of one, is refused with the" (cons "least such name in the oracle's order of names, and the value a fallible loop" (cons "ends with, at each `Err` of its body, must be a fallible value; the body is" (cons "checked as a block that is not a tail, for its applications as for its moves," (cons "and the correspondence traversal treats it as a block." (cons "`correspondCrate` lists the constructs a crate emits instance by instance and" (cons "checks each against the 97 rows of the correspondence table, the element it was" (cons "lowered from, its width, and the elements the program uses; a repeated" (cons "instance is kept once, which does not change which one the oracle reports" (cons "first. Lowering, printing, packaging, and the choice of profile are not part of" (cons "the claim, and a crate whose exported name or origin element holds a non-ASCII" (cons "or non-printable scalar is outside it." (nil String)))))))))))))))))))))))))))))) + (cons "A `Crate` is the closed Rust AST (`calculus::rust::ast`) as first-order data" (cons "(§17.13 rule 1): whether the profile is `rust-core`, and the items as a chain," (cons "each sort carrying its lists as its own `Nil`/`Cons` chain. A literal is" (cons "read for its kind and width and a runtime function for its row of the table" (cons "the module transcribes from `runtime::Item` (path, failure, heap use, width)," (cons "so the payload of a literal is not data. `Result.error` carries the oracle's" (cons "message to the byte, including the `{:?}` of a `Type`, of an `Option`," (cons "and of a slice of strings. `validateCrate` checks, in the order of the oracle," (cons "that each enum, `apply`, and function is declared once, that every type a crate" (cons "names is declared and, in `rust-core`, has no heap component (and no heap" (cons "construct or runtime function appears), that every name is bound once per" (cons "function and in scope, that a value is moved at most once on every path" (cons "(including the components of a pair, and the alternatives of an `if` and a" (cons "`match`), that a fallible call propagates exactly where its function is" (cons "fallible, and that each `apply` arm states the failure of the function it calls." (cons "A loop over a state (`Loop`, the constructor `ELoop` of the module) moves its" (cons "state into the loop's own binding and runs its body again after each `Ok`, so a" (cons "body that moves a name outside it, or a component of one, is refused with the" (cons "least such name in the oracle's order of names, and the value a fallible loop" (cons "ends with, at each `Err` of its body, must be a fallible value; the body is" (cons "checked as a block that is not a tail, for its applications as for its moves," (cons "and the correspondence traversal treats it as a block." (cons "`correspondCrate` lists the constructs a crate emits instance by instance and" (cons "checks each against the 98 rows of the correspondence table, the element it was" (cons "lowered from, its width, and the elements the program uses; a repeated" (cons "instance is kept once, which does not change which one the oracle reports" (cons "first. Lowering, printing, packaging, and the choice of profile are not part of" (cons "the claim, and a crate whose exported name or origin element holds a non-ASCII" (cons "or non-printable scalar is outside it." (nil String)))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -5052,12 +5066,12 @@ } definition{ - name: i0368, + name: i0369, parameters: [], result: DocRows::Item, body: constructor{ arguments: [ - (cons "`BS-05` holds both roots to the oracle. The crates are those the renderer" (cons "lowers (`rust::lower`) from the 164 distinct programs among the 247 committed" (cons "package manifests of `compiler/rust` and `tests/production-export` and the 122" (cons "fixtures of `compiler/fixtures` (223 distinct crates over both profiles, with" (cons "the `elements` the renderer realizes), a rule corpus that reaches each of the" (cons "48 refusals a crate of the closed AST can reach three times (132 `validateCrate`" (cons "runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run" (cons "out first; the refusal that a construct has no row of the table cannot be" (cons "reached), 17 crates by hand for the merge of moved sets at an `if` and a" (cons "`match`, and 34 by hand for the loop rules; that is 406 runs of `validateCrate`" (cons "(165 refused) and 269 of `correspondCrate` (46 refused), and the case asserts" (cons "these counts. On every host, the rendered `rust-std` packages of both" (cons "roots (§17.16), compiled by the pinned rustc, are run on all of them. On the" (cons "normative host, the lowered programs of both roots are run under the calculus" (cons "evaluator (§17.14) on the crates of at most 400 expressions (200 of the 223;" (cons "the larger ones are the compiler's own packages and are held to the oracle by" (cons "the compiled run) with the rule corpus, and on 500 seeded mutants of the" (cons "crates of at most 80 expressions (a node replaced by another of the crate, a" (cons "name, type, pattern, constructor, callee, origin, or width changed, an item or" (cons "binding or arm dropped, doubled, or swapped, a call's propagation flipped, a" (cons "dispatch arm restated, a block run in a loop, the profile exchanged, and the" (cons "elements of the program changed); the rendered packages are also run on 2,000 further seeded mutants" (cons "per root. The outcome of a run is the result and, for a refusal, the message," (cons "and one difference fails the case. Sixteen planted defects in the source (a heap" (cons "type admitted under `rust-core`, a name bound twice accepted, the moves of" (cons "earlier match arms forgotten, a component moved after its whole accepted, an" (cons "undeclared ADT type accepted, a `?` in an infallible function accepted, a" (cons "fallible call without propagation accepted, an `apply` arm's failure not" (cons "compared with its function's, a correspondence row narrowed, the width of a" (cons "runtime call not compared, a name or a component moved in a loop body accepted," (cons "the end of a fallible loop not checked, a loop's state not moved into the loop," (cons "the name a loop's refusal reports not the least, and a loop body checked as a" (cons "tail) are each detected by the same differential, and" (cons "under the pinned Lean the production export (§24.7) certifies both roots beside" (cons "the others, whose packages are the committed ones under" (cons "`tests/production-export/bootstrap/`." (nil String))))))))))))))))))))))))))))))))))))) + (cons "`BS-05` holds both roots to the oracle. The crates are those the renderer" (cons "lowers (`rust::lower`) from the 164 distinct programs among the 247 committed" (cons "package manifests of `compiler/rust` and `tests/production-export` and the 122" (cons "fixtures of `compiler/fixtures` (223 distinct crates over both profiles, with" (cons "the `elements` the renderer realizes), a rule corpus that reaches each of the" (cons "48 refusals a crate of the closed AST can reach three times (132 `validateCrate`" (cons "runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run" (cons "out first; the refusal that a construct has no row of the table cannot be" (cons "reached), 17 crates by hand for the merge of moved sets at an `if` and a" (cons "`match`, 34 by hand for the loop rules, and 5 by hand for the rule of a constant" (cons "(§17.16 *Constants*); that is 411 runs of `validateCrate`" (cons "(169 refused) and 269 of `correspondCrate` (46 refused), and the case asserts" (cons "these counts. On every host, the rendered `rust-std` packages of both" (cons "roots (§17.16), compiled by the pinned rustc, are run on all of them. On the" (cons "normative host, the lowered programs of both roots are run under the calculus" (cons "evaluator (§17.14) on the crates of at most 400 expressions (200 of the 223;" (cons "the larger ones are the compiler's own packages and are held to the oracle by" (cons "the compiled run) with the rule corpus, and on 500 seeded mutants of the" (cons "crates of at most 80 expressions (a node replaced by another of the crate, a" (cons "name, type, pattern, constructor, callee, origin, or width changed, an item or" (cons "binding or arm dropped, doubled, or swapped, a call's propagation flipped, a" (cons "dispatch arm restated, a block run in a loop, the profile exchanged, and the" (cons "elements of the program changed); the rendered packages are also run on 2,000 further seeded mutants" (cons "per root. The outcome of a run is the result and, for a refusal, the message," (cons "and one difference fails the case. Sixteen planted defects in the source (a heap" (cons "type admitted under `rust-core`, a name bound twice accepted, the moves of" (cons "earlier match arms forgotten, a component moved after its whole accepted, an" (cons "undeclared ADT type accepted, a `?` in an infallible function accepted, a" (cons "fallible call without propagation accepted, an `apply` arm's failure not" (cons "compared with its function's, a correspondence row narrowed, the width of a" (cons "runtime call not compared, a name or a component moved in a loop body accepted," (cons "the end of a fallible loop not checked, a loop's state not moved into the loop," (cons "the name a loop's refusal reports not the least, and a loop body checked as a" (cons "tail) are each detected by the same differential, and" (cons "under the pinned Lean the production export (§24.7) certifies both roots beside" (cons "the others, whose packages are the committed ones under" (cons "`tests/production-export/bootstrap/`." (nil String)))))))))))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] From 1811253dfaa34a24764c5207b212a58c270d3886 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 19:08:23 +0000 Subject: [PATCH 17/21] SP-24, MD-14: Artifacts as data is a chapter item of spec/src (SPEC.md is its projection) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- spec/src/Chapter17.lex.tex | 278 +++++++++++++++++++------------------ 1 file changed, 146 insertions(+), 132 deletions(-) diff --git a/spec/src/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index b7e52355bb..c98f3133a0 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -3249,7 +3249,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**A function rendered as a loop** (`SP-20`). The renderer writes a function whose" (cons "self calls are all tail calls as a loop (§17.16), so the crate no longer holds" (cons "the recursive body that the calculus function corresponds to. `FunOK` is" (cons "therefore the disjunction of two statements: `FunOK0`, the one above, and" (cons "`FunLoop`, that the crate's body is the loop form `loopOf` of an ordinary" (cons "recursive body, with the Boolean checks of `loopCheckOf` (the renamed" (cons "parameters and the kept ones are distinct, the originals of the changed" (cons "parameters are none of the kept ones, the kept ones are locals, and the loop" (cons "body mentions no renamed parameter) closed by evaluation, together with the" (cons "`Corr` derivation for that recursive body. The recursive body, how each" (cons "parameter is carried (changed, kept, or dropped), the state and result types," (cons "and the numbers of the holder and of the renamed parameters are the witnesses" (cons "of `FunLoop`. `funSem_loop` proves the simulation of such a function from the" (cons "simulation of the recursive body, the iteration of the loop on the iteration" (cons "of the calls, and `funSem_of` takes the second disjunct to it; `Corr`, its" (cons "recursor, and `sound` are untouched. The aligner recovers the witnesses by" (cons "inverting the rendering of loops, which reads the holder bound to the state," (cons "the destructuring that begins the loop body, the renamed parameters, and the" (cons "`Ok` and `Err` wraps of the tails, and then requires the library's form of the" (cons "recovered body, transliterated, to be exactly the crate's function: a loop that" (cons "is not in the image of the rendering is refused with *Certificate B rejected*" (cons "(`LLV7015`) and the reason, not aligned by guess. Two things of the recursive" (cons "body leave no trace in the loop form and are chosen: a kept parameter is read" (cons "by `Clone`, which the library accepts as it accepts every read, and the" (cons "argument of a dropped parameter is recovered only when it is a temporary the" (cons "block binds." (nil String))))))))))))))))))))))))))) + (cons "**Artifacts as data** (`SP-24`, `MD-14`). An artifact declaration (§17.12 rule" (cons "2) elaborates to a definition of its decoded value, which the lowering holds as" (cons "one literal of the target program when the definition's body is a list built" (cons "from `Nil` and `Cons` of literals: the declaration, and not the shape of a" (cons "term, decides which definitions fold, so an ordinary definition that builds the" (cons "same list keeps its construction. The literal is charged its weight on each read" (cons "(§17.14 *Cost*) where the chain it replaces was evaluated, node by node, at each" (cons "call, and the `rust-std` rendering holds it as a constant built once per thread" (cons "(§17.16 *Constants*). Certificate A relates the source's construction of the" (cons "list to the literal by the lemma that relates any literal to its value" (cons "(`conv_value`, stated for every `Value`), so the preservation library has no" (cons "new lemma and `Corr` no new constructor; certificate B encodes the constant as" (cons "the machine's `ItemDef.constant` (§17.16 *Constants*), whose function the" (cons "machine finds by the same lookup as any function, so the derivation of a" (cons "constant is the derivation of a function of no parameters over its literal." (nil String)))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -3263,7 +3263,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**No Lean text template in the production compiler.** The staged audit module" (cons "is an auxiliary module of typed commands (`#print axioms`, `#print \"marker\"`," (cons "`#print name`, `#check @name`) that the Lean backend renders. It is rendered" (cons "without the `module` header, because Lean refuses a `module` that imports a" (cons "file that is not one and the certificates it imports are rendered outside the" (cons "module system via `lean_text_legacy` (scoped in `namespace ` without a" (cons "`module` header so each certificate's inline decoder stays local and can be" (cons "imported by certificate E and the audit module). No other string literal under `crates/lexlean/src/production/`," (cons "and none in the probe and audit module part of `backend/lean.rs` beyond the" (cons "renderer of those commands and the quote of a name, is Lean syntax: a" (cons "lexer-level scan of the sources, which drops test code and reads every string" (cons "literal, finds none outside a short allow-list of the printouts of kernel terms" (cons "that developers read (`conformance_sp_17`; the definition of Lean syntax and" (cons "the planted templates it reports are in VERIFICATION.md)." (nil String))))))))))))))) + (cons "**A function rendered as a loop** (`SP-20`). The renderer writes a function whose" (cons "self calls are all tail calls as a loop (§17.16), so the crate no longer holds" (cons "the recursive body that the calculus function corresponds to. `FunOK` is" (cons "therefore the disjunction of two statements: `FunOK0`, the one above, and" (cons "`FunLoop`, that the crate's body is the loop form `loopOf` of an ordinary" (cons "recursive body, with the Boolean checks of `loopCheckOf` (the renamed" (cons "parameters and the kept ones are distinct, the originals of the changed" (cons "parameters are none of the kept ones, the kept ones are locals, and the loop" (cons "body mentions no renamed parameter) closed by evaluation, together with the" (cons "`Corr` derivation for that recursive body. The recursive body, how each" (cons "parameter is carried (changed, kept, or dropped), the state and result types," (cons "and the numbers of the holder and of the renamed parameters are the witnesses" (cons "of `FunLoop`. `funSem_loop` proves the simulation of such a function from the" (cons "simulation of the recursive body, the iteration of the loop on the iteration" (cons "of the calls, and `funSem_of` takes the second disjunct to it; `Corr`, its" (cons "recursor, and `sound` are untouched. The aligner recovers the witnesses by" (cons "inverting the rendering of loops, which reads the holder bound to the state," (cons "the destructuring that begins the loop body, the renamed parameters, and the" (cons "`Ok` and `Err` wraps of the tails, and then requires the library's form of the" (cons "recovered body, transliterated, to be exactly the crate's function: a loop that" (cons "is not in the image of the rendering is refused with *Certificate B rejected*" (cons "(`LLV7015`) and the reason, not aligned by guess. Two things of the recursive" (cons "body leave no trace in the loop form and are chosen: a kept parameter is read" (cons "by `Clone`, which the library accepts as it accepts every read, and the" (cons "argument of a dropped parameter is recovered only when it is a temporary the" (cons "block binds." (nil String))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -3277,7 +3277,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "**Evidence.** The conformance suite certifies every production root of" (cons "`examples/production`, `examples/production-coverage`, `examples/models`, and" (cons "`examples/reasoning`, and verification checks every example's certificates as part of its" (cons "published set. Together these roots exercise every runtime row of the" (cons "production registry (§17.13), a type parameter through an instance of a" (cons "generic definition: arithmetic at every width, text and bytes, documents," (cons "records, instances, generic and nested inductive types, higher-order" (cons "functions with captures, structural, mutual, and well-founded recursion," (cons "every collection template, every key order, the model constructs, and a" (cons "recursive tree (`Grove`) whose nodes carry a set, a list of children, a map," (cons "an option of a child, and a list of pairs of a number and a child, whose" (cons "leaves carry a map and whose third constructor holds a result of a child or a" (cons "number, and whose boundary validators are one mutual group." (nil String)))))))))))))) + (cons "**No Lean text template in the production compiler.** The staged audit module" (cons "is an auxiliary module of typed commands (`#print axioms`, `#print \"marker\"`," (cons "`#print name`, `#check @name`) that the Lean backend renders. It is rendered" (cons "without the `module` header, because Lean refuses a `module` that imports a" (cons "file that is not one and the certificates it imports are rendered outside the" (cons "module system via `lean_text_legacy` (scoped in `namespace ` without a" (cons "`module` header so each certificate's inline decoder stays local and can be" (cons "imported by certificate E and the audit module). No other string literal under `crates/lexlean/src/production/`," (cons "and none in the probe and audit module part of `backend/lean.rs` beyond the" (cons "renderer of those commands and the quote of a name, is Lean syntax: a" (cons "lexer-level scan of the sources, which drops test code and reads every string" (cons "literal, finds none outside a short allow-list of the printouts of kernel terms" (cons "that developers read (`conformance_sp_17`; the definition of Lean syntax and" (cons "the planted templates it reports are in VERIFICATION.md)." (nil String))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -3291,7 +3291,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "Mutations. It plants defects after lowering, while the proof is still" (cons "derived from the source, in the lowered program: branches swapped, an" (cons "addition that subtracts, a checked operation bounded as another, a wrong" (cons "constructor, a slice's bounds exchanged, a wrong callee, a wrong literal; and" (cons "in the boundary, an entry that omits the check of a validated parameter, a" (cons "validator that omits the check of a component of its type, and a validator" (cons "that admits an equal key. Each of the first seven is planted at the first, a" (cons "middle, and the last place it applies in the roots of the coverage example," (cons "and each of the three of the boundary at every place it applies, so that every" (cons "validated parameter and every component check is planted in turn. Lean must" (cons "reject each, and the first error must lie in the relation of the function the" (cons "mutation changed (`__rel_k` for a definition, instance, or lambda `k`," (cons "`__vrel_k` for a validator, `entry` for the entry; for a member of a library" (cons "template, whose relation the certificate states where it is instantiated, the" (cons "relation of a caller). It plants defects after rendering, in each crate," (cons "while the program is unchanged: the same kinds, and an entry that omits the" (cons "check of a validated parameter, at the first, a middle, and the last place" (cons "each applies across the renderings of the renderer fixtures and of the entries" (cons "of the coverage roots (every validated parameter for the last); the aligner" (cons "must refuse the crate naming the mutated function, or Lean's first error on" (cons "the realigned derivation and on the unmutated derivation restated over the" (cons "mutated crate must lie in the derivation `fun` of that function; the" (cons "width change is also refused by the renderer's correspondence check (§17.16)." (cons "A defect in A or B leaves certificate E unbuildable, since it imports both; it" (cons "also plants, in certificate E's own statement, at every place, the other" (cons "result shape of each `RealizesFn` and another function for each `fnIdent`," (cons "and Lean's first error must lie in the composition `root`. A lowering that does" (cons "not validate a parameter, or lowers a validator that checks nothing, is" (cons "planted in the lowered program and the certificate generator must refuse it" (cons "(**Boundary**); a call of a validator from the root, a validator that reaches" (cons "the program, and validators with no entry are each refused by the boundary" (cons "audit." (nil String))))))))))))))))))))))))))))))))) + (cons "**Evidence.** The conformance suite certifies every production root of" (cons "`examples/production`, `examples/production-coverage`, `examples/models`, and" (cons "`examples/reasoning`, and verification checks every example's certificates as part of its" (cons "published set. Together these roots exercise every runtime row of the" (cons "production registry (§17.13), a type parameter through an instance of a" (cons "generic definition: arithmetic at every width, text and bytes, documents," (cons "records, instances, generic and nested inductive types, higher-order" (cons "functions with captures, structural, mutual, and well-founded recursion," (cons "every collection template, every key order, the model constructs, and a" (cons "recursive tree (`Grove`) whose nodes carry a set, a list of children, a map," (cons "an option of a child, and a list of pairs of a number and a child, whose" (cons "leaves carry a map and whose third constructor holds a result of a child or a" (cons "number, and whose boundary validators are one mutual group." (nil String)))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -3305,7 +3305,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "Differentials. On seeded inputs to every root, on inputs with larger numbers" (cons "and longer sequences, on inputs at the top and the bottom of every scalar type" (cons "and with each parameter in turn at the top, on a search over inputs whose" (cons "scalars are each small or at a bound, and, through its entry, on valid inputs" (cons "and on inputs that break the invariant of each validated parameter in turn," (cons "the calculus interpreter's outcome must equal the certificate's `denote` or" (cons "`denoteEntry` evaluated by Lean and the declared machine's outcome on the" (cons "root's crate. Every root whose closure declares an overflow is run on an input" (cons "on which it overflows, so the overflow arm of each statement is exercised on" (cons "the interpreter, Lean, the machine, and rustc, except the roots below, whose" (cons "declared overflow no input reaches (the registry's effect rows" (cons "over-approximate). Of the 59 certified roots of the four examples, 44" (cons "declare an overflow, 19 of them reach it, and the other 25 rest on the" (cons "kernel proof alone for the overflow arm of E, B, and the machine, because" (cons "either the operands that can overflow do not depend on the root's parameters," (cons "or the overflow is a sequence, text, or collection of 2^64 elements, which no" (cons "test can build, or, for the model roots, no input found overflows their" (cons "arithmetic over the decoded weights, or, for four of the reasoning roots," (cons "no input found overflows the arithmetic of their rule guards and conclusions. The list is checked against the suite" (cons "both ways: a root on it that overflows, or a root off it that does not, fails" (cons "`conformance_sp_03`." (nil String)))))))))))))))))))))) + (cons "Mutations. It plants defects after lowering, while the proof is still" (cons "derived from the source, in the lowered program: branches swapped, an" (cons "addition that subtracts, a checked operation bounded as another, a wrong" (cons "constructor, a slice's bounds exchanged, a wrong callee, a wrong literal; and" (cons "in the boundary, an entry that omits the check of a validated parameter, a" (cons "validator that omits the check of a component of its type, and a validator" (cons "that admits an equal key. Each of the first seven is planted at the first, a" (cons "middle, and the last place it applies in the roots of the coverage example," (cons "and each of the three of the boundary at every place it applies, so that every" (cons "validated parameter and every component check is planted in turn. Lean must" (cons "reject each, and the first error must lie in the relation of the function the" (cons "mutation changed (`__rel_k` for a definition, instance, or lambda `k`," (cons "`__vrel_k` for a validator, `entry` for the entry; for a member of a library" (cons "template, whose relation the certificate states where it is instantiated, the" (cons "relation of a caller). It plants defects after rendering, in each crate," (cons "while the program is unchanged: the same kinds, and an entry that omits the" (cons "check of a validated parameter, at the first, a middle, and the last place" (cons "each applies across the renderings of the renderer fixtures and of the entries" (cons "of the coverage roots (every validated parameter for the last); the aligner" (cons "must refuse the crate naming the mutated function, or Lean's first error on" (cons "the realigned derivation and on the unmutated derivation restated over the" (cons "mutated crate must lie in the derivation `fun` of that function; the" (cons "width change is also refused by the renderer's correspondence check (§17.16)." (cons "A defect in A or B leaves certificate E unbuildable, since it imports both; it" (cons "also plants, in certificate E's own statement, at every place, the other" (cons "result shape of each `RealizesFn` and another function for each `fnIdent`," (cons "and Lean's first error must lie in the composition `root`. A lowering that does" (cons "not validate a parameter, or lowers a validator that checks nothing, is" (cons "planted in the lowered program and the certificate generator must refuse it" (cons "(**Boundary**); a call of a validator from the root, a validator that reaches" (cons "the program, and validators with no entry are each refused by the boundary" (cons "audit." (nil String))))))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] @@ -3317,6 +3317,20 @@ name: i0242, parameters: [], result: DocRows::Item, + body: constructor{ + arguments: [ + (cons "Differentials. On seeded inputs to every root, on inputs with larger numbers" (cons "and longer sequences, on inputs at the top and the bottom of every scalar type" (cons "and with each parameter in turn at the top, on a search over inputs whose" (cons "scalars are each small or at a bound, and, through its entry, on valid inputs" (cons "and on inputs that break the invariant of each validated parameter in turn," (cons "the calculus interpreter's outcome must equal the certificate's `denote` or" (cons "`denoteEntry` evaluated by Lean and the declared machine's outcome on the" (cons "root's crate. Every root whose closure declares an overflow is run on an input" (cons "on which it overflows, so the overflow arm of each statement is exercised on" (cons "the interpreter, Lean, the machine, and rustc, except the roots below, whose" (cons "declared overflow no input reaches (the registry's effect rows" (cons "over-approximate). Of the 59 certified roots of the four examples, 44" (cons "declare an overflow, 19 of them reach it, and the other 25 rest on the" (cons "kernel proof alone for the overflow arm of E, B, and the machine, because" (cons "either the operands that can overflow do not depend on the root's parameters," (cons "or the overflow is a sequence, text, or collection of 2^64 elements, which no" (cons "test can build, or, for the model roots, no input found overflows their" (cons "arithmetic over the decoded weights, or, for four of the reasoning roots," (cons "no input found overflows the arithmetic of their rule guards and conclusions. The list is checked against the suite" (cons "both ways: a root on it that overflows, or a root off it that does not, fails" (cons "`conformance_sp_03`." (nil String)))))))))))))))))))))) + ], + constructor: DocRows::Item.para, + type_arguments: [] + }, + executable: true +} + +definition{ + name: i0243, + parameters: [], + result: DocRows::Item, body: constructor{ arguments: [ "unreached-overflow", @@ -3329,7 +3343,7 @@ } definition{ - name: i0243, + name: i0244, parameters: [], result: DocRows::Item, body: constructor{ @@ -3343,7 +3357,7 @@ } definition{ - name: i0244, + name: i0245, parameters: [], result: DocRows::Item, body: constructor{ @@ -3355,7 +3369,7 @@ } definition{ - name: i0245, + name: i0246, parameters: [], result: DocRows::Item, body: constructor{ @@ -3369,7 +3383,7 @@ } definition{ - name: i0246, + name: i0247, parameters: [], result: DocRows::Item, body: constructor{ @@ -3383,7 +3397,7 @@ } definition{ - name: i0247, + name: i0248, parameters: [], result: DocRows::Item, body: constructor{ @@ -3397,7 +3411,7 @@ } definition{ - name: i0248, + name: i0249, parameters: [], result: DocRows::Item, body: constructor{ @@ -3411,7 +3425,7 @@ } definition{ - name: i0249, + name: i0250, parameters: [], result: DocRows::Item, body: constructor{ @@ -3425,7 +3439,7 @@ } definition{ - name: i0250, + name: i0251, parameters: [], result: DocRows::Item, body: constructor{ @@ -3439,7 +3453,7 @@ } definition{ - name: i0251, + name: i0252, parameters: [], result: DocRows::Item, body: constructor{ @@ -3453,7 +3467,7 @@ } definition{ - name: i0252, + name: i0253, parameters: [], result: DocRows::Item, body: constructor{ @@ -3467,7 +3481,7 @@ } definition{ - name: i0253, + name: i0254, parameters: [], result: DocRows::Item, body: constructor{ @@ -3481,7 +3495,7 @@ } definition{ - name: i0254, + name: i0255, parameters: [], result: DocRows::Item, body: constructor{ @@ -3495,7 +3509,7 @@ } definition{ - name: i0255, + name: i0256, parameters: [], result: DocRows::Item, body: constructor{ @@ -3509,7 +3523,7 @@ } definition{ - name: i0256, + name: i0257, parameters: [], result: DocRows::Item, body: constructor{ @@ -3523,7 +3537,7 @@ } definition{ - name: i0257, + name: i0258, parameters: [], result: DocRows::Item, body: constructor{ @@ -3537,7 +3551,7 @@ } definition{ - name: i0258, + name: i0259, parameters: [], result: DocRows::Item, body: constructor{ @@ -3551,7 +3565,7 @@ } definition{ - name: i0259, + name: i0260, parameters: [], result: DocRows::Item, body: constructor{ @@ -3565,7 +3579,7 @@ } definition{ - name: i0260, + name: i0261, parameters: [], result: DocRows::Item, body: constructor{ @@ -3579,7 +3593,7 @@ } definition{ - name: i0261, + name: i0262, parameters: [], result: DocRows::Item, body: constructor{ @@ -3593,7 +3607,7 @@ } definition{ - name: i0262, + name: i0263, parameters: [], result: DocRows::Item, body: constructor{ @@ -3605,7 +3619,7 @@ } definition{ - name: i0263, + name: i0264, parameters: [], result: DocRows::Item, body: constructor{ @@ -3619,7 +3633,7 @@ } definition{ - name: i0264, + name: i0265, parameters: [], result: DocRows::Item, body: constructor{ @@ -3633,7 +3647,7 @@ } definition{ - name: i0265, + name: i0266, parameters: [], result: DocRows::Item, body: constructor{ @@ -3647,7 +3661,7 @@ } definition{ - name: i0266, + name: i0267, parameters: [], result: DocRows::Item, body: constructor{ @@ -3661,7 +3675,7 @@ } definition{ - name: i0267, + name: i0268, parameters: [], result: DocRows::Item, body: constructor{ @@ -3675,7 +3689,7 @@ } definition{ - name: i0268, + name: i0269, parameters: [], result: DocRows::Item, body: constructor{ @@ -3689,7 +3703,7 @@ } definition{ - name: i0269, + name: i0270, parameters: [], result: DocRows::Item, body: constructor{ @@ -3703,7 +3717,7 @@ } definition{ - name: i0270, + name: i0271, parameters: [], result: DocRows::Item, body: constructor{ @@ -3717,7 +3731,7 @@ } definition{ - name: i0271, + name: i0272, parameters: [], result: DocRows::Item, body: constructor{ @@ -3731,7 +3745,7 @@ } definition{ - name: i0272, + name: i0273, parameters: [], result: DocRows::Item, body: constructor{ @@ -3745,7 +3759,7 @@ } definition{ - name: i0273, + name: i0274, parameters: [], result: DocRows::Item, body: constructor{ @@ -3759,7 +3773,7 @@ } definition{ - name: i0274, + name: i0275, parameters: [], result: DocRows::Item, body: constructor{ @@ -3773,7 +3787,7 @@ } definition{ - name: i0275, + name: i0276, parameters: [], result: DocRows::Item, body: constructor{ @@ -3787,7 +3801,7 @@ } definition{ - name: i0276, + name: i0277, parameters: [], result: DocRows::Item, body: constructor{ @@ -3801,7 +3815,7 @@ } definition{ - name: i0277, + name: i0278, parameters: [], result: DocRows::Item, body: constructor{ @@ -3815,7 +3829,7 @@ } definition{ - name: i0278, + name: i0279, parameters: [], result: DocRows::Item, body: constructor{ @@ -3829,7 +3843,7 @@ } definition{ - name: i0279, + name: i0280, parameters: [], result: DocRows::Item, body: constructor{ @@ -3843,7 +3857,7 @@ } definition{ - name: i0280, + name: i0281, parameters: [], result: DocRows::Item, body: constructor{ @@ -3857,7 +3871,7 @@ } definition{ - name: i0281, + name: i0282, parameters: [], result: DocRows::Item, body: constructor{ @@ -3871,7 +3885,7 @@ } definition{ - name: i0282, + name: i0283, parameters: [], result: DocRows::Item, body: constructor{ @@ -3883,7 +3897,7 @@ } definition{ - name: i0283, + name: i0284, parameters: [], result: DocRows::Item, body: constructor{ @@ -3897,7 +3911,7 @@ } definition{ - name: i0284, + name: i0285, parameters: [], result: DocRows::Item, body: constructor{ @@ -3911,7 +3925,7 @@ } definition{ - name: i0285, + name: i0286, parameters: [], result: DocRows::Item, body: constructor{ @@ -3925,7 +3939,7 @@ } definition{ - name: i0286, + name: i0287, parameters: [], result: DocRows::Item, body: constructor{ @@ -3939,7 +3953,7 @@ } definition{ - name: i0287, + name: i0288, parameters: [], result: DocRows::Item, body: constructor{ @@ -3953,7 +3967,7 @@ } definition{ - name: i0288, + name: i0289, parameters: [], result: DocRows::Item, body: constructor{ @@ -3967,7 +3981,7 @@ } definition{ - name: i0289, + name: i0290, parameters: [], result: DocRows::Item, body: constructor{ @@ -3981,7 +3995,7 @@ } definition{ - name: i0290, + name: i0291, parameters: [], result: DocRows::Item, body: constructor{ @@ -3995,7 +4009,7 @@ } definition{ - name: i0291, + name: i0292, parameters: [], result: DocRows::Item, body: constructor{ @@ -4009,7 +4023,7 @@ } definition{ - name: i0292, + name: i0293, parameters: [], result: DocRows::Item, body: constructor{ @@ -4023,7 +4037,7 @@ } definition{ - name: i0293, + name: i0294, parameters: [], result: DocRows::Item, body: constructor{ @@ -4037,7 +4051,7 @@ } definition{ - name: i0294, + name: i0295, parameters: [], result: DocRows::Item, body: constructor{ @@ -4051,7 +4065,7 @@ } definition{ - name: i0295, + name: i0296, parameters: [], result: DocRows::Item, body: constructor{ @@ -4065,7 +4079,7 @@ } definition{ - name: i0296, + name: i0297, parameters: [], result: DocRows::Item, body: constructor{ @@ -4079,7 +4093,7 @@ } definition{ - name: i0297, + name: i0298, parameters: [], result: DocRows::Item, body: constructor{ @@ -4091,7 +4105,7 @@ } definition{ - name: i0298, + name: i0299, parameters: [], result: DocRows::Item, body: constructor{ @@ -4105,7 +4119,7 @@ } definition{ - name: i0299, + name: i0300, parameters: [], result: DocRows::Item, body: constructor{ @@ -4117,7 +4131,7 @@ } definition{ - name: i0300, + name: i0301, parameters: [], result: DocRows::Item, body: constructor{ @@ -4131,7 +4145,7 @@ } definition{ - name: i0301, + name: i0302, parameters: [], result: DocRows::Item, body: constructor{ @@ -4145,7 +4159,7 @@ } definition{ - name: i0302, + name: i0303, parameters: [], result: DocRows::Item, body: constructor{ @@ -4157,7 +4171,7 @@ } definition{ - name: i0303, + name: i0304, parameters: [], result: DocRows::Item, body: constructor{ @@ -4171,7 +4185,7 @@ } definition{ - name: i0304, + name: i0305, parameters: [], result: DocRows::Item, body: constructor{ @@ -4186,7 +4200,7 @@ } definition{ - name: i0305, + name: i0306, parameters: [], result: DocRows::Item, body: constructor{ @@ -4200,7 +4214,7 @@ } definition{ - name: i0306, + name: i0307, parameters: [], result: DocRows::Item, body: constructor{ @@ -4212,7 +4226,7 @@ } definition{ - name: i0307, + name: i0308, parameters: [], result: DocRows::Item, body: constructor{ @@ -4226,7 +4240,7 @@ } definition{ - name: i0308, + name: i0309, parameters: [], result: DocRows::Item, body: constructor{ @@ -4241,7 +4255,7 @@ } definition{ - name: i0309, + name: i0310, parameters: [], result: DocRows::Item, body: constructor{ @@ -4255,7 +4269,7 @@ } definition{ - name: i0310, + name: i0311, parameters: [], result: DocRows::Item, body: constructor{ @@ -4267,7 +4281,7 @@ } definition{ - name: i0311, + name: i0312, parameters: [], result: DocRows::Item, body: constructor{ @@ -4281,7 +4295,7 @@ } definition{ - name: i0312, + name: i0313, parameters: [], result: DocRows::Item, body: constructor{ @@ -4295,7 +4309,7 @@ } definition{ - name: i0313, + name: i0314, parameters: [], result: DocRows::Item, body: constructor{ @@ -4307,7 +4321,7 @@ } definition{ - name: i0314, + name: i0315, parameters: [], result: DocRows::Item, body: constructor{ @@ -4321,7 +4335,7 @@ } definition{ - name: i0315, + name: i0316, parameters: [], result: DocRows::Item, body: constructor{ @@ -4335,7 +4349,7 @@ } definition{ - name: i0316, + name: i0317, parameters: [], result: DocRows::Item, body: constructor{ @@ -4349,7 +4363,7 @@ } definition{ - name: i0317, + name: i0318, parameters: [], result: DocRows::Item, body: constructor{ @@ -4363,7 +4377,7 @@ } definition{ - name: i0318, + name: i0319, parameters: [], result: DocRows::Item, body: constructor{ @@ -4377,7 +4391,7 @@ } definition{ - name: i0319, + name: i0320, parameters: [], result: DocRows::Item, body: constructor{ @@ -4389,7 +4403,7 @@ } definition{ - name: i0320, + name: i0321, parameters: [], result: DocRows::Item, body: constructor{ @@ -4403,7 +4417,7 @@ } definition{ - name: i0321, + name: i0322, parameters: [], result: DocRows::Item, body: constructor{ @@ -4417,7 +4431,7 @@ } definition{ - name: i0322, + name: i0323, parameters: [], result: DocRows::Item, body: constructor{ @@ -4429,7 +4443,7 @@ } definition{ - name: i0323, + name: i0324, parameters: [], result: DocRows::Item, body: constructor{ @@ -4443,7 +4457,7 @@ } definition{ - name: i0324, + name: i0325, parameters: [], result: DocRows::Item, body: constructor{ @@ -4457,7 +4471,7 @@ } definition{ - name: i0325, + name: i0326, parameters: [], result: DocRows::Item, body: constructor{ @@ -4469,7 +4483,7 @@ } definition{ - name: i0326, + name: i0327, parameters: [], result: DocRows::Item, body: constructor{ @@ -4483,7 +4497,7 @@ } definition{ - name: i0327, + name: i0328, parameters: [], result: DocRows::Item, body: constructor{ @@ -4495,7 +4509,7 @@ } definition{ - name: i0328, + name: i0329, parameters: [], result: DocRows::Item, body: constructor{ @@ -4509,7 +4523,7 @@ } definition{ - name: i0329, + name: i0330, parameters: [], result: DocRows::Item, body: constructor{ @@ -4523,7 +4537,7 @@ } definition{ - name: i0330, + name: i0331, parameters: [], result: DocRows::Item, body: constructor{ @@ -4538,7 +4552,7 @@ } definition{ - name: i0331, + name: i0332, parameters: [], result: DocRows::Item, body: constructor{ @@ -4552,7 +4566,7 @@ } definition{ - name: i0332, + name: i0333, parameters: [], result: DocRows::Item, body: constructor{ @@ -4566,7 +4580,7 @@ } definition{ - name: i0333, + name: i0334, parameters: [], result: DocRows::Item, body: constructor{ @@ -4580,7 +4594,7 @@ } definition{ - name: i0334, + name: i0335, parameters: [], result: DocRows::Item, body: constructor{ @@ -4594,7 +4608,7 @@ } definition{ - name: i0335, + name: i0336, parameters: [], result: DocRows::Item, body: constructor{ @@ -4608,7 +4622,7 @@ } definition{ - name: i0336, + name: i0337, parameters: [], result: DocRows::Item, body: constructor{ @@ -4620,7 +4634,7 @@ } definition{ - name: i0337, + name: i0338, parameters: [], result: DocRows::Item, body: constructor{ @@ -4634,7 +4648,7 @@ } definition{ - name: i0338, + name: i0339, parameters: [], result: DocRows::Item, body: constructor{ @@ -4648,7 +4662,7 @@ } definition{ - name: i0339, + name: i0340, parameters: [], result: DocRows::Item, body: constructor{ @@ -4662,7 +4676,7 @@ } definition{ - name: i0340, + name: i0341, parameters: [], result: DocRows::Item, body: constructor{ @@ -4676,7 +4690,7 @@ } definition{ - name: i0341, + name: i0342, parameters: [], result: DocRows::Item, body: constructor{ @@ -4690,7 +4704,7 @@ } definition{ - name: i0342, + name: i0343, parameters: [], result: DocRows::Item, body: constructor{ @@ -4704,7 +4718,7 @@ } definition{ - name: i0343, + name: i0344, parameters: [], result: DocRows::Item, body: constructor{ @@ -4718,7 +4732,7 @@ } definition{ - name: i0344, + name: i0345, parameters: [], result: DocRows::Item, body: constructor{ @@ -4730,7 +4744,7 @@ } definition{ - name: i0345, + name: i0346, parameters: [], result: DocRows::Item, body: constructor{ @@ -4744,7 +4758,7 @@ } definition{ - name: i0346, + name: i0347, parameters: [], result: DocRows::Item, body: constructor{ @@ -4758,7 +4772,7 @@ } definition{ - name: i0347, + name: i0348, parameters: [], result: DocRows::Item, body: constructor{ @@ -4772,7 +4786,7 @@ } definition{ - name: i0348, + name: i0349, parameters: [], result: DocRows::Item, body: constructor{ @@ -4786,7 +4800,7 @@ } definition{ - name: i0349, + name: i0350, parameters: [], result: DocRows::Item, body: constructor{ @@ -4800,7 +4814,7 @@ } definition{ - name: i0350, + name: i0351, parameters: [], result: DocRows::Item, body: constructor{ @@ -4814,7 +4828,7 @@ } definition{ - name: i0351, + name: i0352, parameters: [], result: DocRows::Item, body: constructor{ @@ -4828,7 +4842,7 @@ } definition{ - name: i0352, + name: i0353, parameters: [], result: DocRows::Item, body: constructor{ @@ -4842,7 +4856,7 @@ } definition{ - name: i0353, + name: i0354, parameters: [], result: DocRows::Item, body: constructor{ @@ -4856,7 +4870,7 @@ } definition{ - name: i0354, + name: i0355, parameters: [], result: DocRows::Item, body: constructor{ @@ -4870,7 +4884,7 @@ } definition{ - name: i0355, + name: i0356, parameters: [], result: DocRows::Item, body: constructor{ @@ -4884,7 +4898,7 @@ } definition{ - name: i0356, + name: i0357, parameters: [], result: DocRows::Item, body: constructor{ @@ -4898,7 +4912,7 @@ } definition{ - name: i0357, + name: i0358, parameters: [], result: DocRows::Item, body: constructor{ @@ -4912,7 +4926,7 @@ } definition{ - name: i0358, + name: i0359, parameters: [], result: DocRows::Item, body: constructor{ @@ -4926,7 +4940,7 @@ } definition{ - name: i0359, + name: i0360, parameters: [], result: DocRows::Item, body: constructor{ @@ -4940,7 +4954,7 @@ } definition{ - name: i0360, + name: i0361, parameters: [], result: DocRows::Item, body: constructor{ @@ -4954,7 +4968,7 @@ } definition{ - name: i0361, + name: i0362, parameters: [], result: DocRows::Item, body: constructor{ @@ -4968,7 +4982,7 @@ } definition{ - name: i0362, + name: i0363, parameters: [], result: DocRows::Item, body: constructor{ @@ -4982,7 +4996,7 @@ } definition{ - name: i0363, + name: i0364, parameters: [], result: DocRows::Item, body: constructor{ @@ -4996,7 +5010,7 @@ } definition{ - name: i0364, + name: i0365, parameters: [], result: DocRows::Item, body: constructor{ @@ -5010,7 +5024,7 @@ } definition{ - name: i0365, + name: i0366, parameters: [], result: DocRows::Item, body: constructor{ @@ -5024,7 +5038,7 @@ } definition{ - name: i0366, + name: i0367, parameters: [], result: DocRows::Item, body: constructor{ @@ -5038,7 +5052,7 @@ } definition{ - name: i0367, + name: i0368, parameters: [], result: DocRows::Item, body: constructor{ @@ -5052,7 +5066,7 @@ } definition{ - name: i0368, + name: i0369, parameters: [], result: DocRows::Item, body: constructor{ @@ -5066,7 +5080,7 @@ } definition{ - name: i0369, + name: i0370, parameters: [], result: DocRows::Item, body: constructor{ From e288efe00342240a181b33792b88b01d45e4e496 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 19:19:03 +0000 Subject: [PATCH 18/21] README: the register has 442 IDs (RP-11) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c411a9713..67c13be9a3 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ just vv # the complete normative acceptance gate (SPEC.md §9.2) just release # vv, then the §30 release criterion; refused until 1.0.0 ``` -All 438 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed. +All 442 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed. The differential against the independent generator `lean4-prod` (SPEC.md §17.19, `OR-01`..`OR-08`) acquires it at its pinned commit: from the checkout `LEXLEAN_ORACLE_DIR` names, or by fetching the commit with `git` into the Cargo target directory (`LEXLEAN_ORACLE_CACHE` overrides), and builds it with the pinned Lean and Rust toolchains. It is validation evidence only and no input to any identity. An oracle that cannot be acquired, is not the pinned files, or fails is unavailable: that fails the gate on Linux x86-64 and is printed as `NOT VALIDATED` elsewhere, and is never reported as agreement. From 4e77ba24f6da58fc5f3b81005f77452c5d32108f Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 19:19:37 +0000 Subject: [PATCH 19/21] README: the capability ranges end at the register's last TC, RB, SP, and MD IDs (RP-11) Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 67c13be9a3..f520a5a4a0 100644 --- a/README.md +++ b/README.md @@ -176,12 +176,12 @@ Every row is validated by `just vv`; the IDs link the claim to its register row, | Filesystem confinement, no shell, no hidden network, closed failure model | `SE-01`..`SE-12` | `build` | | Language-1.2 production eligibility: closed targets, effects, and construct dispositions; runtime closures; target-dependent, fail-closed root analysis; deterministic eligibility reports; an exhaustiveness audit; measured stack bounds for every recursive root a harness runs | `PD-01`..`PD-08` | `build` | | Named-root extraction through Lean's compiler front end: an adapter that is a closed tooling module over a registry derived from the pinned Lean and probed on every extraction, checked against a handwritten oracle; a closed, canonical, root-independent compiler input; fail-closed rejection; and an exact closure cross-check against production eligibility | `NE-01`..`NE-06` | `build` | -| The production realization calculus: a closed target syntax with canonical identity, a kernel-checked denotation, a realization library agreeing with LexLean's own collection primitives, complete realization coverage of the production registry, and a differentially tested Rust profile | `TC-01`..`TC-07` | `build` | -| The canonical Rust backend: a closed, checked Rust AST whose every construct corresponds to the calculus; hygienic identifiers, single ownership with last-use and component moves, exact failure typing, and no hidden allocation; contiguous lists with constant-work cells; a closed runtime library boundary of stated machine primitives; deterministic packages with checked exports, a lint gate and crate attributes read from one embedded language module, and provenance that states the realization's effects | `RB-01`..`RB-14` | `build` | +| The production realization calculus: a closed target syntax with canonical identity, a kernel-checked denotation, a realization library agreeing with LexLean's own collection primitives, complete realization coverage of the production registry, and a differentially tested Rust profile | `TC-01`..`TC-08` | `build` | +| The canonical Rust backend: a closed, checked Rust AST whose every construct corresponds to the calculus; hygienic identifiers, single ownership with last-use and component moves, exact failure typing, and no hidden allocation; contiguous lists with constant-work cells; a closed runtime library boundary of stated machine primitives; deterministic packages with checked exports, a lint gate and crate attributes read from one embedded language module, and provenance that states the realization's effects | `RB-01`..`RB-18` | `build` | | GNAF requests over the calculus: an optimizer-independent complete-system universe, a machine contract that accounts every action, scalar and Pareto orders without weighting, fail-closed validation, and kernel-checked answers and authority vectors | `GN-01`..`GN-08` | `build` | | GNAF certification: certificates that prove a global optimum, an argmin, or a complete Pareto frontier over the independent universe from a premise for every system, a library proving the checker sound, closed transformation schemas, local normality kept distinct from optimality, a bridge from a representation metric to execution cost, and honest non-global statuses | `GC-01`..`GC-11` | `build` | -| Semantic preservation from the source to the calculus: a validated lowering of every production root, a kernel-checked certificate per root relating the lowered program to the source denotation with exact width predicates, a differential evaluator, a proof library that is LexLean source (native core modules migrated once from the Lean it replaces, its Lean generated by the compiler) pinned by exact axioms, certificate checking in verification, a declared Rust machine on which every rendering is evaluated, certificate B relating every rendering to its program, certificate E composing them end to end, boundary validators, a rustc differential of the declared machine, and certificates A and B as kernel-term data built by the production compiler, which carries no Lean text template | `SP-01`..`SP-20` | `build` | -| Language-1.2 models: content-addressed typed artifacts, contracts with sound validators, exact deterministic, rule, statistical, neural, and composite realizations, generated evidence obligations restated in Lean, checked runtime boundaries, and their identity, production, and verification | `MD-01`..`MD-13` | `build` | +| Semantic preservation from the source to the calculus: a validated lowering of every production root, a kernel-checked certificate per root relating the lowered program to the source denotation with exact width predicates, a differential evaluator, a proof library that is LexLean source (native core modules migrated once from the Lean it replaces, its Lean generated by the compiler) pinned by exact axioms, certificate checking in verification, a declared Rust machine on which every rendering is evaluated, certificate B relating every rendering to its program, certificate E composing them end to end, boundary validators, a rustc differential of the declared machine, and certificates A and B as kernel-term data built by the production compiler, which carries no Lean text template | `SP-01`..`SP-24` | `build` | +| Language-1.2 models: content-addressed typed artifacts, contracts with sound validators, exact deterministic, rule, statistical, neural, and composite realizations, generated evidence obligations restated in Lean, checked runtime boundaries, and their identity, production, and verification | `MD-01`..`MD-14` | `build` | | The differential validation oracle: `lean4-prod` pinned by commit and content hash as validation evidence only, a corpus of every production root and one probe per runtime construct, a comparison of acceptance, contract, behavior, and resources that never compares bytes, versioned tables of known differences and of constructs outside the overlap, planted discrepancies detected, failures that are unavailable rather than validated, and its isolation from every identity | `OR-01`..`OR-08` | `build` | | The production export contract: a stable, versioned `lexlean::api::production` façade and its CLI through which a consumer compiles production roots to certified Rust packages; closed requests refused before Lean on every root, target, pin, evidence, path, and package defect; results binding every output to the source, semantic, compiler-semantics, target, compiler-input, preservation, and certificate identities with unforgeable certification; deterministic, confined, offline bundles; source-free replay; versioned schemas; each output's effects and what `recursion` asks of the host | `PX-01`..`PX-13` | `build` | | Language-1.2 reasoning machines: logics, guarded inference rules, verifiers, and forward, search, and generate-and-verify reasoners elaborated to ordinary declarations, with exact obligations, fixed-template theorems over the axiom-free reasoning runtime, a closed runtime boundary, resource ledgers, and their production, calculus, and GNAF realization | `RS-01`..`RS-14` | `build` | From dc770e55c494edd369a650d2207751112da5f686 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 20 Oct 2026 23:07:54 +0000 Subject: [PATCH 20/21] Merge release/v0.5 (7d4e9f63a): SPEC.md is the projection, the register has 446 IDs Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- README.md | 2 +- SPEC.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 37642ac085..133732dd88 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ just vv # the complete normative acceptance gate (SPEC.md §9.2) just release # vv, then the §30 release criterion; refused until 1.0.0 ``` -All 442 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed. +All 446 registered conformance IDs are implemented and pass; `just vv` runs clean from a checkout with the pinned toolchain installed. The differential against the independent generator `lean4-prod` (SPEC.md §17.19, `OR-01`..`OR-08`) acquires it at its pinned commit: from the checkout `LEXLEAN_ORACLE_DIR` names, or by fetching the commit with `git` into the Cargo target directory (`LEXLEAN_ORACLE_CACHE` overrides), and builds it with the pinned Lean and Rust toolchains. It is validation evidence only and no input to any identity. An oracle that cannot be acquired, is not the pinned files, or fails is unavailable: that fails the gate on Linux x86-64 and is printed as `NOT VALIDATED` elsewhere, and is never reported as agreement. diff --git a/SPEC.md b/SPEC.md index 61542b347e..f68388004f 100644 --- a/SPEC.md +++ b/SPEC.md @@ -10521,7 +10521,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `NS-05` | `normative-source` | SPEC.md regenerates byte-identically from the chapter modules of the specification project, its conformance-ID table, its diagnostic-code table, its authority table, and its stated total being derived from the register, registry, and authority modules and never typed, and the projector refuses a chapter item it does not read. | §26.3, §27.5, §31 | | `NS-06` | `normative-source` | The hand-edited normative inputs of the repository are the `.lex.tex` modules of the specification project: `model/` holds only the projected files and the copies an authority row vendors, every Markdown file at the root is a projection or is on the closed list of hand-written documents, the projections carry the notice that names their source, and no hand-written document restates a registered statement, a plant of each being refused naming R1. | §27.2, §27.5, §27.10 | -**Total required capability IDs:** 442. +**Total required capability IDs:** 446. No row may be downgraded to `some-true` or `open`. Upstream Lean facts are ledger/authority rows, not substitutions for these build behaviors. From ce93e72b51a868c58d9258688f13dfd8c2c9fc74 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 21 Oct 2026 06:47:31 +0000 Subject: [PATCH 21/21] BS-05: reach the refusal of a match on a list by hand, restate the vector counts On the regenerated corpus the seeded mutation search drew heap-list-match twice in 400,000 draws, below the three runs each refusal is held to, and any change of the base crates moves the draws. The refusal is therefore reached by three hand-built rust-core crates (BY_HAND_ONLY), asserted at least three times; the template leaves the seeded list. The regenerated corpus holds a constant crate, which brings constant-shape into the seeded search. Vectors: validateCrate 415 (172 refused), correspondCrate 270 (46 refused), 685 in all; evaluator 201 crates, 392 + 247 vectors, 500 seeded mutants with 270 and 260 refused. Restated in SPEC 17.23, the BS-05 row, the scenario and VERIFICATION.md. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01NZLb4yopYgjBGQngfSuFeQ --- CONFORMANCE.md | 2 +- SPEC.md | 10 +- VERIFICATION.md | 2 +- .../src/cases/bootstrap/rust_validate.rs | 98 +++++++++++++++++-- features/suites/bootstrap.feature | 2 +- model/ids.toml | 2 +- spec/src/Chapter17.lex.tex | 2 +- spec/src/IdsBS.lex.tex | 2 +- 8 files changed, 99 insertions(+), 21 deletions(-) diff --git a/CONFORMANCE.md b/CONFORMANCE.md index 38819d5805..5c01d2835c 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -64,7 +64,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `BS-02` | `build` | The preservation lexer and token audit of SPEC.md §17.17 are language-1.2 source in the `bootstrap/` project: `lex` and `auditTokens` of `TokenAudit` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `production::preserve::{lex, audit_tokens}` on every lexeme, position, and rejection message for the first 1,500 characters of every module of the shipped preservation library and calculus modules, the number-lexing corpus, and every token-audit unit vector; on the normative host, both roots' lowered programs under the calculus evaluator agree with the Rust oracle on those vectors and a seeded corpus, the rendered packages under the pinned rustc agree with the oracle on the large seeded corpus of generated and mutated Lean texts with no disagreement, a planted defect in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | | `BS-03` | `build` | The primitive scanner of SPEC.md §12.2 is language-1.2 source in the `bootstrap/` project: `scanSource` and `rejectAtoms` of `PrimitiveScan` are production roots eligible for `rust-std` with exactly their declared effects; on every host of the matrix, both roots' rendered `rust-std` packages under that host's pinned rustc agree with the Rust oracle `source::scan::{scan, reject_forbidden_atoms}` on every atom with its class, text, and byte, line, and column spans and on every rejection with its code, message, span, and help, for the deterministic vectors (the oracle's unit inputs, the atom limit at N and N+1, atom lists with gaps, payload strings, and notation bodies), a 128-byte window and a 2,048-byte prefix of every committed `.lex.tex` source, and the whole of each such source up to 8,192 bytes (up to 1,024 bytes, one source in four, for `rejectAtoms`); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the vectors and the 128-byte windows and on 80 seeded texts, the packages agree on 2,500 seeded texts, each of ten planted defects in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | | `BS-04` | `build` | The target calculus's checker of SPEC.md §17.14 (`lexlean::calculus::check`), for a program given as calculus data, each list of a recursive type carried as a chain of that type's own `Nil` and `Cons` constructors and decoded back to the program on every vector (reading a program from its canonical JSON is not part of this row), is language-1.2 source in the `bootstrap/` project: `checkProgram` and `checkArguments` of `CalculusCheck` are production roots eligible for `rust-std` with exactly their declared effects; on the normative host the lowered programs of both roots under the calculus evaluator agree with the Rust checker on acceptance and on the rejection message to the byte for every committed target program and the refusal edits of `TC-02` and for a seeded corpus of data-level mutations, and each planted defect in the source is detected; on every host the rendered `rust-std` packages of both roots under the pinned rustc agree with the Rust checker on the deterministic vectors, and on the normative host also on a larger seeded corpus with no disagreement; strings whose Rust `Debug` spelling escapes a non-ASCII scalar other than `U+0080`..`U+009F` are outside the claim; and the certified packages the production export publishes for the project are the committed ones. | -| `BS-05` | `build` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | +| `BS-05` | `build` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant, and for 3 hand-built crates of a match on a list (415 `validateCrate` runs, 172 of them refusals, and 270 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (201) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | ## calculus diff --git a/SPEC.md b/SPEC.md index 8c63d0ca6c..81f1ebe092 100644 --- a/SPEC.md +++ b/SPEC.md @@ -7610,13 +7610,13 @@ the `elements` the renderer realizes), a rule corpus that reaches each of the runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run out first; the refusal that a construct has no row of the table cannot be reached), 17 crates by hand for the merge of moved sets at an `if` and a -`match`, 34 by hand for the loop rules, and 5 by hand for the rule of a constant -(§17.16 *Constants*); that is 411 runs of `validateCrate` -(169 refused) and 269 of `correspondCrate` (46 refused), and the case asserts +`match`, 34 by hand for the loop rules, 5 by hand for the rule of a constant, and 3 by hand for a match on a list +(§17.16 *Constants*); that is 415 runs of `validateCrate` +(172 refused) and 270 of `correspondCrate` (46 refused), and the case asserts these counts. On every host, the rendered `rust-std` packages of both roots (§17.16), compiled by the pinned rustc, are run on all of them. On the normative host, the lowered programs of both roots are run under the calculus -evaluator (§17.14) on the crates of at most 400 expressions (200 of the 223; +evaluator (§17.14) on the crates of at most 400 expressions (201 of the 223; the larger ones are the compiler's own packages and are held to the oracle by the compiled run) with the rule corpus, and on 500 seeded mutants of the crates of at most 80 expressions (a node replaced by another of the crate, a @@ -10543,7 +10543,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `BS-02` | `bootstrap` | The preservation lexer and token audit of SPEC.md §17.17 are language-1.2 source in the `bootstrap/` project: `lex` and `auditTokens` of `TokenAudit` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `production::preserve::{lex, audit_tokens}` on every lexeme, position, and rejection message for the first 1,500 characters of every module of the shipped preservation library and calculus modules, the number-lexing corpus, and every token-audit unit vector; on the normative host, both roots' lowered programs under the calculus evaluator agree with the Rust oracle on those vectors and a seeded corpus, the rendered packages under the pinned rustc agree with the oracle on the large seeded corpus of generated and mutated Lean texts with no disagreement, a planted defect in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | §17.17, §17.23 | | `BS-03` | `bootstrap` | The primitive scanner of SPEC.md §12.2 is language-1.2 source in the `bootstrap/` project: `scanSource` and `rejectAtoms` of `PrimitiveScan` are production roots eligible for `rust-std` with exactly their declared effects; on every host of the matrix, both roots' rendered `rust-std` packages under that host's pinned rustc agree with the Rust oracle `source::scan::{scan, reject_forbidden_atoms}` on every atom with its class, text, and byte, line, and column spans and on every rejection with its code, message, span, and help, for the deterministic vectors (the oracle's unit inputs, the atom limit at N and N+1, atom lists with gaps, payload strings, and notation bodies), a 128-byte window and a 2,048-byte prefix of every committed `.lex.tex` source, and the whole of each such source up to 8,192 bytes (up to 1,024 bytes, one source in four, for `rejectAtoms`); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the vectors and the 128-byte windows and on 80 seeded texts, the packages agree on 2,500 seeded texts, each of ten planted defects in the source is detected, and the certified packages the production export publishes for the project are the committed ones. | §12.2, §17.23 | | `BS-04` | `bootstrap` | The target calculus's checker of SPEC.md §17.14 (`lexlean::calculus::check`), for a program given as calculus data, each list of a recursive type carried as a chain of that type's own `Nil` and `Cons` constructors and decoded back to the program on every vector (reading a program from its canonical JSON is not part of this row), is language-1.2 source in the `bootstrap/` project: `checkProgram` and `checkArguments` of `CalculusCheck` are production roots eligible for `rust-std` with exactly their declared effects; on the normative host the lowered programs of both roots under the calculus evaluator agree with the Rust checker on acceptance and on the rejection message to the byte for every committed target program and the refusal edits of `TC-02` and for a seeded corpus of data-level mutations, and each planted defect in the source is detected; on every host the rendered `rust-std` packages of both roots under the pinned rustc agree with the Rust checker on the deterministic vectors, and on the normative host also on a larger seeded corpus with no disagreement; strings whose Rust `Debug` spelling escapes a non-ASCII scalar other than `U+0080`..`U+009F` are outside the claim; and the certified packages the production export publishes for the project are the committed ones. | §17.14, §17.23 | -| `BS-05` | `bootstrap` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | §17.16, §17.23 | +| `BS-05` | `bootstrap` | The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant, and for 3 hand-built crates of a match on a list (415 `validateCrate` runs, 172 of them refusals, and 270 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (201) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. | §17.16, §17.23 | | `PK-01` | `packages` | A language-1.2 project that declares a source package by its identifier, version, kind `path`, and the member directory a `lexlean-workspace.toml` lists locks it by the tree digest of its manifest and source files, its manifest digest, its version, its module prefix, and its own packages, and the configuration and the lock read back to the bytes written; a project without a source package keeps its bytes, and a package of another kind, a source package in another language, a changed byte or version (LLC0105), an undeclared package (LLC0106), a module prefix claimed twice (LLC0107), a project or a package outside the workspace (LLC0108), a path that escapes it, and a symlink (LLS8001) are each refused with the named code. | §10.5, §11.1, §25.1 | | `PK-02` | `packages` | A module of a project imports only modules of its own project and modules of the packages the project declares, and a module of a package only modules of itself and of the packages its own manifest declares: a package module is a module of the importing project under its own module prefix, a module of a package the project does not declare fails with LLR3009, and an import cycle through a package fails with LLR3003. | §10.5, §15.1 | | `PK-03` | `packages` | An importing project builds and verifies under the pinned Lean offline, and its package modules are generated, elaborated, replayed with `leanchecker`, and audited for their exact axioms under the package's module prefix with the package as their origin in the records; the source ID of the project changes with the pins, and no file of the package is written by `fmt`, `build`, or `verify`. | §10.5, §21.3, §22 | diff --git a/VERIFICATION.md b/VERIFICATION.md index a89b3b6c55..af6f22a30c 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -15741,7 +15741,7 @@ Authoring found four shapes certificate A and certificate B do not accept, each ### the bootstrap Rust crate validator can fail its oracle (SPEC.md §17.23, §17.16) -`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, 34 hand-built crates of the loop rules, and 5 hand-built crates of the rule of a constant, that is 411 `validateCrate` vectors (169 refused) and 269 `correspondCrate` vectors (46 refused), 680 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 680. On the normative host the evaluator agrees on the 200 crates of at most 400 expressions, the rule runs, and the hand-built crates (388 + 246 vectors), and on 500 seeded mutants (271 and 244 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. +`BS-05` holds the two production roots of `LexLeanBoot.RustValidate` (`bootstrap/src/RustValidate.lex.tex`) to the stage-0 oracle they replace, `calculus::rust::validate::{validate, correspond}`. The 164 distinct programs among the 247 committed package manifests and 122 fixtures lower to 223 distinct crates over both profiles; with 132 `validateCrate` and 12 `correspondCrate` rule runs (each of the 48 reachable refusals three times, found by a seeded mutation search at a fixed seed, which asserts that it reached the target and does not stop short of it), 17 hand-built crates of the merge of moved sets, 34 hand-built crates of the loop rules, 5 hand-built crates of the rule of a constant, and 3 hand-built crates of a match on a list, that is 415 `validateCrate` vectors (172 refused) and 270 `correspondCrate` vectors (46 refused), 685 in all. On every host both roots' rendered `rust-std` packages, compiled by the pinned rustc, agree with the oracle on all 685. On the normative host the evaluator agrees on the 201 crates of at most 400 expressions, the rule runs, and the hand-built crates (392 + 247 vectors), and on 500 seeded mutants (270 and 260 refused), and the rendered packages agree on 2,000 further seeded mutants per root. The case passed on the branch merged with `main` after wave 6 (#220), with the production export under the pinned Lean 4.32.1. The refusal of a match on a list (`heap-list-match`) is reached by hand: the seeded search drew it twice in 400,000 draws over the regenerated corpus, below the three runs each refusal is held to, and any change of the base crates shifts the draws, so it is not left to the seed; the case asserts that the three hand-built crates give it at least three times. The regenerated corpus holds a constant crate, which puts the refusal that a constant is not an infallible closed literal within the seeded search. Every one of these counts is an assertion of the case (`COMMITTED_*`, `RULE_*`, `VECTORS_*`, `EVALUATOR_*`, `SEEDED_*`), so a tree that no longer gives them fails the case instead of leaving this paragraph stale. The loop rules (the oracle's `Expr::Loop`, SP-19 and RB-14) are `ELoop [Id, Expr]` of the module: ownership of the state across a body that runs again (two refusals, for a name and for a component, naming the least offender in the oracle's order of names), the fallible-tail rule, `apply_types` with `tail = false` for the body, and the correspondence traversal treating the body as a block. The correspondence table was re-diffed against the oracle's `CORRESPONDENCE` after SP-19: 97 rows (98 with the `constant` row of RB-18), and the six that gained `expr:call` (`destructure:pair`, `type:result`, `type:pair`, `construct:ok`, `construct:err`, `construct:pair`) are the only difference from the table first transcribed; the module's table and the oracle's are equal row for row and element for element. diff --git a/crates/conformance/src/cases/bootstrap/rust_validate.rs b/crates/conformance/src/cases/bootstrap/rust_validate.rs index 2948e2f9b3..80f622e27e 100644 --- a/crates/conformance/src/cases/bootstrap/rust_validate.rs +++ b/crates/conformance/src/cases/bootstrap/rust_validate.rs @@ -1597,6 +1597,16 @@ fn mutant(krate: &Crate, seeded: &mut Seeded, pool: &Pool) -> Crate { /// reach; `no-row` cannot be reached, because every construct the AST emits /// has a row of the table, and the row-less path is the one the module /// transcribes without a vector to reach it. +/// Refusals the mutation search reaches too rarely to rest a count on: it hit +/// `heap-list-match` twice in its 400,000 draws once the committed corpus held +/// the `cached-literal` crate, where before it hit three times, so the +/// reachability of the refusal depended on the seed and not on the rule. These +/// are reached by crates built by hand (`list_match_crates`) and held to be +/// covered like the others. (`constant-shape` took its place among the +/// searched refusals: the committed corpus now holds a crate with a constant, +/// which the search mutates into one that breaks the rule.) +const BY_HAND_ONLY: &[&str] = &["heap-list-match"]; + const REACHABLE: &[&str] = &[ "enum-not-declared", "enum-declared-twice", @@ -1607,7 +1617,6 @@ const REACHABLE: &[&str] = &[ "type-fn-undeclared", "heap-string-literal", "heap-byte-literal", - "heap-list-match", "heap-boxed-read", "heap-box", "heap-runtime", @@ -1642,6 +1651,7 @@ const REACHABLE: &[&str] = &[ "dispatch-undeclared", "dispatch-misstated", "propagates-undeclared", + "constant-shape", "wrong-origin", "unused-element", "unused-type", @@ -1786,6 +1796,7 @@ fn coverage(runs: &[Run]) -> BTreeMap<&'static str, usize> { fn uncovered(counts: &BTreeMap<&'static str, usize>) -> Vec<&'static str> { REACHABLE .iter() + .chain(BY_HAND_ONLY) .copied() .filter(|template| !counts.contains_key(template)) .collect() @@ -1899,6 +1910,59 @@ fn rule_vectors(bases: &[&Rendered], each: usize) -> (Vec, Vec) { (validated, corresponded) } +/// Crates by hand for the refusal of a list match under `rust-core`: a +/// function with no heap type in its signature whose body matches the +/// `uncons` of a name, as the tail, as a binding, and on one branch of an `if`. +/// The heap check of the match comes before the read of its scrutinee, so the +/// name need not be bound. They are vectors of both validators, whose messages +/// must agree to the byte. +fn list_match_crates() -> Vec { + let at = Origin::of; + let nat = |n: u64| Expr::Lit(Lit::Nat(n), at("value:nat")); + let matched = |value: u64| Expr::Match { + scrutinee: Box::new(Expr::Uncons(Ident::Local(0))), + arms: vec![ + (Pat::None, Block::of(nat(value))), + (Pat::Some(Box::new(Pat::Wild)), Block::of(nat(value + 1))), + ], + at: at("match:list"), + }; + let function = |parameters: Vec<(Pat, Type)>, body: Block| Crate { + profile: Profile::Core, + items: vec![ItemDef::Function { + name: Ident::Function(0), + parameters, + result: Type::Nat, + body, + at: at("function"), + }], + }; + vec![ + function(Vec::new(), Block::of(matched(0))), + function( + Vec::new(), + Block { + lets: vec![Let { + pat: Pat::Bind(Ident::Local(1)), + ty: None, + value: matched(2), + at: at("let"), + }], + tail: Expr::Move(Ident::Local(1), at("read")), + }, + ), + function( + vec![(Pat::Bind(Ident::Local(2)), Type::Bool)], + Block::of(Expr::If { + condition: Box::new(Expr::Copy(Ident::Local(2), at("read"))), + then_branch: Box::new(Block::of(matched(4))), + else_branch: Box::new(Block::of(nat(6))), + at: at("expr:cond"), + }), + ), + ] +} + /// Crates by hand for the rule of a constant (SPEC.md §17.16 *Constants*): a /// literal the rule accepts, then a call in its body, a result that can fail, /// and a binding before the literal, each refused by the rule, and a name @@ -2904,15 +2968,16 @@ const RULE_CORRESPOND_RUNS: usize = 12; const BRANCH_CRATES: usize = 17; const LOOP_CRATES: usize = 34; const CONSTANT_CRATES: usize = 5; -const VECTORS_VALIDATE: usize = 411; -const REFUSED_VALIDATE: usize = 169; -const VECTORS_CORRESPOND: usize = 269; +const LIST_MATCH_CRATES: usize = 3; +const VECTORS_VALIDATE: usize = 415; +const REFUSED_VALIDATE: usize = 172; +const VECTORS_CORRESPOND: usize = 270; const REFUSED_CORRESPOND: usize = 46; -const EVALUATOR_CRATES: usize = 200; -const EVALUATOR_VALIDATE: usize = 388; -const EVALUATOR_CORRESPOND: usize = 246; -const SEEDED_REFUSED_VALIDATE: usize = 271; -const SEEDED_REFUSED_CORRESPOND: usize = 244; +const EVALUATOR_CRATES: usize = 201; +const EVALUATOR_VALIDATE: usize = 392; +const EVALUATOR_CORRESPOND: usize = 247; +const SEEDED_REFUSED_VALIDATE: usize = 270; +const SEEDED_REFUSED_CORRESPOND: usize = 260; pub(super) fn case() { let started = std::time::Instant::now(); @@ -2946,6 +3011,7 @@ pub(super) fn case() { .into_iter() .chain(loop_crates()) .chain(constant_crates()) + .chain(list_match_crates()) .collect(); assert_eq!( (rule_validate.len(), rule_correspond.len()), @@ -2957,8 +3023,14 @@ pub(super) fn case() { branch_crates().len(), loop_crates().len(), constant_crates().len(), + list_match_crates().len(), + ), + ( + BRANCH_CRATES, + LOOP_CRATES, + CONSTANT_CRATES, + LIST_MATCH_CRATES ), - (BRANCH_CRATES, LOOP_CRATES, CONSTANT_CRATES), "the hand-built crates" ); rule_validate.extend(by_hand.iter().map(validate_run)); @@ -2977,6 +3049,12 @@ pub(super) fn case() { "refusals no rule vector reaches: {:?}", uncovered(&counts) ); + for template in BY_HAND_ONLY { + assert!( + counts.get(template).copied().unwrap_or(0) >= RULES_EACH, + "the crates by hand reach `{template}` {RULES_EACH} times" + ); + } let accepted_validate: Vec = all .iter() .map(|rendered| validate_run(&rendered.krate)) diff --git a/features/suites/bootstrap.feature b/features/suites/bootstrap.feature index 625f346111..42adc3e756 100644 --- a/features/suites/bootstrap.feature +++ b/features/suites/bootstrap.feature @@ -31,7 +31,7 @@ Feature: bootstrap And every planted defect is detected, and every exported package is byte-identical to its committed package and realizes the lowered program @BS-05 @build - Scenario: The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. + Scenario: The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant, and for 3 hand-built crates of a match on a list (415 `validateCrate` runs, 172 of them refusals, and 270 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (201) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim. Given the committed `bootstrap` project, the crates the Rust renderer lowers from every committed target program, the refusals the seeded rule runs and the hand-built crates give, and the Rust validator `calculus::rust::validate` as the oracle When the project is checked and built, both roots' lowered programs are run by the evaluator on those crates and a seeded mutation corpus, both roots' rendered rust-std packages are run on those crates and the large seeded corpus, a defect is planted in the source, and the project is exported through the production pipeline Then both roots are eligible for rust-std with exactly their declared effects and no run disagrees with the oracle diff --git a/model/ids.toml b/model/ids.toml index 5489b7ff7b..56a088db8c 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -2558,7 +2558,7 @@ statement = "The target calculus's checker of SPEC.md §17.14 (`lexlean::calculu id = "BS-05" level = "build" suite = "bootstrap" -statement = "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim." +statement = "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant, and for 3 hand-built crates of a match on a list (415 `validateCrate` runs, 172 of them refusals, and 270 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (201) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim." [[id]] id = "PK-01" diff --git a/spec/src/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index 9121e667fc..6041d32482 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -5086,7 +5086,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "`BS-05` holds both roots to the oracle. The crates are those the renderer" (cons "lowers (`rust::lower`) from the 164 distinct programs among the 247 committed" (cons "package manifests of `compiler/rust` and `tests/production-export` and the 122" (cons "fixtures of `compiler/fixtures` (223 distinct crates over both profiles, with" (cons "the `elements` the renderer realizes), a rule corpus that reaches each of the" (cons "48 refusals a crate of the closed AST can reach three times (132 `validateCrate`" (cons "runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run" (cons "out first; the refusal that a construct has no row of the table cannot be" (cons "reached), 17 crates by hand for the merge of moved sets at an `if` and a" (cons "`match`, 34 by hand for the loop rules, and 5 by hand for the rule of a constant" (cons "(§17.16 *Constants*); that is 411 runs of `validateCrate`" (cons "(169 refused) and 269 of `correspondCrate` (46 refused), and the case asserts" (cons "these counts. On every host, the rendered `rust-std` packages of both" (cons "roots (§17.16), compiled by the pinned rustc, are run on all of them. On the" (cons "normative host, the lowered programs of both roots are run under the calculus" (cons "evaluator (§17.14) on the crates of at most 400 expressions (200 of the 223;" (cons "the larger ones are the compiler's own packages and are held to the oracle by" (cons "the compiled run) with the rule corpus, and on 500 seeded mutants of the" (cons "crates of at most 80 expressions (a node replaced by another of the crate, a" (cons "name, type, pattern, constructor, callee, origin, or width changed, an item or" (cons "binding or arm dropped, doubled, or swapped, a call's propagation flipped, a" (cons "dispatch arm restated, a block run in a loop, the profile exchanged, and the" (cons "elements of the program changed); the rendered packages are also run on 2,000 further seeded mutants" (cons "per root. The outcome of a run is the result and, for a refusal, the message," (cons "and one difference fails the case. Sixteen planted defects in the source (a heap" (cons "type admitted under `rust-core`, a name bound twice accepted, the moves of" (cons "earlier match arms forgotten, a component moved after its whole accepted, an" (cons "undeclared ADT type accepted, a `?` in an infallible function accepted, a" (cons "fallible call without propagation accepted, an `apply` arm's failure not" (cons "compared with its function's, a correspondence row narrowed, the width of a" (cons "runtime call not compared, a name or a component moved in a loop body accepted," (cons "the end of a fallible loop not checked, a loop's state not moved into the loop," (cons "the name a loop's refusal reports not the least, and a loop body checked as a" (cons "tail) are each detected by the same differential, and" (cons "under the pinned Lean the production export (§24.7) certifies both roots beside" (cons "the others, whose packages are the committed ones under" (cons "`tests/production-export/bootstrap/`." (nil String)))))))))))))))))))))))))))))))))))))) + (cons "`BS-05` holds both roots to the oracle. The crates are those the renderer" (cons "lowers (`rust::lower`) from the 164 distinct programs among the 247 committed" (cons "package manifests of `compiler/rust` and `tests/production-export` and the 122" (cons "fixtures of `compiler/fixtures` (223 distinct crates over both profiles, with" (cons "the `elements` the renderer realizes), a rule corpus that reaches each of the" (cons "48 refusals a crate of the closed AST can reach three times (132 `validateCrate`" (cons "runs and 12 `correspondCrate` runs, asserted: the corpus fails if its draws run" (cons "out first; the refusal that a construct has no row of the table cannot be" (cons "reached), 17 crates by hand for the merge of moved sets at an `if` and a" (cons "`match`, 34 by hand for the loop rules, 5 by hand for the rule of a constant, and 3 by hand for a match on a list" (cons "(§17.16 *Constants*); that is 415 runs of `validateCrate`" (cons "(172 refused) and 270 of `correspondCrate` (46 refused), and the case asserts" (cons "these counts. On every host, the rendered `rust-std` packages of both" (cons "roots (§17.16), compiled by the pinned rustc, are run on all of them. On the" (cons "normative host, the lowered programs of both roots are run under the calculus" (cons "evaluator (§17.14) on the crates of at most 400 expressions (201 of the 223;" (cons "the larger ones are the compiler's own packages and are held to the oracle by" (cons "the compiled run) with the rule corpus, and on 500 seeded mutants of the" (cons "crates of at most 80 expressions (a node replaced by another of the crate, a" (cons "name, type, pattern, constructor, callee, origin, or width changed, an item or" (cons "binding or arm dropped, doubled, or swapped, a call's propagation flipped, a" (cons "dispatch arm restated, a block run in a loop, the profile exchanged, and the" (cons "elements of the program changed); the rendered packages are also run on 2,000 further seeded mutants" (cons "per root. The outcome of a run is the result and, for a refusal, the message," (cons "and one difference fails the case. Sixteen planted defects in the source (a heap" (cons "type admitted under `rust-core`, a name bound twice accepted, the moves of" (cons "earlier match arms forgotten, a component moved after its whole accepted, an" (cons "undeclared ADT type accepted, a `?` in an infallible function accepted, a" (cons "fallible call without propagation accepted, an `apply` arm's failure not" (cons "compared with its function's, a correspondence row narrowed, the width of a" (cons "runtime call not compared, a name or a component moved in a loop body accepted," (cons "the end of a fallible loop not checked, a loop's state not moved into the loop," (cons "the name a loop's refusal reports not the least, and a loop body checked as a" (cons "tail) are each detected by the same differential, and" (cons "under the pinned Lean the production export (§24.7) certifies both roots beside" (cons "the others, whose packages are the committed ones under" (cons "`tests/production-export/bootstrap/`." (nil String)))))))))))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] diff --git a/spec/src/IdsBS.lex.tex b/spec/src/IdsBS.lex.tex index b93bd64beb..d5ee7ec78a 100644 --- a/spec/src/IdsBS.lex.tex +++ b/spec/src/IdsBS.lex.tex @@ -40,7 +40,7 @@ name: bs05, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "BS-05", level := "build", suite := "bootstrap", statement := "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant (411 `validateCrate` runs, 169 of them refusals, and 269 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (200) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim.", sections := "§17.16, §17.23"}), + body: (record Rows::IdRow {id := "BS-05", level := "build", suite := "bootstrap", statement := "The Rust crate validator of SPEC.md §17.16 is language-1.2 source in the `bootstrap/` project: `validateCrate` and `correspondCrate` of `RustValidate` are production roots eligible for `rust-std` with exactly their declared effects; on every host, both roots' rendered `rust-std` packages under the pinned rustc agree with the Rust oracle `calculus::rust::validate::{validate, correspond}` on the exact outcome and message for the 223 distinct crates the renderer lowers from the 164 distinct programs among the 247 committed package manifests and 122 fixtures, for 132 `validateCrate` and 12 `correspondCrate` runs that reach each of the 48 reachable refusals three times, for 17 hand-built crates of the merge of moved sets, for 34 hand-built crates of the loop rules, and for 5 hand-built crates of the rule of a constant, and for 3 hand-built crates of a match on a list (415 `validateCrate` runs, 172 of them refusals, and 270 `correspondCrate` runs, 46 of them refusals); on the normative host, both roots' lowered programs under the calculus evaluator agree with the oracle on the crates of at most 400 expressions (201) with the rule runs and on 500 seeded mutants of the crates of at most 80 expressions, the rendered packages under the pinned rustc agree on 2,000 further seeded mutants per root, sixteen planted defects in the source are each detected, and the certified packages the production export publishes for the project are the committed ones; lowering, printing, packaging, and crates naming a non-ASCII or non-printable scalar are outside the claim.", sections := "§17.16, §17.23"}), executable: true } \end{semanticmodule}