diff --git a/CONFORMANCE.md b/CONFORMANCE.md index b453f9b478..d19625febd 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 @@ -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` | 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 @@ -334,6 +335,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. | ## normative-source @@ -393,6 +395,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. | ## production @@ -520,6 +523,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 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/README.md b/README.md index 6ffb9fe248..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. @@ -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` | diff --git a/SPEC.md b/SPEC.md index 304d9ec78e..0724d8abac 100644 --- a/SPEC.md +++ b/SPEC.md @@ -4361,7 +4361,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; @@ -4813,6 +4817,30 @@ 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) 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`, `int_mul`, `int_neg`, `int_quot`, `parse_decimal` at `int`, `succ`), a call to @@ -7550,7 +7578,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 @@ -7566,8 +7594,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 @@ -10356,6 +10385,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `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` | 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 | @@ -10370,6 +10400,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `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 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 | @@ -10409,6 +10440,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `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 | | `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 | @@ -10422,6 +10454,7 @@ Every row below is normative, has honesty level `build`, and is projected byte-f | `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 | @@ -10494,7 +10527,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, 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 | @@ -10517,7 +10550,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. diff --git a/VERIFICATION.md b/VERIFICATION.md index 2f6a61c07e..5d38ea8aeb 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -4009,6 +4009,120 @@ 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) + +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}"`: + +```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 +``` + +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 +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. + +### rust constants can fail (RB-18) + +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, six 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 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 + 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). +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`, +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 Probe: `compare_bytes` and byte equality were both treated as reducible, and @@ -15457,7 +15571,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 @@ -15583,9 +15697,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 (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, 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/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/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/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..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,6 +472,20 @@ fn enc_item_def(item: &ItemDef) -> Value { enc_origin(at), ], ), + ItemDef::Constant { + name, + result, + body, + at, + } => adt( + 5, + vec![ + enc_ident(name), + enc_type(result), + enc_block(body), + enc_origin(at), + ], + ), ItemDef::Function { name, parameters, @@ -859,6 +873,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 +1286,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)), @@ -1699,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") { @@ -1868,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. @@ -2807,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; @@ -2845,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/calculus.rs b/crates/conformance/src/cases/calculus.rs index 9f82d64e1a..d1a97435c0 100644 --- a/crates/conformance/src/cases/calculus.rs +++ b/crates/conformance/src/cases/calculus.rs @@ -1518,6 +1518,160 @@ 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"}}}), + ), + ( + "result", + json!({"kind": "result", "ok": {"kind": "nat"}, "error": {"kind": "string"}}), + json!({"kind": "ok", "value": nat("3")}), + ), + ( + "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/conformance/src/cases/rust_backend.rs b/crates/conformance/src/cases/rust_backend.rs index e02a664834..ed5eeccaed 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,286 @@ 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"); + + // 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). + { + 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(); + 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 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())); + } + 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/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 95e15bb9ef..519cd59c04 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2185,6 +2185,26 @@ 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_18() { + repo_conformance::cases::run("RB-18"); +} + +#[test] +fn conformance_sp_24() { + repo_conformance::cases::run("SP-24"); +} + +#[test] +fn conformance_md_14() { + repo_conformance::cases::run("MD-14"); +} + #[test] fn conformance_ns_01() { repo_conformance::cases::run("NS-01"); 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/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..16ecb71641 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 { @@ -1295,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.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..11b9b54ca7 100644 --- a/crates/lexlean/src/production/certificate/data_b/syntax.rs +++ b/crates/lexlean/src/production/certificate/data_b/syntax.rs @@ -606,6 +606,17 @@ impl Writer<'_, '_> { &[fn_type, parameters, result, fallible, arms], ) } + ItemDef::Constant { + name, + result, + body, + at: _, + } => { + let name = self.rs_ident(name); + let result = self.rs_type(result); + let body = self.rs_block(body); + self.rs_apply("ItemDef.constant", &[name, result, body]) + } ItemDef::Function { name, parameters, 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/calculus.feature b/features/suites/calculus.feature index 5a5837c3af..efe745883d 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: 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, 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 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..d165c29f09 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-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 diff --git a/features/suites/rust-backend.feature b/features/suites/rust-backend.feature index 7cb0d10a62..5200343f95 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-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 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 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} 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 094116d7ba..5cc9dfc2f5 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1702,6 +1702,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 = "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" level = "build" @@ -1786,6 +1792,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-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." + [[id]] id = "GN-01" level = "build" @@ -2020,6 +2032,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-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." + [[id]] id = "MD-01" level = "build" @@ -2098,6 +2116,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" @@ -2534,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, 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/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index e43c5e95ce..6841609726 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -1989,7 +1989,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: [] @@ -2363,7 +2363,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: [] @@ -2377,7 +2377,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: [] @@ -2391,7 +2391,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: [] @@ -2405,7 +2405,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: [] @@ -2419,7 +2419,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: [] @@ -2433,7 +2433,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: [] @@ -2447,7 +2447,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: [] @@ -2461,7 +2461,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: [] @@ -2473,6 +2473,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))))))))))))) @@ -2484,7 +2498,7 @@ } definition{ - name: i0183, + name: i0184, parameters: [], result: DocRows::Item, body: constructor{ @@ -2498,7 +2512,7 @@ } definition{ - name: i0184, + name: i0185, parameters: [], result: DocRows::Item, body: constructor{ @@ -2512,7 +2526,7 @@ } definition{ - name: i0185, + name: i0186, parameters: [], result: DocRows::Item, body: constructor{ @@ -2526,7 +2540,7 @@ } definition{ - name: i0186, + name: i0187, parameters: [], result: DocRows::Item, body: constructor{ @@ -2540,7 +2554,7 @@ } definition{ - name: i0187, + name: i0188, parameters: [], result: DocRows::Item, body: constructor{ @@ -2552,7 +2566,7 @@ } definition{ - name: i0188, + name: i0189, parameters: [], result: DocRows::Item, body: constructor{ @@ -2566,7 +2580,7 @@ } definition{ - name: i0189, + name: i0190, parameters: [], result: DocRows::Item, body: constructor{ @@ -2580,7 +2594,7 @@ } definition{ - name: i0190, + name: i0191, parameters: [], result: DocRows::Item, body: constructor{ @@ -2594,7 +2608,7 @@ } definition{ - name: i0191, + name: i0192, parameters: [], result: DocRows::Item, body: constructor{ @@ -2609,7 +2623,7 @@ } definition{ - name: i0192, + name: i0193, parameters: [], result: DocRows::Item, body: constructor{ @@ -2623,7 +2637,7 @@ } definition{ - name: i0193, + name: i0194, parameters: [], result: DocRows::Item, body: constructor{ @@ -2637,7 +2651,7 @@ } definition{ - name: i0194, + name: i0195, parameters: [], result: DocRows::Item, body: constructor{ @@ -2651,7 +2665,7 @@ } definition{ - name: i0195, + name: i0196, parameters: [], result: DocRows::Item, body: constructor{ @@ -2665,7 +2679,7 @@ } definition{ - name: i0196, + name: i0197, parameters: [], result: DocRows::Item, body: constructor{ @@ -2679,7 +2693,7 @@ } definition{ - name: i0197, + name: i0198, parameters: [], result: DocRows::Item, body: constructor{ @@ -2693,7 +2707,7 @@ } definition{ - name: i0198, + name: i0199, parameters: [], result: DocRows::Item, body: constructor{ @@ -2707,7 +2721,7 @@ } definition{ - name: i0199, + name: i0200, parameters: [], result: DocRows::Item, body: constructor{ @@ -2721,7 +2735,7 @@ } definition{ - name: i0200, + name: i0201, parameters: [], result: DocRows::Item, body: constructor{ @@ -2735,7 +2749,7 @@ } definition{ - name: i0201, + name: i0202, parameters: [], result: DocRows::Item, body: constructor{ @@ -2749,7 +2763,7 @@ } definition{ - name: i0202, + name: i0203, parameters: [], result: DocRows::Item, body: constructor{ @@ -2763,7 +2777,7 @@ } definition{ - name: i0203, + name: i0204, parameters: [], result: DocRows::Item, body: constructor{ @@ -2777,7 +2791,7 @@ } definition{ - name: i0204, + name: i0205, parameters: [], result: DocRows::Item, body: constructor{ @@ -2791,7 +2805,7 @@ } definition{ - name: i0205, + name: i0206, parameters: [], result: DocRows::Item, body: constructor{ @@ -2805,7 +2819,7 @@ } definition{ - name: i0206, + name: i0207, parameters: [], result: DocRows::Item, body: constructor{ @@ -2819,7 +2833,7 @@ } definition{ - name: i0207, + name: i0208, parameters: [], result: DocRows::Item, body: constructor{ @@ -2833,7 +2847,7 @@ } definition{ - name: i0208, + name: i0209, parameters: [], result: DocRows::Item, body: constructor{ @@ -2848,7 +2862,7 @@ } definition{ - name: i0209, + name: i0210, parameters: [], result: DocRows::Item, body: constructor{ @@ -2862,7 +2876,7 @@ } definition{ - name: i0210, + name: i0211, parameters: [], result: DocRows::Item, body: constructor{ @@ -2876,7 +2890,7 @@ } definition{ - name: i0211, + name: i0212, parameters: [], result: DocRows::Item, body: constructor{ @@ -2890,7 +2904,7 @@ } definition{ - name: i0212, + name: i0213, parameters: [], result: DocRows::Item, body: constructor{ @@ -2905,7 +2919,7 @@ } definition{ - name: i0213, + name: i0214, parameters: [], result: DocRows::Item, body: constructor{ @@ -2920,7 +2934,7 @@ } definition{ - name: i0214, + name: i0215, parameters: [], result: DocRows::Item, body: constructor{ @@ -2935,7 +2949,7 @@ } definition{ - name: i0215, + name: i0216, parameters: [], result: DocRows::Item, body: constructor{ @@ -2950,7 +2964,7 @@ } definition{ - name: i0216, + name: i0217, parameters: [], result: DocRows::Item, body: constructor{ @@ -2965,7 +2979,7 @@ } definition{ - name: i0217, + name: i0218, parameters: [], result: DocRows::Item, body: constructor{ @@ -2979,7 +2993,7 @@ } definition{ - name: i0218, + name: i0219, parameters: [], result: DocRows::Item, body: constructor{ @@ -2993,7 +3007,7 @@ } definition{ - name: i0219, + name: i0220, parameters: [], result: DocRows::Item, body: constructor{ @@ -3007,7 +3021,7 @@ } definition{ - name: i0220, + name: i0221, parameters: [], result: DocRows::Item, body: constructor{ @@ -3021,7 +3035,7 @@ } definition{ - name: i0221, + name: i0222, parameters: [], result: DocRows::Item, body: constructor{ @@ -3035,7 +3049,7 @@ } definition{ - name: i0222, + name: i0223, parameters: [], result: DocRows::Item, body: constructor{ @@ -3049,7 +3063,7 @@ } definition{ - name: i0223, + name: i0224, parameters: [], result: DocRows::Item, body: constructor{ @@ -3063,7 +3077,7 @@ } definition{ - name: i0224, + name: i0225, parameters: [], result: DocRows::Item, body: constructor{ @@ -3077,7 +3091,7 @@ } definition{ - name: i0225, + name: i0226, parameters: [], result: DocRows::Item, body: constructor{ @@ -3089,7 +3103,7 @@ } definition{ - name: i0226, + name: i0227, parameters: [], result: DocRows::Item, body: constructor{ @@ -3103,7 +3117,7 @@ } definition{ - name: i0227, + name: i0228, parameters: [], result: DocRows::Item, body: constructor{ @@ -3117,7 +3131,7 @@ } definition{ - name: i0228, + name: i0229, parameters: [], result: DocRows::Item, body: constructor{ @@ -3131,7 +3145,7 @@ } definition{ - name: i0229, + name: i0230, parameters: [], result: DocRows::Item, body: constructor{ @@ -3146,7 +3160,7 @@ } definition{ - name: i0230, + name: i0231, parameters: [], result: DocRows::Item, body: constructor{ @@ -3160,7 +3174,7 @@ } definition{ - name: i0231, + name: i0232, parameters: [], result: DocRows::Item, body: constructor{ @@ -3175,7 +3189,7 @@ } definition{ - name: i0232, + name: i0233, parameters: [], result: DocRows::Item, body: constructor{ @@ -3189,7 +3203,7 @@ } definition{ - name: i0233, + name: i0234, parameters: [], result: DocRows::Item, body: constructor{ @@ -3203,7 +3217,7 @@ } definition{ - name: i0234, + name: i0235, parameters: [], result: DocRows::Item, body: constructor{ @@ -3217,7 +3231,7 @@ } definition{ - name: i0235, + name: i0236, parameters: [], result: DocRows::Item, body: constructor{ @@ -3231,7 +3245,7 @@ } definition{ - name: i0236, + name: i0237, parameters: [], result: DocRows::Item, body: constructor{ @@ -3245,7 +3259,7 @@ } definition{ - name: i0237, + name: i0238, parameters: [], result: DocRows::Item, body: constructor{ @@ -3259,7 +3273,7 @@ } definition{ - name: i0238, + name: i0239, parameters: [], result: DocRows::Item, body: constructor{ @@ -3273,7 +3287,7 @@ } definition{ - name: i0239, + name: i0240, parameters: [], result: DocRows::Item, body: constructor{ @@ -3287,7 +3301,7 @@ } definition{ - name: i0240, + name: i0241, parameters: [], result: DocRows::Item, body: constructor{ @@ -3301,7 +3315,7 @@ } definition{ - name: i0241, + name: i0242, parameters: [], result: DocRows::Item, body: constructor{ @@ -3316,7 +3330,7 @@ } definition{ - name: i0242, + name: i0243, parameters: [], result: DocRows::Item, body: constructor{ @@ -3330,7 +3344,7 @@ } definition{ - name: i0243, + name: i0244, parameters: [], result: DocRows::Item, body: constructor{ @@ -3342,7 +3356,7 @@ } definition{ - name: i0244, + name: i0245, parameters: [], result: DocRows::Item, body: constructor{ @@ -3356,7 +3370,7 @@ } definition{ - name: i0245, + name: i0246, parameters: [], result: DocRows::Item, body: constructor{ @@ -3370,7 +3384,7 @@ } definition{ - name: i0246, + name: i0247, parameters: [], result: DocRows::Item, body: constructor{ @@ -3384,7 +3398,7 @@ } definition{ - name: i0247, + name: i0248, parameters: [], result: DocRows::Item, body: constructor{ @@ -3398,7 +3412,7 @@ } definition{ - name: i0248, + name: i0249, parameters: [], result: DocRows::Item, body: constructor{ @@ -3412,7 +3426,7 @@ } definition{ - name: i0249, + name: i0250, parameters: [], result: DocRows::Item, body: constructor{ @@ -3426,7 +3440,7 @@ } definition{ - name: i0250, + name: i0251, parameters: [], result: DocRows::Item, body: constructor{ @@ -3440,7 +3454,7 @@ } definition{ - name: i0251, + name: i0252, parameters: [], result: DocRows::Item, body: constructor{ @@ -3454,7 +3468,7 @@ } definition{ - name: i0252, + name: i0253, parameters: [], result: DocRows::Item, body: constructor{ @@ -3468,7 +3482,7 @@ } definition{ - name: i0253, + name: i0254, parameters: [], result: DocRows::Item, body: constructor{ @@ -3482,7 +3496,7 @@ } definition{ - name: i0254, + name: i0255, parameters: [], result: DocRows::Item, body: constructor{ @@ -3496,7 +3510,7 @@ } definition{ - name: i0255, + name: i0256, parameters: [], result: DocRows::Item, body: constructor{ @@ -3510,7 +3524,7 @@ } definition{ - name: i0256, + name: i0257, parameters: [], result: DocRows::Item, body: constructor{ @@ -3524,7 +3538,7 @@ } definition{ - name: i0257, + name: i0258, parameters: [], result: DocRows::Item, body: constructor{ @@ -3538,7 +3552,7 @@ } definition{ - name: i0258, + name: i0259, parameters: [], result: DocRows::Item, body: constructor{ @@ -3552,7 +3566,7 @@ } definition{ - name: i0259, + name: i0260, parameters: [], result: DocRows::Item, body: constructor{ @@ -3566,7 +3580,7 @@ } definition{ - name: i0260, + name: i0261, parameters: [], result: DocRows::Item, body: constructor{ @@ -3580,7 +3594,7 @@ } definition{ - name: i0261, + name: i0262, parameters: [], result: DocRows::Item, body: constructor{ @@ -3592,7 +3606,7 @@ } definition{ - name: i0262, + name: i0263, parameters: [], result: DocRows::Item, body: constructor{ @@ -3606,7 +3620,7 @@ } definition{ - name: i0263, + name: i0264, parameters: [], result: DocRows::Item, body: constructor{ @@ -3620,7 +3634,7 @@ } definition{ - name: i0264, + name: i0265, parameters: [], result: DocRows::Item, body: constructor{ @@ -3634,7 +3648,7 @@ } definition{ - name: i0265, + name: i0266, parameters: [], result: DocRows::Item, body: constructor{ @@ -3648,7 +3662,7 @@ } definition{ - name: i0266, + name: i0267, parameters: [], result: DocRows::Item, body: constructor{ @@ -3662,7 +3676,7 @@ } definition{ - name: i0267, + name: i0268, parameters: [], result: DocRows::Item, body: constructor{ @@ -3676,7 +3690,7 @@ } definition{ - name: i0268, + name: i0269, parameters: [], result: DocRows::Item, body: constructor{ @@ -3690,7 +3704,7 @@ } definition{ - name: i0269, + name: i0270, parameters: [], result: DocRows::Item, body: constructor{ @@ -3704,7 +3718,7 @@ } definition{ - name: i0270, + name: i0271, parameters: [], result: DocRows::Item, body: constructor{ @@ -3718,7 +3732,7 @@ } definition{ - name: i0271, + name: i0272, parameters: [], result: DocRows::Item, body: constructor{ @@ -3732,7 +3746,7 @@ } definition{ - name: i0272, + name: i0273, parameters: [], result: DocRows::Item, body: constructor{ @@ -3746,7 +3760,7 @@ } definition{ - name: i0273, + name: i0274, parameters: [], result: DocRows::Item, body: constructor{ @@ -3760,7 +3774,7 @@ } definition{ - name: i0274, + name: i0275, parameters: [], result: DocRows::Item, body: constructor{ @@ -3774,7 +3788,7 @@ } definition{ - name: i0275, + name: i0276, parameters: [], result: DocRows::Item, body: constructor{ @@ -3788,7 +3802,7 @@ } definition{ - name: i0276, + name: i0277, parameters: [], result: DocRows::Item, body: constructor{ @@ -3802,7 +3816,7 @@ } definition{ - name: i0277, + name: i0278, parameters: [], result: DocRows::Item, body: constructor{ @@ -3816,7 +3830,7 @@ } definition{ - name: i0278, + name: i0279, parameters: [], result: DocRows::Item, body: constructor{ @@ -3830,7 +3844,7 @@ } definition{ - name: i0279, + name: i0280, parameters: [], result: DocRows::Item, body: constructor{ @@ -3844,7 +3858,7 @@ } definition{ - name: i0280, + name: i0281, parameters: [], result: DocRows::Item, body: constructor{ @@ -3858,7 +3872,7 @@ } definition{ - name: i0281, + name: i0282, parameters: [], result: DocRows::Item, body: constructor{ @@ -3870,7 +3884,7 @@ } definition{ - name: i0282, + name: i0283, parameters: [], result: DocRows::Item, body: constructor{ @@ -3884,7 +3898,7 @@ } definition{ - name: i0283, + name: i0284, parameters: [], result: DocRows::Item, body: constructor{ @@ -3898,7 +3912,7 @@ } definition{ - name: i0284, + name: i0285, parameters: [], result: DocRows::Item, body: constructor{ @@ -3912,7 +3926,7 @@ } definition{ - name: i0285, + name: i0286, parameters: [], result: DocRows::Item, body: constructor{ @@ -3926,7 +3940,7 @@ } definition{ - name: i0286, + name: i0287, parameters: [], result: DocRows::Item, body: constructor{ @@ -3940,7 +3954,7 @@ } definition{ - name: i0287, + name: i0288, parameters: [], result: DocRows::Item, body: constructor{ @@ -3954,7 +3968,7 @@ } definition{ - name: i0288, + name: i0289, parameters: [], result: DocRows::Item, body: constructor{ @@ -3968,7 +3982,7 @@ } definition{ - name: i0289, + name: i0290, parameters: [], result: DocRows::Item, body: constructor{ @@ -3982,7 +3996,7 @@ } definition{ - name: i0290, + name: i0291, parameters: [], result: DocRows::Item, body: constructor{ @@ -3996,7 +4010,7 @@ } definition{ - name: i0291, + name: i0292, parameters: [], result: DocRows::Item, body: constructor{ @@ -4010,7 +4024,7 @@ } definition{ - name: i0292, + name: i0293, parameters: [], result: DocRows::Item, body: constructor{ @@ -4024,7 +4038,7 @@ } definition{ - name: i0293, + name: i0294, parameters: [], result: DocRows::Item, body: constructor{ @@ -4038,7 +4052,7 @@ } definition{ - name: i0294, + name: i0295, parameters: [], result: DocRows::Item, body: constructor{ @@ -4052,7 +4066,7 @@ } definition{ - name: i0295, + name: i0296, parameters: [], result: DocRows::Item, body: constructor{ @@ -4066,7 +4080,7 @@ } definition{ - name: i0296, + name: i0297, parameters: [], result: DocRows::Item, body: constructor{ @@ -4078,7 +4092,7 @@ } definition{ - name: i0297, + name: i0298, parameters: [], result: DocRows::Item, body: constructor{ @@ -4092,7 +4106,7 @@ } definition{ - name: i0298, + name: i0299, parameters: [], result: DocRows::Item, body: constructor{ @@ -4104,7 +4118,7 @@ } definition{ - name: i0299, + name: i0300, parameters: [], result: DocRows::Item, body: constructor{ @@ -4118,7 +4132,7 @@ } definition{ - name: i0300, + name: i0301, parameters: [], result: DocRows::Item, body: constructor{ @@ -4132,7 +4146,7 @@ } definition{ - name: i0301, + name: i0302, parameters: [], result: DocRows::Item, body: constructor{ @@ -4144,7 +4158,7 @@ } definition{ - name: i0302, + name: i0303, parameters: [], result: DocRows::Item, body: constructor{ @@ -4158,7 +4172,7 @@ } definition{ - name: i0303, + name: i0304, parameters: [], result: DocRows::Item, body: constructor{ @@ -4173,7 +4187,7 @@ } definition{ - name: i0304, + name: i0305, parameters: [], result: DocRows::Item, body: constructor{ @@ -4187,7 +4201,7 @@ } definition{ - name: i0305, + name: i0306, parameters: [], result: DocRows::Item, body: constructor{ @@ -4199,7 +4213,7 @@ } definition{ - name: i0306, + name: i0307, parameters: [], result: DocRows::Item, body: constructor{ @@ -4213,7 +4227,7 @@ } definition{ - name: i0307, + name: i0308, parameters: [], result: DocRows::Item, body: constructor{ @@ -4228,7 +4242,7 @@ } definition{ - name: i0308, + name: i0309, parameters: [], result: DocRows::Item, body: constructor{ @@ -4242,7 +4256,7 @@ } definition{ - name: i0309, + name: i0310, parameters: [], result: DocRows::Item, body: constructor{ @@ -4254,7 +4268,7 @@ } definition{ - name: i0310, + name: i0311, parameters: [], result: DocRows::Item, body: constructor{ @@ -4268,7 +4282,7 @@ } definition{ - name: i0311, + name: i0312, parameters: [], result: DocRows::Item, body: constructor{ @@ -4282,7 +4296,7 @@ } definition{ - name: i0312, + name: i0313, parameters: [], result: DocRows::Item, body: constructor{ @@ -4294,7 +4308,7 @@ } definition{ - name: i0313, + name: i0314, parameters: [], result: DocRows::Item, body: constructor{ @@ -4308,7 +4322,7 @@ } definition{ - name: i0314, + name: i0315, parameters: [], result: DocRows::Item, body: constructor{ @@ -4322,7 +4336,7 @@ } definition{ - name: i0315, + name: i0316, parameters: [], result: DocRows::Item, body: constructor{ @@ -4336,7 +4350,7 @@ } definition{ - name: i0316, + name: i0317, parameters: [], result: DocRows::Item, body: constructor{ @@ -4350,7 +4364,7 @@ } definition{ - name: i0317, + name: i0318, parameters: [], result: DocRows::Item, body: constructor{ @@ -4364,7 +4378,7 @@ } definition{ - name: i0318, + name: i0319, parameters: [], result: DocRows::Item, body: constructor{ @@ -4376,7 +4390,7 @@ } definition{ - name: i0319, + name: i0320, parameters: [], result: DocRows::Item, body: constructor{ @@ -4390,7 +4404,7 @@ } definition{ - name: i0320, + name: i0321, parameters: [], result: DocRows::Item, body: constructor{ @@ -4404,7 +4418,7 @@ } definition{ - name: i0321, + name: i0322, parameters: [], result: DocRows::Item, body: constructor{ @@ -4416,7 +4430,7 @@ } definition{ - name: i0322, + name: i0323, parameters: [], result: DocRows::Item, body: constructor{ @@ -4430,7 +4444,7 @@ } definition{ - name: i0323, + name: i0324, parameters: [], result: DocRows::Item, body: constructor{ @@ -4444,7 +4458,7 @@ } definition{ - name: i0324, + name: i0325, parameters: [], result: DocRows::Item, body: constructor{ @@ -4456,7 +4470,7 @@ } definition{ - name: i0325, + name: i0326, parameters: [], result: DocRows::Item, body: constructor{ @@ -4470,7 +4484,7 @@ } definition{ - name: i0326, + name: i0327, parameters: [], result: DocRows::Item, body: constructor{ @@ -4482,7 +4496,7 @@ } definition{ - name: i0327, + name: i0328, parameters: [], result: DocRows::Item, body: constructor{ @@ -4496,7 +4510,7 @@ } definition{ - name: i0328, + name: i0329, parameters: [], result: DocRows::Item, body: constructor{ @@ -4510,7 +4524,7 @@ } definition{ - name: i0329, + name: i0330, parameters: [], result: DocRows::Item, body: constructor{ @@ -4525,7 +4539,7 @@ } definition{ - name: i0330, + name: i0331, parameters: [], result: DocRows::Item, body: constructor{ @@ -4539,7 +4553,7 @@ } definition{ - name: i0331, + name: i0332, parameters: [], result: DocRows::Item, body: constructor{ @@ -4553,7 +4567,7 @@ } definition{ - name: i0332, + name: i0333, parameters: [], result: DocRows::Item, body: constructor{ @@ -4567,7 +4581,7 @@ } definition{ - name: i0333, + name: i0334, parameters: [], result: DocRows::Item, body: constructor{ @@ -4581,7 +4595,7 @@ } definition{ - name: i0334, + name: i0335, parameters: [], result: DocRows::Item, body: constructor{ @@ -4595,7 +4609,7 @@ } definition{ - name: i0335, + name: i0336, parameters: [], result: DocRows::Item, body: constructor{ @@ -4607,7 +4621,7 @@ } definition{ - name: i0336, + name: i0337, parameters: [], result: DocRows::Item, body: constructor{ @@ -4621,7 +4635,7 @@ } definition{ - name: i0337, + name: i0338, parameters: [], result: DocRows::Item, body: constructor{ @@ -4635,7 +4649,7 @@ } definition{ - name: i0338, + name: i0339, parameters: [], result: DocRows::Item, body: constructor{ @@ -4649,7 +4663,7 @@ } definition{ - name: i0339, + name: i0340, parameters: [], result: DocRows::Item, body: constructor{ @@ -4663,7 +4677,7 @@ } definition{ - name: i0340, + name: i0341, parameters: [], result: DocRows::Item, body: constructor{ @@ -4677,7 +4691,7 @@ } definition{ - name: i0341, + name: i0342, parameters: [], result: DocRows::Item, body: constructor{ @@ -4691,7 +4705,7 @@ } definition{ - name: i0342, + name: i0343, parameters: [], result: DocRows::Item, body: constructor{ @@ -4705,7 +4719,7 @@ } definition{ - name: i0343, + name: i0344, parameters: [], result: DocRows::Item, body: constructor{ @@ -4717,7 +4731,7 @@ } definition{ - name: i0344, + name: i0345, parameters: [], result: DocRows::Item, body: constructor{ @@ -4731,7 +4745,7 @@ } definition{ - name: i0345, + name: i0346, parameters: [], result: DocRows::Item, body: constructor{ @@ -4745,7 +4759,7 @@ } definition{ - name: i0346, + name: i0347, parameters: [], result: DocRows::Item, body: constructor{ @@ -4759,7 +4773,7 @@ } definition{ - name: i0347, + name: i0348, parameters: [], result: DocRows::Item, body: constructor{ @@ -4773,7 +4787,7 @@ } definition{ - name: i0348, + name: i0349, parameters: [], result: DocRows::Item, body: constructor{ @@ -4787,7 +4801,7 @@ } definition{ - name: i0349, + name: i0350, parameters: [], result: DocRows::Item, body: constructor{ @@ -4801,7 +4815,7 @@ } definition{ - name: i0350, + name: i0351, parameters: [], result: DocRows::Item, body: constructor{ @@ -4815,7 +4829,7 @@ } definition{ - name: i0351, + name: i0352, parameters: [], result: DocRows::Item, body: constructor{ @@ -4829,7 +4843,7 @@ } definition{ - name: i0352, + name: i0353, parameters: [], result: DocRows::Item, body: constructor{ @@ -4843,7 +4857,7 @@ } definition{ - name: i0353, + name: i0354, parameters: [], result: DocRows::Item, body: constructor{ @@ -4857,7 +4871,7 @@ } definition{ - name: i0354, + name: i0355, parameters: [], result: DocRows::Item, body: constructor{ @@ -4871,7 +4885,7 @@ } definition{ - name: i0355, + name: i0356, parameters: [], result: DocRows::Item, body: constructor{ @@ -4885,7 +4899,7 @@ } definition{ - name: i0356, + name: i0357, parameters: [], result: DocRows::Item, body: constructor{ @@ -4899,7 +4913,7 @@ } definition{ - name: i0357, + name: i0358, parameters: [], result: DocRows::Item, body: constructor{ @@ -4913,7 +4927,7 @@ } definition{ - name: i0358, + name: i0359, parameters: [], result: DocRows::Item, body: constructor{ @@ -4927,7 +4941,7 @@ } definition{ - name: i0359, + name: i0360, parameters: [], result: DocRows::Item, body: constructor{ @@ -4941,7 +4955,7 @@ } definition{ - name: i0360, + name: i0361, parameters: [], result: DocRows::Item, body: constructor{ @@ -4955,7 +4969,7 @@ } definition{ - name: i0361, + name: i0362, parameters: [], result: DocRows::Item, body: constructor{ @@ -4969,7 +4983,7 @@ } definition{ - name: i0362, + name: i0363, parameters: [], result: DocRows::Item, body: constructor{ @@ -4983,7 +4997,7 @@ } definition{ - name: i0363, + name: i0364, parameters: [], result: DocRows::Item, body: constructor{ @@ -4997,7 +5011,7 @@ } definition{ - name: i0364, + name: i0365, parameters: [], result: DocRows::Item, body: constructor{ @@ -5011,7 +5025,7 @@ } definition{ - name: i0365, + name: i0366, parameters: [], result: DocRows::Item, body: constructor{ @@ -5025,7 +5039,7 @@ } definition{ - name: i0366, + name: i0367, parameters: [], result: DocRows::Item, body: constructor{ @@ -5039,12 +5053,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: [] @@ -5053,12 +5067,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: [] 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/IdsMD.lex.tex b/spec/src/IdsMD.lex.tex index f454193837..17b604eb32 100644 --- a/spec/src/IdsMD.lex.tex +++ b/spec/src/IdsMD.lex.tex @@ -107,5 +107,13 @@ body: (record Rows::IdRow {id := "MD-13", 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.", sections := "§17.12, §28.6"}), executable: true } + +definition{ + 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"}), + executable: true +} \end{semanticmodule} \end{lexlean} diff --git a/spec/src/IdsRB.lex.tex b/spec/src/IdsRB.lex.tex index a3c9811a47..27d3b83a3c 100644 --- a/spec/src/IdsRB.lex.tex +++ b/spec/src/IdsRB.lex.tex @@ -115,5 +115,13 @@ body: (record Rows::IdRow {id := "RB-14", 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.", sections := "§17.13, §17.14, §17.16"}), executable: true } + +definition{ + name: rb18, + parameters: [], + result: Rows::IdRow, + 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} \end{lexlean} diff --git a/spec/src/IdsSP.lex.tex b/spec/src/IdsSP.lex.tex index da818c28ff..c310b53b8b 100644 --- a/spec/src/IdsSP.lex.tex +++ b/spec/src/IdsSP.lex.tex @@ -163,5 +163,13 @@ body: (record Rows::IdRow {id := "SP-20", 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.", sections := "§17.16, §17.17"}), executable: true } + +definition{ + 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"}), + executable: true +} \end{semanticmodule} \end{lexlean} diff --git a/spec/src/IdsTC.lex.tex b/spec/src/IdsTC.lex.tex index 78a6c71473..d9ceaf0911 100644 --- a/spec/src/IdsTC.lex.tex +++ b/spec/src/IdsTC.lex.tex @@ -59,5 +59,13 @@ body: (record Rows::IdRow {id := "TC-07", 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.", sections := "§17.14"}), executable: true } + +definition{ + name: tc08, + parameters: [], + result: Rows::IdRow, + 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} \end{lexlean}