From 017d0c325c16fccddef38905a701cd6097eae529 Mon Sep 17 00:00:00 2001 From: humuhumu33 Date: Thu, 12 Nov 2026 21:05:18 +0000 Subject: [PATCH 1/3] BS-50: the tables and predicates of the lexicon entry schema as source (#269) LexiconSchema holds six production roots to lexicon::entry and lexicon::package: tokenIndex (the category, frame, channel, associativity and feature tokens), shapeFacts (frame_permitted, fixed_arity and the category facts), surfaceSafety (surface_safety over the atoms of BS-03, with is_math_safe_scalar), isLeanName, tomlCommentAt and entryPath. None admits recursion. The case holds them to the oracle on 838 named vectors, the committed lexicon entries and TOML files, and seeded inputs; 24 planted defects are each detected by their own vector. Co-Authored-By: Claude Opus 5.5 --- .github/bdd-parts.json | 3 + .github/intel-host-lanes.json | 2 +- .github/vv-rows.json | 9 + CHANGELOG.md | 8 + CONFORMANCE.md | 1 + README.md | 4 +- SPEC.md | 21 +- VERIFICATION.md | 39 + bootstrap/README.md | 3 + bootstrap/lexlean.lock | 57 - bootstrap/lexlean.toml | 2 +- bootstrap/src/LexiconSchema.lex.tex | 426 +++++++ crates/conformance/src/cases/bootstrap.rs | 2 + .../src/cases/bootstrap/lexicon_schema.rs | 1059 +++++++++++++++++ crates/conformance/src/cases/repository.rs | 2 +- crates/conformance/tests/conformance.rs | 5 + features/suites/bootstrap.feature | 7 + model/ids.toml | 6 + tests/production-export/bootstrap/roots.json | 48 + xtask/src/spec_links.rs | 4 +- 20 files changed, 1643 insertions(+), 65 deletions(-) delete mode 100644 bootstrap/lexlean.lock create mode 100755 bootstrap/src/LexiconSchema.lex.tex create mode 100755 crates/conformance/src/cases/bootstrap/lexicon_schema.rs diff --git a/.github/bdd-parts.json b/.github/bdd-parts.json index f385106a69..9360ab8abc 100644 --- a/.github/bdd-parts.json +++ b/.github/bdd-parts.json @@ -277,6 +277,9 @@ ], "bootstrap-manifest-text": [ "BS-34" + ], + "bootstrap-lexicon-schema": [ + "BS-50" ] }, "targets": { diff --git a/.github/intel-host-lanes.json b/.github/intel-host-lanes.json index 6a7f0aa94a..e45f88f329 100644 --- a/.github/intel-host-lanes.json +++ b/.github/intel-host-lanes.json @@ -1,7 +1,7 @@ { "producer": ["honesty"], "lanes": { - "lower": ["bootstrap-lower", "bootstrap-lexicon-lse", "bootstrap-lexicon-lre", "bootstrap-surface-module", "bootstrap-diagnostics", "bootstrap-cli-output"], + "lower": ["bootstrap-lower", "bootstrap-lexicon-lse", "bootstrap-lexicon-lre", "bootstrap-surface-module", "bootstrap-diagnostics", "bootstrap-cli-output", "bootstrap-lexicon-schema"], "print": ["bootstrap-print", "bootstrap-bodies", "bootstrap-succeed", "bootstrap-loops", "bootstrap-assemble", "bootstrap-package", "bootstrap-check", "bootstrap-gnaf", "bootstrap-runtime", "bootstrap-terms", "bootstrap-tooling-latex", "bootstrap-structural-grammar", "bootstrap-surface-lex", "bootstrap-surface-doc", "bootstrap-surface-generic", "bootstrap-surface-tooling", "bootstrap-lock-text", "bootstrap-content-id", "bootstrap-project-text", "bootstrap-manifest-text"], "validate": ["bootstrap-validate", "compiler", "preservation", "preservation-lists", "preservation-runtime", "preservation-support", "preservation-prims", "preservation-std", "production"], "moves": ["bootstrap-moves", "verification", "rest"] diff --git a/.github/vv-rows.json b/.github/vv-rows.json index 7223ecaf22..a16a63f654 100644 --- a/.github/vv-rows.json +++ b/.github/vv-rows.json @@ -358,5 +358,14 @@ "width": "", "memory_kib": "", "hints": "" + }, + { + "part": "bdd-bootstrap-lexicon-schema", + "recipes": "bdd", + "examples_part": "", + "bdd_part": "bootstrap-lexicon-schema", + "width": "", + "memory_kib": "", + "hints": "" } ] diff --git a/CHANGELOG.md b/CHANGELOG.md index d9e3754e69..1e90b0025d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,14 @@ workspace carried at those versions without a tag. ## Unreleased +- The tables and predicates of the lexicon entry schema as language-1.2 source, + the first slice of the lexicon closure (SPEC.md §17.23, §13.1 to §13.6, `BS-50`, + #269; no new diagnostic code, no change to the language-1.2 identity). + `tokenIndex`, `shapeFacts`, `surfaceSafety`, `isLeanName`, `tomlCommentAt`, + and `entryPath` of `LexiconSchema` return what the schema's token tables, + `frame_permitted` with the category and frame facts, `surface_safety`, + `is_lean_name`, `toml_comment_at`, and `entry_path` return; `surfaceSafety` + reads the atoms of `scanSource`. None admits `recursion`. - Decision regions (SPEC.md §17.12, `PF-24`, UOR-Foundation/PrismPM#605; no new diagnostic code; changes the language-1.2 identity). The runtime gains a sixth native module, `LexLeanRuntime.Regions`: a checker of local box diff --git a/CONFORMANCE.md b/CONFORMANCE.md index a1d178c889..7ab24c2d92 100644 --- a/CONFORMANCE.md +++ b/CONFORMANCE.md @@ -91,6 +91,7 @@ the error registry does not sanction (R5, `ERRORS.md`). | `BS-32` | `build` | The labeled hash recipes of content identity of SPEC.md §21.1 to §21.5, §11.5, §19.8, and §22.9 (`artifact::content_id`: the frame of a label and a payload, each preceded by its big-endian length in four and eight bytes, under a domain and a NUL; `tree_digest` over path and content rows; `source_id` over the project manifest, the lock, and the sources; `semantic_id_for` over the compiler-semantics digest, the language, the pinned Lean toolchain, the linked IR, and the lexicon closure; `build_id`; `attestation_id`; and `pdf_recipe_id`) is language-1.2 source in the `bootstrap/` project, as six production roots of `ContentId` over the standard library's SHA-256: `treeDigest`, `sourceId`, `semanticId`, `buildId`, `attestationId`, and `pdfRecipeId`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built inputs that reach every frame of every recipe, lengths beyond one byte, and messages across blocks, on the trees and source inputs of the committed projects, on the source and semantic IDs of every committed build manifest, whose recorded build ID the oracle reproduces, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; choosing and normalizing the files of a tree or a source ID, and serializing the IR, the closure, and the attestation body, are outside the claim. | | `BS-33` | `build` | The canonical text of the project manifest of SPEC.md §10.1 and its digest (`config::ProjectConfig::canonical_toml`: the ten header keys in their fixed order with the pinned Lean toolchain, the lexicon sources sorted by package or the empty array when there is none, the artifact sources and the source packages in their order, the eleven limits in their fixed order, and the PDF provider; and `config_sha256`: the lower-case hex SHA-256 of that text) is language-1.2 source in the `bootstrap/` project, as two production roots of `ProjectText` over the TOML writers of `BS-31`: `canonicalProject` and `configSha256`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built configurations, which reach every kind of lexicon source, the empty source list, equal packages, every optional table, escapes, and the largest limits, on every committed `lexlean.toml` that parses, and on seeded configurations; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading and validating a manifest is outside the claim. | | `BS-34` | `build` | The build manifest of SPEC.md §21.6 in the canonical JSON of §21.7 (`artifact::manifest::BuildManifest::to_json` written as a file: the specification, the compiler version and semantics ID, the language, the project, the source, semantic, and build IDs, the pinned Lean toolchain, the selection and the module rows in their order, a module's origin only when it has one, and the input and output rows sorted by kind, path, length, and digest, each digest in lower-case hex) is language-1.2 source in the `bootstrap/` project, as the production root `buildManifest` of `ManifestText` over the standard library's `Json` writer, eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator, agree with the oracle to the byte on hand-built manifests, which reach every key of the row order, lengths across a byte, a module's origin, and escapes, on every committed build manifest, each of which is the oracle's text of its own fields, and on seeded manifests; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; gathering the rows of a build and hashing its files are outside the claim. | +| `BS-50` | `build` | The tables and predicates of the lexicon entry schema of SPEC.md §13.1 to §13.6 (`lexicon::entry`: the category, frame, channel, associativity, and feature tokens, each read as its position in the schema's order; for a category, a frame, and a surface arity, `frame_permitted`, the arity `Frame::fixed_arity` fixes, whether the category is core-only, carries a signature, or needs a canonical source form in some channel, and the channels it requires one in; `is_lean_name`, the conservative ASCII Lean-name grammar; and `surface_safety` over the atoms of the primitive scanner, with the allow-list of `is_math_safe_scalar`, nothing or the message naming the first atom that is not renderer-safe; and `lexicon::package`: `toml_comment_at`, the offset of the first comment outside every TOML string form, and `entry_path`) is language-1.2 source in the `bootstrap/` project, as six production roots of `LexiconSchema` over the atoms of `BS-03`: `tokenIndex`, `shapeFacts`, `surfaceSafety`, `isLeanName`, `tomlCommentAt`, and `entryPath`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built vectors, which reach every token of every table, every category with every frame at four arities, every class of atom in every channel, and the edges of the allow-list, on every form surface, Lean name, and entry ID of the committed lexicon entries and on every committed TOML file, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading an entry file and the diagnostics of the entry validator are outside the claim. | ## calculus diff --git a/README.md b/README.md index db42958671..2d3184baf6 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,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 496 registered conformance IDs have their named tests; `just vv` checks them with the pinned toolchain installed. +All 497 registered conformance IDs have their named tests; `just vv` checks them 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. @@ -197,7 +197,7 @@ Every row is validated by `just vv`; the IDs link the claim to its register row, | The language-1.2 authoring notation: a readable `.lex.tex` text for a semantic module, in bijection with its canonical JSON, whose every position and variant is read from the schema, with readable forms for types and terms and a generic form for every other value, formatted canonically by `fmt` failing closed, the only form in which a language-1.2 source of the product is written (the data form is refused under language 1.2, and `lexlean::sdk` is the explicit conversion), the same for the compiler-tooling modules in the generic notation, with no compiler-semantics ID that depends on which form an embedded module is written in, with no product source owned by a generator but five named records, read and written by programs only through the authoring API (`lexlean::sdk`), and, for a native core module, a readable program over the shared table of kernel terms whose numbering is the order of its text | `AU-01`..`AU-13` | `build` | | The runtime of generated Lean as native modules: the portable, collection, model, and reasoning runtimes of language 1.2 are LexLean source that every generated module imports, migrated losslessly and audited against their exact axioms, the released runtime text of languages 1.0 and 1.1 is frozen data equal to their released output, and no other Lean runtime text remains in the compiler but the decoder of core module 2 | `RT-01`..`RT-04` | `build` | | The standard library: language-1.2 source beside the compiler whose members are certified production roots, each validated against its oracle by a seeded differential of its evaluator and rustc realizations; bytes and text over `Bytes`, an output buffer of a given capacity written in order; decimal and hexadecimal; the byte order and stable sorts over it; canonical JSON reading and writing; maps and sets over byte keys; SHA-256 against FIPS 180-4, the NIST CAVP vectors, and the `sha2` crate; and the `std-models` and `std-reasoning` source packages, generic over types, whose laws are kernel-checked theorems and whose application is the `helpdesk` example | `SL-01`, `SL-02`, `SL-03`, `SL-04`, `SL-05`, `SL-09`, `SL-10`, `SL-11`, `SL-13`, `SL-14` | `build` | -| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, the LaTeX of a tooling module, the structural grammar, the lexer of the authoring notation, its layout algebra, its generic notation, the notation of a tooling module, the reader and printer of LexLean Semantic Expressions, the reader of LexLean Rendering Expressions, where the module of a source is, the canonical diagnostic and its terminal output, the canonical text of the lock file and of the project manifest, the hash recipes of content identity, and the build manifest, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-34` | `build` | +| The bootstrap project: the compiler's own components as language-1.2 source compiled by LexLean's production pipeline to certified Rust packages, the exact axiom-output parser and its closed Lean-name check, the primitive scanner of §12.2, the preservation lexer and token audit, the target calculus's checker, the Rust crate validator, the Rust printer, the runtime syntax validator, the failure typing and the types of the Rust lowering, its last-use moves, its literal values and its terms, the package renderer, the GNAF request validation, the LaTeX of a tooling module, the structural grammar, the lexer of the authoring notation, its layout algebra, its generic notation, the notation of a tooling module, the reader and printer of LexLean Semantic Expressions, the reader of LexLean Rendering Expressions, where the module of a source is, the canonical diagnostic and its terminal output, the canonical text of the lock file and of the project manifest, the hash recipes of content identity, and the build manifest, the tables and predicates of the lexicon entry schema, each held to the Rust it replaces (the stage-0 oracle) by the committed vectors and a seeded differential of its evaluator and rustc realizations, with planted defects detected and the production export committed | `BS-01`..`BS-50` | `build` | | Source packages: a language-1.2 project imports the modules of a locked, content-addressed package of its workspace: `[[source_package]]` and `lexlean-workspace.toml`, the pins in `lexlean.lock` recomputed by every command, imports closed at link, no re-export of a package's production roots, and the package's modules replayed by the importer's `verify` with their origin in the records | `PK-01`..`PK-05` | `build` | | The literal `nat-add-zero` example, the Lean-verified feature examples, and the complete negative fixture suite | `EX-01`..`EX-09` | `build` | | Language-1.2 text components: tokenizers and their round-trip laws, with the laws carried as one native core module the generated modules import rather than authored Lean text | `LM-01`, `LM-02`, `LM-03`, `LM-13` | `build` | diff --git a/SPEC.md b/SPEC.md index 7c7fedf619..8e315ead41 100644 --- a/SPEC.md +++ b/SPEC.md @@ -9116,6 +9116,24 @@ module with a state machine over the tokens, reading each member value with the span runs from the first token of the element to the end of its last. Neither of the last two admits `recursion`. The decoder of a tooling module and the checker stay in the host. +The tables and predicates of the lexicon entry schema (§13.1 to §13.6) are the first +component of the lexicon closure as source (`BS-50`, issue 269), the module `LexiconSchema` +over the atoms of the primitive scanner (`BS-03`), with six production roots for `rust-std`: + +| Root | Takes | Returns | Oracle | +| --- | --- | --- | --- | +| `LexLeanBoot.LexiconSchema.tokenIndex` | a table and a token | its position in the schema's order, or none | `Category::parse`, `Frame::parse`, `Channel::parse`, `Associativity::parse`, `entry::FEATURES` | +| `LexLeanBoot.LexiconSchema.shapeFacts` | a category, a frame, and a surface arity | whether the frame is permitted, the arity it fixes, and the category's facts | `entry::frame_permitted`, `Frame::fixed_arity`, `Category::core_only`, `has_signature`, `required_channels`, `needs_some_canonical` | +| `LexLeanBoot.LexiconSchema.surfaceSafety` | the atoms of a surface and a channel | nothing, or the message naming the first atom that is not renderer-safe | `entry::surface_safety` | +| `LexLeanBoot.LexiconSchema.isLeanName` | a text | whether it is a conservative ASCII Lean name | `entry::is_lean_name` | +| `LexLeanBoot.LexiconSchema.tomlCommentAt` | a TOML text | the offset of its first comment outside every string form | `package::toml_comment_at` | +| `LexLeanBoot.LexiconSchema.entryPath` | a local entry ID | its file path under `entries/` | `package::entry_path` | + +`surfaceSafety` decodes each scalar of a Unicode atom from its UTF-8 bytes and tests the +allow-list of `is_math_safe_scalar`; `tomlCommentAt` is the oracle's machine of five states over +the bytes. None of the roots admits `recursion`. Reading an entry file and the diagnostics of +the entry validator stay in the host. + ## 18. Lean backend ### 18.1 Output contract @@ -12152,6 +12170,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `BS-32` | `bootstrap` | The labeled hash recipes of content identity of SPEC.md §21.1 to §21.5, §11.5, §19.8, and §22.9 (`artifact::content_id`: the frame of a label and a payload, each preceded by its big-endian length in four and eight bytes, under a domain and a NUL; `tree_digest` over path and content rows; `source_id` over the project manifest, the lock, and the sources; `semantic_id_for` over the compiler-semantics digest, the language, the pinned Lean toolchain, the linked IR, and the lexicon closure; `build_id`; `attestation_id`; and `pdf_recipe_id`) is language-1.2 source in the `bootstrap/` project, as six production roots of `ContentId` over the standard library's SHA-256: `treeDigest`, `sourceId`, `semanticId`, `buildId`, `attestationId`, and `pdfRecipeId`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built inputs that reach every frame of every recipe, lengths beyond one byte, and messages across blocks, on the trees and source inputs of the committed projects, on the source and semantic IDs of every committed build manifest, whose recorded build ID the oracle reproduces, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; choosing and normalizing the files of a tree or a source ID, and serializing the IR, the closure, and the attestation body, are outside the claim. | §17.23, §21.1, §21.5 | | `BS-33` | `bootstrap` | The canonical text of the project manifest of SPEC.md §10.1 and its digest (`config::ProjectConfig::canonical_toml`: the ten header keys in their fixed order with the pinned Lean toolchain, the lexicon sources sorted by package or the empty array when there is none, the artifact sources and the source packages in their order, the eleven limits in their fixed order, and the PDF provider; and `config_sha256`: the lower-case hex SHA-256 of that text) is language-1.2 source in the `bootstrap/` project, as two production roots of `ProjectText` over the TOML writers of `BS-31`: `canonicalProject` and `configSha256`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built configurations, which reach every kind of lexicon source, the empty source list, equal packages, every optional table, escapes, and the largest limits, on every committed `lexlean.toml` that parses, and on seeded configurations; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading and validating a manifest is outside the claim. | §10.1, §17.23 | | `BS-34` | `bootstrap` | The build manifest of SPEC.md §21.6 in the canonical JSON of §21.7 (`artifact::manifest::BuildManifest::to_json` written as a file: the specification, the compiler version and semantics ID, the language, the project, the source, semantic, and build IDs, the pinned Lean toolchain, the selection and the module rows in their order, a module's origin only when it has one, and the input and output rows sorted by kind, path, length, and digest, each digest in lower-case hex) is language-1.2 source in the `bootstrap/` project, as the production root `buildManifest` of `ManifestText` over the standard library's `Json` writer, eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator, agree with the oracle to the byte on hand-built manifests, which reach every key of the row order, lengths across a byte, a module's origin, and escapes, on every committed build manifest, each of which is the oracle's text of its own fields, and on seeded manifests; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; gathering the rows of a build and hashing its files are outside the claim. | §17.23, §21.6, §21.7 | +| `BS-50` | `bootstrap` | The tables and predicates of the lexicon entry schema of SPEC.md §13.1 to §13.6 (`lexicon::entry`: the category, frame, channel, associativity, and feature tokens, each read as its position in the schema's order; for a category, a frame, and a surface arity, `frame_permitted`, the arity `Frame::fixed_arity` fixes, whether the category is core-only, carries a signature, or needs a canonical source form in some channel, and the channels it requires one in; `is_lean_name`, the conservative ASCII Lean-name grammar; and `surface_safety` over the atoms of the primitive scanner, with the allow-list of `is_math_safe_scalar`, nothing or the message naming the first atom that is not renderer-safe; and `lexicon::package`: `toml_comment_at`, the offset of the first comment outside every TOML string form, and `entry_path`) is language-1.2 source in the `bootstrap/` project, as six production roots of `LexiconSchema` over the atoms of `BS-03`: `tokenIndex`, `shapeFacts`, `surfaceSafety`, `isLeanName`, `tomlCommentAt`, and `entryPath`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built vectors, which reach every token of every table, every category with every frame at four arities, every class of atom in every channel, and the edges of the allow-list, on every form surface, Lean name, and entry ID of the committed lexicon entries and on every committed TOML file, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading an entry file and the diagnostics of the entry validator are outside the claim. | §17.23, §13.1, §13.2, §13.3, §13.4, §13.5, §13.6 | | `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 | @@ -12168,7 +12187,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `LM-09` | `language-models` | No prompt is code: no member of the closed language maps `string` or `bytes` to a function, a term, or source — every operation of the primitive registry that takes a `string` or `bytes` operand is classified by the audit with a data result, the registry's schema enumeration and the production registry's primitive rows equal one another and equal that classified set, and the text declarations of `lexlean/semantic-module/2` state no `string`-typed member, so a prompt reaches a model only as the tokens `encodeText` makes of it; a planted operation or text member of that shape is caught by the audit with its name. | §17.12 | | `LM-13` | `language-models` | The text laws a tokenizer elaborates through are LexLean source and not authored text: the module that states them is one language-1.2 native core module of the embedded `language/text-1.2` project, the project holds no file of Lean source, no independently authored Lean file anywhere in the release tree declares the `LexLeanText` namespace or lies under its module root, and the one-time migration input is absent; the registry lists only that module, the declarations and their exact axiom policies are read from its native data, which the compiler embeds and hashes into the language-1.2 semantics, and a module that declares a text component imports the generated module rather than splicing any Lean text. | §17.10, §17.12 | -**Total required capability IDs:** 496. +**Total required capability IDs:** 497. 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 685148b770..0092a8f0b9 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -11552,6 +11552,45 @@ axioms the module now declares. The case then stops at the stack-bound step, bootstrap member did before its regeneration, which produces the package and measures the root's stack bound. +### the tables of the lexicon entry schema are source (BS-50) + +`BS-50` holds the six production roots of `LexLeanBoot.LexiconSchema` +(`bootstrap/src/LexiconSchema.lex.tex`) to `lexicon::entry` and +`lexicon::package`: `tokenIndex` to the category, frame, channel, and +associativity parsers and the feature list, as a position in the schema's +order; `shapeFacts` to `frame_permitted`, `Frame::fixed_arity`, and the +category's `core_only`, `has_signature`, `required_channels`, and +`needs_some_canonical`; `surfaceSafety` to `surface_safety` over the atoms the +primitive scanner returns, which reads each scalar of a Unicode atom from its +UTF-8 bytes against the allow-list of `is_math_safe_scalar`; `isLeanName` to +`is_lean_name`; `tomlCommentAt` to `toml_comment_at`; and `entryPath` to +`entry_path`. No root admits `recursion`: each scan is a loop under +`iterate_until` or a fold. The oracle is the existing public code of +`entry.rs` and `package.rs`; no Rust outside the case changes. + +The case holds the roots to the oracle on hand-built vectors that reach every +token of every table and near misses, every category with every frame at +arities 0 to 3 and at the largest, every class of atom in every channel and +the edges of every range of the allow-list, Lean names with empty, leading, +and trailing segments, comments inside and after every TOML string form with +escapes, and entry IDs of empty segments; on every form surface in its own +channel and the two others, every Lean name of a denotation or an eliminator, +and every entry ID of the committed lexicon entries, and on every committed +TOML file; and on seeded inputs. Each of the 24 planted defects names the one +vector that catches it, and the case asserts that the site of each plant +occurs once. The row's statement carries no counts. + +The case was first compiled and run on the normative host over `release/v0.4` +at `26e5e0ace` (`cargo test -p repo-conformance --test conformance -- +conformance_bs_50`). Its corpus is 838 named vectors, 1,064 committed forms, +725 Lean names, 1,007 entry IDs, 1,055 lexicon files, and 1,683 other TOML +files, and 300 and 2,000 seeded runs per root. The evaluator agrees with the +oracle on 8,317 runs, the rendered packages under the pinned rustc on 18,500 +runs, and each of the 24 planted defects is detected by its own vector. The +case then stops at the stack-bound step, `bootstrap/token_index is no package +of the committed exports`, as each bootstrap member does before its +regeneration, which produces the six packages. + ### the lexer of the authoring notation is source (BS-22) `BS-22` holds the two production roots of `LexLeanBoot.SurfaceLex` diff --git a/bootstrap/README.md b/bootstrap/README.md index c99de3f256..a7f14e15b7 100644 --- a/bootstrap/README.md +++ b/bootstrap/README.md @@ -55,3 +55,6 @@ writers it uses, and the standard library's `Numeral`, `Order`, and `Sha256`, an canonical project manifest of SPEC.md §10.1 and its digest. `src/ManifestText.lex.tex` (SPEC.md §17.23, `BS-34`) imports the standard library's `Json`, `Numeral`, `Order`, and `Text`, and writes the build manifest of SPEC.md §21.6. +`src/LexiconSchema.lex.tex` (SPEC.md §17.23, `BS-50`) imports `PrimitiveScan` (`BS-03`), whose +atoms it reads, `LexiconLse` (`BS-25`), whose byte classes it uses, and the standard library's +`Text`: the tables and predicates of the lexicon entry schema of SPEC.md §13. diff --git a/bootstrap/lexlean.lock b/bootstrap/lexlean.lock deleted file mode 100644 index 9a9a6f8899..0000000000 --- a/bootstrap/lexlean.lock +++ /dev/null @@ -1,57 +0,0 @@ -spec = "lexlean/lock/2" -language = "1.2" -compiler_semantics = "a82990b56aa082f57e3bf3e2d6494d75a8170f26e269448de19110f5459655ad" -project_config_sha256 = "cb6f1d4f33f8c6a8b7e593d6c53094526bd477d565600f42c530fc1e4adaa5d4" -lean_toolchain = "leanprover/lean4:v4.32.1" - -[[workspace_file]] -path = "lake-manifest.json" -sha256 = "736b7fb038a81af813e3e29b7c1ea7575ceefb442c8fb2e4df805d4bd87010b6" - -[[workspace_file]] -path = "lakefile.toml" -sha256 = "4faafd773dfa00e427b139318e863070b818aa6e229ce493b24ec906b60fa5df" - -[[workspace_file]] -path = "lean-toolchain" -sha256 = "8e3538e0ab5f81a3ee04927d8838c8c674e0e112838b4b3ce87ec218143276af" - -[[package]] -id = "lexlean.core" -version = "1.2.0" -kind = "builtin" -source = "embedded" -revision = "compiler-semantics" -tree_sha256 = "827317cae68c162f3a96c8a8de4e53ab348e7d3724fd2b834fa85ecde1a1b392" -manifest_sha256 = "271079763d269cc873531f515e56da960cd6321393b9460ff0e617666fa01d71" -imports = [] - -[[package]] -id = "lexlean.std.bool" -version = "1.2.0" -kind = "builtin" -source = "embedded" -revision = "compiler-semantics" -tree_sha256 = "3bc0fb09d706ffa7d5a1363302ea87c049acc7c7dcafde63c62682620c11be9b" -manifest_sha256 = "de58de2cf18a7a5a62d8c20649139d6dfe1f7b16b3130c75f150fbac5440a71e" -imports = ["lexlean.core@1.2.0"] - -[[package]] -id = "lexlean.std.nat" -version = "1.2.0" -kind = "builtin" -source = "embedded" -revision = "compiler-semantics" -tree_sha256 = "e0db021e01b91d651c43921d66f6b0023c8efbf17cac2ec53192ce5305e4e1ac" -manifest_sha256 = "6fb446b39e3c1c18a5f10cfa1f7aa2bd431837719eb0eb7489aadf452c9420a7" -imports = ["lexlean.core@1.2.0", "lexlean.std.bool@1.2.0"] - -[[source_package]] -id = "std" -version = "1.0.0" -kind = "path" -source = "stdlib" -module_prefix = "LexLeanStd" -tree_sha256 = "316ac824e54957e79f4bdd5ed1f3228b7c5a817333134bddff9552d254434a08" -manifest_sha256 = "1dbb7c6933b8f2a4a9d4af7746eefcb077ea1b339d9b88a63eadf64b6a348f4f" -imports = [] diff --git a/bootstrap/lexlean.toml b/bootstrap/lexlean.toml index 680666515e..a9ab64f8f3 100644 --- a/bootstrap/lexlean.toml +++ b/bootstrap/lexlean.toml @@ -3,7 +3,7 @@ name = "bootstrap" language = "1.2" module_prefix = "LexLeanBoot" source_roots = ["src"] -entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/CliOutput.lex.tex", "src/ContentId.lex.tex", "src/Diagnostics.lex.tex", "src/GnafValidate.lex.tex", "src/LexiconLre.lex.tex", "src/LexiconLse.lex.tex", "src/LockText.lex.tex", "src/ManifestText.lex.tex", "src/PrimitiveScan.lex.tex", "src/ProjectText.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/StructuralGrammar.lex.tex", "src/SurfaceDoc.lex.tex", "src/SurfaceGeneric.lex.tex", "src/SurfaceLex.lex.tex", "src/SurfaceModule.lex.tex", "src/SurfaceTooling.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] +entrypoints = ["src/AxiomOutput.lex.tex", "src/CalculusCheck.lex.tex", "src/CliOutput.lex.tex", "src/ContentId.lex.tex", "src/Diagnostics.lex.tex", "src/GnafValidate.lex.tex", "src/LexiconLre.lex.tex", "src/LexiconLse.lex.tex", "src/LexiconSchema.lex.tex", "src/LockText.lex.tex", "src/ManifestText.lex.tex", "src/PrimitiveScan.lex.tex", "src/ProjectText.lex.tex", "src/RuntimeValidate.lex.tex", "src/RustAssemble.lex.tex", "src/RustAst.lex.tex", "src/RustBodies.lex.tex", "src/RustLoops.lex.tex", "src/RustLower.lex.tex", "src/RustMoves.lex.tex", "src/RustPackage.lex.tex", "src/RustPrint.lex.tex", "src/RustSucceed.lex.tex", "src/RustTerms.lex.tex", "src/RustValidate.lex.tex", "src/StructuralGrammar.lex.tex", "src/SurfaceDoc.lex.tex", "src/SurfaceGeneric.lex.tex", "src/SurfaceLex.lex.tex", "src/SurfaceModule.lex.tex", "src/SurfaceTooling.lex.tex", "src/TokenAudit.lex.tex", "src/ToolingAst.lex.tex", "src/ToolingLatex.lex.tex"] build_root = ".lexlean" lockfile = "lexlean.lock" lean_workspace = "." diff --git a/bootstrap/src/LexiconSchema.lex.tex b/bootstrap/src/LexiconSchema.lex.tex new file mode 100755 index 0000000000..f3db90f824 --- /dev/null +++ b/bootstrap/src/LexiconSchema.lex.tex @@ -0,0 +1,426 @@ +\begin{lexlean}{LexiconSchema} +\useglossary{lexlean.std.nat@1.2.0} +\importmodule{LexLeanStd.Text} +\importmodule{LexiconLse} +\importmodule{PrimitiveScan} +\title{Natural number addition} +\begin{semanticmodule} +structure{ + name: Shape, + type_parameters: [], + parameters: [], + fields: [ + {name: permitted, type: Bool}, + {name: fixedArity, type: (Option Nat)}, + {name: coreOnly, type: Bool}, + {name: hasSignature, type: Bool}, + {name: requiredChannels, type: (List Nat)}, + {name: needsSome, type: Bool} + ] +} + +structure{ + name: Cm, + type_parameters: [], + parameters: [], + fields: [{name: pos, type: Nat}, {name: mode, type: Nat}, {name: found, type: (Option Nat)}] +} + +definition{ + name: lit, + parameters: [literal : String], + result: Bytes, + body: (prim utf8_encode literal : Bytes), + executable: true +} + +definition{ + name: cat, + parameters: [left : Bytes, right : Bytes], + result: Bytes, + body: (prim append left right : Bytes), + executable: true +} + +definition{ + name: indexIn, + parameters: [table : (List Bytes), text : Bytes], + result: (Option Nat), + body: (second (prim list_fold (fun [text] (state : (Nat * (Option Nat))) (row : Bytes) => (match (second state) + | Option.some found => state + | Option.none => (if (prim equal row text : Bool) then ((first state), (ctor Option.some [Nat] (first state))) else (((first state) + 1), (ctor Option.none [Nat]))))) (0, (ctor Option.none [Nat])) table : (Nat * (Option Nat)))), + executable: true +} + +definition{ + name: natAt, + parameters: [table : (List Nat), wanted : Nat], + result: Nat, + body: (second (prim list_fold (fun [wanted] (state : (Nat * Nat)) (row : Nat) => (if ((first state) =? wanted) then (((first state) + 1), row) else (((first state) + 1), (second state)))) (0, 0) table : (Nat * Nat))), + executable: true +} + +definition{ + name: categories, + parameters: [], + result: (List Bytes), + body: (cons (lit "structural") (cons (lit "grammar") (cons (lit "label-word") (cons (lit "type-noun") (cons (lit "term-constant") (cons (lit "function") (cons (lit "prefix-function") (cons (lit "postfix-function") (cons (lit "infix-function") (cons (lit "noun-function") (cons (lit "binary-noun-function") (cons (lit "predicate-constant") (cons (lit "adjective-predicate") (cons (lit "intransitive-predicate") (cons (lit "transitive-predicate") (cons (lit "infix-predicate") (cons (lit "proof-constant") (nil Bytes)))))))))))))))))), + executable: true +} + +definition{ + name: frames, + parameters: [], + result: (List Bytes), + body: (cons (lit "atom") (cons (lit "call") (cons (lit "prefix") (cons (lit "postfix") (cons (lit "infix") (cons (lit "noun-of") (cons (lit "binary-noun-of") (cons (lit "adjective") (cons (lit "intransitive") (cons (lit "transitive") (nil Bytes))))))))))), + executable: true +} + +definition{ + name: channels, + parameters: [], + result: (List Bytes), + body: (cons (lit "text") (cons (lit "math") (cons (lit "both") (nil Bytes)))), + executable: true +} + +definition{ + name: associativities, + parameters: [], + result: (List Bytes), + body: (cons (lit "left") (cons (lit "right") (cons (lit "none") (nil Bytes)))), + executable: true +} + +definition{ + name: features, + parameters: [], + result: (List Bytes), + body: (cons (lit "singular") (cons (lit "plural") (cons (lit "sentence-case") (cons (lit "lower-case") (cons (lit "article-a") (cons (lit "article-an") (nil Bytes))))))), + executable: true +} + +definition{ + name: tableOf, + parameters: [which : Nat], + result: (List Bytes), + body: (if (which =? 0) then (categories) else (if (which =? 1) then (frames) else (if (which =? 2) then (channels) else (if (which =? 3) then (associativities) else (features))))), + executable: true +} + +definition{ + name: tokenIndex, + parameters: [which : Nat, text : Bytes], + result: (Option Nat), + body: (indexIn (tableOf which) text), + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} + +definition{ + name: framesOfCategories, + parameters: [], + result: (List Nat), + body: (cons 0 (cons 0 (cons 0 (cons 0 (cons 0 (cons 1 (cons 2 (cons 3 (cons 4 (cons 5 (cons 6 (cons 0 (cons 7 (cons 8 (cons 9 (cons 4 (cons 0 (nil Nat)))))))))))))))))), + executable: true +} + +definition{ + name: channelsOfCategories, + parameters: [], + result: (List Nat), + body: (cons 0 (cons 0 (cons 1 (cons 0 (cons 0 (cons 2 (cons 2 (cons 2 (cons 2 (cons 1 (cons 1 (cons 2 (cons 1 (cons 1 (cons 1 (cons 2 (cons 2 (nil Nat)))))))))))))))))), + executable: true +} + +definition{ + name: permittedFrame, + parameters: [category : Nat, arity : Nat], + result: Nat, + body: (if (category =? 16) then (if (arity =? 0) then 0 else 1) else (natAt (framesOfCategories) category)), + executable: true +} + +definition{ + name: fixedArity, + parameters: [frame : Nat], + result: (Option Nat), + body: (if (frame =? 1) then (ctor Option.none [Nat]) else (if (frame =? 0) then (ctor Option.some [Nat] 0) else (if (if (frame =? 4) then true else (if (frame =? 6) then true else (frame =? 9))) then (ctor Option.some [Nat] 2) else (ctor Option.some [Nat] 1)))), + executable: true +} + +definition{ + name: requiredChannels, + parameters: [category : Nat], + result: (List Nat), + body: (let code : Nat := (natAt (channelsOfCategories) category); (if (code =? 1) then (cons 0 (nil Nat)) else (if (code =? 2) then (cons 1 (nil Nat)) else (nil Nat)))), + executable: true +} + +definition{ + name: shapeFacts, + parameters: [category : Nat, frame : Nat, arity : Nat], + result: Shape, + body: (record Shape {permitted := (frame =? (permittedFrame category arity)), fixedArity := (fixedArity frame), coreOnly := (category (mathSafeStep text n position)) (n + 1) 0 : (Nat * Bool))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: textSafePunctuation, + parameters: [], + result: (List Bytes), + body: (cons (lit ":") (cons (lit "-") (cons (lit ",") (cons (lit ".") (cons (lit ";") (cons (lit "'") (nil Bytes))))))), + executable: true +} + +definition{ + name: rendererUnsafeAscii, + parameters: [], + result: (List Bytes), + body: (cons 0x5c (cons 0x25 (cons 0x24 (cons 0x23 (cons 0x26 (cons 0x7e (cons 0x5e (cons 0x5f (cons 0x7b (cons 0x7d (cons 0x22 (cons 0x60 (nil Bytes))))))))))))), + executable: true +} + +definition{ + name: mathDelimiters, + parameters: [], + result: (List Bytes), + body: (cons (lit "(") (cons (lit ")") (cons (lit "[") (cons (lit "]") (nil Bytes))))), + executable: true +} + +definition{ + name: isIn, + parameters: [table : (List Bytes), text : Bytes], + result: Bool, + body: (match (indexIn table text) | Option.some found => true | Option.none => false), + executable: true +} + +definition{ + name: textOk, + parameters: [atom : PrimitiveScan::Atom], + result: Bool, + body: (match (project atom kind) + | PrimitiveScan::AtomClass.Control => false + | PrimitiveScan::AtomClass.Word => true + | PrimitiveScan::AtomClass.Numeral => false + | PrimitiveScan::AtomClass.Delimiter => false + | PrimitiveScan::AtomClass.AsciiSymbol => (isIn (textSafePunctuation) (project atom text)) + | PrimitiveScan::AtomClass.UnicodeSymbol => false + | PrimitiveScan::AtomClass.Whitespace => true), + executable: true +} + +definition{ + name: mathOk, + parameters: [atom : PrimitiveScan::Atom, place : Nat], + result: Bool, + body: (match (project atom kind) + | PrimitiveScan::AtomClass.Control => false + | PrimitiveScan::AtomClass.Word => true + | PrimitiveScan::AtomClass.Numeral => (0 (isIn (mathDelimiters) (project atom text)) + | PrimitiveScan::AtomClass.AsciiSymbol => (if (isIn (rendererUnsafeAscii) (project atom text)) then false else true) + | PrimitiveScan::AtomClass.UnicodeSymbol => (allMathSafe (project atom text)) + | PrimitiveScan::AtomClass.Whitespace => true), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: className, + parameters: [atom : PrimitiveScan::Atom], + result: Bytes, + body: (match (project atom kind) + | PrimitiveScan::AtomClass.Control => (lit "control") + | PrimitiveScan::AtomClass.Word => (lit "word") + | PrimitiveScan::AtomClass.Numeral => (lit "numeral") + | PrimitiveScan::AtomClass.Delimiter => (lit "delimiter") + | PrimitiveScan::AtomClass.AsciiSymbol => (lit "ascii-symbol") + | PrimitiveScan::AtomClass.UnicodeSymbol => (lit "unicode-symbol") + | PrimitiveScan::AtomClass.Whitespace => (lit "whitespace")), + executable: true +} + +definition{ + name: channelName, + parameters: [channel : Nat], + result: Bytes, + body: (if (channel =? 0) then (lit "text") else (if (channel =? 1) then (lit "math") else (lit "text and math"))), + executable: true +} + +definition{ + name: atomSafe, + parameters: [atom : PrimitiveScan::Atom, place : Nat, channel : Nat], + result: Bool, + body: (if (channel =? 0) then (textOk atom) else (if (channel =? 1) then (mathOk atom place) else (if (textOk atom) then (mathOk atom place) else false))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: unsafeMessage, + parameters: [atom : PrimitiveScan::Atom, channel : Nat], + result: Bytes, + body: (cat (cat (cat (cat (cat (cat (lit "`") (project atom text)) (lit "` (")) (className atom)) (lit ") is not renderer-safe in the ")) (channelName channel)) (lit " channel")), + executable: true +} + +definition{ + name: surfaceSafety, + parameters: [atoms : (List PrimitiveScan::Atom), channel : Nat], + result: (Option Bytes), + body: (second (prim list_fold (fun [channel] (state : (Nat * (Option Bytes))) (atom : PrimitiveScan::Atom) => (match (second state) + | Option.some reason => state + | Option.none => (if (atomSafe atom (first state) channel) then (((first state) + 1), (ctor Option.none [Bytes])) else (((first state) + 1), (ctor Option.some [Bytes] (unsafeMessage atom channel)))))) (0, (ctor Option.none [Bytes])) atoms : (Nat * (Option Bytes)))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} + +definition{ + name: isNameStart, + parameters: [value : Nat], + result: Bool, + body: (if (LexiconLse::isAlphaNum value) then true else (value =? 95)), + executable: true +} + +definition{ + name: isNameRest, + parameters: [value : Nat], + result: Bool, + body: (if (LexiconLse::isAlnumNum value) then true else (value =? 95)), + executable: true +} + +definition{ + name: leanStep, + parameters: [text : Bytes, n : Nat, st : (Nat * Bool)], + result: (Option (Nat * Bool)), + body: (let position : Nat := (first st); (if (position (leanStep text n st)) (n + 1) (0, true) : ((Nat * Bool) * Bool))); (if ((first final) =? n) then (if (second final) then false else true) else false))), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} + +definition{ + name: cmMove, + parameters: [st : Cm, step : Nat, mode : Nat], + result: (Option Cm), + body: (ctor Option.some [Cm] (record Cm {pos := ((project st pos) + step), mode := mode, found := (ctor Option.none [Nat])})), + executable: true +} + +definition{ + name: plainStep, + parameters: [text : Bytes, st : Cm], + result: (Option Cm), + body: (let position : Nat := (project st pos); (if (LexLeanStd.Text::matchAt text 0x222222 position) then (cmMove st 3 3) else (if (LexLeanStd.Text::matchAt text 0x272727 position) then (cmMove st 3 4) else (let value : Nat := (LexiconLse::byteNum text position); (if (value =? 34) then (cmMove st 1 1) else (if (value =? 39) then (cmMove st 1 2) else (if (value =? 35) then (ctor Option.some [Cm] (record Cm {pos := position, mode := 0, found := (ctor Option.some [Nat] position)})) else (cmMove st 1 0)))))))), + axioms: [Quot.sound, propext], + executable: true +} + +definition{ + name: commentStep, + parameters: [text : Bytes, n : Nat, st : Cm], + result: (Option Cm), + body: (match (project st found) + | Option.some spot => (ctor Option.none [Cm]) + | Option.none => (let position : Nat := (project st pos); (if (position (commentStep text n st)) (n + 2) (record Cm {pos := 0, mode := 0, found := (ctor Option.none [Nat])}) : (Cm * Bool))) found)), + axioms: [Quot.sound, propext], + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} + +definition{ + name: entryPath, + parameters: [localId : Bytes], + result: Bytes, + body: (cat (cat (lit "entries/") (LexLeanStd.Text::joinWith (LexLeanStd.Text::splitOn localId (46 : UInt8)) (lit "/"))) (lit ".toml")), + executable: true, + production: {effects: [allocation, overflow], targets: [rust-std]} +} +\end{semanticmodule} +\end{lexlean} diff --git a/crates/conformance/src/cases/bootstrap.rs b/crates/conformance/src/cases/bootstrap.rs index ac797da29e..f1ff65b4bf 100644 --- a/crates/conformance/src/cases/bootstrap.rs +++ b/crates/conformance/src/cases/bootstrap.rs @@ -27,6 +27,7 @@ mod diagnostics; mod gnaf_validate; mod lexicon_lre; mod lexicon_lse; +mod lexicon_schema; mod lock_text; mod manifest_text; mod project_text; @@ -2574,6 +2575,7 @@ fn case(id: &str) { "BS-32" => content_id::case(), "BS-33" => project_text::case(), "BS-34" => manifest_text::case(), + "BS-50" => lexicon_schema::case(), other => panic!("no bootstrap case is wired for {other}"), } } diff --git a/crates/conformance/src/cases/bootstrap/lexicon_schema.rs b/crates/conformance/src/cases/bootstrap/lexicon_schema.rs new file mode 100755 index 0000000000..7c220d4e51 --- /dev/null +++ b/crates/conformance/src/cases/bootstrap/lexicon_schema.rs @@ -0,0 +1,1059 @@ +//! `BS-50` (SPEC.md §17.23, §13.1 to §13.6): the tables and predicates of the +//! lexicon entry schema as language-1.2 source, `LexLeanBoot.LexiconSchema`, +//! held to the byte to `lexlean::lexicon::entry` (the category, frame, +//! channel, associativity and feature tokens, `frame_permitted`, +//! `Frame::fixed_arity`, `Category::core_only`, `has_signature`, +//! `required_channels`, `needs_some_canonical`, `is_lean_name`, +//! `surface_safety` with `is_math_safe_scalar`) and to +//! `lexlean::lexicon::package::{toml_comment_at, entry_path}`. +//! +//! `surfaceSafety` reads the atoms of the primitive scanner of `BS-03`, so a +//! form's surface is scanned by the oracle's scanner and handed over as the +//! atoms `scanSource` returns. Each planted defect names the one vector that +//! catches it. + +use std::collections::{BTreeMap, BTreeSet}; + +use lexlean::calculus::Value; +use lexlean::lexicon::entry::{ + frame_permitted, is_lean_name, surface_safety, Associativity, Category, Channel, Frame, + FEATURES, +}; +use lexlean::lexicon::package::{entry_path, toml_comment_at}; +use lexlean::source::atom::Atom; +use serde_json::Value as Json2; + +use super::rust_validate::{eligibility_of, rustc_differential}; +use super::scan::atom_value; +use super::{list, option, text, Run, Seeded}; +use crate::production_export as harness; +use crate::support::{self, repo_root}; + +const MODULE: &str = "LexLeanBoot.LexiconSchema"; +const ROOTS: [(&str, &[&str]); 6] = [ + ("tokenIndex", &["allocation", "overflow"]), + ("shapeFacts", &["allocation", "overflow"]), + ("surfaceSafety", &["allocation", "overflow"]), + ("isLeanName", &["allocation", "overflow"]), + ("tomlCommentAt", &["allocation", "overflow"]), + ("entryPath", &["allocation", "overflow"]), +]; + +/// The most a part of a certificate of a root may be, as the row states. +const CERTIFICATE_BUDGET: u64 = 3_145_728; +/// Seeded runs per root under the evaluator, and under rustc. +const EVALUATOR_SEEDED: usize = 300; +const RUSTC_SEEDED: usize = 2_000; + +/// The schema tokens in the order of the oracle's enums. +const CATEGORIES: [&str; 17] = [ + "structural", + "grammar", + "label-word", + "type-noun", + "term-constant", + "function", + "prefix-function", + "postfix-function", + "infix-function", + "noun-function", + "binary-noun-function", + "predicate-constant", + "adjective-predicate", + "intransitive-predicate", + "transitive-predicate", + "infix-predicate", + "proof-constant", +]; +const FRAMES: [&str; 10] = [ + "atom", + "call", + "prefix", + "postfix", + "infix", + "noun-of", + "binary-noun-of", + "adjective", + "intransitive", + "transitive", +]; +const CHANNELS: [&str; 3] = ["text", "math", "both"]; +const ASSOCIATIVITIES: [&str; 3] = ["left", "right", "none"]; + +// ------------------------------------------------------------- the encoders + +fn nat(value: u64) -> Value { + Value::Nat { + value: value.to_string(), + } +} + +fn boolean(value: bool) -> Value { + Value::Bool { value } +} + +fn index_of(table: &[&str], token: &str) -> u64 { + u64::try_from( + table + .iter() + .position(|row| *row == token) + .unwrap_or_else(|| panic!("`{token}` is in its table")), + ) + .expect("an index") +} + +fn channel_of(index: u64) -> Channel { + Channel::parse(CHANNELS[usize::try_from(index).expect("an index")]).expect("a channel") +} + +fn channel_index(channel: Channel) -> u64 { + match channel { + Channel::Text => 0, + Channel::Math => 1, + Channel::Both => 2, + } +} + +/// What the oracle reads a token of table `which` as: its position in the +/// enum, or nothing. +fn token_value(which: u64, token: &str) -> Value { + let found = match which { + 0 => Category::parse(token).map(|category| index_of(&CATEGORIES, category.as_str())), + 1 => Frame::parse(token).map(|frame| index_of(&FRAMES, frame.as_str())), + 2 => Channel::parse(token).map(channel_index), + 3 => Associativity::parse(token).map(|associativity| match associativity { + Associativity::Left => 0, + Associativity::Right => 1, + Associativity::None => 2, + }), + _ => FEATURES + .iter() + .position(|feature| *feature == token) + .map(|found| u64::try_from(found).expect("an index")), + }; + option(found.map(nat)) +} + +fn token_run(which: u64, token: &str) -> Run { + ( + vec![nat(which), text(token)], + serde_json::to_value(token_value(which, token)).expect("a value is JSON"), + ) +} + +/// What the oracle says of a category, a frame, and a surface arity, as the +/// module's `Shape`. +fn shape_run(category: u64, frame: u64, arity: u32) -> Run { + let category_enum = Category::parse(CATEGORIES[usize::try_from(category).expect("an index")]) + .expect("a category"); + let frame_enum = + Frame::parse(FRAMES[usize::try_from(frame).expect("an index")]).expect("a frame"); + let shape = Value::Adt { + constructor: 0, + fields: vec![ + boolean(frame_permitted(category_enum, frame_enum, arity)), + option(frame_enum.fixed_arity().map(|fixed| nat(u64::from(fixed)))), + boolean(category_enum.core_only()), + boolean(category_enum.has_signature()), + list( + category_enum + .required_channels() + .iter() + .map(|channel| nat(channel_index(*channel))) + .collect(), + ), + boolean(category_enum.needs_some_canonical()), + ], + }; + ( + vec![nat(category), nat(frame), nat(u64::from(arity))], + serde_json::to_value(shape).expect("a value is JSON"), + ) +} + +/// The atoms of a surface, as the oracle's scanner reads it when a package +/// loads (`entry::parse_entry`). +fn atoms_of(surface: &str) -> Option> { + let scalars = u64::try_from(surface.chars().count()).expect("a count"); + lexlean::source::scan::scan("
", surface, scalars).ok() +} + +fn safety_run(atoms: &[Atom], channel: u64) -> Run { + let outcome = surface_safety(atoms, channel_of(channel)).err(); + ( + vec![list(atoms.iter().map(atom_value).collect()), nat(channel)], + serde_json::to_value(option(outcome.as_deref().map(text))).expect("a value is JSON"), + ) +} + +fn lean_run(name: &str) -> Run { + ( + vec![text(name)], + serde_json::to_value(boolean(is_lean_name(name))).expect("a value is JSON"), + ) +} + +fn comment_run(source: &str) -> Run { + let found = toml_comment_at(source).map(|at| nat(u64::try_from(at).expect("an offset"))); + ( + vec![text(source)], + serde_json::to_value(option(found)).expect("a value is JSON"), + ) +} + +fn path_run(local: &str) -> Run { + ( + vec![text(local)], + serde_json::to_value(text(&entry_path(local))).expect("a value is JSON"), + ) +} + +// ------------------------------------------------------------------ vectors + +struct Vector { + label: String, + root: usize, + run: Run, +} + +fn scanned(surface: &str) -> Vec { + atoms_of(surface).unwrap_or_else(|| panic!("`{surface}` scans")) +} + +#[allow(clippy::too_many_lines)] +fn named() -> Vec { + let mut out: Vec = Vec::new(); + let mut add = |label: String, root: usize, run: Run| { + out.push(Vector { label, root, run }); + }; + + // tokenIndex: every token of every table, and near misses. + let tables: [(u64, Vec<&str>); 5] = [ + (0, CATEGORIES.to_vec()), + (1, FRAMES.to_vec()), + (2, CHANNELS.to_vec()), + (3, ASSOCIATIVITIES.to_vec()), + (4, FEATURES.to_vec()), + ]; + for (which, table) in &tables { + for token in table { + add( + format!("the token `{token}` of table {which}"), + 0, + token_run(*which, token), + ); + } + for miss in ["", "Structural", "atom ", "noun_of", "both-", "article"] { + add( + format!("the near miss `{miss}` in table {which}"), + 0, + token_run(*which, miss), + ); + } + } + add( + "a frame is not a category".to_owned(), + 0, + token_run(0, "infix"), + ); + add( + "a category is not a frame".to_owned(), + 0, + token_run(1, "function"), + ); + + // shapeFacts: every category with every frame, at arities 0, 1, 2, 3. + for category in 0..17u64 { + for frame in 0..10u64 { + for arity in 0..4u32 { + add( + format!( + "the shape of {} as {} at arity {arity}", + CATEGORIES[usize::try_from(category).expect("an index")], + FRAMES[usize::try_from(frame).expect("an index")] + ), + 1, + shape_run(category, frame, arity), + ); + } + } + } + add( + "the shape at the largest arity".to_owned(), + 1, + shape_run(16, 1, u32::MAX), + ); + + // surfaceSafety. + for (label, surface, channel) in [ + ("a text word", "natural number", 0), + ( + "a text surface with every safe punctuation", + "a: b-c, d. e; f'", + 0, + ), + ("a text surface with a colon", "is: a", 0), + ("a text surface with a parenthesis", "f(x)", 0), + ("a text surface with a numeral", "x 2", 0), + ("a text surface with a plus", "a + b", 0), + ("a text surface with a Unicode symbol", "\u{2200}", 0), + ("a text surface with a control", "\\N", 0), + ("a math plus", "+", 1), + ("a math surface with an underscore", "a_b", 1), + ( + "a math surface with every unsafe symbol", + "\\%$#&~^_{}\"`", + 1, + ), + ("a math surface with brackets", "[a](b)", 1), + ("a math surface with a brace", "{", 1), + ("a math surface led by a numeral", "2x", 1), + ("a math surface with an inner numeral", "x2", 1), + ("a math surface with alpha", "\u{3b1}", 1), + ("a math surface with capital omega", "\u{3a9}", 1), + ("a math surface with final sigma", "\u{3c2}", 1), + ("a math surface with not", "\u{ac}", 1), + ("a math surface with times", "\u{d7}", 1), + ("a math surface with division", "\u{f7}", 1), + ("a math surface with a middle dot", "\u{b7}", 1), + ("a math surface with plus-minus", "\u{b1}", 1), + ("a math surface with an ellipsis", "\u{2026}", 1), + ("a math surface with a prime", "\u{2032}", 1), + ("a math surface with a triple prime", "\u{2034}", 1), + ("a math surface with a quadruple prime", "\u{2057}", 1), + ("a math surface with the naturals", "\u{2115}", 1), + ("a math surface with an arrow", "\u{2192}", 1), + ("a math surface with for all", "\u{2200}", 1), + ("a math surface with the last operator", "\u{22ff}", 1), + ("a math surface with a ceiling", "\u{2308}", 1), + ("a math surface with a floor end", "\u{230b}", 1), + ("a math surface with an angle bracket", "\u{27e8}", 1), + ("a math surface with a white bracket", "\u{2983}", 1), + ("a math surface with a circled plus operator", "\u{2a01}", 1), + ("a math surface of a double-struck letter", "\u{1d538}", 1), + ("a math surface with the last alphanumeric", "\u{1d7ff}", 1), + ("a math surface with e acute", "\u{e9}", 1), + ("a math surface with a euro sign", "\u{20ac}", 1), + ("a math surface with an emoji", "\u{1f600}", 1), + ("a math surface with a control", "\\alpha", 1), + ("a both surface with a plus", "a + b", 2), + ("a both surface of words", "the sum", 2), + ("a both surface with a colon", "a:b", 2), + ("a both surface with a Unicode symbol", "\u{2264}", 2), + ("two unsafe atoms", "a % b $ c", 1), + ("no atoms", "", 1), + ] { + let atoms = if surface.is_empty() { + Vec::new() + } else { + scanned(surface) + }; + add(label.to_owned(), 2, safety_run(&atoms, channel)); + } + + // isLeanName. + for (label, name) in [ + ("a Lean name", "Nat.add"), + ("a Lean name of one segment", "Nat"), + ("a Lean name led by an underscore", "_private.x"), + ("a Lean name with digits", "Nat.add_zero1"), + ("the empty name", ""), + ("a name of one dot", "."), + ("a name with two dots", "Nat..add"), + ("a name with a trailing dot", "Nat."), + ("a name with a leading dot", ".Nat"), + ("a name whose segment starts with a digit", "Nat.1add"), + ("a name with a hyphen", "Nat.add-zero"), + ("a name with a space", "Nat add"), + ("a name with a non-ASCII letter", "Nat.\u{3b1}"), + ("a name with a prime", "Nat.add'"), + ] { + add(label.to_owned(), 3, lean_run(name)); + } + + // tomlCommentAt. + for (label, source) in [ + ("a comment line", "# c"), + ("no comment", "a = 1\n"), + ("a comment after a value", "a = 1 # c\n"), + ("a hash in a basic string", "a = \"#\"\n"), + ("an escaped quote before a hash", "a = \"x\\\"#\""), + ("an escaped backslash before a hash", "a = \"x\\\\\"#"), + ("a hash in a literal string", "a = '#'"), + ("a literal string broken by a line", "a = 'x\n# c"), + ("a basic string broken by a line", "a = \"x\n# c"), + ("a hash in a multi-line string", "a = \"\"\"\n#\n\"\"\""), + ("a quote inside a multi-line string", "a = \"\"\"x\"#\"\"\""), + ( + "an escape inside a multi-line string", + "a = \"\"\"\\\"\"\"#\"\"\"", + ), + ("a hash after a multi-line string", "a = \"\"\"x\"\"\" # c"), + ("a hash in a multi-line literal string", "a = '''\n#'''"), + ("a hash after a multi-line literal string", "a = '''x''' #"), + ("an unclosed basic string", "a = \"#"), + ("a backslash at the end", "a = \"\\"), + ("a non-ASCII byte before a hash", "a = \"\u{e9}\" #"), + ("an empty text", ""), + ] { + add(label.to_owned(), 4, comment_run(source)); + } + + // entryPath. + for (label, local) in [ + ("a nested entry", "nat.add.zero"), + ("an entry of one segment", "zero"), + ("an entry with hyphens", "nat.add-comm"), + ("the empty entry", ""), + ("an entry of empty segments", ".."), + ] { + add(label.to_owned(), 5, path_run(local)); + } + out +} + +// ------------------------------------------------------------- the corpora + +/// Every committed lexicon file and its parsed TOML, by repository path. +fn committed_files() -> Vec<(String, String)> { + let root = repo_root(); + let walker = walkdir::WalkDir::new(root.as_std_path()) + .sort_by_file_name() + .into_iter() + .filter_entry(|entry| { + let name = entry.file_name().to_string_lossy(); + !(entry.file_type().is_dir() + && (matches!(name.as_ref(), "target" | ".git" | ".lexlean") + || support::holds_cache_tag(entry))) + }); + let mut out = Vec::new(); + for entry in walker.flatten() { + let path = entry.path(); + let shown = path.to_string_lossy().replace('\\', "/"); + if !entry.file_type().is_file() || !shown.ends_with(".toml") { + continue; + } + let Ok(content) = std::fs::read_to_string(path) else { + continue; + }; + let relative = path + .strip_prefix(root.as_std_path()) + .expect("under the root") + .to_string_lossy() + .replace('\\', "/"); + out.push((relative, content)); + } + out +} + +fn is_entry_file(path: &str) -> bool { + path.contains("/entries/") +} + +fn is_lexicon_file(path: &str) -> bool { + is_entry_file(path) || path.ends_with("/lexicon.toml") +} + +/// The committed corpora: every form surface with its channel, every Lean +/// name of a denotation or an eliminator, every entry ID, and every TOML text. +struct Committed { + surfaces: Vec<(String, u64)>, + names: Vec, + ids: Vec, + lexicon_texts: Vec, + other_texts: Vec, +} + +fn committed() -> Committed { + let mut surfaces = Vec::new(); + let mut names = Vec::new(); + let mut ids = Vec::new(); + let mut lexicon_texts = Vec::new(); + let mut other_texts = Vec::new(); + for (path, content) in committed_files() { + if is_lexicon_file(&path) { + lexicon_texts.push(content.clone()); + } else { + other_texts.push(content.clone()); + } + if !is_entry_file(&path) { + continue; + } + let Ok(value) = content.parse::() else { + continue; + }; + if let Some(local) = value.get("id").and_then(toml::Value::as_str) { + ids.push(local.to_owned()); + } + if let Some(denotation) = value.get("denotation").and_then(toml::Value::as_table) { + for key in ["module", "name"] { + if let Some(name) = denotation.get(key).and_then(toml::Value::as_str) { + names.push(name.to_owned()); + } + } + } + if let Some(eliminator) = value.get("eliminator").and_then(toml::Value::as_table) { + for key in ["cases_lean_name", "induction_lean_name"] { + if let Some(name) = eliminator.get(key).and_then(toml::Value::as_str) { + names.push(name.to_owned()); + } + } + for constructor in eliminator + .get("constructor") + .and_then(toml::Value::as_array) + .into_iter() + .flatten() + { + if let Some(name) = constructor.get("lean_name").and_then(toml::Value::as_str) { + names.push(name.to_owned()); + } + } + } + for form in value + .get("form") + .and_then(toml::Value::as_array) + .into_iter() + .flatten() + { + let (Some(surface), Some(channel)) = ( + form.get("surface").and_then(toml::Value::as_str), + form.get("channel").and_then(toml::Value::as_str), + ) else { + continue; + }; + if let Some(found) = CHANNELS.iter().position(|row| *row == channel) { + surfaces.push((surface.to_owned(), u64::try_from(found).expect("an index"))); + } + } + } + Committed { + surfaces, + names, + ids, + lexicon_texts, + other_texts, + } +} + +// ------------------------------------------------------------------- seeded + +const SURFACE_PIECES: &[&str] = &[ + "a", + "nat", + "x", + "the", + "of", + "1", + "20", + " ", + " ", + ":", + "-", + ",", + ".", + ";", + "'", + "+", + "=", + "<", + "*", + "/", + "|", + "!", + "?", + "@", + "%", + "$", + "#", + "&", + "~", + "^", + "_", + "\"", + "`", + "(", + ")", + "[", + "]", + "{", + "}", + "\\N", + "\\alpha", + "\u{2200}", + "\u{3b1}", + "\u{3a9}", + "\u{2115}", + "\u{2192}", + "\u{2264}", + "\u{2282}", + "\u{2308}", + "\u{27e8}", + "\u{2983}", + "\u{2a01}", + "\u{1d538}", + "\u{e9}", + "\u{20ac}", + "\u{2026}", + "\u{2032}", + "\u{ac}", + "\u{d7}", +]; +const NAME_PIECES: &[&str] = &[ + "Nat", "add", "_", "1", ".", "x9", "-", "\u{3b1}", "'", "Zero", "", " ", +]; +const TOML_PIECES: &[&str] = &[ + "\"", "'", "\"\"\"", "'''", "#", "\\", "\n", "a = ", "x", " ", "\u{e9}", "[t]", +]; +const ID_PIECES: &[&str] = &["a", "b1", ".", "-", "nat", "add", "", "zero"]; +const TOKEN_PIECES: &[&str] = &[ + "infix", "function", "-", "noun", "of", "both", "text", "article", "a", "n", "left", "plural", + "case", "Atom", " ", +]; + +fn joined(seeded: &mut Seeded, pieces: &[&str], most: usize) -> String { + (0..seeded.below(most + 1)) + .map(|_| *seeded.pick(pieces)) + .collect() +} + +/// `count` seeded runs of each root that reads text: surfaces in a channel, +/// Lean names, TOML texts, entry IDs, and tokens. +fn seeded_runs(count: usize) -> [Vec; 6] { + let mut seeded = Seeded(0x0B55_0050); + let mut runs: [Vec; 6] = Default::default(); + while runs[2].len() < count { + let surface = joined(&mut seeded, SURFACE_PIECES, 6); + if let Some(atoms) = atoms_of(&surface) { + let channel = u64::try_from(seeded.below(3)).expect("a channel"); + runs[2].push(safety_run(&atoms, channel)); + } + } + for _ in 0..count { + let which = u64::try_from(seeded.below(5)).expect("a table"); + runs[0].push(token_run(which, &joined(&mut seeded, TOKEN_PIECES, 3))); + runs[3].push(lean_run(&joined(&mut seeded, NAME_PIECES, 6))); + runs[4].push(comment_run(&joined(&mut seeded, TOML_PIECES, 10))); + runs[5].push(path_run(&joined(&mut seeded, ID_PIECES, 5))); + } + runs +} + +// ------------------------------------------------------------------- plants + +struct Plant { + label: &'static str, + root: usize, + site: &'static str, + replacement: &'static str, + vector: &'static str, +} + +const PLANTS: &[Plant] = &[ + Plant { + label: "a category is read as a frame", + root: 0, + site: "(if (which =? 0) then (categories) else", + replacement: "(if (which =? 0) then (frames) else", + vector: "the token `structural` of table 0", + }, + Plant { + label: "the last feature is lost", + root: 0, + site: "(cons (lit \"article-a\") (cons (lit \"article-an\") (nil Bytes)))", + replacement: "(cons (lit \"article-a\") (nil Bytes))", + vector: "the token `article-an` of table 4", + }, + Plant { + label: "the index counts from one", + root: 0, + site: "(0, (ctor Option.none [Nat])) table : (Nat * (Option Nat))", + replacement: "(1, (ctor Option.none [Nat])) table : (Nat * (Option Nat))", + vector: "the token `left` of table 3", + }, + Plant { + label: "a proof constant of arity one is an atom", + root: 1, + site: "(if (arity =? 0) then 0 else 1)", + replacement: "(if (arity =? 0) then 0 else 0)", + vector: "the shape of proof-constant as call at arity 1", + }, + Plant { + label: "a prefix frame fixes two", + root: 1, + site: "(if (frame =? 4) then true else (if (frame =? 6) then true else (frame =? 9)))", + replacement: "(if (frame =? 4) then true else (if (frame =? 6) then true else (if (frame =? 9) then true else (frame =? 2))))", + vector: "the shape of prefix-function as prefix at arity 1", + }, + Plant { + label: "a label word has a signature", + root: 1, + site: "hasSignature := (2 (0 true", + vector: "a math surface led by a numeral", + }, + Plant { + label: "the mathematical alphanumerics end early", + root: 2, + site: "(inRange code 119808 120831)", + replacement: "(inRange code 119808 119999)", + vector: "a math surface of a double-struck letter", + }, + Plant { + label: "a two-byte scalar keeps five bits too few", + root: 2, + site: "(prim multiply (prim remainder lead 32 0 : Nat) 64 : Nat)", + replacement: "(prim multiply (prim remainder lead 32 0 : Nat) 32 : Nat)", + vector: "a math surface with alpha", + }, + Plant { + label: "a delimiter is named an ASCII symbol", + root: 2, + site: "| PrimitiveScan::AtomClass.Delimiter => (lit \"delimiter\")", + replacement: "| PrimitiveScan::AtomClass.Delimiter => (lit \"ascii-symbol\")", + vector: "a text surface with a parenthesis", + }, + Plant { + label: "both channels are the math channel", + root: 2, + site: "(if (textOk atom) then (mathOk atom place) else false)", + replacement: "(mathOk atom place)", + vector: "a both surface with a plus", + }, + Plant { + label: "the last unsafe atom is reported", + root: 2, + site: "| Option.some reason => state", + replacement: "| Option.some reason => (if (atomSafe atom (first state) channel) then (((first state) + 1), (second state)) else (((first state) + 1), (ctor Option.some [Bytes] (unsafeMessage atom channel))))", + vector: "two unsafe atoms", + }, + Plant { + label: "a segment may start with a digit", + root: 3, + site: "(if (isNameStart value) then", + replacement: "(if (isNameRest value) then", + vector: "a name whose segment starts with a digit", + }, + Plant { + label: "an empty segment is a segment", + root: 3, + site: "(if (value =? 46) then (if (second st) then (ctor Option.none [(Nat * Bool)])", + replacement: "(if (value =? 46) then (if false then (ctor Option.none [(Nat * Bool)])", + vector: "a name with two dots", + }, + Plant { + label: "a trailing dot ends a name", + root: 3, + site: "(if (second final) then false else true)", + replacement: "true", + vector: "a name with a trailing dot", + }, + Plant { + label: "an escape does not skip the next byte", + root: 4, + site: "(if (value =? 92) then (cmMove st 2 1)", + replacement: "(if (value =? 92) then (cmMove st 1 1)", + vector: "an escaped quote before a hash", + }, + Plant { + label: "a literal string ends at a quote only", + root: 4, + site: "(if (if (value =? 39) then true else (value =? 10)) then (cmMove st 1 0) else (cmMove st 1 2))", + replacement: "(if (value =? 39) then (cmMove st 1 0) else (cmMove st 1 2))", + vector: "a literal string broken by a line", + }, + Plant { + label: "one quote ends a multi-line string", + root: 4, + site: "(if (LexLeanStd.Text::matchAt text 0x222222 position) then (cmMove st 3 0) else (if (value =? 92) then (cmMove st 2 3)", + replacement: "(if (value =? 34) then (cmMove st 1 0) else (if (value =? 92) then (cmMove st 2 3)", + vector: "a quote inside a multi-line string", + }, + Plant { + label: "the comment is found one byte late", + root: 4, + site: "found := (ctor Option.some [Nat] position)", + replacement: "found := (ctor Option.some [Nat] (position + 1))", + vector: "a comment line", + }, + Plant { + label: "dots stay dots", + root: 5, + site: "(LexLeanStd.Text::splitOn localId (46 : UInt8))", + replacement: "(LexLeanStd.Text::splitOn localId (47 : UInt8))", + vector: "a nested entry", + }, +]; + +fn plants(vectors: &[Vector]) { + let mut missed = Vec::new(); + for plant in PLANTS { + let vector = vectors + .iter() + .find(|vector| vector.label == plant.vector) + .unwrap_or_else(|| panic!("{}: no vector `{}`", plant.label, plant.vector)); + assert_eq!( + vector.root, plant.root, + "{}: the vector is a run of the root planted", + plant.label + ); + let planted = support::P::bootstrap(); + let source = planted.read_raw("src/LexiconSchema.lex.tex"); + assert_eq!( + source.matches(plant.site).count(), + 1, + "{}: the plant site occurs once", + plant.label + ); + planted.write( + "src/LexiconSchema.lex.tex", + &source.replacen(plant.site, plant.replacement, 1), + ); + let checked = support::checked_project(&planted); + let low = super::lower(&checked, &planted, MODULE, ROOTS[plant.root].0); + match super::evaluate(&low, std::slice::from_ref(&vector.run), 1).first() { + Some(first) => eprintln!( + "BS-50: plant detected: {}: {}", + plant.label, + first.chars().take(160).collect::() + ), + None => missed.push(plant.label), + } + } + assert!( + missed.is_empty(), + "planted defects their own vector does not detect: {missed:?}" + ); +} + +fn export(lowered: &BTreeMap<&str, super::Lowered>) { + let exported = harness::exported("bootstrap"); + let bundle = exported.bundle(); + let mut realized = 0usize; + for exported_root in &exported.output.result.roots { + let Some((member, low)) = exported_root + .root + .strip_prefix(&format!("{MODULE}.")) + .and_then(|member| lowered.get(member).map(|low| (member, low))) + else { + continue; + }; + let largest = exported_root + .outputs + .iter() + .flat_map(|output| &output.certification.certificates) + .map(|certificate| certificate.file.byte_length) + .max() + .expect("a certificate"); + eprintln!( + "BS-50: {}: largest certificate part {largest} bytes", + exported_root.root + ); + assert!( + largest <= CERTIFICATE_BUDGET, + "{}: a certificate part of {largest} bytes is beyond {CERTIFICATE_BUDGET}", + exported_root.root + ); + for output in &exported_root.outputs { + let package: Json2 = serde_json::from_slice( + &std::fs::read( + bundle + .join(&output.package.directory) + .join("package.json") + .as_std_path(), + ) + .expect("package.json"), + ) + .expect("package JSON"); + assert_eq!( + package["program"], + serde_json::to_value(&low.program).expect("a program is JSON"), + "{member}: the exported package realizes the program the differential ran" + ); + realized += 1; + } + } + assert_eq!(realized, ROOTS.len(), "one certified package per root"); + let packages = harness::tree(&bundle.join("packages")); + let committed_packages = harness::tree(&harness::fixture_dir("bootstrap").join("packages")); + assert_eq!( + packages.keys().collect::>(), + committed_packages.keys().collect::>(), + "the exported package files are the committed ones" + ); + for (relative, content) in &packages { + assert!( + committed_packages.get(relative) == Some(content), + "packages/{relative} differs from the committed package" + ); + } +} + +#[allow(clippy::too_many_lines)] +pub(super) fn case() { + let started = std::time::Instant::now(); + let project = support::P::bootstrap(); + let checked_units = project.check_ok(); + assert!( + checked_units.units.contains_key("LexiconSchema") + && checked_units.units.contains_key("PrimitiveScan") + && checked_units.units.contains_key("LexiconLse"), + "LexiconSchema, PrimitiveScan and LexiconLse are linked modules of the project" + ); + eligibility_of(&project, "LexiconSchema", MODULE, &ROOTS); + for token in CATEGORIES { + assert_eq!( + Category::parse(token).map(Category::as_str), + Some(token), + "the category table is the oracle's" + ); + } + for token in FRAMES { + assert_eq!( + Frame::parse(token).map(Frame::as_str), + Some(token), + "the frame table is the oracle's" + ); + } + + let vectors = named(); + let labels: BTreeSet<&str> = vectors.iter().map(|vector| vector.label.as_str()).collect(); + assert_eq!(labels.len(), vectors.len(), "each vector has its own label"); + let mut by_root: [Vec; 6] = Default::default(); + for vector in &vectors { + by_root[vector.root].push(vector.run.clone()); + } + let safe = serde_json::to_value(Value::None).expect("a value is JSON"); + let unsafe_named = vectors + .iter() + .filter(|vector| vector.root == 2 && vector.run.1 != safe) + .count(); + assert!(unsafe_named >= 15, "the named surfaces reach refusals"); + + // The committed corpora. + let corpus = committed(); + assert!( + corpus.surfaces.len() >= 300, + "the committed entries carry {} forms", + corpus.surfaces.len() + ); + let mut committed_runs: [Vec; 6] = Default::default(); + for (surface, channel) in &corpus.surfaces { + let atoms = scanned(surface); + committed_runs[2].push(safety_run(&atoms, *channel)); + for other in (0..3).filter(|other| other != channel) { + committed_runs[2].push(safety_run(&atoms, other)); + } + } + for name in &corpus.names { + committed_runs[3].push(lean_run(name)); + } + for local in &corpus.ids { + committed_runs[5].push(path_run(local)); + } + for source in &corpus.lexicon_texts { + committed_runs[4].push(comment_run(source)); + } + let other_comment_runs: Vec = corpus + .other_texts + .iter() + .map(|source| comment_run(source)) + .collect(); + let normative = support::normative_host(); + let (evaluator_seeded, rustc_seeded) = if normative { + (seeded_runs(EVALUATOR_SEEDED), seeded_runs(RUSTC_SEEDED)) + } else { + (Default::default(), Default::default()) + }; + eprintln!( + "BS-50: {} vectors, {} committed forms, {} Lean names, {} entry IDs, {} lexicon files and {} other TOML files ({:?})", + vectors.len(), + corpus.surfaces.len(), + corpus.names.len(), + corpus.ids.len(), + corpus.lexicon_texts.len(), + other_comment_runs.len(), + started.elapsed() + ); + + let checked = support::checked_project(&project); + let lowered: BTreeMap<&str, super::Lowered> = ROOTS + .iter() + .map(|(root, _)| (*root, super::lower(&checked, &project, MODULE, root))) + .collect(); + if normative { + for (index, (root, _)) in ROOTS.iter().enumerate() { + let mut corpus_runs: Vec = by_root[index].clone(); + corpus_runs.extend(committed_runs[index].iter().cloned()); + corpus_runs.extend(evaluator_seeded[index].iter().cloned()); + let disagreements = super::evaluate(&lowered[root], &corpus_runs, 5); + assert!( + disagreements.is_empty(), + "{root} and the Rust oracle disagree: {disagreements:?}" + ); + eprintln!( + "BS-50: {root}: the evaluator agrees on {} runs ({:?})", + corpus_runs.len(), + started.elapsed() + ); + } + plants(&vectors); + } else { + eprintln!("BS-50: platform-bound host: the evaluator, the seeded runs, and the planted defects run on the normative host"); + } + + let mut compiled: [Vec; 6] = Default::default(); + for (index, runs) in compiled.iter_mut().enumerate() { + runs.append(&mut by_root[index]); + runs.append(&mut committed_runs[index]); + runs.extend(rustc_seeded[index].iter().cloned()); + } + compiled[4].extend(other_comment_runs); + let suites: Vec<(&str, &super::Lowered, &[Run])> = ROOTS + .iter() + .enumerate() + .map(|(index, (root, _))| (*root, &lowered[root], compiled[index].as_slice())) + .collect(); + let total = rustc_differential("BS-50", &suites, "oracle"); + eprintln!("BS-50: {total} rustc runs agree ({:?})", started.elapsed()); + + if !support::lean_backed("BS-50") { + return; + } + export(&lowered); + eprintln!("BS-50: passed in {:?}", started.elapsed()); +} diff --git a/crates/conformance/src/cases/repository.rs b/crates/conformance/src/cases/repository.rs index b08d25beb8..aa4b828b91 100644 --- a/crates/conformance/src/cases/repository.rs +++ b/crates/conformance/src/cases/repository.rs @@ -898,7 +898,7 @@ pub(crate) fn run(id: &str) { let model = repo_model::Model::load(&root.join("model").into_std_path_buf()) .expect("the model loads"); let table = spec_table(); - assert_eq!(table.len(), 496, "§31 has 496 rows"); + assert_eq!(table.len(), 497, "§31 has 497 rows"); assert_eq!(model.ids.id.len(), table.len(), "register row count"); for ((spec_id, spec_suite, spec_statement), row) in table.iter().zip(model.ids.id.iter()) diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index c83090918d..8dadaad50f 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -2410,6 +2410,11 @@ fn conformance_bs_34() { repo_conformance::cases::run("BS-34"); } +#[test] +fn conformance_bs_50() { + repo_conformance::cases::run("BS-50"); +} + #[test] fn conformance_pk_01() { repo_conformance::cases::run("PK-01"); diff --git a/features/suites/bootstrap.feature b/features/suites/bootstrap.feature index 13e468aa52..aa6ff276a2 100644 --- a/features/suites/bootstrap.feature +++ b/features/suites/bootstrap.feature @@ -208,3 +208,10 @@ Feature: bootstrap When the project is checked and built, and the lowered program and the rendered package of the root are run on those manifests Then the root is eligible for rust-std with exactly its declared effects, no certificate part is beyond 3,145,728 bytes, the root equals the file bytes of `BuildManifest::to_json` on every run, and each committed manifest is the oracle's text of its own fields And every planted defect is detected by its own vector, and the exported packages are byte-identical to the committed packages and realize the programs the differential ran + + @BS-50 @build + Scenario: The tables and predicates of the lexicon entry schema of SPEC.md §13.1 to §13.6 (`lexicon::entry`: the category, frame, channel, associativity, and feature tokens, each read as its position in the schema's order; for a category, a frame, and a surface arity, `frame_permitted`, the arity `Frame::fixed_arity` fixes, whether the category is core-only, carries a signature, or needs a canonical source form in some channel, and the channels it requires one in; `is_lean_name`, the conservative ASCII Lean-name grammar; and `surface_safety` over the atoms of the primitive scanner, with the allow-list of `is_math_safe_scalar`, nothing or the message naming the first atom that is not renderer-safe; and `lexicon::package`: `toml_comment_at`, the offset of the first comment outside every TOML string form, and `entry_path`) is language-1.2 source in the `bootstrap/` project, as six production roots of `LexiconSchema` over the atoms of `BS-03`: `tokenIndex`, `shapeFacts`, `surfaceSafety`, `isLeanName`, `tomlCommentAt`, and `entryPath`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built vectors, which reach every token of every table, every category with every frame at four arities, every class of atom in every channel, and the edges of the allow-list, on every form surface, Lean name, and entry ID of the committed lexicon entries and on every committed TOML file, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading an entry file and the diagnostics of the entry validator are outside the claim. + Given the committed `bootstrap` project, hand-built tokens, shapes, surfaces, names, TOML texts, and entry IDs, the committed lexicon entries and TOML files, and seeded inputs + When the project is checked and built, and the lowered programs and the rendered packages of the six roots are run on those inputs + Then each root is eligible for rust-std with exactly its declared effects, no certificate part is beyond 3,145,728 bytes, and each root equals its oracle in `lexicon::entry` or `lexicon::package` on every run + And every planted defect is detected by its own vector, and the exported packages are byte-identical to the committed packages and realize the programs the differential ran diff --git a/model/ids.toml b/model/ids.toml index 81d8d603d1..a23c099f54 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -2894,6 +2894,12 @@ level = "build" suite = "bootstrap" statement = "The build manifest of SPEC.md §21.6 in the canonical JSON of §21.7 (`artifact::manifest::BuildManifest::to_json` written as a file: the specification, the compiler version and semantics ID, the language, the project, the source, semantic, and build IDs, the pinned Lean toolchain, the selection and the module rows in their order, a module's origin only when it has one, and the input and output rows sorted by kind, path, length, and digest, each digest in lower-case hex) is language-1.2 source in the `bootstrap/` project, as the production root `buildManifest` of `ManifestText` over the standard library's `Json` writer, eligible for `rust-std` with exactly its declared effects, `allocation`, `overflow`, and `recursion`, and with no part of its certificate beyond 3,145,728 bytes; its rendered `rust-std` package under the pinned rustc, and on the normative host its lowered program under the calculus evaluator, agree with the oracle to the byte on hand-built manifests, which reach every key of the row order, lengths across a byte, a module's origin, and escapes, on every committed build manifest, each of which is the oracle's text of its own fields, and on seeded manifests; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; gathering the rows of a build and hashing its files are outside the claim." +[[id]] +id = "BS-50" +level = "build" +suite = "bootstrap" +statement = "The tables and predicates of the lexicon entry schema of SPEC.md §13.1 to §13.6 (`lexicon::entry`: the category, frame, channel, associativity, and feature tokens, each read as its position in the schema's order; for a category, a frame, and a surface arity, `frame_permitted`, the arity `Frame::fixed_arity` fixes, whether the category is core-only, carries a signature, or needs a canonical source form in some channel, and the channels it requires one in; `is_lean_name`, the conservative ASCII Lean-name grammar; and `surface_safety` over the atoms of the primitive scanner, with the allow-list of `is_math_safe_scalar`, nothing or the message naming the first atom that is not renderer-safe; and `lexicon::package`: `toml_comment_at`, the offset of the first comment outside every TOML string form, and `entry_path`) is language-1.2 source in the `bootstrap/` project, as six production roots of `LexiconSchema` over the atoms of `BS-03`: `tokenIndex`, `shapeFacts`, `surfaceSafety`, `isLeanName`, `tomlCommentAt`, and `entryPath`, each eligible for `rust-std` with exactly its declared effects, `allocation` and `overflow`, and each with no part of its certificate beyond 3,145,728 bytes; their rendered `rust-std` packages under the pinned rustc, and on the normative host their lowered programs under the calculus evaluator, agree with the oracle to the byte on hand-built vectors, which reach every token of every table, every category with every frame at four arities, every class of atom in every channel, and the edges of the allow-list, on every form surface, Lean name, and entry ID of the committed lexicon entries and on every committed TOML file, and on seeded inputs; each planted defect in the source is detected by the one vector it names, and the certified packages the production export publishes for the project are the committed ones; reading an entry file and the diagnostics of the entry validator are outside the claim." + [[id]] id = "PK-01" level = "build" diff --git a/tests/production-export/bootstrap/roots.json b/tests/production-export/bootstrap/roots.json index 32674a57bb..77d3a08cb9 100644 --- a/tests/production-export/bootstrap/roots.json +++ b/tests/production-export/bootstrap/roots.json @@ -495,6 +495,54 @@ "rust-std" ], "version": "1.0.0" + }, + { + "name": "entry_path", + "root": "LexLeanBoot.LexiconSchema.entryPath", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, + { + "name": "is_lean_name", + "root": "LexLeanBoot.LexiconSchema.isLeanName", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, + { + "name": "shape_facts", + "root": "LexLeanBoot.LexiconSchema.shapeFacts", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, + { + "name": "surface_safety", + "root": "LexLeanBoot.LexiconSchema.surfaceSafety", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, + { + "name": "token_index", + "root": "LexLeanBoot.LexiconSchema.tokenIndex", + "targets": [ + "rust-std" + ], + "version": "1.0.0" + }, + { + "name": "toml_comment_at", + "root": "LexLeanBoot.LexiconSchema.tomlCommentAt", + "targets": [ + "rust-std" + ], + "version": "1.0.0" } ] } diff --git a/xtask/src/spec_links.rs b/xtask/src/spec_links.rs index f97eb8c07c..8bc0b72d97 100644 --- a/xtask/src/spec_links.rs +++ b/xtask/src/spec_links.rs @@ -61,8 +61,8 @@ fn parse_table(spec: &str) -> Result, Fail> { pub fn validate(root: &Path) -> Result<(), Fail> { let spec = std::fs::read_to_string(root.join("SPEC.md"))?; let rows = parse_table(&spec)?; - if rows.len() != 496 { - return Err(format!("RP-07: the §31 table has {} rows, not 496", rows.len()).into()); + if rows.len() != 497 { + return Err(format!("RP-497: the §497 table has {} rows, not 497", rows.len()).into()); } // The prose total under the table is part of the contract a reader // relies on; a row added without it would leave §31 contradicting itself. From d77717dab42aa1d3c8b53c2f28ff354d5e6b23c7 Mon Sep 17 00:00:00 2001 From: humuhumu33 Date: Fri, 13 Nov 2026 00:14:45 +0000 Subject: [PATCH 2/3] BS-50: an if reads a flag of a pair through a definition, so its certificate checks Certificate B of leanStep was rejected by the kernel (LLV7015 in regeneration run 43316802288): the preservation proof of an `if` whose condition is `(second st)` of a pair does not type-check. The condition now reads the flag through `segAt`, as every certified condition that is a call does; the two plant sites follow it. Co-Authored-By: Claude Opus 5.5 --- bootstrap/src/LexiconSchema.lex.tex | 12 +- .../src/cases/bootstrap/lexicon_schema.rs | 126 +++--------------- 2 files changed, 30 insertions(+), 108 deletions(-) diff --git a/bootstrap/src/LexiconSchema.lex.tex b/bootstrap/src/LexiconSchema.lex.tex index f3db90f824..c72a6e54a6 100755 --- a/bootstrap/src/LexiconSchema.lex.tex +++ b/bootstrap/src/LexiconSchema.lex.tex @@ -357,11 +357,19 @@ executable: true } +definition{ + name: segAt, + parameters: [st : (Nat * Bool)], + result: Bool, + body: (second st), + executable: true +} + definition{ name: leanStep, parameters: [text : Bytes, n : Nat, st : (Nat * Bool)], result: (Option (Nat * Bool)), - body: (let position : Nat := (first st); (if (position (leanStep text n st)) (n + 1) (0, true) : ((Nat * Bool) * Bool))); (if ((first final) =? n) then (if (second final) then false else true) else false))), + body: (let n : Nat := (prim length text : Nat); (let final : (Nat * Bool) := (first (prim iterate_until (fun [n, text] (st : (Nat * Bool)) => (leanStep text n st)) (n + 1) (0, true) : ((Nat * Bool) * Bool))); (if ((first final) =? n) then (if (segAt final) then false else true) else false))), axioms: [Quot.sound, propext], executable: true, production: {effects: [allocation, overflow], targets: [rust-std]} diff --git a/crates/conformance/src/cases/bootstrap/lexicon_schema.rs b/crates/conformance/src/cases/bootstrap/lexicon_schema.rs index 7c220d4e51..31bc27f2cf 100755 --- a/crates/conformance/src/cases/bootstrap/lexicon_schema.rs +++ b/crates/conformance/src/cases/bootstrap/lexicon_schema.rs @@ -144,10 +144,9 @@ fn token_run(which: u64, token: &str) -> Run { /// What the oracle says of a category, a frame, and a surface arity, as the /// module's `Shape`. fn shape_run(category: u64, frame: u64, arity: u32) -> Run { - let category_enum = Category::parse(CATEGORIES[usize::try_from(category).expect("an index")]) - .expect("a category"); - let frame_enum = - Frame::parse(FRAMES[usize::try_from(frame).expect("an index")]).expect("a frame"); + let category_enum = + Category::parse(CATEGORIES[usize::try_from(category).expect("an index")]).expect("a category"); + let frame_enum = Frame::parse(FRAMES[usize::try_from(frame).expect("an index")]).expect("a frame"); let shape = Value::Adt { constructor: 0, fields: vec![ @@ -237,30 +236,14 @@ fn named() -> Vec { ]; for (which, table) in &tables { for token in table { - add( - format!("the token `{token}` of table {which}"), - 0, - token_run(*which, token), - ); + add(format!("the token `{token}` of table {which}"), 0, token_run(*which, token)); } for miss in ["", "Structural", "atom ", "noun_of", "both-", "article"] { - add( - format!("the near miss `{miss}` in table {which}"), - 0, - token_run(*which, miss), - ); + add(format!("the near miss `{miss}` in table {which}"), 0, token_run(*which, miss)); } } - add( - "a frame is not a category".to_owned(), - 0, - token_run(0, "infix"), - ); - add( - "a category is not a frame".to_owned(), - 0, - token_run(1, "function"), - ); + add("a frame is not a category".to_owned(), 0, token_run(0, "infix")); + add("a category is not a frame".to_owned(), 0, token_run(1, "function")); // shapeFacts: every category with every frame, at arities 0, 1, 2, 3. for category in 0..17u64 { @@ -287,11 +270,7 @@ fn named() -> Vec { // surfaceSafety. for (label, surface, channel) in [ ("a text word", "natural number", 0), - ( - "a text surface with every safe punctuation", - "a: b-c, d. e; f'", - 0, - ), + ("a text surface with every safe punctuation", "a: b-c, d. e; f'", 0), ("a text surface with a colon", "is: a", 0), ("a text surface with a parenthesis", "f(x)", 0), ("a text surface with a numeral", "x 2", 0), @@ -300,11 +279,7 @@ fn named() -> Vec { ("a text surface with a control", "\\N", 0), ("a math plus", "+", 1), ("a math surface with an underscore", "a_b", 1), - ( - "a math surface with every unsafe symbol", - "\\%$#&~^_{}\"`", - 1, - ), + ("a math surface with every unsafe symbol", "\\%$#&~^_{}\"`", 1), ("a math surface with brackets", "[a](b)", 1), ("a math surface with a brace", "{", 1), ("a math surface led by a numeral", "2x", 1), @@ -384,10 +359,7 @@ fn named() -> Vec { ("a basic string broken by a line", "a = \"x\n# c"), ("a hash in a multi-line string", "a = \"\"\"\n#\n\"\"\""), ("a quote inside a multi-line string", "a = \"\"\"x\"#\"\"\""), - ( - "an escape inside a multi-line string", - "a = \"\"\"\\\"\"\"#\"\"\"", - ), + ("an escape inside a multi-line string", "a = \"\"\"\\\"\"\"#\"\"\""), ("a hash after a multi-line string", "a = \"\"\"x\"\"\" # c"), ("a hash in a multi-line literal string", "a = '''\n#'''"), ("a hash after a multi-line literal string", "a = '''x''' #"), @@ -538,65 +510,11 @@ fn committed() -> Committed { // ------------------------------------------------------------------- seeded const SURFACE_PIECES: &[&str] = &[ - "a", - "nat", - "x", - "the", - "of", - "1", - "20", - " ", - " ", - ":", - "-", - ",", - ".", - ";", - "'", - "+", - "=", - "<", - "*", - "/", - "|", - "!", - "?", - "@", - "%", - "$", - "#", - "&", - "~", - "^", - "_", - "\"", - "`", - "(", - ")", - "[", - "]", - "{", - "}", - "\\N", - "\\alpha", - "\u{2200}", - "\u{3b1}", - "\u{3a9}", - "\u{2115}", - "\u{2192}", - "\u{2264}", - "\u{2282}", - "\u{2308}", - "\u{27e8}", - "\u{2983}", - "\u{2a01}", - "\u{1d538}", - "\u{e9}", - "\u{20ac}", - "\u{2026}", - "\u{2032}", - "\u{ac}", - "\u{d7}", + "a", "nat", "x", "the", "of", "1", "20", " ", " ", ":", "-", ",", ".", ";", "'", "+", "=", + "<", "*", "/", "|", "!", "?", "@", "%", "$", "#", "&", "~", "^", "_", "\"", "`", "(", ")", + "[", "]", "{", "}", "\\N", "\\alpha", "\u{2200}", "\u{3b1}", "\u{3a9}", "\u{2115}", + "\u{2192}", "\u{2264}", "\u{2282}", "\u{2308}", "\u{27e8}", "\u{2983}", "\u{2a01}", + "\u{1d538}", "\u{e9}", "\u{20ac}", "\u{2026}", "\u{2032}", "\u{ac}", "\u{d7}", ]; const NAME_PIECES: &[&str] = &[ "Nat", "add", "_", "1", ".", "x9", "-", "\u{3b1}", "'", "Zero", "", " ", @@ -606,8 +524,8 @@ const TOML_PIECES: &[&str] = &[ ]; const ID_PIECES: &[&str] = &["a", "b1", ".", "-", "nat", "add", "", "zero"]; const TOKEN_PIECES: &[&str] = &[ - "infix", "function", "-", "noun", "of", "both", "text", "article", "a", "n", "left", "plural", - "case", "Atom", " ", + "infix", "function", "-", "noun", "of", "both", "text", "article", "a", "n", "left", + "plural", "case", "Atom", " ", ]; fn joined(seeded: &mut Seeded, pieces: &[&str], most: usize) -> String { @@ -771,14 +689,14 @@ const PLANTS: &[Plant] = &[ Plant { label: "an empty segment is a segment", root: 3, - site: "(if (value =? 46) then (if (second st) then (ctor Option.none [(Nat * Bool)])", + site: "(if (value =? 46) then (if (segAt st) then (ctor Option.none [(Nat * Bool)])", replacement: "(if (value =? 46) then (if false then (ctor Option.none [(Nat * Bool)])", vector: "a name with two dots", }, Plant { label: "a trailing dot ends a name", root: 3, - site: "(if (second final) then false else true)", + site: "(if (segAt final) then false else true)", replacement: "true", vector: "a name with a trailing dot", }, @@ -988,11 +906,7 @@ pub(super) fn case() { for source in &corpus.lexicon_texts { committed_runs[4].push(comment_run(source)); } - let other_comment_runs: Vec = corpus - .other_texts - .iter() - .map(|source| comment_run(source)) - .collect(); + let other_comment_runs: Vec = corpus.other_texts.iter().map(|source| comment_run(source)).collect(); let normative = support::normative_host(); let (evaluator_seeded, rustc_seeded) = if normative { (seeded_runs(EVALUATOR_SEEDED), seeded_runs(RUSTC_SEEDED)) From 1fa2d41ac973bb65ead1cf3900c07fda0d53ebf4 Mon Sep 17 00:00:00 2001 From: humuhumu33 Date: Fri, 13 Nov 2026 17:48:28 +0000 Subject: [PATCH 3/3] Relock bootstrap and refresh model documents after the release merge Co-Authored-By: Claude Sonnet 5 --- bootstrap/lexlean.lock | 57 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 bootstrap/lexlean.lock diff --git a/bootstrap/lexlean.lock b/bootstrap/lexlean.lock new file mode 100644 index 0000000000..8458da75bd --- /dev/null +++ b/bootstrap/lexlean.lock @@ -0,0 +1,57 @@ +spec = "lexlean/lock/2" +language = "1.2" +compiler_semantics = "a82990b56aa082f57e3bf3e2d6494d75a8170f26e269448de19110f5459655ad" +project_config_sha256 = "4b43e33e5cb6a8cc0299f1babb5023e7ef0c14aa34f5d3da8fb7dbcfe602194d" +lean_toolchain = "leanprover/lean4:v4.32.1" + +[[workspace_file]] +path = "lake-manifest.json" +sha256 = "736b7fb038a81af813e3e29b7c1ea7575ceefb442c8fb2e4df805d4bd87010b6" + +[[workspace_file]] +path = "lakefile.toml" +sha256 = "4faafd773dfa00e427b139318e863070b818aa6e229ce493b24ec906b60fa5df" + +[[workspace_file]] +path = "lean-toolchain" +sha256 = "8e3538e0ab5f81a3ee04927d8838c8c674e0e112838b4b3ce87ec218143276af" + +[[package]] +id = "lexlean.core" +version = "1.2.0" +kind = "builtin" +source = "embedded" +revision = "compiler-semantics" +tree_sha256 = "827317cae68c162f3a96c8a8de4e53ab348e7d3724fd2b834fa85ecde1a1b392" +manifest_sha256 = "271079763d269cc873531f515e56da960cd6321393b9460ff0e617666fa01d71" +imports = [] + +[[package]] +id = "lexlean.std.bool" +version = "1.2.0" +kind = "builtin" +source = "embedded" +revision = "compiler-semantics" +tree_sha256 = "3bc0fb09d706ffa7d5a1363302ea87c049acc7c7dcafde63c62682620c11be9b" +manifest_sha256 = "de58de2cf18a7a5a62d8c20649139d6dfe1f7b16b3130c75f150fbac5440a71e" +imports = ["lexlean.core@1.2.0"] + +[[package]] +id = "lexlean.std.nat" +version = "1.2.0" +kind = "builtin" +source = "embedded" +revision = "compiler-semantics" +tree_sha256 = "e0db021e01b91d651c43921d66f6b0023c8efbf17cac2ec53192ce5305e4e1ac" +manifest_sha256 = "6fb446b39e3c1c18a5f10cfa1f7aa2bd431837719eb0eb7489aadf452c9420a7" +imports = ["lexlean.core@1.2.0", "lexlean.std.bool@1.2.0"] + +[[source_package]] +id = "std" +version = "1.0.0" +kind = "path" +source = "stdlib" +module_prefix = "LexLeanStd" +tree_sha256 = "316ac824e54957e79f4bdd5ed1f3228b7c5a817333134bddff9552d254434a08" +manifest_sha256 = "1dbb7c6933b8f2a4a9d4af7746eefcb077ea1b339d9b88a63eadf64b6a348f4f" +imports = []