| # GENERATED by scripts/overview-links.sh --update — do not edit by hand. | |
| # | |
| # Every line-anchored link of README.md and OVERVIEW.md, in document | |
| # order, with the lines it points at. A diff here means a citation moved | |
| # or its text changed: re-read the paragraph that cites it, fix the link | |
| # or the prose, then regenerate. | |
| == con-leche/ConLeche/Model/PureChecker.lean#L30-L39 | |
| 30 /-- **Every stream the checker accepts has a model in every set theory.** -/ | |
| 31 theorem model_exists (V : Type w) [SetTheory V] | |
| 32 (pins : List NatOpPinSet) (maxNatSize : Nat) (ds : Array Declaration) | |
| 33 (accepted : (checkDecls .verified pins maxNatSize ds).isOk) : | |
| 34 ∃ model, IsModel V model (· ∈ constantsOf ds.toList) := by | |
| 35 cases h : checkDecls .verified pins maxNatSize ds with | |
| 36 | error e => rw [h] at accepted; cases accepted | |
| 37 | ok env => | |
| 38 obtain ⟨m⟩ := Cached.checkDecls_sound (V := V) h | |
| 39 exact ⟨_, isModel_of_envModelM m (Cached.checkDecls_recordsStored h)⟩ | |
| == con-leche/ConLeche/Verify/Cached/MainC.lean#L33-L39 | |
| 33 /-- **Acceptance**: what the fold accepts carries the model. -/ | |
| 34 theorem checkDecls_sound | |
| 35 {ds : Array Declaration} {env' : Env} | |
| 36 (h : checkDecls .verified pins maxNatSize ds = .ok env') : | |
| 37 Nonempty (EnvModelM V env') := by | |
| 38 obtain ⟨n, fe, r, rfl⟩ := checkDecls_run .verified h | |
| 39 exact (declsRun_model (V := V) r rfl ConLeche.Model.EnvModelOk.empty).nonempty | |
| == proof/ConRon/MainTheorem.lean#L112-L115 | |
| 112 theorem main_json_model (V : Type w) [ConLeche.SetTheory V] {file : String} {fs : FS} | |
| 113 {b : ByteArray} | |
| 114 (h : ConRon.CanGive ["--", file] fs 0) (hb : fs.file file = some b) : | |
| 115 ∃ r, parseChunks [b] = .ok r ∧ ∃ model, IsModel V model (· ∈ constantsOf r.decls.toList) := | |
| == proof/ConRon/MainTheorem.lean#L123-L126 | |
| 123 theorem main_no_False (V : Type w) [ConLeche.SetTheory V] {file : String} {fs : FS} | |
| 124 {b : ByteArray} | |
| 125 (h : ConRon.CanGive ["--", file] fs 0) (hb : fs.file file = some b) | |
| 126 (hF : jsonWithTheoremFalse [b]) : False := | |
| == crates/con-ron-core/src/arena/handle.rs#L4-L13 | |
| 4 //! One 32-bit word per handle, in one of two shapes. The top bit is the tier | |
| 5 //! in both; bit 30 says which shape the rest is: | |
| 6 //! | |
| 7 //! ```text | |
| 8 //! wide (expression `app` only) narrow (every other node) | |
| 9 //! bit 31 tier bit 31 tier | |
| 10 //! bit 30 1 bit 30 0 | |
| 11 //! bits 29…0 index bits 29…26 ctor tag (4 bits) | |
| 12 //! bits 25…0 index | |
| 13 //! ``` | |
| == crates/con-ron-core/src/arena/store.rs#L1196-L1210 | |
| 1196 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Store.lean:351-363 ETables | |
| 1197 /// One tier of the expression store: ten arrays, ten derived columns, ten | |
| 1198 /// cons tables. | |
| 1199 pub struct ETables { | |
| 1200 pub bvars: Tbl<BVarNode, EIdx, u64>, | |
| 1201 pub fvars: Tbl<FVarNode, EIdx, u64>, | |
| 1202 pub sorts: Tbl<SortNode, EIdx, u64>, | |
| 1203 pub consts: Tbl<ConstNode, EIdx, u64>, | |
| 1204 pub apps: Tbl<AppNode, EIdx, u64>, | |
| 1205 pub lams: Tbl<BindNode, EIdx, u64>, | |
| 1206 pub foralls: Tbl<BindNode, EIdx, u64>, | |
| 1207 pub lets: Tbl<LetNode, EIdx, u64>, | |
| 1208 pub lits: Tbl<LitNode, EIdx, u64>, | |
| 1209 pub projs: Tbl<ProjNode, EIdx, u64>, | |
| 1210 } | |
| == crates/con-ron/src/bin/con-ron.rs#L49-L172 | |
| 49 const SYNOPSIS: &str = "\ | |
| 50 Usage: | |
| 51 con-ron [OPTIONS] [--] FILE.ndjson | |
| 52 con-ron [OPTIONS] --compare [--] CHALLENGE.ndjson SOLUTION.ndjson | |
| 53 con-ron [OPTIONS] --olean --search-path=DIRS [--] MODULE... | |
| 54 con-ron [OPTIONS] --check-graph --search-path=DIRS [--] MODULE... | |
| 55 con-ron [OPTIONS] --olean --module --search-path=DIRS [--] MODULE | |
| 56 con-ron [OPTIONS] --olean --modular --search-path=DIRS [--] MODULE | |
| 57 con-ron [OPTIONS] --olean --schedule[-OPT=V] --search-path=DIRS [--] MODULE | |
| 58 con-ron [OPTIONS] --olean --compare [--trusted-search-path=DIRS] | |
| 59 --search-path=DIRS [--] CHALLENGE SOLUTION | |
| 60 con-ron [OPTIONS] --check-graph --compare [--trusted-search-path=DIRS] | |
| 61 --search-path=DIRS [--] CHALLENGE SOLUTION | |
| 62 con-ron [OPTIONS] --olean --module|--modular|--schedule[-OPT=V] | |
| 63 --compare [--trusted-search-path=DIRS] --search-path=DIRS | |
| 64 [--] CHALLENGE SOLUTION"; | |
| 65 | |
| 66 /// con-leche: ConLeche/Driver/Cli.lean:134-135 tryHelp | |
| 67 /// The line after a usage error. | |
| 68 const TRY_HELP: &str = "Try 'con-ron --help' for more information."; | |
| 69 | |
| 70 /// con-leche: ConLeche/Driver/Cli.lean:137-260 helpText | |
| 71 /// The `--help` text: con-leche's, with this binary's name and con-ron's | |
| 72 /// documentation. DESIGN.md §3.1: message | |
| 73 /// strings need not match. | |
| 74 const HELP_HEAD: &str = "\ | |
| 75 Check Lean declarations from a lean4export file or from .olean modules. | |
| 76 "; | |
| 77 | |
| 78 /// con-leche: ConLeche/Driver/Cli.lean:137-260 helpText | |
| 79 /// The rest of the `--help` text, after the synopsis. The scheduler is the | |
| 80 /// simple one (`con_ron::schedule`): its settings con-ron does not run are | |
| 81 /// listed by name, as usage errors, in place of their descriptions. | |
| 82 const HELP_TAIL: &str = "\ | |
| 83 Options: | |
| 84 --verified Check in the mode the soundness theorem covers (default) | |
| 85 --trusted Skip the checks only the proof needs; outside the theorem | |
| 86 --jobs=N Worker threads (default: one per hardware thread, at most 16) | |
| 87 --max-nat-size=N Largest Nat numeral in bytes the checker takes in or | |
| 88 computes; a larger one is rejected (default 134217728) | |
| 89 --progress[=PACE] Report progress on stderr: PACE is N declarations | |
| 90 (default 1), P% of each phase, or Ss seconds | |
| 91 --help Print this help and exit | |
| 92 -- End of options | |
| 93 | |
| 94 lean4export input: | |
| 95 --compare CHALLENGE.ndjson SOLUTION.ndjson: check SOLUTION, then | |
| 96 check CHALLENGE, its axioms justified by SOLUTION: each | |
| 97 axiom of CHALLENGE (but the standard ones) and each | |
| 98 declaration whose value uses sorry is accepted as an | |
| 99 axiom of its statement when SOLUTION holds a constant | |
| 100 of that name and type, up to the names of level | |
| 101 parameters, and everything that type reads is the same | |
| 102 in both, record by record. Prints the justified axioms | |
| 103 | |
| 104 .olean input: | |
| 105 --olean Read modules and their import closure from .olean files | |
| 106 --search-path=DIRS Colon-separated .olean directories; repeatable | |
| 107 --constant=NAME Check only NAME and what it mentions; repeatable | |
| 108 (outside the theorems) | |
| 109 --compare CHALLENGE SOLUTION: check the closure of the module | |
| 110 SOLUTION, then the closure of CHALLENGE, its axioms | |
| 111 justified by SOLUTION's as for lean4export input. | |
| 112 Prints the justified axioms. With --constant=NAME | |
| 113 (declarations of CHALLENGE itself), only NAME and | |
| 114 what it reads. With --check-graph, --module, | |
| 115 --modular or --schedule: CHALLENGE as one more module | |
| 116 of a modular run over the closures of both, with | |
| 117 `import all SOLUTION` added to its header: a | |
| 118 declaration of CHALLENGE that a loaded module holds | |
| 119 must be that constant (a hole, theorem or opaque | |
| 120 constant by its type, a definition with its value, up | |
| 121 to the names of level parameters; an inductive type | |
| 122 as it is), every other one is checked (its --module | |
| 123 run is the compare worker; the guarantee needs every | |
| 124 command to exit 0) | |
| 125 --trusted-search-path=DIRS | |
| 126 With --compare: CHALLENGE and all it imports must be | |
| 127 in DIRS, and are read from there only; SOLUTION's | |
| 128 modules from DIRS first, then --search-path (the | |
| 129 modular modes read every module so). With --module | |
| 130 alone: MODULE's closure read from DIRS first, then | |
| 131 --search-path. | |
| 132 Colon-separated; repeatable | |
| 133 --check-graph Check only that the modules' import graph is acyclic | |
| 134 and that every import is on the search path | |
| 135 --module Check MODULE's own declarations alone, against what | |
| 136 they read of the modules it loads | |
| 137 --modular Check every module of MODULE's closure as --module | |
| 138 does, in this one process | |
| 139 --schedule Check every module of MODULE's closure by a --module | |
| 140 process each (--jobs=1 each), at most --jobs=N at a | |
| 141 time; a line per finished module on stdout, then each | |
| 142 failing module's verdict and last stderr line, and the | |
| 143 run's verdict: the first failing module in the graph's | |
| 144 order, its code (timeout, stack, a signal: 3); with | |
| 145 --schedule-timeout=S a time limit per worker | |
| 146 --worker-stack-size=SIZE the workers' thread stacks (with a unit: 8G), set | |
| 147 as their LEAN_STACK_SIZE_KB (without the flag they | |
| 148 inherit the environment; con-ron's default is 1G) | |
| 149 --schedule-order=ORDER shuffled (default; by a hash of the names) or graph: | |
| 150 the order in which the modules start | |
| 151 --schedule-commands start nothing; print on stdout, one per line and | |
| 152 shell-quoted, the commands that check the closure: | |
| 153 the --check-graph run, then one --module run per | |
| 154 module in the start order (--jobs=N only if given); | |
| 155 the modular guarantee needs every one to exit 0 on | |
| 156 one unchanged snapshot of the files (with | |
| 157 --worker-stack-size, each worker's line starts | |
| 158 with LEAN_STACK_SIZE_KB=K); -memory, -log and | |
| 159 -timeout are ignored | |
| 160 | |
| 161 con-leche's scheduler settings con-ron does not run (a usage error, exit 3): | |
| 162 --schedule-log=FILE, --schedule-memory=SIZE (con-ron's --schedule keeps no | |
| 163 log and no memory budget) | |
| 164 | |
| 165 Exit status: | |
| 166 0 accepted | |
| 167 1 rejected: a declaration is invalid | |
| 168 2 declined: an unsupported feature | |
| 169 3 error: bad usage, malformed input or an internal failure | |
| 170 | |
| 171 Documentation: | |
| 172 README.md and OVERVIEW.md of the con-ron repository"; | |
| == crates/con-ron/src/driver.rs#L18-L23 | |
| 18 | |
| 19 use std::time::Instant; | |
| 20 | |
| 21 use con_ron_core::arena::env as ienv; | |
| 22 use con_ron_core::arena::env::IDeclaration; | |
| 23 use con_ron_core::frontend::pace::{pace_due_count, pace_on, pace_trace, Pace}; | |
| == crates/con-ron-core/src/kernel/name.rs#L641-L653 | |
| 641 pub fn render(n: &Name) -> Vec<u32> { | |
| 642 match &n.0.kind { | |
| 643 NameKind::Anonymous => { | |
| 644 const A: [u32; 11] = [91, 97, 110, 111, 110, 121, 109, 111, 117, 115, 93]; | |
| 645 crate::kernel::core_types::code_points(&A) | |
| 646 } | |
| 647 _ => { | |
| 648 let cs = component_list(n, Vec::new()); | |
| 649 let k = cs.len(); | |
| 650 display_acc_finish(render_from(&cs, k, display_acc_empty())) | |
| 651 } | |
| 652 } | |
| 653 } | |
| == flake.nix#L5-L29 | |
| 5 # Aeneas pins the Charon commit it needs (see `charon-pin` upstream) and | |
| 6 # Charon pins the Rust nightly it needs (`rust-toolchain`). Everything | |
| 7 # else follows from these two so that the Rust we write is compiled by | |
| 8 # exactly the toolchain Charon understands. | |
| 9 aeneas.url = "github:AeneasVerif/aeneas/1dc8ad31b1b062a77c50e29144a6c7bba955fa09"; | |
| 10 nixpkgs.follows = "aeneas/charon/nixpkgs"; | |
| 11 flake-utils.follows = "aeneas/flake-utils"; | |
| 12 }; | |
| 13 | |
| 14 outputs = { self, nixpkgs, flake-utils, aeneas, ... }: | |
| 15 flake-utils.lib.eachDefaultSystem (system: | |
| 16 let | |
| 17 pkgs = nixpkgs.legacyPackages.${system}; | |
| 18 charonPkgs = aeneas.inputs.charon.packages.${system}; | |
| 19 aeneasPkgs = aeneas.packages.${system}; | |
| 20 in { | |
| 21 packages = { | |
| 22 charon = charonPkgs.charon; | |
| 23 aeneas = aeneasPkgs.aeneas; | |
| 24 rustToolchain = charonPkgs.rustToolchain; | |
| 25 }; | |
| 26 | |
| 27 devShells.default = pkgs.mkShell { | |
| 28 packages = [ | |
| 29 charonPkgs.rustToolchain # rustc/cargo nightly pinned by Charon | |
| == proof/ConRon/MainTheorem.lean#L10-L100 | |
| 10 /-! | |
| 11 # `ConRon.MainTheorem` — the main theorems about the binary (task #171, DESIGN.md §3.9) | |
| 12 | |
| 13 The twin of `ConLeche/MainTheorem.lean`: the same theorem names, in the same order, with the | |
| 14 same statements word for word, but con-leche's run premise `ModelIO.CanGive (Driver.runArgs | |
| 15 args) fs 0` is con-ron's `ConRon.CanGive args fs 0` (`MainTheorem/Model.lean`): the extracted | |
| 16 driver `driver::cli::run_args` exits 0 on the argument list `args` at the MODEL instance of the | |
| 17 trait `CheckerIo`, `Model.snapshotIo fs`, from some oracle. The model is con-ron's `ModelIO`: | |
| 18 its file operations answer from the snapshot `fs` (a failure where `fs` has no answer, and at a | |
| 19 path that is not a well-formed string); every escape that answers a value (the help's and the | |
| 20 scheduler's exit codes, the hardware thread count, the copies' error) takes its answer from the | |
| 21 oracle, so any value of its type is possible; the worker map folds each job over the claims the | |
| 22 oracle picks; the code map runs every job; the notifications do nothing. That the model | |
| 23 answers as `fs` and keeps the two maps' contracts are theorems about it | |
| 24 (`Model.snapshotIo_answersAs`, `snapshotIo_poolSound`, `snapshotIo_codesSound`), which the walks | |
| 25 use through the instance-generic `CanGiveConforming` (`CanGive.conforming`). | |
| 26 | |
| 27 **What is proved, and what is trusted** (con-leche's `ConLeche/Frontend/CheckerIO.lean`, its | |
| 28 module doc, says the same of its binary; OVERVIEW §3.1 is this paragraph's table). The | |
| 29 theorems say: every run of the model that exits 0 implies the statement. The binary's `main` | |
| 30 (`crates/con-ron/src/bin/con-ron.rs`) is the argument list's code points (an argument that is | |
| 31 not UTF-8 is exit 3), the checking thread, the same generic `run_args` at the binary's instance | |
| 32 `StdIo` (`crates/con-ron/src/std_io.rs`), the flush and the exit with the code `run_args` | |
| 33 returned; those lines are read, not proved. The code is computed by the extracted driver and | |
| 34 returned outside every escape. A run of the binary that exits 0 is one of the model's runs, | |
| 35 with that code, if | |
| 36 | |
| 37 1. every file operation the run PERFORMS answered as one snapshot `fs` of the files: the same | |
| 38 value where the model has one, and a failure where the model fails (`StdIo` fails at a path | |
| 39 with a code point that is not a character, at a real path that is not valid UTF-8, at a size | |
| 40 its file's contents do not end at, and at a path whose file was replaced between two | |
| 41 openings of it; it reads every byte range through the run's one handle of the file, up to | |
| 42 where a read finds the end). Those checks catch a path replaced by another file, not a file | |
| 43 rewritten in place: that the files do not change during the run is assumed, as con-leche | |
| 44 assumes it, not enforced; | |
| 45 and on the binary's platform the Rust's spelling of a module's file (`files::mod_file_of`) is | |
| 46 upstream's (`modFile`), which the logic cannot decide (`System.FilePath`'s `/` reads the | |
| 47 opaque `System.Platform.isWindows`), so the model also fails where they would differ; | |
| 48 2. the escapes and notifications do not change what the file operations see (none writes a file | |
| 49 a check reads: they print, read the clock, count threads, keep what the run built, and start | |
| 50 the scheduler, whose workers only read) and do not end the process with exit code 0; | |
| 51 3. the two maps' actual runs are some oracle's: the worker map (`pool::parallel_all`) runs each | |
| 52 worker from the job's first state over the positions it claims, in increasing order, every | |
| 53 position claimed, and answers `Ok` only when every step did, which is an argument about its | |
| 54 control flow; the code map runs every module's step and answers their codes in order; and | |
| 55 4. Rust, its standard library and Aeneas run and model the code as written. | |
| 56 | |
| 57 The argument is then con-leche's: the extracted code is the same at both instances; at every file | |
| 58 operation the run performs, the binary's answer is, by (1) and (2), the model's; at every escape | |
| 59 the binary's answer is SOME value of its type, and the model has an oracle that gives it (the | |
| 60 oracle is chosen after the run, answer by answer); at each map, by (3), an oracle's claims give | |
| 61 the binary's answer. So, by induction along the run, a run of the binary that reaches the exit | |
| 62 with 0 is one of the model's runs, and what is proved of all of those holds of it. Calls the run | |
| 63 does not perform constrain nothing. | |
| 64 | |
| 65 What differs from con-leche: an ORACLE in the instance's state where con-leche has a | |
| 66 non-determinism monad (Aeneas models a trait method as a function, so "any outcome" is "the | |
| 67 oracle's", the oracle existentially chosen); and POSITIONAL reads (`read_range`) where con-leche | |
| 68 opens a handle and reads it forward (the model's `ModelIO.read` slices the file from the | |
| 69 handle's position; con-ron's slice is at the offset the reader passes, the reader's own | |
| 70 position). One `&self` escape answers a value, `worker_copies`, inside the code map where the | |
| 71 instance is shared: in the model its answer is the oracle's function of its arguments, so it | |
| 72 claims that two calls with the same arguments at one state agree, which the binary's | |
| 73 (deterministic in its arguments) does; and it can only turn an accept into a failure. | |
| 74 | |
| 75 **Several processes.** `main_modular`, `main_modular_compare` and | |
| 76 `main_modular_compare_no_False` are about several runs of the binary: they assume (1) to (4) of | |
| 77 every run, with one snapshot for all of them, as con-leche's do. | |
| 78 | |
| 79 **The proofs.** Each theorem is a walk of the extracted driver and a conclusion. The walk | |
| 80 (`MainTheorem/Driver.lean`, `CompareJson.lean`, `Oleans.lean`, `Modular.lean`, | |
| 81 `CompareOleans.lean`, `CompareModular.lean`, over the argument parses of `Args.lean`, | |
| 82 `ModArgs.lean` and `CmpArgs.lean`) inverts `run_args` at the theorem's argument list, one | |
| 83 lemma per driver function, down to the calls of the verified stages, and hands them to the | |
| 84 staged lemmas of `MainTheorem/Stages.lean`: one premise per call, Theorem 2 (the Rust refines the | |
| 85 twin), then Theorem 1 (the twin refines con-leche's pure checker). `MainTheorem/Conclusions.lean` | |
| 86 turns the staged conclusions into con-leche's words with con-leche's own soundness theorems: | |
| 87 | |
| 88 | theorem | the walk | the conclusion | | |
| 89 |---|---|---| | |
| 90 | `main_json_model`, `main_no_False` | `json_stages_of_canGive` | `json_model_of_stages`, `json_no_False_of_stages` | | |
| 91 | `main_compare_json_model` | `compare_json_stages_of_canGive` | `compare_json_model_of_stages` | | |
| 92 | `main_oleans` | `oleans_of_canGive` | `oleans_model_of_stages_dec` | | |
| 93 | `main_compare_model` | `compare_of_canGive` | `compare_model_of_stages_dec` | | |
| 94 | `main_modular`, `main_modular_one` | `modular_of_canGive`, `modular_one_of_canGive` | `Stages.model_modular_of` | | |
| 95 | `main_modular_compare`, `main_modular_compare_one`, `main_modular_compare_no_False` | `modular_cmp_facts_of_canGive`, `modular_cmp_one_of_canGive` | `cmp_family`, `cmp_no_False` | | |
| 96 | |
| 97 The proofs use the axioms `propext`, `Classical.choice`, `Quot.sound` and | |
| 98 `PINS_TEXT._native.decide.ax_1`, the one Aeneas spends on the embedded pin text's definition, | |
| 99 and no other (the census at the end of this file). | |
| 100 -/ | |
| == proof/ConRon/MainTheorem.lean#L112-L137 | |
| 112 theorem main_json_model (V : Type w) [ConLeche.SetTheory V] {file : String} {fs : FS} | |
| 113 {b : ByteArray} | |
| 114 (h : ConRon.CanGive ["--", file] fs 0) (hb : fs.file file = some b) : | |
| 115 ∃ r, parseChunks [b] = .ok r ∧ ∃ model, IsModel V model (· ∈ constantsOf r.decls.toList) := | |
| 116 have ⟨h1, h2, hreads, h3, h4, hpins, h5, h6, h7, h8, hcat⟩ := | |
| 117 ConRon.json_stages_of_canGive h.conforming hb | |
| 118 json_model_of_stages V h1 h2 hreads hcat h3 h4 hpins h5 h6 h7 h8 | |
| 119 | |
| 120 /-- con-leche: ConLeche/MainTheorem.lean:51-57 main_no_False — | |
| 121 **No accepted file declares a theorem of type `False`**: no exit 0 of `-- <file>` reads a | |
| 122 `jsonWithTheoremFalse` file. -/ | |
| 123 theorem main_no_False (V : Type w) [ConLeche.SetTheory V] {file : String} {fs : FS} | |
| 124 {b : ByteArray} | |
| 125 (h : ConRon.CanGive ["--", file] fs 0) (hb : fs.file file = some b) | |
| 126 (hF : jsonWithTheoremFalse [b]) : False := | |
| 127 have ⟨h1, h2, hreads, h3, h4, hpins, h5, h6, h7, h8, hcat⟩ := | |
| 128 ConRon.json_stages_of_canGive h.conforming hb | |
| 129 json_no_False_of_stages V hcat hF h1 h2 hreads h3 h4 hpins h5 h6 h7 h8 | |
| 130 | |
| 131 /-- con-leche: ConLeche/MainTheorem.lean:60-67 main_compare_json_model — | |
| 132 **An accepted comparison's challenge file has a model**: an exit 0 of `--compare -- <c> <s>` | |
| 133 read the file `c` as records that have a model in every set theory. -/ | |
| 134 theorem main_compare_json_model (V : Type w) [ConLeche.SetTheory V] {c s : String} {fs : FS} | |
| 135 (h : ConRon.CanGive ["--compare", "--", c, s] fs 0) : | |
| 136 ∃ bC rC, fs.file c = some bC ∧ parseChunks [bC] = .ok rC ∧ | |
| 137 ∃ model, IsModel V model (· ∈ constantsOf rC.decls.toList) := | |
| == proof/ConRon/MainTheorem.lean#L148-L200 | |
| 148 theorem main_oleans (V : Type w) [SetTheory V] {dirs root : String} {r : Name} {fs : FS} | |
| 149 (hr : Olean.parseModName root = some r) | |
| 150 (h : ConRon.CanGive ["--olean", "--search-path=" ++ dirs, "--", root] fs 0) : | |
| 151 ∃ model, IsModel V model (Olean.closureConstants (Driver.searchPathOf dirs) fs #[r]) := | |
| 152 oleans_of_canGive V hr h.conforming | |
| 153 | |
| 154 open ConLeche ConLeche.Frontend in | |
| 155 /-- con-leche: ConLeche/MainTheorem.lean:88-95 main_compare_model — | |
| 156 **An accepted comparison's challenge closure has a model**: every exit 0 of `--olean | |
| 157 --compare --trusted-search-path=<T> --search-path=<D> -- <c> <s>` has a model of the constants | |
| 158 of the challenge's closure, read through the challenge's directories, on every snapshot that | |
| 159 agrees with the run's there. -/ | |
| 160 theorem main_compare_model (V : Type w) [SetTheory V] {T D c s : String} {C S : Name} {fs : FS} | |
| 161 (hc : Olean.parseModName c = some C) (hs : Olean.parseModName s = some S) | |
| 162 (h : ConRon.CanGive ["--olean", "--compare", "--trusted-search-path=" ++ T, | |
| 163 "--search-path=" ++ D, "--", c, s] fs 0) : | |
| 164 ∀ fs', FS.AgreeUnder (Driver.trustedOr (Driver.searchPathOf T) (Driver.searchPathOf D)) fs fs' → | |
| 165 ∃ model, IsModel V model (Olean.closureConstants | |
| 166 (Driver.trustedOr (Driver.searchPathOf T) (Driver.searchPathOf D)) fs' #[C]) := | |
| 167 compare_of_canGive V hc hs h.conforming | |
| 168 | |
| 169 open ConLeche ConLeche.Frontend in | |
| 170 /-- con-leche: ConLeche/MainTheorem.lean:109-122 main_modular — | |
| 171 **An accepted modular check has a family of models**: on a snapshot where `--check-graph | |
| 172 --search-path=<dirs> -- <root>` exits 0 and every module of the headers' closure of `root` has | |
| 173 an exit 0 of `--olean --module`, every module of the closure has a model of its constants, and | |
| 174 the models agree on what the modules see of each other. -/ | |
| 175 theorem main_modular (V : Type w) [SetTheory V] {dirs root : String} {r : Name} {fs : FS} | |
| 176 (hr : Olean.parseModName root = some r) | |
| 177 (h : ConRon.CanGive ["--check-graph", "--search-path=" ++ dirs, "--", root] fs 0) | |
| 178 (hwork : ∀ m', Olean.HdrClosure (Driver.searchPathOf dirs) fs [r] m' → ∃ root', | |
| 179 Olean.parseModName root' = some m' ∧ | |
| 180 ConRon.CanGive ["--olean", "--module", "--search-path=" ++ dirs, "--", root'] fs 0) : | |
| 181 ∃ model : Name → (Name → List Nat → V), | |
| 182 (∀ m, Olean.InClosure (Driver.searchPathOf dirs) fs #[r] m → | |
| 183 IsModel V (model m) (Olean.moduleConstants (Driver.searchPathOf dirs) fs m)) ∧ | |
| 184 (∀ m n m', Olean.InClosure (Driver.searchPathOf dirs) fs #[r] m → | |
| 185 Olean.Sees (Driver.searchPathOf dirs) fs m n m' → model m n = model m' n) := | |
| 186 modular_of_canGive V hr h.conforming | |
| 187 fun m hm => (hwork m hm).imp fun _ h => ⟨h.1, h.2.conforming⟩ | |
| 188 | |
| 189 open ConLeche ConLeche.Frontend in | |
| 190 /-- con-leche: ConLeche/MainTheorem.lean:126-135 main_modular_one — | |
| 191 **The same, in one process**: every exit 0 of `--olean --modular --search-path=<dirs> | |
| 192 -- <root>` has the family of models of `main_modular`. -/ | |
| 193 theorem main_modular_one (V : Type w) [SetTheory V] {dirs root : String} {r : Name} {fs : FS} | |
| 194 (hr : Olean.parseModName root = some r) | |
| 195 (h : ConRon.CanGive ["--olean", "--modular", "--search-path=" ++ dirs, "--", root] fs 0) : | |
| 196 ∃ model : Name → (Name → List Nat → V), | |
| 197 (∀ m, Olean.InClosure (Driver.searchPathOf dirs) fs #[r] m → | |
| 198 IsModel V (model m) (Olean.moduleConstants (Driver.searchPathOf dirs) fs m)) ∧ | |
| 199 (∀ m n m', Olean.InClosure (Driver.searchPathOf dirs) fs #[r] m → | |
| 200 Olean.Sees (Driver.searchPathOf dirs) fs m n m' → model m n = model m' n) := | |
| == proof/ConRon/MainTheorem.lean#L210-L270 | |
| 210 theorem main_modular_compare (V : Type w) [SetTheory V] {T D c s : String} {C S : Name} | |
| 211 {fs : FS} (hc : Olean.parseModName c = some C) (hs : Olean.parseModName s = some S) | |
| 212 (hgraph : ConRon.CanGive ["--check-graph", "--compare", | |
| 213 "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", c, s] fs 0) | |
| 214 (hwork : ∀ m, Olean.HdrClosure | |
| 215 (⟨C, S, Driver.searchPathOf T, Driver.searchPathOf D, none⟩ : Driver.CmpReq).solRoots fs | |
| 216 [C, S] m → m ≠ C → | |
| 217 ∃ root', Olean.parseModName root' = some m ∧ ConRon.CanGive | |
| 218 ["--olean", "--module", "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", | |
| 219 root'] fs 0) | |
| 220 (hcmp : ConRon.CanGive ["--olean", "--module", "--compare", | |
| 221 "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", c, s] fs 0) : | |
| 222 let sp := Driver.trustedOr (Driver.searchPathOf T) (Driver.searchPathOf D) | |
| 223 ∀ fs', FS.AgreeUnder sp fs fs' → | |
| 224 ∃ model : Name → (Name → List Nat → V), | |
| 225 (∀ m, Olean.InClosure sp fs' #[C] m → IsModel V (model m) (Olean.moduleConstants sp fs' m)) ∧ | |
| 226 (∀ m n m', Olean.InClosure sp fs' #[C] m → Olean.Sees sp fs' m n m' → | |
| 227 model m n = model m' n) := | |
| 228 have ⟨_, _, good, hC, edges, inj, hhdr, acc⟩ := | |
| 229 modular_cmp_facts_of_canGive hc hs hgraph.conforming | |
| 230 (fun m hm hne => (hwork m hm hne).imp fun _ h => ⟨h.1, h.2.conforming⟩) hcmp.conforming | |
| 231 cmp_family V good hC edges inj hhdr acc | |
| 232 | |
| 233 open ConLeche ConLeche.Frontend in | |
| 234 /-- con-leche: ConLeche/MainTheorem.lean:166-176 main_modular_compare_one — | |
| 235 **The same, in one process**: every exit 0 of `--olean --modular --compare` has the family | |
| 236 of `main_modular_compare`. -/ | |
| 237 theorem main_modular_compare_one (V : Type w) [SetTheory V] {T D c s : String} {C S : Name} | |
| 238 {fs : FS} (hc : Olean.parseModName c = some C) (hs : Olean.parseModName s = some S) | |
| 239 (h : ConRon.CanGive ["--olean", "--modular", "--compare", | |
| 240 "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", c, s] fs 0) : | |
| 241 let sp := Driver.trustedOr (Driver.searchPathOf T) (Driver.searchPathOf D) | |
| 242 ∀ fs', FS.AgreeUnder sp fs fs' → | |
| 243 ∃ model : Name → (Name → List Nat → V), | |
| 244 (∀ m, Olean.InClosure sp fs' #[C] m → IsModel V (model m) (Olean.moduleConstants sp fs' m)) ∧ | |
| 245 (∀ m n m', Olean.InClosure sp fs' #[C] m → Olean.Sees sp fs' m n m' → | |
| 246 model m n = model m' n) := | |
| 247 modular_cmp_one_of_canGive V hc hs h.conforming | |
| 248 | |
| 249 open ConLeche ConLeche.Frontend in | |
| 250 /-- con-leche: ConLeche/MainTheorem.lean:183-199 main_modular_compare_no_False — | |
| 251 **No accepted modular comparison's challenge module holds a constant of type `False`**: no | |
| 252 snapshot where every command of `main_modular_compare` exits 0 has a constant of type `False` in | |
| 253 the challenge module `C`, read through the challenge's directories. This covers what `C` sees | |
| 254 through its solution too, which the family of `main_modular_compare` does not. -/ | |
| 255 theorem main_modular_compare_no_False (V : Type w) [SetTheory V] {T D c s : String} | |
| 256 {C S : Name} {fs : FS} {ci : ConstantInfo} | |
| 257 (hc : Olean.parseModName c = some C) (hs : Olean.parseModName s = some S) | |
| 258 (hgraph : ConRon.CanGive ["--check-graph", "--compare", | |
| 259 "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", c, s] fs 0) | |
| 260 (hwork : ∀ m, Olean.HdrClosure | |
| 261 (⟨C, S, Driver.searchPathOf T, Driver.searchPathOf D, none⟩ : Driver.CmpReq).solRoots fs | |
| 262 [C, S] m → m ≠ C → | |
| 263 ∃ root', Olean.parseModName root' = some m ∧ ConRon.CanGive | |
| 264 ["--olean", "--module", "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", | |
| 265 root'] fs 0) | |
| 266 (hcmp : ConRon.CanGive ["--olean", "--module", "--compare", | |
| 267 "--trusted-search-path=" ++ T, "--search-path=" ++ D, "--", c, s] fs 0) | |
| 268 (hci : Olean.InModulePart (Driver.trustedOr (Driver.searchPathOf T) (Driver.searchPathOf D)) | |
| 269 fs C .private ci) | |
| 270 (hty : ci.type = .const falseName []) : False := | |
| == proof/ConRon/MainTheorem/Model.lean#L417-L420 | |
| 417 def CanGive (args : List String) (fs : ConLeche.FS) (c : UInt8) : Prop := | |
| 418 ∃ (argv : alloc.vec.Vec (alloc.vec.Vec Std.U32)) (o o' : Model.Tape) (c' : Std.U8), | |
| 419 ArgvOf argv args ∧ driver.cli.run_args (Model.snapshotIo fs) o argv = ok (c', o') ∧ | |
| 420 c'.val = c.toNat | |
| == proof/ConRon/MainTheorem/Stages.lean#L25-L95 | |
| 25 /-! | |
| 26 # `ConRon.MainTheorem.Stages` — the staged lemmas: Theorem 2 ∘ Theorem 1 ∘ con-leche | |
| 27 | |
| 28 The main theorems (`ConRon/MainTheorem.lean`) are proved from these lemmas. Each states, for | |
| 29 one mode of the binary, what follows from the verified calls the driver makes in that mode: | |
| 30 one premise per call, in the driver's order, each starting from the state the previous one | |
| 31 left and the first from the binary's own start values. The driver walks of | |
| 32 `MainTheorem/*.lean` take an exit 0 of the extracted driver `run_args` to exactly these | |
| 33 premises, and `MainTheorem/Conclusions.lean` turns the conclusions here into con-leche's words. | |
| 34 This is the one module that imports both `ConRon.Bridge` (Theorem 1, (B) ⇒ (A)) and | |
| 35 `ConRon.Refine2` (Theorem 2, (C) ⇒ (B)): | |
| 36 | |
| 37 * `model_exists` / `no_False_declaration` — a lean4export file (`driver::check_main`); | |
| 38 * `no_False_oleans` / `model_exists_oleans` — the same on `--olean` (`check_main::check_oleans`); | |
| 39 * `model_exists_compare` / `no_False_compare` and `model_exists_oleans_compare` / | |
| 40 `no_False_oleans_compare` — a challenge checked with its axioms justified by a solution | |
| 41 (`driver::compare_json`, `driver::compare`; §4b and §4c), about the challenge alone; | |
| 42 * `model_modular` and its compared forms — the graph check and a module's worker | |
| 43 (`driver::graph`, `driver::worker`, `driver::modular`, `driver::compare_module`). | |
| 44 | |
| 45 The calls are marked `// ConRon.MainTheorem.Stages: <premise>` in the driver's Rust. | |
| 46 | |
| 47 ## The pipeline, stage by stage | |
| 48 | |
| 49 On a lean4export file the driver (`crates/con-ron-core/src/driver/check_main.rs`) calls, in | |
| 50 this order, on one `AState` made from `AState::empty()` and one `PersTier::empty()`: | |
| 51 | |
| 52 intern_reserved_pins → builtin_prelude_e → parse_source (FileChunks) | |
| 53 → prepare_d → decode_embedded → intern_all_pins → (the check phase) | |
| 54 | |
| 55 **The check phase** (`check_main::check_phase`) builds the stream's index from the records | |
| 56 (`stream_index::build_index`), freezes the tier with the index in it (`checker::freeze_tier`), | |
| 57 runs every record's job on the instance's worker map, and thaws the tier. The lemmas take one | |
| 58 premise per step (`h6` the index, `h7` the freeze, `h8` the map), which `poolAccepts_intro` | |
| 59 assembles into `Refine2/Checker/Phased.lean`'s `PoolAccepts`. `h8` is the worker map's | |
| 60 contract (`PoolSound`) at the driver's step (`ParallelAll` at `jobStep`): index lists, one per | |
| 61 worker, covering every job, each in increasing order, and for each a fold of `run_job` over its | |
| 62 indices from `worker_state`, accepting. | |
| 63 | |
| 64 The proof: | |
| 65 | |
| 66 1. **Theorem 2, per stage** — `Refine2`'s `…_refines` lemmas walk the Rust runs | |
| 67 into twin runs from the twin's own start state `AState.init EStore.empty`, | |
| 68 related at every step (`AStateRel₀`/`AStateInv`: lockstep); `rust_stages`; | |
| 69 2. **Theorem 1** — `Bridge/Stages.lean` takes the twin runs: | |
| 70 `Arena.pooledAccepts_bridge` makes the check phase's accept con-leche's pure | |
| 71 fold `checkDeclsPure` accepting the denoted stream at `streamEnv` of it; | |
| 72 3. **con-leche** — `checkDeclsPure_sound_of` turns the pure accept into a model, | |
| 73 and `no_proof_of_False_pure` refutes a `False` theorem in the stream. | |
| 74 | |
| 75 ## The named hypotheses | |
| 76 | |
| 77 The lemmas start from the binary's own start values (`startState` = | |
| 78 `AState::empty()`, `emptyTier` = `PersTier::empty()`) and name the call the | |
| 79 driver makes at each step. Beside `[ConLeche.SetTheory V]`, the file's shape | |
| 80 `hfalse` and the one premise per call (`h1`…`h5`, `hpins`, `h6`…`h8`), what | |
| 81 they assume is exactly: | |
| 82 | |
| 83 * `hreads : ReadsAs sinst src chunks.val` — the reads are the chunks: the driver | |
| 84 parses with the verified reader loop `parse_source` over `FileChunks`, and | |
| 85 `Refine2/Frontend/Source.lean`'s `parse_source_eq` makes that `parse_chunks` over | |
| 86 the chunks the reads hand out; the walk proves the reads are the file's bytes in | |
| 87 the snapshot (`fileChunks_loop`); | |
| 88 * on `--olean`, `hsnap : SnapshotOf finst fsv F` — the file instance answers as | |
| 89 one snapshot `F`. | |
| 90 | |
| 91 `hpins` is the premise for the binary's pin step: the pin list is what the verified | |
| 92 decoder read, at any text (as con-leche's theorems hold at every pin list); | |
| 93 `model_exists_embedded` / `no_False_declaration_embedded` fix the text to the embedded | |
| 94 `PINS_TEXT`. | |
| 95 -/ | |
| == proof/ConRon/MainTheorem/Stages.lean#L628-L654 | |
| 628 theorem no_False_declaration (V : Type w) [ConLeche.SetTheory V] | |
| 629 {chunks : alloc.vec.Vec (alloc.vec.Vec Std.U8)} | |
| 630 (hfalse : ConLeche.jsonWithTheoremFalse (absChunks chunks)) | |
| 631 {st1 st2 st3 st4 st5 st6 : arena.monad.AState} | |
| 632 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 633 {pre : frontend.prepare.PreludeIx} | |
| 634 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 635 {Sc : Type} {sinst : frontend.export_c.ChunkSource Sc} {src src' : Sc} | |
| 636 (hreads : ReadsAs sinst src chunks.val) | |
| 637 {r : frontend.export_c.ParseResultD} | |
| 638 (h3 : frontend.export_c.parse_source sinst emptyTier st2 src = ok (.Ok r, st3, src')) | |
| 639 {prepared : frontend.prepare.Prepared} | |
| 640 (h4 : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st3 pre r.decls () = ok (.Ok prepared, st4)) | |
| 641 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 642 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 643 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 644 {maxNatSize : ron.nat.Nat} | |
| 645 (h5 : arena.checker.intern_all_pins emptyTier st4 pins maxNatSize = ok (.Ok ipins, st5)) | |
| 646 {ix : arena.stream_index.IStreamIndex} | |
| 647 (h6 : (do | |
| 648 let e ← arena.stream_index.stream_index_empty | |
| 649 arena.stream_index.build_index emptyTier st5 e prepared.decls 0#usize) = ok (.Ok ix, st6)) | |
| 650 {tier : arena.store.PersTier} {frozen : arena.store.EStore} | |
| 651 (h7 : arena.checker.freeze_tier st6.store ix = ok (tier, frozen)) | |
| 652 (h8 : ParallelAll prepared.decls.length (arena.checker.worker_state st6.pins) | |
| 653 (jobStep tier .Verified ipins prepared.decls)) : | |
| 654 False := by | |
| == crates/con-ron-core/src/driver/check_main.rs#L451-L525 | |
| 451 pub fn check_main<I: CheckerIo>(io: &mut I, a: &Args, file: &Vec<u32>) -> u8 { | |
| 452 let verified = a.verified; | |
| 453 let mode = if verified { CheckMode::Verified } else { CheckMode::Trusted }; | |
| 454 let mut st = AState::empty(); | |
| 455 let pers = PersTier::empty(); | |
| 456 // ConRon.MainTheorem.Stages: h1 | |
| 457 match pins::intern_reserved_pins(&pers, &mut st) { | |
| 458 Err(e) => { | |
| 459 io.note(&Note::ReservedPins(e, verified)); | |
| 460 return 3; | |
| 461 } | |
| 462 Ok(()) => (), | |
| 463 } | |
| 464 io.read_starts(&a.progress, file); | |
| 465 // ConRon.MainTheorem.Stages: h2 | |
| 466 let prelude_ix = match prelude::builtin_prelude_e(&pers, &mut st) { | |
| 467 Err((e, line)) => { | |
| 468 io.note(&Note::Prelude(e, line, verified)); | |
| 469 return 3; | |
| 470 } | |
| 471 Ok(p) => p, | |
| 472 }; | |
| 473 // ConRon.MainTheorem.Stages: hreads, h3 | |
| 474 let (read, err) = { | |
| 475 let mut src = FileChunks { fs: &*io, path: file, off: 0, reads: 0, err: None }; | |
| 476 let read = export_c::parse_source(&pers, &mut st, &mut src); | |
| 477 (read, src.err) | |
| 478 }; | |
| 479 match err { | |
| 480 Some(m) => { | |
| 481 io.note(&Note::ReadFailed(str_copy(file), m)); | |
| 482 return 3; | |
| 483 } | |
| 484 None => (), | |
| 485 } | |
| 486 let parsed = match read { | |
| 487 Err((e, line)) => { | |
| 488 let c = exit_code(&e); | |
| 489 io.note(&Note::Parse(e, line, str_copy(file), verified)); | |
| 490 return c; | |
| 491 } | |
| 492 Ok(p) => p, | |
| 493 }; | |
| 494 let file_records = parsed.decls.len(); | |
| 495 // ConRon.MainTheorem.Stages: h4 | |
| 496 let prepared = match prepare::prepare_d(&pers, &mut st, prelude_ix, parsed.decls, &DeclUsedConsts) { | |
| 497 Err(e) => { | |
| 498 let c = exit_code(&e); | |
| 499 io.note(&Note::Frontend(e, verified)); | |
| 500 return c; | |
| 501 } | |
| 502 Ok(p) => p, | |
| 503 }; | |
| 504 if prepared.hoisted.len() > 0 { | |
| 505 io.hoisted(&pers, &st.store, &prepared.hoisted); | |
| 506 } | |
| 507 // ConRon.MainTheorem.Stages: hpins | |
| 508 let pins: Vec<NatOpPinSet> = match embedded_pins(&*io) { | |
| 509 None => return 3, | |
| 510 Some(ps) => ps, | |
| 511 }; | |
| 512 // ConRon.MainTheorem.Stages: h5 | |
| 513 let ipins = match checker::intern_all_pins(&pers, &mut st, &pins, &a.max_nat_size) { | |
| 514 Err(e) => { | |
| 515 let c = exit_code(&e); | |
| 516 io.note(&Note::Frontend(e, verified)); | |
| 517 return c; | |
| 518 } | |
| 519 Ok(p) => p, | |
| 520 }; | |
| 521 let jobs: u64 = jobs_for_run(io, a); | |
| 522 // ConRon.MainTheorem.Stages: h6, h7, h8 | |
| 523 let verdict = check_phase(io, &pers, &mut st, &mode, &ipins, None, &prepared.decls, jobs, file_records, prepared.synthesised); | |
| 524 verdict_of(io, &pers, st, prepared.decls, verdict, file_records, verified) | |
| 525 } | |
| == proof/ConRon/MainTheorem/Stages.lean#L580-L605 | |
| 580 theorem model_exists (V : Type w) [ConLeche.SetTheory V] | |
| 581 {st1 st2 st3 st4 st5 st6 : arena.monad.AState} | |
| 582 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 583 {pre : frontend.prepare.PreludeIx} | |
| 584 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 585 {Sc : Type} {sinst : frontend.export_c.ChunkSource Sc} {src src' : Sc} | |
| 586 {chunks : alloc.vec.Vec (alloc.vec.Vec Std.U8)} | |
| 587 (hreads : ReadsAs sinst src chunks.val) | |
| 588 {r : frontend.export_c.ParseResultD} | |
| 589 (h3 : frontend.export_c.parse_source sinst emptyTier st2 src = ok (.Ok r, st3, src')) | |
| 590 {prepared : frontend.prepare.Prepared} | |
| 591 (h4 : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st3 pre r.decls () = ok (.Ok prepared, st4)) | |
| 592 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 593 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 594 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 595 {maxNatSize : ron.nat.Nat} | |
| 596 (h5 : arena.checker.intern_all_pins emptyTier st4 pins maxNatSize = ok (.Ok ipins, st5)) | |
| 597 {ix : arena.stream_index.IStreamIndex} | |
| 598 (h6 : (do | |
| 599 let e ← arena.stream_index.stream_index_empty | |
| 600 arena.stream_index.build_index emptyTier st5 e prepared.decls 0#usize) = ok (.Ok ix, st6)) | |
| 601 {tier : arena.store.PersTier} {frozen : arena.store.EStore} | |
| 602 (h7 : arena.checker.freeze_tier st6.store ix = ok (tier, frozen)) | |
| 603 (h8 : ParallelAll prepared.decls.length (arena.checker.worker_state st6.pins) | |
| 604 (jobStep tier .Verified ipins prepared.decls)) : | |
| 605 ∃ env, RustDenotes prepared.decls st6 env ∧ Nonempty (ConLeche.Model V env) := by | |
| == proof/ConRon/MainTheorem/Stages.lean#L473-L477 | |
| 473 def RustDenotes (ds : alloc.vec.Vec arena.env.IDeclaration) (st : arena.monad.AState) | |
| 474 (env : ConLeche.Env) : Prop := | |
| 475 ∃ (lst : ConRon.Arena.AState) (dsP : List ConLeche.Declaration), | |
| 476 AStateRel emptyTier st lst ∧ ConRon.Bridge.denoteDecls lst.store (absIDeclL ds) = some dsP ∧ | |
| 477 env = ConLeche.streamEnv dsP | |
| == crates/con-ron/src/std_io.rs#L1-L12 | |
| 1 //! `std_io` — the binary's instance of the core's `CheckerIo` (DESIGN.md §3.9, | |
| 2 //! task #171): the file reads, the worker map, the escapes, and the rendering | |
| 3 //! of every event the verified driver (`con_ron_core::driver`) hands it, in the | |
| 4 //! binary's words. All of it is outside the theorems, which are about the | |
| 5 //! model instance (`proof/ConRon/MainTheorem/Model.lean`); what they assume of | |
| 6 //! a run of this one is OVERVIEW §3.1: the file operations it performs answer | |
| 7 //! as one snapshot (each path opened once, `olean_fs::RunFiles`), its maps' runs | |
| 8 //! are an oracle's, its escapes write no file and do not end the process. | |
| 9 //! | |
| 10 //! The text of a usage error, of a help or a synopsis are the binary's | |
| 11 //! (`bin/con-ron.rs`), handed in as `StdIoHooks`; the scheduler is | |
| 12 //! `crate::modular::schedule`. | |
| == crates/con-ron/src/bin/con-ron.rs#L206-L243 | |
| 206 fn main() -> ! { | |
| 207 let mut argv: Vec<String> = Vec::new(); | |
| 208 for a in std::env::args_os().skip(1) { | |
| 209 match a.into_string() { | |
| 210 Ok(s) => argv.push(s), | |
| 211 Err(_) => { | |
| 212 eprintln!("con-ron: an argument is not valid UTF-8"); | |
| 213 exit_after_verdict(3) | |
| 214 } | |
| 215 } | |
| 216 } | |
| 217 let h = std::thread::Builder::new() | |
| 218 .stack_size(driver::stack_bytes()) | |
| 219 .spawn(move || -> u8 { | |
| 220 let cps: Vec<Vec<u32>> = argv.iter().map(|a| con_ron::render::cps(a)).collect(); | |
| 221 let mut io = con_ron::std_io::StdIo::new(con_ron::std_io::StdIoHooks { | |
| 222 help: print_help, | |
| 223 synopsis: print_synopsis, | |
| 224 usage: usage_error, | |
| 225 }); | |
| 226 let code = con_ron_core::driver::cli::run_args(&mut io, &cps); | |
| 227 // the instance (and what it kept) is never dropped: con-leche task #336 | |
| 228 exit_after_verdict(code) | |
| 229 }); | |
| 230 match h { | |
| 231 Err(e) => { | |
| 232 eprintln!("con-ron: cannot spawn the checking thread: {}", e); | |
| 233 exit_after_verdict(3) | |
| 234 } | |
| 235 Ok(h) => match h.join() { | |
| 236 Ok(code) => exit_after_verdict(code), | |
| 237 Err(_) => { | |
| 238 eprintln!("con-ron: the checking thread died"); | |
| 239 exit_after_verdict(3) | |
| 240 } | |
| 241 }, | |
| 242 } | |
| 243 } | |
| == proof/ConRon/MainTheorem/Stages.lean#L846-L883 | |
| 846 theorem no_False_oleans (V : Type w) [ConLeche.SetTheory V] {F : ConLeche.FS} | |
| 847 {m : ConLeche.Name} {d : ConLeche.Frontend.Olean.ModDecoded} | |
| 848 {c : ConLeche.Frontend.Olean.CEntryF ConLeche.Name ConLeche.Expr} {v : ConLeche.Expr} | |
| 849 {all : List ConLeche.Name} | |
| 850 {names : List kernel.name.Name} {dirs : alloc.vec.Vec (alloc.vec.Vec Std.U32)} | |
| 851 (hcl : ConLeche.Frontend.Olean.InClosure (ConRon.Refine2.Frontend.Olean.absSearchPath dirs) F | |
| 852 (names.map ConRon.Refine.absName).toArray m) | |
| 853 (hv : ConLeche.Frontend.Olean.ViewOf (ConRon.Refine2.Frontend.Olean.absSearchPath dirs) F m d) | |
| 854 (hmem : c ∈ d.constants) (hk : c.kind = .thm v all) | |
| 855 (hty : c.type = .const ConLeche.falseName []) | |
| 856 {st1 st2 stR st4 st5 st6 : arena.monad.AState} | |
| 857 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 858 {pre : frontend.prepare.PreludeIx} | |
| 859 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 860 {roots : alloc.vec.Vec arena.handle.NIdx} | |
| 861 (hroots : InternRoots emptyTier st2 names roots.val stR) | |
| 862 {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} {fsv : Fs} | |
| 863 (hsnap : SnapshotOf finst fsv F) | |
| 864 {rd : frontend.olean.records.OleanRead} {store3 : arena.store.EStore} | |
| 865 (h3 : frontend.olean.records.read_oleans finst fsv emptyTier stR.store ⟨dirs, alloc.vec.Vec.new _⟩ roots none false false | |
| 866 = ok (.Ok rd, store3)) | |
| 867 {prepared : frontend.prepare.Prepared} | |
| 868 (h4 : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { stR with store := store3 } pre rd.decls rd | |
| 869 = ok (.Ok prepared, st4)) | |
| 870 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 871 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 872 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 873 {maxNatSize : ron.nat.Nat} | |
| 874 (h5 : arena.checker.intern_all_pins emptyTier st4 pins maxNatSize = ok (.Ok ipins, st5)) | |
| 875 {ix : arena.stream_index.IStreamIndex} | |
| 876 (h6 : (do | |
| 877 let e ← arena.stream_index.stream_index_empty | |
| 878 arena.stream_index.build_index emptyTier st5 e prepared.decls 0#usize) = ok (.Ok ix, st6)) | |
| 879 {tier : arena.store.PersTier} {frozen : arena.store.EStore} | |
| 880 (h7 : arena.checker.freeze_tier st6.store ix = ok (tier, frozen)) | |
| 881 (h8 : ParallelAll prepared.decls.length (oleanWorkerInit st6.pins) | |
| 882 (oleanJobStep finst fsv tier .Verified ipins prepared.decls rd.pins rd.values ⟨dirs, alloc.vec.Vec.new _⟩)) : | |
| 883 False := | |
| == proof/ConRon/MainTheorem/Stages.lean#L892-L921 | |
| 892 theorem model_exists_oleans (V : Type w) [ConLeche.SetTheory V] {F : ConLeche.FS} | |
| 893 {names : List kernel.name.Name} {dirs : alloc.vec.Vec (alloc.vec.Vec Std.U32)} | |
| 894 {st1 st2 stR st4 st5 st6 : arena.monad.AState} | |
| 895 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 896 {pre : frontend.prepare.PreludeIx} | |
| 897 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 898 {roots : alloc.vec.Vec arena.handle.NIdx} | |
| 899 (hroots : InternRoots emptyTier st2 names roots.val stR) | |
| 900 {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} {fsv : Fs} | |
| 901 (hsnap : SnapshotOf finst fsv F) | |
| 902 {rd : frontend.olean.records.OleanRead} {store3 : arena.store.EStore} | |
| 903 (h3 : frontend.olean.records.read_oleans finst fsv emptyTier stR.store ⟨dirs, alloc.vec.Vec.new _⟩ roots none false false | |
| 904 = ok (.Ok rd, store3)) | |
| 905 {prepared : frontend.prepare.Prepared} | |
| 906 (h4 : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { stR with store := store3 } pre rd.decls rd | |
| 907 = ok (.Ok prepared, st4)) | |
| 908 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 909 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 910 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 911 {maxNatSize : ron.nat.Nat} | |
| 912 (h5 : arena.checker.intern_all_pins emptyTier st4 pins maxNatSize = ok (.Ok ipins, st5)) | |
| 913 {ix : arena.stream_index.IStreamIndex} | |
| 914 (h6 : (do | |
| 915 let e ← arena.stream_index.stream_index_empty | |
| 916 arena.stream_index.build_index emptyTier st5 e prepared.decls 0#usize) = ok (.Ok ix, st6)) | |
| 917 {tier : arena.store.PersTier} {frozen : arena.store.EStore} | |
| 918 (h7 : arena.checker.freeze_tier st6.store ix = ok (tier, frozen)) | |
| 919 (h8 : ParallelAll prepared.decls.length (oleanWorkerInit st6.pins) | |
| 920 (oleanJobStep finst fsv tier .Verified ipins prepared.decls rd.pins rd.values ⟨dirs, alloc.vec.Vec.new _⟩)) : | |
| 921 ∃ env, RustDenotesFilled prepared.decls st6 env ∧ Nonempty (ConLeche.Model V env) := | |
| == proof/ConRon/MainTheorem/Stages.lean#L196-L209 | |
| 196 structure SnapshotOf {Fs : Type} (inst : frontend.checker_io.CheckerFs Fs) (fsv : Fs) | |
| 197 (F : ConLeche.FS) : Prop where | |
| 198 path_exists : ∀ {p q}, PathRel p q → ∀ b, inst.path_exists fsv p = ok (.Ok b) → | |
| 199 b = (F.real q).isSome | |
| 200 is_dir : ∀ {p q}, PathRel p q → ∀ b, inst.is_dir fsv p = ok (.Ok b) → b = F.dir q | |
| 201 real_path : ∀ {p q}, PathRel p q → ∀ r, inst.real_path fsv p = ok (.Ok r) → | |
| 202 F.real q = some ⟨ConRon.Refine.absString r⟩ ∧ ConRon.Refine.StrWF r | |
| 203 read_bin_file : ∀ {p q}, PathRel p q → ∀ b, inst.read_bin_file fsv p = ok (.Ok b) → | |
| 204 F.file q = some (absBytes (alloc.vec.Vec.deref b)) | |
| 205 read_range : ∀ {p q}, PathRel p q → ∀ off len b, inst.read_range fsv p off len = ok (.Ok b) → | |
| 206 ∃ whole, F.file q = some whole ∧ absBytes (alloc.vec.Vec.deref b) = | |
| 207 whole.extract off.val (min (off.val + len.val) whole.size) | |
| 208 file_size : ∀ {p q}, PathRel p q → ∀ s, inst.file_size fsv p = ok (.Ok s) → | |
| 209 ∃ whole, F.file q = some whole ∧ s.val = whole.size | |
| == proof/ConRon/MainTheorem/Stages.lean#L1215-L1258 | |
| 1215 theorem model_exists_compare (V : Type w) [ConLeche.SetTheory V] | |
| 1216 {st1 st2 st3 st4 st5 st6 st7 st9 st10 st11 : arena.monad.AState} | |
| 1217 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 1218 {pre : frontend.prepare.PreludeIx} | |
| 1219 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 1220 {Sc : Type} {sinst : frontend.export_c.ChunkSource Sc} {srcC srcC' srcS srcS' : Sc} | |
| 1221 {chunksC chunksS : alloc.vec.Vec (alloc.vec.Vec Std.U8)} | |
| 1222 (hreadsC : ReadsAs sinst srcC chunksC.val) (hreadsS : ReadsAs sinst srcS chunksS.val) | |
| 1223 {rC rS : frontend.export_c.ParseResultD} | |
| 1224 (h3 : frontend.export_c.parse_source sinst emptyTier st2 srcC = ok (.Ok rC, st3, srcC')) | |
| 1225 (h3S : frontend.export_c.parse_source sinst emptyTier st3 srcS = ok (.Ok rS, st4, srcS')) | |
| 1226 {preC : frontend.prepare.PreludeIx} | |
| 1227 (hdup : frontend.prepare.prelude_ix_dup pre = ok preC) | |
| 1228 {prepS : frontend.prepare.Prepared} | |
| 1229 (h4S : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st4 pre rS.decls () = ok (.Ok prepS, st5)) | |
| 1230 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 1231 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 1232 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 1233 {maxNatSize : ron.nat.Nat} | |
| 1234 (h5 : arena.checker.intern_all_pins emptyTier st5 pins maxNatSize = ok (.Ok ipins, st6)) | |
| 1235 {ixS : arena.stream_index.IStreamIndex} | |
| 1236 (h6S : (do | |
| 1237 let e ← arena.stream_index.stream_index_empty | |
| 1238 arena.stream_index.build_index emptyTier st6 e prepS.decls 0#usize) = ok (.Ok ixS, st7)) | |
| 1239 {tierS : arena.store.PersTier} {frozenS : arena.store.EStore} | |
| 1240 (h7S : arena.checker.freeze_tier st7.store ixS = ok (tierS, frozenS)) | |
| 1241 (h8S : ParallelAll prepS.decls.length (arena.checker.worker_state st7.pins) | |
| 1242 (jobStep tierS .Verified ipins prepS.decls)) | |
| 1243 {prepC : frontend.prepare.Prepared} | |
| 1244 (h4 : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st7 preC rC.decls () = ok (.Ok prepC, st9)) | |
| 1245 {recsC : alloc.vec.Vec arena.env.IDeclaration} | |
| 1246 (hside : arena.justify.side_records emptyTier st9 prepC.decls 0#usize (alloc.vec.Vec.new _) = | |
| 1247 ok (.Ok recsC, st10)) | |
| 1248 {sol : arena.justify.Solution} | |
| 1249 (hsol : arena.justify.solution_of ixS recsC = ok sol) | |
| 1250 {ixC : arena.stream_index.IStreamIndex} | |
| 1251 (h6 : (do | |
| 1252 let e ← arena.stream_index.stream_index_empty | |
| 1253 arena.stream_index.build_index emptyTier st10 e recsC 0#usize) = ok (.Ok ixC, st11)) | |
| 1254 {tierC : arena.store.PersTier} {frozenC : arena.store.EStore} | |
| 1255 (h7 : arena.checker.freeze_tier st11.store ixC = ok (tierC, frozenC)) | |
| 1256 (h8 : ParallelAll recsC.length (arena.checker.worker_state st11.pins) | |
| 1257 (jobStepSol tierC .Verified ipins (some sol) recsC)) : | |
| 1258 ∃ env, RustDenotes recsC st10 env ∧ Nonempty (ConLeche.Model V env) := by | |
| == proof/ConRon/MainTheorem/Stages.lean#L1281-L1325 | |
| 1281 theorem no_False_compare (V : Type w) [ConLeche.SetTheory V] | |
| 1282 {chunksC chunksS : alloc.vec.Vec (alloc.vec.Vec Std.U8)} | |
| 1283 (hfalse : ConLeche.jsonWithTheoremFalse (absChunks chunksC)) | |
| 1284 {st1 st2 st3 st4 st5 st6 st7 st9 st10 st11 : arena.monad.AState} | |
| 1285 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 1286 {pre : frontend.prepare.PreludeIx} | |
| 1287 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 1288 {Sc : Type} {sinst : frontend.export_c.ChunkSource Sc} {srcC srcC' srcS srcS' : Sc} | |
| 1289 (hreadsC : ReadsAs sinst srcC chunksC.val) (hreadsS : ReadsAs sinst srcS chunksS.val) | |
| 1290 {rC rS : frontend.export_c.ParseResultD} | |
| 1291 (h3 : frontend.export_c.parse_source sinst emptyTier st2 srcC = ok (.Ok rC, st3, srcC')) | |
| 1292 (h3S : frontend.export_c.parse_source sinst emptyTier st3 srcS = ok (.Ok rS, st4, srcS')) | |
| 1293 {preC : frontend.prepare.PreludeIx} | |
| 1294 (hdup : frontend.prepare.prelude_ix_dup pre = ok preC) | |
| 1295 {prepS : frontend.prepare.Prepared} | |
| 1296 (h4S : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st4 pre rS.decls () = ok (.Ok prepS, st5)) | |
| 1297 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 1298 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 1299 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 1300 {maxNatSize : ron.nat.Nat} | |
| 1301 (h5 : arena.checker.intern_all_pins emptyTier st5 pins maxNatSize = ok (.Ok ipins, st6)) | |
| 1302 {ixS : arena.stream_index.IStreamIndex} | |
| 1303 (h6S : (do | |
| 1304 let e ← arena.stream_index.stream_index_empty | |
| 1305 arena.stream_index.build_index emptyTier st6 e prepS.decls 0#usize) = ok (.Ok ixS, st7)) | |
| 1306 {tierS : arena.store.PersTier} {frozenS : arena.store.EStore} | |
| 1307 (h7S : arena.checker.freeze_tier st7.store ixS = ok (tierS, frozenS)) | |
| 1308 (h8S : ParallelAll prepS.decls.length (arena.checker.worker_state st7.pins) | |
| 1309 (jobStep tierS .Verified ipins prepS.decls)) | |
| 1310 {prepC : frontend.prepare.Prepared} | |
| 1311 (h4 : frontend.prepare.prepare_d frontend.nat_op_ground.DeclUsedConsts.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier st7 preC rC.decls () = ok (.Ok prepC, st9)) | |
| 1312 {recsC : alloc.vec.Vec arena.env.IDeclaration} | |
| 1313 (hside : arena.justify.side_records emptyTier st9 prepC.decls 0#usize (alloc.vec.Vec.new _) = | |
| 1314 ok (.Ok recsC, st10)) | |
| 1315 {sol : arena.justify.Solution} | |
| 1316 (hsol : arena.justify.solution_of ixS recsC = ok sol) | |
| 1317 {ixC : arena.stream_index.IStreamIndex} | |
| 1318 (h6 : (do | |
| 1319 let e ← arena.stream_index.stream_index_empty | |
| 1320 arena.stream_index.build_index emptyTier st10 e recsC 0#usize) = ok (.Ok ixC, st11)) | |
| 1321 {tierC : arena.store.PersTier} {frozenC : arena.store.EStore} | |
| 1322 (h7 : arena.checker.freeze_tier st11.store ixC = ok (tierC, frozenC)) | |
| 1323 (h8 : ParallelAll recsC.length (arena.checker.worker_state st11.pins) | |
| 1324 (jobStepSol tierC .Verified ipins (some sol) recsC)) : | |
| 1325 False := by | |
| == proof/ConRon/Bridge/Compare/Model.lean#L69-L76 | |
| 69 @[expose] def MixedStep (pinsP : List NatOpPinSet) (JS : Solution) (env : Env) (pd : Declaration) | |
| 70 (env' : Env) : Prop := | |
| 71 (justifiable pd = none ∧ | |
| 72 ∃ F, ConLeche.checkDecl .verified (fueledOps .verified F) pinsP env pd = .ok env') ∨ | |
| 73 (∃ cv, justifiable pd = some cv ∧ env' = ⟨.axiomInfo cv :: env.consts, env.tables⟩ ∧ | |
| 74 justifyWhy JS (mkFEnv env) cv = none ∧ basisNamesOk pd = true ∧ | |
| 75 ∃ F, ConstantValRun F env cv cv.type) | |
| 76 | |
| == proof/ConRon/MainTheorem/Stages.lean#L1535-L1597 | |
| 1535 theorem no_False_oleans_compare (V : Type w) [ConLeche.SetTheory V] {F : ConLeche.FS} | |
| 1536 {m : ConLeche.Name} {d : ConLeche.Frontend.Olean.ModDecoded} | |
| 1537 {cc : ConLeche.Frontend.Olean.CEntryF ConLeche.Name ConLeche.Expr} {v : ConLeche.Expr} | |
| 1538 {all : List ConLeche.Name} {c : kernel.name.Name} {cr : frontend.olean.files.Roots} | |
| 1539 (hcl : ConLeche.Frontend.Olean.InClosure (absRoots cr) F #[ConRon.Refine.absName c] m) | |
| 1540 (hv : ConLeche.Frontend.Olean.ViewOf (absRoots cr) F m d) | |
| 1541 (hmem : cc ∈ d.constants) (hk : cc.kind = .thm v all) | |
| 1542 (hty : cc.type = .const ConLeche.falseName []) | |
| 1543 {st1 st2 st4 st4h st5 st6 st7 st10 st11 : arena.monad.AState} | |
| 1544 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 1545 {pre : frontend.prepare.PreludeIx} | |
| 1546 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 1547 {s : kernel.name.Name} {ch sh : arena.handle.NIdx} {stR1 stR : arena.monad.AState} | |
| 1548 (hwfC : ConRon.Refine.NameWF c) (hwfS : ConRon.Refine.NameWF s) | |
| 1549 (hnC : arena.monad.intern_name emptyTier st2 c = ok (.Ok ch, stR1)) | |
| 1550 (hnS : arena.monad.intern_name emptyTier stR1 s = ok (.Ok sh, stR)) | |
| 1551 {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} {fsv : Fs} | |
| 1552 (hsnap : SnapshotOf finst fsv F) | |
| 1553 {sr : frontend.olean.files.Roots} {rootsC rootsS : alloc.vec.Vec arena.handle.NIdx} | |
| 1554 (hrC : rootsC.val = [ch]) (hrS : rootsS.val = [sh]) | |
| 1555 {rdC rdS : frontend.olean.records.OleanRead} {store3 store5 : arena.store.EStore} | |
| 1556 (h3 : frontend.olean.records.read_oleans finst fsv emptyTier stR.store cr rootsC none true true | |
| 1557 = ok (.Ok rdC, store3)) | |
| 1558 {preC : frontend.prepare.PreludeIx} | |
| 1559 (hdup : frontend.prepare.prelude_ix_dup pre = ok preC) | |
| 1560 {prepC : frontend.prepare.Prepared} | |
| 1561 (h4 : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { stR with store := store3 } preC rdC.decls rdC | |
| 1562 = ok (.Ok prepC, st4)) | |
| 1563 {holed : alloc.vec.Vec arena.env.IDeclaration} | |
| 1564 (hhole : frontend.compare.hole_records frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts rdC emptyTier st4 prepC.decls 0#usize (alloc.vec.Vec.new _) | |
| 1565 = ok (.Ok holed, st4h)) | |
| 1566 (h3S : frontend.olean.records.read_oleans finst fsv emptyTier st4h.store sr rootsS none true false | |
| 1567 = ok (.Ok rdS, store5)) | |
| 1568 {prepS : frontend.prepare.Prepared} | |
| 1569 (h4S : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { st4h with store := store5 } pre rdS.decls rdS | |
| 1570 = ok (.Ok prepS, st5)) | |
| 1571 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 1572 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 1573 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 1574 {maxNatSize : ron.nat.Nat} | |
| 1575 (h5 : arena.checker.intern_all_pins emptyTier st5 pins maxNatSize = ok (.Ok ipins, st6)) | |
| 1576 {ixS : arena.stream_index.IStreamIndex} | |
| 1577 (h6S : (do | |
| 1578 let e ← arena.stream_index.stream_index_empty | |
| 1579 arena.stream_index.build_index emptyTier st6 e prepS.decls 0#usize) = ok (.Ok ixS, st7)) | |
| 1580 {tierS : arena.store.PersTier} {frozenS : arena.store.EStore} | |
| 1581 (h7S : arena.checker.freeze_tier st7.store ixS = ok (tierS, frozenS)) | |
| 1582 (h8S : ParallelAll prepS.decls.length (oleanWorkerInit st7.pins) | |
| 1583 (oleanJobStep finst fsv tierS .Verified ipins prepS.decls rdS.pins rdS.values sr)) | |
| 1584 {recsC : alloc.vec.Vec arena.env.IDeclaration} | |
| 1585 (hside : arena.justify.side_records emptyTier st7 holed 0#usize (alloc.vec.Vec.new _) = | |
| 1586 ok (.Ok recsC, st10)) | |
| 1587 {sol : arena.justify.Solution} | |
| 1588 (hsol : arena.justify.solution_of ixS recsC = ok sol) | |
| 1589 {ixC : arena.stream_index.IStreamIndex} | |
| 1590 (h6 : (do | |
| 1591 let e ← arena.stream_index.stream_index_empty | |
| 1592 arena.stream_index.build_index emptyTier st10 e recsC 0#usize) = ok (.Ok ixC, st11)) | |
| 1593 {tierC : arena.store.PersTier} {frozenC : arena.store.EStore} | |
| 1594 (h7 : arena.checker.freeze_tier st11.store ixC = ok (tierC, frozenC)) | |
| 1595 (h8 : ParallelAll recsC.length (oleanWorkerInit st11.pins) | |
| 1596 (oleanJobStepSol finst fsv tierC .Verified ipins recsC rdC.pins rdC.values cr (some sol))) : | |
| 1597 False := | |
| == proof/ConRon/MainTheorem/Stages.lean#L1603-L1658 | |
| 1603 theorem model_exists_oleans_compare (V : Type w) [ConLeche.SetTheory V] {F : ConLeche.FS} | |
| 1604 {st1 st2 st4 st4h st5 st6 st7 st10 st11 : arena.monad.AState} | |
| 1605 (h1 : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1)) | |
| 1606 {pre : frontend.prepare.PreludeIx} | |
| 1607 (h2 : frontend.prelude.builtin_prelude_e emptyTier st1 = ok (.Ok pre, st2)) | |
| 1608 {c s : kernel.name.Name} {ch sh : arena.handle.NIdx} {stR1 stR : arena.monad.AState} | |
| 1609 (hwfC : ConRon.Refine.NameWF c) (hwfS : ConRon.Refine.NameWF s) | |
| 1610 (hnC : arena.monad.intern_name emptyTier st2 c = ok (.Ok ch, stR1)) | |
| 1611 (hnS : arena.monad.intern_name emptyTier stR1 s = ok (.Ok sh, stR)) | |
| 1612 {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} {fsv : Fs} | |
| 1613 (hsnap : SnapshotOf finst fsv F) | |
| 1614 {cr sr : frontend.olean.files.Roots} {rootsC rootsS : alloc.vec.Vec arena.handle.NIdx} | |
| 1615 (hrC : rootsC.val = [ch]) (hrS : rootsS.val = [sh]) | |
| 1616 {rdC rdS : frontend.olean.records.OleanRead} {store3 store5 : arena.store.EStore} | |
| 1617 (h3 : frontend.olean.records.read_oleans finst fsv emptyTier stR.store cr rootsC none true true | |
| 1618 = ok (.Ok rdC, store3)) | |
| 1619 {preC : frontend.prepare.PreludeIx} | |
| 1620 (hdup : frontend.prepare.prelude_ix_dup pre = ok preC) | |
| 1621 {prepC : frontend.prepare.Prepared} | |
| 1622 (h4 : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { stR with store := store3 } preC rdC.decls rdC | |
| 1623 = ok (.Ok prepC, st4)) | |
| 1624 {holed : alloc.vec.Vec arena.env.IDeclaration} | |
| 1625 (hhole : frontend.compare.hole_records frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts rdC emptyTier st4 prepC.decls 0#usize (alloc.vec.Vec.new _) | |
| 1626 = ok (.Ok holed, st4h)) | |
| 1627 (h3S : frontend.olean.records.read_oleans finst fsv emptyTier st4h.store sr rootsS none true false | |
| 1628 = ok (.Ok rdS, store5)) | |
| 1629 {prepS : frontend.prepare.Prepared} | |
| 1630 (h4S : frontend.prepare.prepare_d frontend.olean.records.OleanRead.Insts.Con_ron_coreFrontendNat_op_groundUsedConsts emptyTier { st4h with store := store5 } pre rdS.decls rdS | |
| 1631 = ok (.Ok prepS, st5)) | |
| 1632 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 1633 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 1634 {ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet} | |
| 1635 {maxNatSize : ron.nat.Nat} | |
| 1636 (h5 : arena.checker.intern_all_pins emptyTier st5 pins maxNatSize = ok (.Ok ipins, st6)) | |
| 1637 {ixS : arena.stream_index.IStreamIndex} | |
| 1638 (h6S : (do | |
| 1639 let e ← arena.stream_index.stream_index_empty | |
| 1640 arena.stream_index.build_index emptyTier st6 e prepS.decls 0#usize) = ok (.Ok ixS, st7)) | |
| 1641 {tierS : arena.store.PersTier} {frozenS : arena.store.EStore} | |
| 1642 (h7S : arena.checker.freeze_tier st7.store ixS = ok (tierS, frozenS)) | |
| 1643 (h8S : ParallelAll prepS.decls.length (oleanWorkerInit st7.pins) | |
| 1644 (oleanJobStep finst fsv tierS .Verified ipins prepS.decls rdS.pins rdS.values sr)) | |
| 1645 {recsC : alloc.vec.Vec arena.env.IDeclaration} | |
| 1646 (hside : arena.justify.side_records emptyTier st7 holed 0#usize (alloc.vec.Vec.new _) = | |
| 1647 ok (.Ok recsC, st10)) | |
| 1648 {sol : arena.justify.Solution} | |
| 1649 (hsol : arena.justify.solution_of ixS recsC = ok sol) | |
| 1650 {ixC : arena.stream_index.IStreamIndex} | |
| 1651 (h6 : (do | |
| 1652 let e ← arena.stream_index.stream_index_empty | |
| 1653 arena.stream_index.build_index emptyTier st10 e recsC 0#usize) = ok (.Ok ixC, st11)) | |
| 1654 {tierC : arena.store.PersTier} {frozenC : arena.store.EStore} | |
| 1655 (h7 : arena.checker.freeze_tier st11.store ixC = ok (tierC, frozenC)) | |
| 1656 (h8 : ParallelAll recsC.length (oleanWorkerInit st11.pins) | |
| 1657 (oleanJobStepSol finst fsv tierC .Verified ipins recsC rdC.pins rdC.values cr (some sol))) : | |
| 1658 ∃ env, RustDenotesFilled recsC st10 env ∧ Nonempty (ConLeche.Model V env) := | |
| == proof/ConRon/MainTheorem/Stages.lean#L2214-L2254 | |
| 2214 theorem model_modular (V : Type w) [ConLeche.SetTheory V] {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} | |
| 2215 {fsv : Fs} {F : ConLeche.FS} (hsnap : SnapshotOf finst fsv F) | |
| 2216 {dirs : alloc.vec.Vec (alloc.vec.Vec Std.U32)} {rName : kernel.name.Name} | |
| 2217 {g1 gR : arena.monad.AState} {gstore2 gstore3 : arena.store.EStore} | |
| 2218 {pk : frontend.olean.spec.OleanPins} {groots : alloc.vec.Vec arena.handle.NIdx} | |
| 2219 {c : alloc.vec.Vec (arena.handle.NIdx × alloc.vec.Vec (frontend.olean.spec.ImportF arena.handle.NIdx))} | |
| 2220 (h1g : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), g1)) | |
| 2221 (hpk : frontend.olean.spec.olean_pins emptyTier g1.store = ok (.Ok pk, gstore2)) | |
| 2222 (hroots : InternRoots emptyTier { g1 with store := gstore2 } [rName] groots.val gR) | |
| 2223 (hgraph : frontend.modular.graph.graph_of finst fsv pk emptyTier gR.store | |
| 2224 ⟨dirs, alloc.vec.Vec.new _⟩ groots none = ok (.Ok c, gstore3)) | |
| 2225 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 2226 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 2227 (hwork : ∀ m', ConLeche.Frontend.Olean.HdrClosure (absSearchPath dirs) F | |
| 2228 [ConRon.Refine.absName rName] m' → | |
| 2229 ∃ (mName : kernel.name.Name), ConRon.Refine.absName mName = m' ∧ | |
| 2230 ∃ (st1 st2 st3 st4 st5 : arena.monad.AState) (m : arena.handle.NIdx) | |
| 2231 (ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet) (maxNatSize : ron.nat.Nat) | |
| 2232 (w : frontend.modular.worker.WorkerRead) (ds : alloc.vec.Vec arena.env.IDeclaration) | |
| 2233 (ix : arena.stream_index.IStreamIndex) (tier : arena.store.PersTier) | |
| 2234 (frozen : arena.store.EStore) (ws ws' : arena.monad.AState), | |
| 2235 arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1) ∧ | |
| 2236 InternRoots emptyTier st1 [mName] [m] st2 ∧ | |
| 2237 arena.checker.intern_all_pins emptyTier st2 pins maxNatSize = ok (.Ok ipins, st3) ∧ | |
| 2238 frontend.modular.worker.worker_read finst fsv emptyTier st3 ⟨dirs, alloc.vec.Vec.new _⟩ | |
| 2239 ipins m (alloc.vec.Vec.new _) = ok (.Ok w, st4) ∧ | |
| 2240 frontend.modular.worker.worker_decls w = ok ds ∧ | |
| 2241 (do | |
| 2242 let e ← arena.stream_index.stream_index_empty | |
| 2243 arena.stream_index.build_index emptyTier st4 e ds 0#usize) = ok (.Ok ix, st5) ∧ | |
| 2244 arena.checker.freeze_tier st5.store ix = ok (tier, frozen) ∧ | |
| 2245 arena.checker.worker_state st5.pins = ok ws ∧ | |
| 2246 frontend.modular.reach.infer_flags tier ws w.reach.ctx w.reach.pending = ok (.Ok (), ws') ∧ | |
| 2247 ParallelAll (ds.length - w.start.val) (oleanWorkerInit st5.pins) | |
| 2248 (fun c k => oleanJobStepSol finst fsv tier .Verified ipins ds w.pins w.values | |
| 2249 ⟨dirs, alloc.vec.Vec.new _⟩ none c (w.start.val + k))) : | |
| 2250 ∃ model : ConLeche.Name → (ConLeche.Name → List Nat → V), | |
| 2251 (∀ m, ConLeche.Frontend.Olean.InClosure (absSearchPath dirs) F #[ConRon.Refine.absName rName] m → | |
| 2252 ConLeche.IsModel V (model m) (ConLeche.Frontend.Olean.moduleConstants (absSearchPath dirs) F m)) ∧ | |
| 2253 (∀ m n m', ConLeche.Frontend.Olean.InClosure (absSearchPath dirs) F #[ConRon.Refine.absName rName] m → | |
| 2254 ConLeche.Frontend.Olean.Sees (absSearchPath dirs) F m n m' → model m n = model m' n) := | |
| == proof/ConRon/MainTheorem/Stages.lean#L2260-L2332 | |
| 2260 theorem model_modular_compare (V : Type w) [ConLeche.SetTheory V] {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} | |
| 2261 {fsv : Fs} {F : ConLeche.FS} (hsnap : SnapshotOf finst fsv F) | |
| 2262 {tdirs ddirs : alloc.vec.Vec (alloc.vec.Vec Std.U32)} {cName sName : kernel.name.Name} | |
| 2263 {spR : frontend.olean.files.Roots} | |
| 2264 (hsr : absRoots spR = (⟨ConRon.Refine.absName cName, ConRon.Refine.absName sName, | |
| 2265 absSearchPath tdirs, absSearchPath ddirs, none⟩ : ConLeche.Driver.CmpReq).solRoots) | |
| 2266 {g1 gR : arena.monad.AState} {gstore2 gstore3 : arena.store.EStore} | |
| 2267 {pk : frontend.olean.spec.OleanPins} {gc gs : arena.handle.NIdx} | |
| 2268 {groots : alloc.vec.Vec arena.handle.NIdx} (hgr : groots.val = [gc]) | |
| 2269 {cg : alloc.vec.Vec (arena.handle.NIdx × alloc.vec.Vec (frontend.olean.spec.ImportF arena.handle.NIdx))} | |
| 2270 (h1g : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), g1)) | |
| 2271 (hpk : frontend.olean.spec.olean_pins emptyTier g1.store = ok (.Ok pk, gstore2)) | |
| 2272 (hroots : InternRoots emptyTier { g1 with store := gstore2 } [cName, sName] [gc, gs] gR) | |
| 2273 (hgraph : frontend.modular.graph.graph_of finst fsv pk emptyTier gR.store spR groots | |
| 2274 (some (gc, gs)) = ok (.Ok cg, gstore3)) | |
| 2275 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 2276 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 2277 (hwork : ∀ m', ConLeche.Frontend.Olean.HdrClosure (absRoots spR) F | |
| 2278 [ConRon.Refine.absName cName, ConRon.Refine.absName sName] m' → | |
| 2279 m' ≠ ConRon.Refine.absName cName → | |
| 2280 ∃ (mName : kernel.name.Name), ConRon.Refine.absName mName = m' ∧ | |
| 2281 ∃ (m : arena.handle.NIdx) (st1 st2 st3 st4 st5 : arena.monad.AState) (ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet) | |
| 2282 (maxNatSize : ron.nat.Nat) (w : frontend.modular.worker.WorkerRead) | |
| 2283 (ds : alloc.vec.Vec arena.env.IDeclaration) (ix : arena.stream_index.IStreamIndex) | |
| 2284 (tier : arena.store.PersTier) (frozen : arena.store.EStore) (ws ws' : arena.monad.AState), | |
| 2285 arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1) ∧ | |
| 2286 InternRoots emptyTier st1 [mName] [m] st2 ∧ | |
| 2287 arena.checker.intern_all_pins emptyTier st2 pins maxNatSize = ok (.Ok ipins, st3) ∧ | |
| 2288 frontend.modular.worker.worker_read finst fsv emptyTier st3 spR ipins m (alloc.vec.Vec.new _) = ok (.Ok w, st4) ∧ | |
| 2289 frontend.modular.worker.worker_decls w = ok ds ∧ | |
| 2290 (do | |
| 2291 let e ← arena.stream_index.stream_index_empty | |
| 2292 arena.stream_index.build_index emptyTier st4 e ds 0#usize) = ok (.Ok ix, st5) ∧ | |
| 2293 arena.checker.freeze_tier st5.store ix = ok (tier, frozen) ∧ | |
| 2294 arena.checker.worker_state st5.pins = ok ws ∧ | |
| 2295 frontend.modular.reach.infer_flags tier ws w.reach.ctx w.reach.pending = ok (.Ok (), ws') ∧ | |
| 2296 ParallelAll (ds.length - w.start.val) (oleanWorkerInit st5.pins) | |
| 2297 (fun c k => oleanJobStepSol finst fsv tier .Verified ipins ds w.pins w.values | |
| 2298 spR none c (w.start.val + k))) | |
| 2299 (hcmp : ∃ (c sH : arena.handle.NIdx) (xi : frontend.olean.spec.ImportF arena.handle.NIdx) | |
| 2300 (x : alloc.vec.Vec (frontend.olean.spec.ImportF arena.handle.NIdx)) (st1 st2 st3 st4 st5 : arena.monad.AState) (ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet) | |
| 2301 (maxNatSize : ron.nat.Nat) (w : frontend.modular.worker.WorkerRead) | |
| 2302 (ds : alloc.vec.Vec arena.env.IDeclaration) (ix : arena.stream_index.IStreamIndex) | |
| 2303 (tier : arena.store.PersTier) (frozen : arena.store.EStore) (ws ws' : arena.monad.AState), | |
| 2304 arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1) ∧ | |
| 2305 InternRoots emptyTier st1 [cName, sName] [c, sH] st2 ∧ | |
| 2306 frontend.modular.graph.solution_import sH = ok xi ∧ x.val = [xi] ∧ | |
| 2307 arena.checker.intern_all_pins emptyTier st2 pins maxNatSize = ok (.Ok ipins, st3) ∧ | |
| 2308 frontend.modular.worker.worker_read finst fsv emptyTier st3 spR ipins c x = ok (.Ok w, st4) ∧ | |
| 2309 frontend.modular.worker.worker_decls w = ok ds ∧ | |
| 2310 (do | |
| 2311 let e ← arena.stream_index.stream_index_empty | |
| 2312 arena.stream_index.build_index emptyTier st4 e ds 0#usize) = ok (.Ok ix, st5) ∧ | |
| 2313 arena.checker.freeze_tier st5.store ix = ok (tier, frozen) ∧ | |
| 2314 arena.checker.worker_state st5.pins = ok ws ∧ | |
| 2315 frontend.modular.reach.infer_flags tier ws w.reach.ctx w.reach.pending = ok (.Ok (), ws') ∧ | |
| 2316 ParallelAll (ds.length - w.start.val) (oleanWorkerInit st5.pins) | |
| 2317 (fun c k => oleanJobStepSol finst fsv tier .Verified ipins ds w.pins w.values | |
| 2318 spR none c (w.start.val + k))) : | |
| 2319 ∀ fs', ConLeche.FS.AgreeUnder (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs)) | |
| 2320 F fs' → | |
| 2321 ∃ model : ConLeche.Name → (ConLeche.Name → List Nat → V), | |
| 2322 (∀ m, ConLeche.Frontend.Olean.InClosure | |
| 2323 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) | |
| 2324 fs' #[ConRon.Refine.absName cName] m → | |
| 2325 ConLeche.IsModel V (model m) (ConLeche.Frontend.Olean.moduleConstants | |
| 2326 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) fs' m)) ∧ | |
| 2327 (∀ m n m', ConLeche.Frontend.Olean.InClosure | |
| 2328 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) | |
| 2329 fs' #[ConRon.Refine.absName cName] m → | |
| 2330 ConLeche.Frontend.Olean.Sees | |
| 2331 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) | |
| 2332 fs' m n m' → model m n = model m' n) := | |
| == proof/ConRon/MainTheorem/Stages.lean#L2338-L2404 | |
| 2338 theorem no_False_modular_compare (V : Type w) [ConLeche.SetTheory V] {Fs : Type} {finst : frontend.checker_io.CheckerFs Fs} | |
| 2339 {fsv : Fs} {F : ConLeche.FS} (hsnap : SnapshotOf finst fsv F) | |
| 2340 {tdirs ddirs : alloc.vec.Vec (alloc.vec.Vec Std.U32)} {cName sName : kernel.name.Name} | |
| 2341 {spR : frontend.olean.files.Roots} | |
| 2342 (hsr : absRoots spR = (⟨ConRon.Refine.absName cName, ConRon.Refine.absName sName, | |
| 2343 absSearchPath tdirs, absSearchPath ddirs, none⟩ : ConLeche.Driver.CmpReq).solRoots) | |
| 2344 {g1 gR : arena.monad.AState} {gstore2 gstore3 : arena.store.EStore} | |
| 2345 {pk : frontend.olean.spec.OleanPins} {gc gs : arena.handle.NIdx} | |
| 2346 {groots : alloc.vec.Vec arena.handle.NIdx} (hgr : groots.val = [gc]) | |
| 2347 {cg : alloc.vec.Vec (arena.handle.NIdx × alloc.vec.Vec (frontend.olean.spec.ImportF arena.handle.NIdx))} | |
| 2348 (h1g : arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), g1)) | |
| 2349 (hpk : frontend.olean.spec.olean_pins emptyTier g1.store = ok (.Ok pk, gstore2)) | |
| 2350 (hroots : InternRoots emptyTier { g1 with store := gstore2 } [cName, sName] [gc, gs] gR) | |
| 2351 (hgraph : frontend.modular.graph.graph_of finst fsv pk emptyTier gR.store spR groots | |
| 2352 (some (gc, gs)) = ok (.Ok cg, gstore3)) | |
| 2353 {pinText : Slice Std.U8} {pins : alloc.vec.Vec kernel.nat_op_pins.NatOpPinSet} | |
| 2354 (hpins : kernel.pins_decode.decode pinText = ok (.Ok pins)) | |
| 2355 (hwork : ∀ m', ConLeche.Frontend.Olean.HdrClosure (absRoots spR) F | |
| 2356 [ConRon.Refine.absName cName, ConRon.Refine.absName sName] m' → | |
| 2357 m' ≠ ConRon.Refine.absName cName → | |
| 2358 ∃ (mName : kernel.name.Name), ConRon.Refine.absName mName = m' ∧ | |
| 2359 ∃ (m : arena.handle.NIdx) (st1 st2 st3 st4 st5 : arena.monad.AState) (ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet) | |
| 2360 (maxNatSize : ron.nat.Nat) (w : frontend.modular.worker.WorkerRead) | |
| 2361 (ds : alloc.vec.Vec arena.env.IDeclaration) (ix : arena.stream_index.IStreamIndex) | |
| 2362 (tier : arena.store.PersTier) (frozen : arena.store.EStore) (ws ws' : arena.monad.AState), | |
| 2363 arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1) ∧ | |
| 2364 InternRoots emptyTier st1 [mName] [m] st2 ∧ | |
| 2365 arena.checker.intern_all_pins emptyTier st2 pins maxNatSize = ok (.Ok ipins, st3) ∧ | |
| 2366 frontend.modular.worker.worker_read finst fsv emptyTier st3 spR ipins m (alloc.vec.Vec.new _) = ok (.Ok w, st4) ∧ | |
| 2367 frontend.modular.worker.worker_decls w = ok ds ∧ | |
| 2368 (do | |
| 2369 let e ← arena.stream_index.stream_index_empty | |
| 2370 arena.stream_index.build_index emptyTier st4 e ds 0#usize) = ok (.Ok ix, st5) ∧ | |
| 2371 arena.checker.freeze_tier st5.store ix = ok (tier, frozen) ∧ | |
| 2372 arena.checker.worker_state st5.pins = ok ws ∧ | |
| 2373 frontend.modular.reach.infer_flags tier ws w.reach.ctx w.reach.pending = ok (.Ok (), ws') ∧ | |
| 2374 ParallelAll (ds.length - w.start.val) (oleanWorkerInit st5.pins) | |
| 2375 (fun c k => oleanJobStepSol finst fsv tier .Verified ipins ds w.pins w.values | |
| 2376 spR none c (w.start.val + k))) | |
| 2377 (hcmp : ∃ (c sH : arena.handle.NIdx) (xi : frontend.olean.spec.ImportF arena.handle.NIdx) | |
| 2378 (x : alloc.vec.Vec (frontend.olean.spec.ImportF arena.handle.NIdx)) (st1 st2 st3 st4 st5 : arena.monad.AState) (ipins : alloc.vec.Vec arena.nat_op_pin_set.INatOpPinSet) | |
| 2379 (maxNatSize : ron.nat.Nat) (w : frontend.modular.worker.WorkerRead) | |
| 2380 (ds : alloc.vec.Vec arena.env.IDeclaration) (ix : arena.stream_index.IStreamIndex) | |
| 2381 (tier : arena.store.PersTier) (frozen : arena.store.EStore) (ws ws' : arena.monad.AState), | |
| 2382 arena.pins.intern_reserved_pins emptyTier startState = ok (.Ok (), st1) ∧ | |
| 2383 InternRoots emptyTier st1 [cName, sName] [c, sH] st2 ∧ | |
| 2384 frontend.modular.graph.solution_import sH = ok xi ∧ x.val = [xi] ∧ | |
| 2385 arena.checker.intern_all_pins emptyTier st2 pins maxNatSize = ok (.Ok ipins, st3) ∧ | |
| 2386 frontend.modular.worker.worker_read finst fsv emptyTier st3 spR ipins c x = ok (.Ok w, st4) ∧ | |
| 2387 frontend.modular.worker.worker_decls w = ok ds ∧ | |
| 2388 (do | |
| 2389 let e ← arena.stream_index.stream_index_empty | |
| 2390 arena.stream_index.build_index emptyTier st4 e ds 0#usize) = ok (.Ok ix, st5) ∧ | |
| 2391 arena.checker.freeze_tier st5.store ix = ok (tier, frozen) ∧ | |
| 2392 arena.checker.worker_state st5.pins = ok ws ∧ | |
| 2393 frontend.modular.reach.infer_flags tier ws w.reach.ctx w.reach.pending = ok (.Ok (), ws') ∧ | |
| 2394 ParallelAll (ds.length - w.start.val) (oleanWorkerInit st5.pins) | |
| 2395 (fun c k => oleanJobStepSol finst fsv tier .Verified ipins ds w.pins w.values | |
| 2396 spR none c (w.start.val + k))) | |
| 2397 {m : ConLeche.Name} {ci : ConLeche.ConstantInfo} | |
| 2398 (hcl : ConLeche.Frontend.Olean.InClosure | |
| 2399 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) | |
| 2400 F #[ConRon.Refine.absName cName] m) | |
| 2401 (hci : ConLeche.Frontend.Olean.InModulePart | |
| 2402 (ConLeche.Driver.trustedOr (absSearchPath tdirs) (absSearchPath ddirs) : ConLeche.Frontend.Olean.Roots) | |
| 2403 F m .private ci) | |
| 2404 (hty : ci.type = .const ConLeche.falseName []) : False := | |
| == crates/con-ron-core/src/arena/monad.rs#L298-L320 | |
| 298 | |
| 299 /// con-leche: ConLeche/Cached/StateC.lean:256-298 CState | |
| 300 /// Lean twin: `proof/ConRon/Arena/Monad.lean:118-135 AState` — the checker | |
| 301 /// state of (C): the arena, the per-call memo tables and — since task | |
| 302 /// #97-P4c — the per-declaration caches (`whnfCore`, `whnf`, the two infer | |
| 303 /// grades, `defeq`, the level verdicts, the instantiated constants). | |
| 304 pub struct AState { | |
| 305 pub store: EStore, | |
| 306 pub memos: Memos, | |
| 307 /// The per-DECLARATION caches (task #97-P4c, `arena::core_state`): the | |
| 308 /// four entry-point memos (and `whnfCore`'s cheap mode's own), the | |
| 309 /// `defeq` verdict table, the two level-verdict tables and the three lazy | |
| 310 /// instantiated-constant tables. | |
| 311 /// A record of its own beside `memos`, because the per-call clear and the | |
| 312 /// per-declaration drop are different operations on different lifetimes. | |
| 313 pub caches: Caches, | |
| 314 /// The reserved-name pins (task #97-P6-4a, `arena::pins`): the | |
| 315 /// fifty-one constant names, the empty level list, the level `0` and | |
| 316 /// `Sort 1`, interned ONCE into the persistent tier by the driver's | |
| 317 /// `intern_all_pins` and read by handle ever after. Empty until then, | |
| 318 /// which is what makes a premature read a stop rather than a wrong | |
| 319 /// answer (task #97c's hazard). | |
| 320 pub pins: Pins, | |
| == crates/con-ron-core/src/arena/handle.rs#L4-L30 | |
| 4 //! One 32-bit word per handle, in one of two shapes. The top bit is the tier | |
| 5 //! in both; bit 30 says which shape the rest is: | |
| 6 //! | |
| 7 //! ```text | |
| 8 //! wide (expression `app` only) narrow (every other node) | |
| 9 //! bit 31 tier bit 31 tier | |
| 10 //! bit 30 1 bit 30 0 | |
| 11 //! bits 29…0 index bits 29…26 ctor tag (4 bits) | |
| 12 //! bits 25…0 index | |
| 13 //! ``` | |
| 14 //! | |
| 15 //! (tier 0 = persistent, 1 = scratch; the index is into THAT CONSTRUCTOR'S | |
| 16 //! array of THAT TIER). The zero word is a narrow handle — tag 0, | |
| 17 //! persistent, slot 0 — which is the twin's `default : Idx k` and every | |
| 18 //! `of_word(0)` below: the anonymous name, the level `zero`, a handle that | |
| 19 //! decodes. An expression `app` array holds 2^30 = 1 073 741 824 nodes per | |
| 20 //! tier and every other constructor array 2^26 = | |
| 21 //! 67 108 864: apps are 85 % of an export's expression nodes, so they are the | |
| 22 //! array that runs out first, and they get the room. Only the expression | |
| 23 //! `app` tag is wide — a level `param` handle is narrow although `LTAG_PARAM` | |
| 24 //! has `ETAG_APP`'s value — and `word_tag` reads `ETAG_APP` off a word with | |
| 25 //! bit 30 set, so the tag of a handle is read the same way for all four | |
| 26 //! kinds. | |
| 27 //! | |
| 28 //! The tier is the TOP bit, above both shapes' index, so a persistent | |
| 29 //! handle's bits never change when the scratch tier comes and goes | |
| 30 //! (con-leche's lesson 6). | |
| == crates/con-ron-core/src/arena/handle.rs#L186-L212 | |
| 186 // --------------------------------------------------------------------------- | |
| 187 // The four handle kinds (`Handle.lean:78-93`) | |
| 188 // --------------------------------------------------------------------------- | |
| 189 | |
| 190 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:90-91 EIdx | |
| 191 /// An expression handle (DESIGN.md §8.3). | |
| 192 pub struct EIdx { | |
| 193 pub word: u32, | |
| 194 } | |
| 195 | |
| 196 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:92-93 NIdx | |
| 197 /// A name handle (DESIGN.md §8.3). | |
| 198 pub struct NIdx { | |
| 199 pub word: u32, | |
| 200 } | |
| 201 | |
| 202 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:94-95 LIdx | |
| 203 /// A level handle (DESIGN.md §8.3). | |
| 204 pub struct LIdx { | |
| 205 pub word: u32, | |
| 206 } | |
| 207 | |
| 208 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:96-97 LsIdx | |
| 209 /// A level-list handle (DESIGN.md §8.3). | |
| 210 pub struct LsIdx { | |
| 211 pub word: u32, | |
| 212 } | |
| == crates/con-ron-core/src/arena/handle.rs#L511-L559 | |
| 511 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 512 /// Lean twin: `proof/ConRon/Arena/Handle.lean:264-266 ETag.bvar` — the `bvar` | |
| 513 /// constructor, line 401. | |
| 514 pub const ETAG_BVAR: u32 = 0; | |
| 515 | |
| 516 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 517 /// Lean twin: `proof/ConRon/Arena/Handle.lean:267-269 ETag.fvar` — the `fvar` | |
| 518 /// constructor, line 402. | |
| 519 pub const ETAG_FVAR: u32 = 1; | |
| 520 | |
| 521 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 522 /// Lean twin: `proof/ConRon/Arena/Handle.lean:270-272 ETag.sort` — the `sort` | |
| 523 /// constructor, line 403. | |
| 524 pub const ETAG_SORT: u32 = 2; | |
| 525 | |
| 526 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 527 /// Lean twin: `proof/ConRon/Arena/Handle.lean:273-275 ETag.const` — the `const` | |
| 528 /// constructor, line 404. | |
| 529 pub const ETAG_CONST: u32 = 3; | |
| 530 | |
| 531 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 532 /// Lean twin: `proof/ConRon/Arena/Handle.lean:276-278 ETag.app` — the `app` | |
| 533 /// constructor, line 405. | |
| 534 pub const ETAG_APP: u32 = 4; | |
| 535 | |
| 536 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 537 /// Lean twin: `proof/ConRon/Arena/Handle.lean:279-281 ETag.lam` — the `lam` | |
| 538 /// constructor, line 406. | |
| 539 pub const ETAG_LAM: u32 = 5; | |
| 540 | |
| 541 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 542 /// Lean twin: `proof/ConRon/Arena/Handle.lean:282-284 ETag.forallE` — the | |
| 543 /// `forallE` constructor, line 407. | |
| 544 pub const ETAG_FORALL_E: u32 = 6; | |
| 545 | |
| 546 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 547 /// Lean twin: `proof/ConRon/Arena/Handle.lean:285-287 ETag.letE` — the `letE` | |
| 548 /// constructor, line 408. | |
| 549 pub const ETAG_LET_E: u32 = 7; | |
| 550 | |
| 551 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 552 /// Lean twin: `proof/ConRon/Arena/Handle.lean:288-290 ETag.lit` — the `lit` | |
| 553 /// constructor, line 409. | |
| 554 pub const ETAG_LIT: u32 = 8; | |
| 555 | |
| 556 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 557 /// Lean twin: `proof/ConRon/Arena/Handle.lean:291-293 ETag.proj` — the `proj` | |
| 558 /// constructor, line 410. | |
| 559 pub const ETAG_PROJ: u32 = 9; | |
| == crates/con-ron-core/src/arena/handle.rs#L397-L405 | |
| 397 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:112-114 instHashableIdx | |
| 398 /// **The word IS the hash**: nanoda's identity hasher (`unique_hasher.rs`), | |
| 399 /// no mixing at all. | |
| 400 impl Hashable for EIdx { | |
| 401 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Handle.lean:112-114 instHashableIdx | |
| 402 fn hash64(&self) -> u64 { | |
| 403 self.word as u64 | |
| 404 } | |
| 405 } | |
| == crates/con-ron-core/src/arena/store.rs#L1196-L1210 | |
| 1196 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Store.lean:351-363 ETables | |
| 1197 /// One tier of the expression store: ten arrays, ten derived columns, ten | |
| 1198 /// cons tables. | |
| 1199 pub struct ETables { | |
| 1200 pub bvars: Tbl<BVarNode, EIdx, u64>, | |
| 1201 pub fvars: Tbl<FVarNode, EIdx, u64>, | |
| 1202 pub sorts: Tbl<SortNode, EIdx, u64>, | |
| 1203 pub consts: Tbl<ConstNode, EIdx, u64>, | |
| 1204 pub apps: Tbl<AppNode, EIdx, u64>, | |
| 1205 pub lams: Tbl<BindNode, EIdx, u64>, | |
| 1206 pub foralls: Tbl<BindNode, EIdx, u64>, | |
| 1207 pub lets: Tbl<LetNode, EIdx, u64>, | |
| 1208 pub lits: Tbl<LitNode, EIdx, u64>, | |
| 1209 pub projs: Tbl<ProjNode, EIdx, u64>, | |
| 1210 } | |
| == crates/con-ron-core/src/arena/store.rs#L3621-L3656 | |
| 3621 | |
| 3622 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Store.lean:482-502 EStore.intern | |
| 3623 /// Hash-cons an expression node: probe the persistent cons table, then the | |
| 3624 /// scratch one, then append to the tier the store is in (DESIGN.md §8.3). | |
| 3625 /// The cap test is the Lean's `capOK` turned into the `Native` decline | |
| 3626 /// §8.3 puts here. | |
| 3627 /// | |
| 3628 /// **Dispatched ONCE** (task #97-P6-15). The body below used to run the | |
| 3629 /// whole sequence over the `ENodeView`, and each of its four steps | |
| 3630 /// dispatched on the view's tag again and built the node record again: | |
| 3631 /// the persistent probe built it (inside `ETables::find`), the scratch | |
| 3632 /// probe built it a second time, `der_of_view` re-dispatched to compute | |
| 3633 /// the derived word, and `ETables::push` re-dispatched and built it a | |
| 3634 /// third time to append it. So the tag is read once here and the ten per-constructor | |
| 3635 /// paths below each build their record ONCE and hand the same `&r` to the | |
| 3636 /// two probes, to the capacity test and to the push — the same clauses in | |
| 3637 /// the same order, with the dispatch and the two rebuilds gone. | |
| 3638 /// | |
| 3639 /// The twin's `intern` is one `def` over `ENodeView`; what is owed is the | |
| 3640 /// ten-arm spelling and `internC v = intern (view of C)` per constructor, | |
| 3641 /// each of them `rfl` after the `match`. | |
| 3642 pub fn intern(&mut self, pers: &PersTier, v: ENodeView) -> Result<EIdx, CheckError> { | |
| 3643 match v { | |
| 3644 ENodeView::BVar(i) => self.intern_bvar(pers, i), | |
| 3645 ENodeView::FVar(idx, ty) => self.intern_fvar(pers, idx, ty), | |
| 3646 ENodeView::Sort(u) => self.intern_sort(pers, u), | |
| 3647 ENodeView::Const(n, us) => self.intern_const(pers, n, us), | |
| 3648 ENodeView::App(f, a) => self.intern_app(pers, f, a), | |
| 3649 ENodeView::Lam(ty, body) => self.intern_lam(pers, ty, body), | |
| 3650 ENodeView::ForallE(ty, body) => self.intern_forall_e(pers, ty, body), | |
| 3651 ENodeView::LetE(ty, val, body) => self.intern_let_e(pers, ty, val, body), | |
| 3652 ENodeView::Lit(l) => self.intern_lit(pers, l), | |
| 3653 ENodeView::Proj(n, i, e) => self.intern_proj(pers, n, i, e), | |
| 3654 } | |
| 3655 } | |
| 3656 | |
| == crates/con-ron-core/src/arena/store.rs#L3906-L3953 | |
| 3906 pub fn intern_app(&mut self, pers: &PersTier, f: EIdx, a: EIdx) -> Result<EIdx, CheckError> { | |
| 3907 let r: AppNode = AppNode { f, a }; | |
| 3908 let sk: bool = if self.scratch_on { | |
| 3909 if r.f.is_persistent() { | |
| 3910 !r.a.is_persistent() | |
| 3911 } else { | |
| 3912 true | |
| 3913 } | |
| 3914 } else { | |
| 3915 false | |
| 3916 }; | |
| 3917 let hit: Option<EIdx> = if sk { | |
| 3918 None | |
| 3919 } else if pers.frozen { | |
| 3920 pers.e.apps.find(&r) | |
| 3921 } else { | |
| 3922 self.pers.apps.find(&r) | |
| 3923 }; | |
| 3924 match hit { | |
| 3925 Some(hp) => Ok(hp), | |
| 3926 None => { | |
| 3927 if self.scratch_on { | |
| 3928 let at: (usize, Option<EIdx>) = self.scr.apps.find_slot(&r); | |
| 3929 match at.1 { | |
| 3930 Some(hs) => Ok(hs), | |
| 3931 None => { | |
| 3932 if self.scr.apps.full_wide() { | |
| 3933 Err(CheckError::Native(code_points(&M_E_CAP))) | |
| 3934 } else { | |
| 3935 let d: u64 = self.der_of_app(pers, &r.f, &r.a); | |
| 3936 let h: EIdx = | |
| 3937 EIdx::pack_wide(TIER_S, self.scr.apps.size() as u32); | |
| 3938 self.scr.apps.push_at(at.0, r, d, h.dup2()); | |
| 3939 Ok(h) | |
| 3940 } | |
| 3941 } | |
| 3942 } | |
| 3943 } else if self.pers.apps.full_wide() { | |
| 3944 Err(CheckError::Native(code_points(&M_E_CAP))) | |
| 3945 } else { | |
| 3946 let d: u64 = self.der_of_app(pers, &r.f, &r.a); | |
| 3947 let h: EIdx = EIdx::pack_wide(TIER_P, self.pers.apps.size() as u32); | |
| 3948 self.pers.apps.push(r, d, h.dup2()); | |
| 3949 Ok(h) | |
| 3950 } | |
| 3951 } | |
| 3952 } | |
| 3953 } | |
| == proof/ConRon/Arena/WFProofs.lean#L1125-L1126 | |
| 1125 theorem denoteE_inj {st : EStore} (h : StoreWF st) {i j : EIdx} {x : Expr} | |
| 1126 (hi : denoteE st i = some x) (hj : denoteE st j = some x) : i = j := by | |
| == crates/con-ron-core/src/arena/core.rs#L12051-L12070 | |
| 12051 /// its eleven journals — P3 needs it to state that flushing is sound. | |
| 12052 pub fn flush_caches(st: &mut AState) { | |
| 12053 st.caches.reset(); | |
| 12054 } | |
| 12055 | |
| 12056 /// con-leche: none — **a job's bracket, closed** (DESIGN.md §8.3) | |
| 12057 /// Lean twin: `proof/ConRon/Arena/Core.lean:4578-4586 dropScratch` — | |
| 12058 /// the twin's `dropScratch` on a store that STAYS frozen (task #98-FREEZE): the | |
| 12059 /// caches flushed and the scratch tiers emptied, the flag untouched. A | |
| 12060 /// worker's store is frozen for its whole life, so between two jobs it is | |
| 12061 /// frozen with an empty scratch tier where the twin's is scratch-off; nothing | |
| 12062 /// is interned there. | |
| 12063 pub fn leave_record(st: &mut AState) { | |
| 12064 flush_caches(st); | |
| 12065 st.store.clear_scratch(); | |
| 12066 } | |
| 12067 | |
| 12068 /// con-leche: none — **a job's bracket, opened** (DESIGN.md §8.3) | |
| 12069 /// Lean twin: `proof/ConRon/Arena/Core.lean:4588-4595 enterScratch` — | |
| 12070 /// the twin's `enterScratch` on an already frozen store (task #98-FREEZE): the | |
| == crates/con-ron-core/src/arena/checker.rs#L65-L88 | |
| 65 | |
| 66 /// con-leche: none — the phase boundary, which con-leche has no tier to make | |
| 67 /// Lean twin: none — the twin has no tier to move; its worker reads the | |
| 68 /// persistent tier where it is (`AState.worker`, `Arena/Checker.lean`). | |
| 69 /// **The persistent tier and the stream's index into a value**: the four | |
| 70 /// persistent tables and the index move into one `PersTier` handed back | |
| 71 /// `frozen`, for the workers to read (the index is the base `ifenv_find` reads | |
| 72 /// below a job's own layer). A pure MOVE: the store's scratch tiers and flags | |
| 73 /// are untouched (a worker's store is its own, `worker_state`), and | |
| 74 /// `thaw_tier` puts everything back where it was. The driver's store is not | |
| 75 /// read between the two. | |
| 76 pub fn freeze_tier(ar: &mut EStore, ix: IStreamIndex) -> PersTier { | |
| 77 let n: NTables = core::mem::replace(&mut ar.lss.ls.ns.pers, NTables::empty()); | |
| 78 let l: LTables = core::mem::replace(&mut ar.lss.ls.pers, LTables::empty()); | |
| 79 let ls: LsTables = core::mem::replace(&mut ar.lss.pers, LsTables::empty()); | |
| 80 let e: ETables = core::mem::replace(&mut ar.pers, ETables::empty()); | |
| 81 PersTier { | |
| 82 frozen: true, | |
| 83 n, | |
| 84 l, | |
| 85 ls, | |
| 86 e, | |
| 87 env: ix, | |
| 88 } | |
| == crates/con-ron-core/src/arena/store.rs#L1227-L1279 | |
| 1227 /// con-leche: none — arena infrastructure; Lean twin: proof/ConRon/Arena/Store.lean:365-373 EStore | |
| 1228 /// **The persistent tier of all four stores, as one value `n` phase-B workers | |
| 1229 /// read by reference** — DESIGN.md §8.3's "the persistent tier is immutable in | |
| 1230 /// phase B, each worker owns a scratch tier — no atomics anywhere", made | |
| 1231 /// expressible. | |
| 1232 /// | |
| 1233 /// Each store keeps its own `pers` field, which is the tier the PARSE and | |
| 1234 /// phase A's setup append to, and ONE flag, `scratch_on`. **A store is in | |
| 1235 /// one of two states, and "frozen" and "scratch on" are the same thing** (task | |
| 1236 /// #98-FREEZE): | |
| 1237 /// | |
| 1238 /// * **owned, scratch off** (the parse, the setup, between phase A's | |
| 1239 /// declaration brackets): read through the EMPTY stand-in tier | |
| 1240 /// (`PersTier::empty`, `frozen` false), so every persistent read and every | |
| 1241 /// append goes to the owned field; | |
| 1242 /// * **frozen, scratch on** (inside a declaration bracket, and a phase-B | |
| 1243 /// worker for its whole life): the owned field is empty — `freeze` moved it | |
| 1244 /// into a `PersTier` whose `frozen` bit is set — and the store is read | |
| 1245 /// through that tier, so every persistent read goes to it; every append is | |
| 1246 /// a SCRATCH append, so no append can reach a frozen persistent tier, by | |
| 1247 /// construction and not by a guard. | |
| 1248 /// | |
| 1249 /// Which tables a persistent read goes to is therefore the READER's to say | |
| 1250 /// (`frozen`), not the store's: the choice is made by a value that is fixed | |
| 1251 /// for the whole of a bracket or a worker, whatever runs inside it. `freeze` | |
| 1252 /// hands out a frozen tier and turns the scratch tier on; `thaw` takes it back | |
| 1253 /// and turns it off; `empty_frozen` is a worker's store. Promotion — the one | |
| 1254 /// writer of the persistent tier inside a bracket — writes the frozen tier | |
| 1255 /// itself, through `&mut PersTier` (`PersTier::intern_*`). | |
| 1256 /// | |
| 1257 /// **Why a shared PARAMETER and not a field of the state.** Task #97-P6-6 | |
| 1258 /// measured a region inside the threaded `&mut` state eight ways: a bare | |
| 1259 /// `&u64` field on `AState` costs five function bodies Aeneas cannot | |
| 1260 /// translate and the same borrow inside the four stores costs sixteen, while | |
| 1261 /// everything else this split needs — the two-tier layout, the flag, the | |
| 1262 /// value-returning readers below — extracts at zero errors. So the sharing | |
| 1263 /// arrives as an ordinary shared parameter, the shape `fe: &IFEnv` and `mode: | |
| 1264 /// &CheckMode` already have, and the twin's monad becomes `ReaderT PersTier | |
| 1265 /// (StateT AState (Except CheckError))`. | |
| 1266 pub struct PersTier { | |
| 1267 /// This is a frozen store's tier: a store read through it reads its | |
| 1268 /// persistent tables HERE. `false` only for the empty stand-in an owned | |
| 1269 /// store is handed (`PersTier::empty`), which is never read. | |
| 1270 pub frozen: bool, | |
| 1271 pub n: NTables, | |
| 1272 pub l: LTables, | |
| 1273 pub ls: LsTables, | |
| 1274 pub e: ETables, | |
| 1275 /// The stream's index, the frozen base of every job's environment | |
| 1276 /// (`arena::env`'s `IFEnv` note): `checker::freeze_tier` moves it here, so | |
| 1277 /// every worker reads one by reference. Empty in every other tier. | |
| 1278 pub env: IStreamIndex, | |
| 1279 } | |
| == crates/con-ron-core/src/arena/env.rs#L749-L786 | |
| 749 /// con-leche: ConLeche/Kernel/FEnv.lean:189-218 FEnv | |
| 750 /// Lean twin: `proof/ConRon/Arena/Env.lean:274-286 IFEnv` — the environment | |
| 751 /// with its `O(1)` index (DESIGN.md §8.3 lesson 13), over the frozen base of a | |
| 752 /// stream's index, and the two literal flags of its lookups. con-leche's `ovl` | |
| 753 /// field is not ported (see `ifenv_find`). | |
| 754 /// | |
| 755 /// **The environment has two tiers, like the store.** An `IFEnv` is one LAYER: | |
| 756 /// a job's own, empty until its record pushes. The BASE is the stream's index | |
| 757 /// (`arena::stream_index::IStreamIndex`), built once before any check and | |
| 758 /// frozen into the `PersTier` (`checker::freeze_tier`), where every worker reads | |
| 759 /// it by reference. The layer's own entries are all visible (con-leche's local | |
| 760 /// index has no counter); the base is read below the layer's two bounds, | |
| 761 /// con-leche's `FBase.below` and `FBase.belowRec`, which live here because the | |
| 762 /// base itself is shared. | |
| 763 /// | |
| 764 /// **The index row is a SLOT and not an `IConstantInfo`** (task #97-P6-5, | |
| 765 /// lever 1): the twin's row carries the constant itself, a shared value in Lean | |
| 766 /// and a second deep copy in Rust. Every writer keeps `idx` and `env.consts` | |
| 767 /// in step (`ifenv_push`, `ifenv_push_temp`, `ifenv_pop_temp`) and | |
| 768 /// `ifenv_find` reads `env.consts[s]`. The table map `tbls` is built the same | |
| 769 /// way: its row is the table's slot in `env.tables`. | |
| 770 pub struct IFEnv { | |
| 771 pub env: IEnv, | |
| 772 pub idx: HashMap<NIdx, u64>, | |
| 773 pub tbls: HashMap<NIdx, u64>, | |
| 774 /// The base's constants are visible below this counter (`FBase.below`). | |
| 775 pub base_below: u64, | |
| 776 /// The base's tables are visible below this record position | |
| 777 /// (`FBase.belowRec`). | |
| 778 pub base_below_rec: u64, | |
| 779 /// **Are `Nat` literals expandable** here (`nat_lit_stored_by`): the core | |
| 780 /// reads it at every literal it meets, so it is set where the layer is made | |
| 781 /// and kept by every push. | |
| 782 pub nat_lit: bool, | |
| 783 /// **Are string literals expandable** here (`str_lit_stored_by`), as | |
| 784 /// `nat_lit`. | |
| 785 pub str_lit: bool, | |
| 786 } | |
| == crates/con-ron-core/src/arena/monad.rs#L173-L237 | |
| 173 /// con-leche: ConLeche/Cached/ExprOpsC.lean:206-208 MemoXP | |
| 174 /// Lean twin: `proof/ConRon/Arena/Monad.lean:63-107 Memos` — the memo tables of | |
| 175 /// the `ExprOps` twins, in one record. | |
| 176 /// | |
| 177 /// con-leche's cached walks thread each memo through the walk as an | |
| 178 /// argument-and-result pair (`instantiate1XP v memo e d`, a `MemoXP`); the | |
| 179 /// arena carries the eight tables in the state instead, which is what lets a | |
| 180 /// `…Fast` entry clear one without its callers seeing it. | |
| 181 /// | |
| 182 /// **Eight tables, one per con-leche `…Go` the arena runs**, because the walks | |
| 183 /// NEST: `instantiateLift`'s `bvar` arm runs `liftLooseBVars`, so a shared | |
| 184 /// table would answer one walk with the other's answers. One of those walks | |
| 185 /// has no cursor (`instLPGo` keys on the node alone); the arena keys it at | |
| 186 /// cursor `0`, so that all six handle-valued tables have one shape. | |
| 187 /// (`resetMetaGo` and `renameConstsGo` had tables here too; the arena runs | |
| 188 /// neither walk, and task #105 removed both; `lowerLooseBVars`' went with | |
| 189 /// the walk, task #119.) | |
| 190 pub struct Memos { | |
| 191 /// `instantiate1` (`ExprOps.lean:80-116`). | |
| 192 pub inst1_c: HashMap<EIdxNat, EIdx>, | |
| 193 /// `instantiateList` (`ExprOps.lean:267-303`). | |
| 194 pub inst_l_c: HashMap<EIdxNat, EIdx>, | |
| 195 /// `liftLooseBVars` (`ExprOps.lean:430-466`). | |
| 196 pub lift_c: HashMap<EIdxNat, EIdx>, | |
| 197 /// `abstract1` (`ExprOps.lean:1789-1833`). | |
| 198 pub abs1_c: HashMap<EIdxNat, EIdx>, | |
| 199 /// `instantiateLift` (`Cached/ExprOpsC.lean:383-414`). | |
| 200 pub inst1_l_c: HashMap<EIdxNat, EIdx>, | |
| 201 /// `instantiateLevelParams` (`ExprOps.lean:2564-2603`), at cursor `0`. | |
| 202 pub inst_lp_c: HashMap<EIdxNat, EIdx>, | |
| 203 /// `bvarBound` (`ExprOps.lean:1368-1392`). | |
| 204 pub bvar_b_c: HashMap<EIdx, u64>, | |
| 205 /// `fvarRange` (`ExprOps.lean:1397-1422`). | |
| 206 pub fvar_b_c: HashMap<EIdx, u64>, | |
| 207 /// con-leche: none — arena infrastructure (task #97-P6-13) | |
| 208 /// **The level substitution at a LEVEL handle**, for `instLPGo`'s `.sort` | |
| 209 /// arm: `ks` and `us` are fixed for the whole `instLPFast` call, so the | |
| 210 /// handle alone is the key — DESIGN.md §8.3's own idiom, "cleared at every | |
| 211 /// top-level call, so the substitution vector is not in the key". A hit | |
| 212 /// is one `u32`, where a miss reads the level back, substitutes and | |
| 213 /// re-interns. | |
| 214 pub inst_lp_l_c: HashMap<LIdx, LIdx>, | |
| 215 /// con-leche: none — arena infrastructure (task #97-P6-13) | |
| 216 /// The same at a universe-argument LIST handle, for the `.const` arm. | |
| 217 pub inst_lp_ls_c: HashMap<LsIdx, LsIdx>, | |
| 218 /// con-leche: none — arena infrastructure (task #97-PERF-WALKMEMO) | |
| 219 /// **The two guard walks' memos, kept for their ALLOCATION only.** | |
| 220 /// `allLevelParamsDefinedGo` and `constsResolveFGo` thread their memo as | |
| 221 /// an argument (the twin's `(Bool, memo)` result), starting from `∅` at | |
| 222 /// every entry; the port parks the table here between calls so that the | |
| 223 /// next call starts from a cleared table instead of a `HashMap::new()` | |
| 224 /// that re-grows by doubling (task #97-PERF-FRESH §3 item 1). The entry | |
| 225 /// moves it out, resets it (`arena::core_state::take_walk_memo`, which is | |
| 226 /// the twin's `∅`) and puts it back after the walk, so nothing ever reads | |
| 227 /// a row a previous call left; the twin's `Memos` has no counterpart, and | |
| 228 /// Theorem 2's `MemosRel` has no clause for either (only `MemosInv`'s | |
| 229 /// `Inv`). `all_level_params_defined`'s table. | |
| 230 pub lp_def_c: HashMap<EIdx, bool>, | |
| 231 /// con-leche: none — arena infrastructure (task #97-PERF-WALKMEMO) | |
| 232 /// `consts_resolve_f_fast`'s table; see `lp_def_c`. | |
| 233 pub crf_c: HashMap<EIdx, bool>, | |
| 234 /// con-leche: none — arena infrastructure (task #97-PERF-WALKMEMO) | |
| 235 /// `has_loose_bvar_in`'s table; see `lp_def_c`. | |
| 236 pub hlbi_c: HashMap<EIdxNat, bool>, | |
| 237 } | |
| == crates/con-ron-core/src/arena/expr_ops.rs#L35-L49 | |
| 35 //! | |
| 36 //! ## The cutoffs (DESIGN.md §8.3 lesson 20) | |
| 37 //! | |
| 38 //! | walk | cutoff | con-leche's licence | | |
| 39 //! |---|---|---| | |
| 40 //! | `instantiate1_go` | `bvarBRaw < satRange && bvarBRaw <= d` | task #97s's `instantiate1_of_bvarBound_le` | | |
| 41 //! | `abstract1_go` | `fvarB <= d` | `abstract1_of_fvarRange_le` | | |
| 42 //! | `instantiate_lift_go` | `bvarB <= d` | `instantiateLift_of_bvarBound_le` | | |
| 43 //! | `inst_lp_go` | `hasLP = false` | `Expr.instantiateLevelParams_eq_self` | | |
| 44 //! | |
| 45 //! `instantiate1`'s is the one cutoff con-leche does NOT have; DESIGN.md §8.3 | |
| 46 //! asks for it by name and the twin takes it, so the port takes it too. | |
| 47 //! `instantiate_list` and `lift_loose_bvars` have none, here as there: a | |
| 48 //! cutoff the original does not have needs its own licence proved. | |
| 49 //! | |
| == crates/con-ron-core/src/arena/core_state.rs#L466-L513 | |
| 466 /// con-leche: none — arena infrastructure (task #97-PERF-WALKMEMO) | |
| 467 /// The slot count past which `take_walk_memo` hands back a FRESH table | |
| 468 /// instead of a cleared one; see its note for how the value was chosen. | |
| 469 pub const WALK_MEMO_KEEP: usize = 1 << 16; | |
| 470 | |
| 471 /// con-leche: ConLeche/Cached/ExprOpsC.lean:2409-2413 allLevelParamsDefinedC | |
| 472 /// con-leche: ConLeche/Cached/StateC.lean:666-668 constsResolveFC | |
| 473 /// Lean twin: the `∅` that `proof/ConRon/Arena/CheckerBase.lean`'s | |
| 474 /// `allLevelParamsDefined` and `constsResolveFFast` start their walk from — | |
| 475 /// **the parked walk memo, moved out of the state and emptied** (task | |
| 476 /// #97-PERF-WALKMEMO). The slot is left holding `HashMap::new()` (which | |
| 477 /// allocates nothing) for the length of the walk, and the entry puts the | |
| 478 /// grown table back afterwards; either way the table this returns is empty, | |
| 479 /// so the walk starts where the twin's does. | |
| 480 /// | |
| 481 /// **nanoda's guard** (`nanoda_lib/src/expr.rs`, `inst`): a table past | |
| 482 /// `WALK_MEMO_KEEP` slots is dropped rather than kept, so that one huge walk | |
| 483 /// does not leave a huge table behind for every later call. `reset_map`'s | |
| 484 /// `clear_fit` already decays such a table, one eighth of its high-water mark | |
| 485 /// a call, so the guard only decides which of the two is cheaper for an | |
| 486 /// outlier: re-growing from nothing, or `clear_fit`'s re-make at the decayed | |
| 487 /// size. The threshold, measured on `Init` (`--verified --jobs=1`, one | |
| 488 /// `perf stat -e instructions:u` run each, all accepting 57 977): | |
| 489 /// | |
| 490 /// | `WALK_MEMO_KEEP` | instructions:u | | |
| 491 /// |---|---:| | |
| 492 /// | fresh `HashMap::new()` per call (before) | 211 976 016 505 | | |
| 493 /// | 2^10 slots (nanoda's 1024) | 208 379 555 799 | | |
| 494 /// | 2^12 | 206 572 063 910 | | |
| 495 /// | 2^14 | 205 851 105 938 | | |
| 496 /// | **2^16** | **205 785 515 243** | | |
| 497 /// | no guard (2^60) | 205 783 023 575 | | |
| 498 /// | |
| 499 /// A guard low enough to trip on ordinary calls gives the saving back — at | |
| 500 /// nanoda's 1024 more than half of it — because those calls re-grow by | |
| 501 /// doubling, which is exactly the cost this table exists to avoid. 2^16 is | |
| 502 /// the smallest power tried that costs nothing measurable on `Init` (2.5 M | |
| 503 /// instructions over no guard), so it only ever fires on an outlier. | |
| 504 pub fn take_walk_memo<K, V>(slot: &mut HashMap<K, V>) -> HashMap<K, V> { | |
| 505 let m: HashMap<K, V> = core::mem::replace(slot, HashMap::new()); | |
| 506 if m.capacity() > WALK_MEMO_KEEP { | |
| 507 HashMap::new() | |
| 508 } else { | |
| 509 let mut m2: HashMap<K, V> = m; | |
| 510 reset_map(&mut m2); | |
| 511 m2 | |
| 512 } | |
| 513 } | |
| == crates/con-ron-core/src/arena/core_state.rs#L315-L377 | |
| 315 /// con-leche: ConLeche/Cached/StateC.lean:256-298 CState | |
| 316 /// Lean twin: `proof/ConRon/Arena/CoreState.lean:77-132 Caches` — the | |
| 317 /// per-declaration caches of the arena checker, in one record beside | |
| 318 /// `arena::monad`'s per-call `Memos`. Keeping the two apart is deliberate: | |
| 319 /// the per-call clear and the per-declaration drop are different operations | |
| 320 /// on different lifetimes. | |
| 321 pub struct Caches { | |
| 322 /// `whnfCore` at the node (con-leche `CState.whnfCoreC`). The depth is | |
| 323 /// NOT in the key: a handle carries its own typing context, because an | |
| 324 /// `fvar` node carries its type (DESIGN.md §8.3, "Free variables"). | |
| 325 pub whnf_core_c: HashMap<EIdx, EIdx>, | |
| 326 /// `whnfCore` at the node in the CHEAP-projection mode (con-leche | |
| 327 /// `CState.whnfCoreCheapC`, official `cheap_proj`): a separate table, | |
| 328 /// since the two modes' answers differ on a stuck projection. | |
| 329 pub whnf_core_cheap_c: HashMap<EIdx, EIdx>, | |
| 330 /// The full reduction loop at the node (`CState.whnfC`). | |
| 331 pub whnf_c: HashMap<EIdx, EIdx>, | |
| 332 /// Full-grade inference (`CState.inferC`). | |
| 333 pub infer_c: HashMap<EIdx, EIdx>, | |
| 334 /// **The io grade's own table** (`CState.inferIOC`): a hit here never | |
| 335 /// serves a full-`infer` query, and a full-`infer` hit never serves this | |
| 336 /// one. | |
| 337 pub infer_io_c: HashMap<EIdx, EIdx>, | |
| 338 /// Definitional equality at the ORDERED pair, with the verdict — both | |
| 339 /// signs, as con-leche's `defeqC` stores them. | |
| 340 pub defeq_c: HashMap<EIdxPair, bool>, | |
| 341 /// `Level.isEquiv`'s verdict at a pair of level handles. | |
| 342 pub lvl_eq_c: HashMap<LIdxPair, bool>, | |
| 343 /// `Level.isEquivList`'s verdict at a pair of universe-argument lists. | |
| 344 pub lvls_eq_c: HashMap<LsIdxPair, bool>, | |
| 345 /// A stored constant's TYPE at a universe instantiation. | |
| 346 pub const_ty_c: HashMap<NLsKey, EIdx>, | |
| 347 /// A stored definition's VALUE at a universe instantiation. | |
| 348 pub const_val_c: HashMap<NLsKey, EIdx>, | |
| 349 /// An iota rule's body under its `rulePrefix + nfields` λs at the | |
| 350 /// recursor's universe instantiation, keyed by the recursor, the rule's | |
| 351 /// constructor and the levels — the three data that determine it. | |
| 352 pub rule_body_c: HashMap<NNLsKey, EIdx>, | |
| 353 /// con-leche: none — arena infrastructure (task #97-P6-13) | |
| 354 /// **The readback memo DESIGN.md §8.3 promised** and nobody had built: | |
| 355 /// "`Level` ops … run on transient `Level` trees read back from `LIdx` | |
| 356 /// (*memoised readback per declaration*; levels are small)". A level | |
| 357 /// handle's denotation is a function of the handle and of the tier it | |
| 358 /// names, so it is stable for exactly as long as the other tables | |
| 359 /// are, and `Caches::reset` is what makes that true. The value is an | |
| 360 /// `Arc` tree, so a hit is one reference bump where a miss rebuilds the | |
| 361 /// whole tree node by node. | |
| 362 pub read_l_c: HashMap<LIdx, Level>, | |
| 363 /// con-leche: none — arena infrastructure (task #97-P6-13) | |
| 364 /// The same for a NAME handle (`readName`). | |
| 365 pub read_n_c: HashMap<NIdx, Name>, | |
| 366 /// con-leche: none — arena infrastructure (task #97-P6-13) | |
| 367 /// The same for an interned universe-argument LIST (`readLevels`). A hit | |
| 368 /// is one `Vec` allocation and `n` reference bumps. | |
| 369 pub read_ls_c: HashMap<LsIdx, Vec<Level>>, | |
| 370 /// **The eager tower's mode memos** (con-leche `CState.eagerMemos`): the | |
| 371 /// six entry-point tables of the eager tower (the knot at `eager` true, | |
| 372 /// the `defeqE` slot), stored here between eager comparisons and swapped | |
| 373 /// in for each one (`arena::core::enter_eager`). Kept for the declaration | |
| 374 /// like the plain ones, and apart from them: an eager entry never serves a | |
| 375 /// plain query, nor the other way round. | |
| 376 pub eager_memos: ModeMemos, | |
| 377 } | |
| == crates/con-ron-core/src/arena/core.rs#L422-L435 | |
| 422 | |
| 423 // --------------------------------------------------------------------------- | |
| 424 // The lanes: the twin's `r : CoreFnsA`, defunctionalized (the module note) | |
| 425 // --------------------------------------------------------------------------- | |
| 426 | |
| 427 /// con-leche: ConLeche/Kernel/Core.lean:1888-1923 coreKnot | |
| 428 /// Lean twin: `proof/ConRon/Arena/Core.lean:4432-4511 coreKnot` — **the | |
| 429 /// executed knot**: the memoized one, `pureFnsA`'s. | |
| 430 pub const LANE_FULL: u32 = 0; | |
| 431 | |
| 432 /// con-leche: ConLeche/Kernel/CoreIO.lean:44-66 coreKnotIO | |
| 433 /// Lean twin: `proof/ConRon/Arena/CoreIO.lean:34-51 coreKnotIO` — the io knot | |
| 434 /// (the leaf lane): `infer` and `inferIO` are `inferBodyIO` tied to this knot, | |
| 435 /// unmemoized; every other slot is the full knot's. | |
| == crates/con-ron-core/src/ron/hashmap2.rs#L1-L40 | |
| 1 //! con-leche: none — arena infrastructure; a second `Std.HashMap` replacement, proved | |
| 2 //! | |
| 3 //! `ron::HashMap2<K, V>` — proved in `proof/ConRon/Refine/HashMap2.lean` | |
| 4 //! (task #97-HM2; designed in task #97-P6-4b). The same abstract object as | |
| 5 //! `ron::hashmap`'s `HashMap` — a partial map from `K` to `V`, with | |
| 6 //! `Hashable`/`Eq2`/`Dup` as its dictionaries and the same eleven operations | |
| 7 //! — over an **open-addressed, epoch-stamped, flat slot vector** instead of | |
| 8 //! the Aeneas tutorial's chained buckets. `ron::hashmap` is untouched and | |
| 9 //! keeps its proofs (`proof/ConRon/Refine/HashMap.lean`); this module's are | |
| 10 //! in `proof/ConRon/Refine/HashMap2.lean` (task #97-HM2). | |
| 11 //! | |
| 12 //! **Why it exists.** Task #97-P6-1 left `clear_slots + allocate_slots + | |
| 13 //! move_elements*` at 21.8 % of `Init`, "all halving recursions over chained | |
| 14 //! buckets". Task #97-P6-4b counted what those recursions actually do on | |
| 15 //! `Init`, and the counts name the representation rather than the code: | |
| 16 //! | |
| 17 //! | on `Init`, `ron::HashMap` | count | | |
| 18 //! |---|---:| | |
| 19 //! | `get` calls | 1 228 953 968 | | |
| 20 //! | — resolved in 0 or 1 chain step | 98.8 % | | |
| 21 //! | `insert` calls | 627 320 951 | | |
| 22 //! | **`clear` calls** | **36 053 620** | | |
| 23 //! | **— buckets walked by them** | **2 940 488 064** | | |
| 24 //! | — entries those buckets held | 586 917 896 | | |
| 25 //! | buckets pushed by `allocate_slots` | 948 184 512 | | |
| 26 //! | entries moved by `move_elements*` | 349 323 629 | | |
| 27 //! | |
| 28 //! So the chains are *already* short — the table is a good hash table — and | |
| 29 //! essentially all of the 21.8 % is the per-bucket cost of **emptying and | |
| 30 //! re-growing** the slot vector: 2.94 G bucket writes to clear 0.59 G entries | |
| 31 //! (five buckets walked per entry cleared; the average cleared table is 82 | |
| 32 //! buckets holding 16 entries) and 0.95 G `Vec::push`es to allocate them back. | |
| 33 //! Nothing a better chain walk can do touches that. | |
| 34 //! | |
| 35 //! **The representation.** | |
| 36 //! | |
| 37 //! * `slots : Vec<Slot<K, V>>`, `Slot` = `Vacant | Live(u32, K, V)`. No | |
| 38 //! `Box`, no chain, no allocation per entry — an entry *is* a slot. | |
| 39 //! * A `Live` slot is **live only if its stamp is the table's `epoch`**; | |
| 40 //! a `Live` slot with a stale stamp is free space, indistinguishable from | |
| == crates/con-ron-core/src/driver/check_main.rs#L451-L525 | |
| 451 pub fn check_main<I: CheckerIo>(io: &mut I, a: &Args, file: &Vec<u32>) -> u8 { | |
| 452 let verified = a.verified; | |
| 453 let mode = if verified { CheckMode::Verified } else { CheckMode::Trusted }; | |
| 454 let mut st = AState::empty(); | |
| 455 let pers = PersTier::empty(); | |
| 456 // ConRon.MainTheorem.Stages: h1 | |
| 457 match pins::intern_reserved_pins(&pers, &mut st) { | |
| 458 Err(e) => { | |
| 459 io.note(&Note::ReservedPins(e, verified)); | |
| 460 return 3; | |
| 461 } | |
| 462 Ok(()) => (), | |
| 463 } | |
| 464 io.read_starts(&a.progress, file); | |
| 465 // ConRon.MainTheorem.Stages: h2 | |
| 466 let prelude_ix = match prelude::builtin_prelude_e(&pers, &mut st) { | |
| 467 Err((e, line)) => { | |
| 468 io.note(&Note::Prelude(e, line, verified)); | |
| 469 return 3; | |
| 470 } | |
| 471 Ok(p) => p, | |
| 472 }; | |
| 473 // ConRon.MainTheorem.Stages: hreads, h3 | |
| 474 let (read, err) = { | |
| 475 let mut src = FileChunks { fs: &*io, path: file, off: 0, reads: 0, err: None }; | |
| 476 let read = export_c::parse_source(&pers, &mut st, &mut src); | |
| 477 (read, src.err) | |
| 478 }; | |
| 479 match err { | |
| 480 Some(m) => { | |
| 481 io.note(&Note::ReadFailed(str_copy(file), m)); | |
| 482 return 3; | |
| 483 } | |
| 484 None => (), | |
| 485 } | |
| 486 let parsed = match read { | |
| 487 Err((e, line)) => { | |
| 488 let c = exit_code(&e); | |
| 489 io.note(&Note::Parse(e, line, str_copy(file), verified)); | |
| 490 return c; | |
| 491 } | |
| 492 Ok(p) => p, | |
| 493 }; | |
| 494 let file_records = parsed.decls.len(); | |
| 495 // ConRon.MainTheorem.Stages: h4 | |
| 496 let prepared = match prepare::prepare_d(&pers, &mut st, prelude_ix, parsed.decls, &DeclUsedConsts) { | |
| 497 Err(e) => { | |
| 498 let c = exit_code(&e); | |
| 499 io.note(&Note::Frontend(e, verified)); | |
| 500 return c; | |
| 501 } | |
| 502 Ok(p) => p, | |
| 503 }; | |
| 504 if prepared.hoisted.len() > 0 { | |
| 505 io.hoisted(&pers, &st.store, &prepared.hoisted); | |
| 506 } | |
| 507 // ConRon.MainTheorem.Stages: hpins | |
| 508 let pins: Vec<NatOpPinSet> = match embedded_pins(&*io) { | |
| 509 None => return 3, | |
| 510 Some(ps) => ps, | |
| 511 }; | |
| 512 // ConRon.MainTheorem.Stages: h5 | |
| 513 let ipins = match checker::intern_all_pins(&pers, &mut st, &pins, &a.max_nat_size) { | |
| 514 Err(e) => { | |
| 515 let c = exit_code(&e); | |
| 516 io.note(&Note::Frontend(e, verified)); | |
| 517 return c; | |
| 518 } | |
| 519 Ok(p) => p, | |
| 520 }; | |
| 521 let jobs: u64 = jobs_for_run(io, a); | |
| 522 // ConRon.MainTheorem.Stages: h6, h7, h8 | |
| 523 let verdict = check_phase(io, &pers, &mut st, &mode, &ipins, None, &prepared.decls, jobs, file_records, prepared.synthesised); | |
| 524 verdict_of(io, &pers, st, prepared.decls, verdict, file_records, verified) | |
| 525 } | |
| == crates/con-ron-core/src/arena/pins.rs#L1-L60 | |
| 1 //! `arena::pins` — the reserved names, interned ONCE (task #97-P6-4a). | |
| 2 //! | |
| 3 //! con-leche compares its reserved names — `natName`, `natZeroName`, | |
| 4 //! `natSuccName`, the sixteen `Nat`-operation names, the `Bool` trio, the | |
| 5 //! `String`/`List`/`Char` family, the standard and the trusted axiom names — | |
| 6 //! as `Name` VALUES, which Lean builds once per nullary `def` and caches. | |
| 7 //! The arena compares them as HANDLES, so `arena::core::pin` turned each one | |
| 8 //! into `intern_name` of a freshly built `Name`: a `code_points` allocation | |
| 9 //! and an `Arc<NameNode>` per path segment, then one cons-table probe per | |
| 10 //! segment, every time. Task #97-P6-1's counter measured what that costs on | |
| 11 //! `Init`: **140 083 646 `NStore::intern` calls, of which 88 854 033 are | |
| 12 //! probes of a `str` node built purely to be compared and dropped** — tens of | |
| 13 //! millions of rebuilds of about forty constants, in `natLitSupported`'s | |
| 14 //! three probes per literal, in `natOpNames`, in `strLitToConstructor`. | |
| 15 //! | |
| 16 //! This module is DESIGN.md's answer, flagged at task #97c ("the `Pins` | |
| 17 //! record that is NOT here") and deferred there for want of a number: one | |
| 18 //! record, filled once at the driver by `intern_reserved_pins`, and every | |
| 19 //! `pin` of a constant name becomes a field read. | |
| 20 //! | |
| 21 //! **Not `arena::checker`'s `intern_all_pins`.** That one walks the | |
| 22 //! pin list (the embedded one, decoded) into the persistent tier; this one | |
| 23 //! interns the checker's own reserved constants. The two run at the same | |
| 24 //! point of the pipeline and mean different things, which is why they have | |
| 25 //! different names. | |
| 26 //! | |
| 27 //! ## The table is a `Vec`, and that is what kills task #97c's hazard | |
| 28 //! | |
| 29 //! Task #97c declined the record because of an initialisation-order hazard: | |
| 30 //! "a pin read before it is filled compares against the zero word and | |
| 31 //! silently says *not `Nat`*". A record of handle FIELDS has that hazard, | |
| 32 //! because every 32-bit word is a syntactically valid handle. A `Vec<NIdx>` | |
| 33 //! does not: before `intern_reserved_pins` runs the table is EMPTY, so `pin_at` | |
| 34 //! takes its bounds branch and raises `CheckError::Internal` — a loud stop, | |
| 35 //! never a quiet wrong answer. The cost is one `len` compare per read, | |
| 36 //! against an interning walk it replaces. | |
| 37 //! | |
| 38 //! ## What is pinned | |
| 39 //! | |
| 40 //! The fifty-two names below and `basis_names::reserved_basis_names()`'s | |
| 41 //! sixteen, plus the three interned values every `pin` site around them | |
| 42 //! needs: the empty universe-argument list, the level `0` and the expression | |
| 43 //! `Sort 1` (`arena::core`'s `empty_levels`, `zero_level` and `sort_one`, | |
| 44 //! which now read this record instead of interning). | |
| 45 //! | |
| 46 //! All of them go into the PERSISTENT tier, because `intern_reserved_pins` runs | |
| 47 //! before the parse, while the scratch tier is closed. That matters twice: | |
| 48 //! a pinned handle must survive every `drop_scratch` (it is read across all | |
| 49 //! of them), and task #97-P6-1's `pers_find_maybe` rests on "a persistent | |
| 50 //! node's children are persistent", which the bottom-up intern of a closed | |
| 51 //! scratch tier gives for free. | |
| 52 //! | |
| 53 //! **Denotation unchanged.** A pin is `intern_name` of the same `Name`, so | |
| 54 //! the handle this record holds is the handle `pin` computed before — | |
| 55 //! `denoteN` is injective and `intern` is idempotent, so pre-interning a name | |
| 56 //! the export also carries hands the export's parse the very same handle. | |
| 57 //! What changes is only WHEN the intern happens, and how many times. | |
| 58 //! | |
| 59 //! Lean twin: `proof/ConRon/Arena/Monad.lean:118-135 AState` (DESIGN.md §8.6's | |
| 60 //! twin ledger, task #97-P6-4a) — `AState` gains a `pins : Pins` field and | |
| == crates/con-ron-core/src/frontend/prepare.rs#L1-L50 | |
| 1 //! `proof/ConRon/Arena/Frontend/Prepare.lean` — **what happens between the | |
| 2 //! file and the fold** (task #97 P4e part 1). | |
| 3 //! | |
| 4 //! `prepare_prelude` is total — no record of the stream is dropped, rewritten | |
| 5 //! or retagged — and it does two things: | |
| 6 //! | |
| 7 //! 1. **the prelude's declarations first**, the stream's OWN copy of each | |
| 8 //! where the stream has one and a synthesised one only where it has none, | |
| 9 //! so a stream that declares the toolchain's `Bool` is checked on its own | |
| 10 //! `Bool` record; | |
| 11 //! 2. **the ground hoist**: a pinned `Nat` operation's stream-certified | |
| 12 //! structural ground is moved ahead of it when the stream declares it | |
| 13 //! later. | |
| 14 //! | |
| 15 //! Moving a record earlier can only reject, never accept, which is why the | |
| 16 //! spec con-leche proves is as simple as it is: | |
| 17 //! | |
| 18 //! ```text | |
| 19 //! ∃ extra, (∀ d ∈ extra, d ∈ prelude) ∧ | |
| 20 //! (preparePrelude ds).toList.Perm (ds.toList ++ extra) | |
| 21 //! ``` | |
| 22 //! | |
| 23 //! **Step 2 is `frontend::nat_op_ground`'s**, a module of its own exactly as | |
| 24 //! con-leche's is (task #97-P4d; task #97-P4e part 1 shipped an identity | |
| 25 //! placeholder here, because the pass needs the kernel's | |
| 26 //! `natOpNames`/`natDivModNames`, which arrived with the pins). It is why | |
| 27 //! `prepare_d` takes the whole `AState` where everything else in this module | |
| 28 //! needs only the store. | |
| 29 //! | |
| 30 //! **Where the store comes from.** Only `prelude_key`, whose `.anonymous` | |
| 31 //! fall-through has to be INTERNED, and the two functions that call it; | |
| 32 //! [`pick_idx`] and [`declares`] are pure, exactly as con-leche's are, because | |
| 33 //! `env::i_declaration_names` is. | |
| 34 //! Nothing in this module reads or writes a term. | |
| 35 //! | |
| 36 //! **The deviation of the port into the verified core** (task #84), kept | |
| 37 //! verbatim from `con_ron_core::frontend::prepare`: con-leche's `pick` ERASES | |
| 38 //! the picked record from the array (`Array.eraseIdxIfInBounds`) and `frontOf` | |
| 39 //! moves it to the front. The Aeneas subset has no operation that takes an | |
| 40 //! element out of a `Vec` — no `remove`, no `pop`, no `into_iter` — so the | |
| 41 //! port splits the two halves that con-leche fuses: [`pick_idx`] is the cited | |
| 42 //! `ds.findIdx (declares n)` with the erasure recorded in a `picked` mask | |
| 43 //! instead of performed, [`front_of`] runs that over the prelude, and | |
| 44 //! [`prepared_stream`] materialises the whole prepared list in ONE pass. The | |
| 45 //! list that comes out is the same list; the cost is one record copy per | |
| 46 //! record, where the copied fields are handles and `Vec` spines and not terms. | |
| 47 //! con-leche's `pickSpec`/`frontSpec` are not ported (they are `cons`-list | |
| 48 //! specifications with no caller on the run path); `pick_spec` lives in this | |
| 49 //! module's tests, where it still checks `pick_idx` against the specification | |
| 50 //! on every `cargo test`. | |
| == crates/con-ron-core/src/arena/checker.rs#L166-L201 | |
| 166 // --------------------------------------------------------------------------- | |
| 167 | |
| 168 /// con-leche: ConLeche/Kernel/NatOpPins.lean:77-81 _ | |
| 169 /// con-leche: ConLeche/Kernel/Basis.lean:39-45 BasisKind.decls | |
| 170 /// Lean twin: `proof/ConRon/Arena/Checker.lean:130-168 internAllPins` — **the | |
| 171 /// one-time tree walk of DESIGN.md §8.6 P2d**: every datum the checker compares | |
| 172 /// a stream record against, interned into the tier that is live at the call — | |
| 173 /// which, at the driver's call, is the persistent one. | |
| 174 /// | |
| 175 /// The five basis blocks' pins (what a basis block's and a quotient record's | |
| 176 /// job compares the record with), the standard and compiler-trust axiom pins, the reserved names | |
| 177 /// the guards compare by handle, and the `Nat`-operation pin variants, whose | |
| 178 /// interned form is the checker's pin-list parameter (con-leche's task #304). | |
| 179 /// First, the run's maximum `Nat` size goes into the pin record | |
| 180 /// (`Pins::max_nat_size`): con-leche threads it beside the pin list | |
| 181 /// (`checkDecls mode pins maxNatSize`) into every declaration's fresh state | |
| 182 /// (`{ maxNatSize := maxNatSize }`, `Cached.declStep`, `Cached.recordJob`); here | |
| 183 /// every worker copies it with the pins (`worker_state`) and no job writes it. | |
| 184 /// It is stored normalised (`nat::norm`), whatever limbs the caller hands in, | |
| 185 /// so every comparison against it reads it as the number it denotes. | |
| 186 pub fn intern_all_pins( | |
| 187 pers: &PersTier, | |
| 188 st: &mut AState, | |
| 189 pins: &Vec<NatOpPinSet>, | |
| 190 max_nat_size: &Nat, | |
| 191 ) -> Result<Vec<INatOpPinSet>, CheckError> { | |
| 192 st.pins.max_nat_size = nat::norm(nat::clone(max_nat_size).limbs); | |
| 193 match intern_all_basis(pers, st, 0) { | |
| 194 Err(e) => Err(e), | |
| 195 Ok(()) => match intern_all_axiom_pins(pers, st) { | |
| 196 Err(e) => Err(e), | |
| 197 Ok(()) => match intern_all_names(st) { | |
| 198 Err(e) => Err(e), | |
| 199 Ok(()) => intern_pin_sets(pers, st, pins, 0, Vec::new()), | |
| 200 }, | |
| 201 }, | |
| == crates/con-ron-core/src/kernel/pins_text.rs#L40-L44 | |
| 40 pub const PINS_TEXT: &str = "\ | |
| 41 con-ron-pins/2 | |
| 42 E 0 n 0 | |
| 43 N 0 a | |
| 44 N 1 s 0 12 instOfNatNat | |
| == crates/con-ron-core/src/kernel/pins_decode.rs#L1336-L1356 | |
| 1336 /// in file order — which is the order `arena::decl_check::check_div_mod_pin_loop` tries | |
| 1337 /// them in, and therefore the order the list has to be in. | |
| 1338 pub fn decode(t: &[u8]) -> CheckM<Vec<NatOpPinSet>> { | |
| 1339 let hdr = pins_header(); | |
| 1340 if !starts_with_from(t, &hdr, 0) { | |
| 1341 Err(bad_text()) | |
| 1342 } else { | |
| 1343 run_records(t, hdr.len(), tables_new()) | |
| 1344 } | |
| 1345 } | |
| 1346 | |
| 1347 /// con-leche: ConLeche/Kernel/NatOpPins.lean:77-81 _ | |
| 1348 /// (The cited range is the `#load_natop_pins` command that *produces* | |
| 1349 /// `natOpPinSets` while `NatOpPins.lean` elaborates; the declaration is not | |
| 1350 /// written there, hence the `_`.) | |
| 1351 /// **The pin list the binary checks with**: the embedded text, decoded. This | |
| 1352 /// is the pin list of every run (`driver::check_main::embedded_pins`), and the | |
| 1353 /// staged `_embedded` lemmas (`proof/ConRon/MainTheorem/Stages.lean`) take its output as | |
| 1354 /// their pin premise. | |
| 1355 pub fn decode_embedded() -> CheckM<Vec<NatOpPinSet>> { | |
| 1356 decode(PINS_TEXT.as_bytes()) | |
| == crates/con-ron-core/src/frontend/mod.rs#L19-L30 | |
| 19 //! | Rust | Lean twin | con-leche | | |
| 20 //! |---|---|---| | |
| 21 //! | `text` | none | none — the port's message rendering (`String` is `Vec<u32>`) | | |
| 22 //! | `nat_decimal` | none | none — `String.toNat?` on a `natVal` literal (`ron::nat` has no decimal codec) | | |
| 23 //! | `scan_types` | imported, not twinned | `ConLeche/Frontend/Scan/Types.lean` | | |
| 24 //! | `scan_fast` | imported, not twinned | `ConLeche/Frontend/Scan/Fast.lean` (the `@[csimp]` twin the compiler *runs*; `Scan/Naive.lean` is the specification and is not ported) | | |
| 25 //! | `prelude_text` | `include_str` | `ConLeche/Frontend/Prelude.lean:57-62`'s `include_str` — **generated**, `scripts/gen-prelude.sh` | | |
| 26 //! | `types` | `Arena/Frontend/Types.lean` | `Frontend/Export.lean`'s verdicts | | |
| 27 //! | `export_c` | `Arena/Frontend/ExportC.lean` | `Frontend/ExportC.lean` | | |
| 28 //! | `nat_op_ground` | `Arena/Frontend/NatOpGround.lean` | `Frontend/NatOpGround.lean` | | |
| 29 //! | `prepare` | `Arena/Frontend/Prepare.lean` | `Frontend/Prepare.lean` | | |
| 30 //! | `prelude` | `Arena/Frontend/Prelude.lean` | `Frontend/Prelude.lean` | | |
| == crates/con-ron-core/src/frontend/checker_io.rs#L286-L323 | |
| 286 pub struct FileChunks<'a, F: CheckerFs> { | |
| 287 /// the file operations | |
| 288 pub fs: &'a F, | |
| 289 /// the file | |
| 290 pub path: &'a Vec<u32>, | |
| 291 /// where the next read starts: the bytes handed out so far | |
| 292 pub off: u64, | |
| 293 /// the reads that answered so far: a `usize`, so that the chunks they | |
| 294 /// handed out are a list a `usize` indexes (`Vec<Vec<u8>>`, the form the | |
| 295 /// staged lemmas' `parse_chunks` is stated over) on every platform | |
| 296 pub reads: usize, | |
| 297 /// the first read failure, if any | |
| 298 pub err: Option<Vec<u32>>, | |
| 299 } | |
| 300 | |
| 301 /// con-leche: ConLeche/Frontend/CheckerIO.lean:210-218 foldChunks | |
| 302 impl<'a, F: CheckerFs> ChunkSource for FileChunks<'a, F> { | |
| 303 /// con-leche: ConLeche/Frontend/CheckerIO.lean:210-218 foldChunks | |
| 304 /// One read of up to `CHUNK_SIZE` bytes at the offset; empty at the end or | |
| 305 /// on a failure, and empty for good after a failure. | |
| 306 fn next_chunk(&mut self) -> Vec<u8> { | |
| 307 match &self.err { | |
| 308 Some(_) => return Vec::new(), | |
| 309 None => (), | |
| 310 } | |
| 311 match self.fs.read_range(self.path, self.off, CHUNK_SIZE as u64) { | |
| 312 Ok(b) => { | |
| 313 self.off = self.off + (b.len() as u64); | |
| 314 self.reads = self.reads + 1; | |
| 315 b | |
| 316 } | |
| 317 Err(e) => { | |
| 318 self.err = Some(e); | |
| 319 Vec::new() | |
| 320 } | |
| 321 } | |
| 322 } | |
| 323 } | |
| == crates/con-ron-core/src/arena/stream_index.rs#L178-L216 | |
| 178 /// con-leche: ConLeche/Cached/StreamIndex.lean:64-66 buildIndex | |
| 179 /// con-leche: ConLeche/Driver/CheckPool.lean:57-75 Jobs.build | |
| 180 /// Lean twin: `proof/ConRon/Arena/StreamIndex.lean:102-105 buildIndex` — **the frozen | |
| 181 /// index of a stream**, the records folded in order from `i` on and the index | |
| 182 /// frozen past the last (`stream_index_freeze`, con-leche's `Jobs.build`). An | |
| 183 /// `Err` is the store's own failure (a term the install builds could not be | |
| 184 /// interned) or an unfilled pin table, never a verdict about the stream; it | |
| 185 /// carries the position of the record whose reading failed (past the last for | |
| 186 /// the freeze), for the error line. A solution's index (con-leche's `Jobs.side`) is the same build over the solution's records (`justify::solution_of`). | |
| 187 /// | |
| 188 /// **A loop**, one iteration per record: the cited `foldlM` is a loop in Lean, | |
| 189 /// and Rust does not promise to eliminate the tail call (a solution of 1.47 M | |
| 190 /// records overflowed a 1 GiB stack, task #167). Every exit is a `return`, so | |
| 191 /// the extracted `build_index_loop` is the recursion one for one. | |
| 192 pub fn build_index( | |
| 193 pers: &PersTier, | |
| 194 st: &mut AState, | |
| 195 ix: IStreamIndex, | |
| 196 ds: &Vec<IDeclaration>, | |
| 197 i: usize, | |
| 198 ) -> Result<IStreamIndex, (CheckError, u64)> { | |
| 199 let mut ix: IStreamIndex = ix; | |
| 200 let mut i: usize = i; | |
| 201 loop { | |
| 202 if i >= ds.len() { | |
| 203 return match stream_index_freeze(st, ix) { | |
| 204 Err(e) => Err((e, i as u64)), | |
| 205 Ok(fx) => Ok(fx), | |
| 206 }; | |
| 207 } | |
| 208 match stream_index_add(pers, st, ix, &ds[i]) { | |
| 209 Err(e) => return Err((e, i as u64)), | |
| 210 Ok(ix2) => { | |
| 211 ix = ix2; | |
| 212 i = i + 1; | |
| 213 } | |
| 214 } | |
| 215 } | |
| 216 } | |
| == crates/con-ron-core/src/arena/install.rs#L362-L399 | |
| 362 /// con-leche: ConLeche/Kernel/Install.lean:77-91 declConstants | |
| 363 /// con-leche: ConLeche/Cached/CheckerC.lean:104-118 declConstantsC | |
| 364 /// **The constants a declaration installs**, in push order. A block | |
| 365 /// `readBlock` cannot read installs nothing (its check rejects it), and | |
| 366 /// `sorryAx` nothing (any use of it declines). | |
| 367 pub fn decl_constants(pers: &PersTier, st: &mut AState, pd: &IDeclaration) -> Result<Vec<IConstantInfo>, CheckError> { | |
| 368 match pd { | |
| 369 IDeclaration::DefnDecl(cv, value, hint) => { | |
| 370 let mut o: Vec<IConstantInfo> = Vec::new(); | |
| 371 o.push(IConstantInfo::DefnInfo(env::i_constant_val_dup(cv), value.dup2(), reducibility_hint_dup(hint))); | |
| 372 Ok(o) | |
| 373 } | |
| 374 IDeclaration::ThmDecl(cv, _) => { | |
| 375 let mut o: Vec<IConstantInfo> = Vec::new(); | |
| 376 o.push(IConstantInfo::ThmInfo(env::i_constant_val_dup(cv))); | |
| 377 Ok(o) | |
| 378 } | |
| 379 IDeclaration::OpaqueDecl(cv, _) => { | |
| 380 let mut o: Vec<IConstantInfo> = Vec::new(); | |
| 381 o.push(IConstantInfo::AxiomInfo(env::i_constant_val_dup(cv))); | |
| 382 Ok(o) | |
| 383 } | |
| 384 IDeclaration::AxiomDecl(cv) => decl_constants_axiom(pers, st, cv), | |
| 385 IDeclaration::QuotDecl(k, cv) => match basis::quot_at(pers, st, k, cv) { | |
| 386 Err(e) => Err(e), | |
| 387 Ok(ci) => { | |
| 388 let mut o: Vec<IConstantInfo> = Vec::new(); | |
| 389 o.push(ci); | |
| 390 Ok(o) | |
| 391 } | |
| 392 }, | |
| 393 IDeclaration::IndDecl(block, n_p) => match block_shape::read_block(pers, st, *n_p, block) { | |
| 394 Err(e) => Err(e), | |
| 395 Ok(Ok(p)) => block_constants(pers, st, &p), | |
| 396 Ok(Err(_)) => Ok(Vec::new()), | |
| 397 }, | |
| 398 } | |
| 399 } | |
| == crates/con-ron-core/src/arena/stream_index.rs#L276-L294 | |
| 276 } | |
| 277 | |
| 278 /// con-leche: ConLeche/Cached/StreamIndex.lean:95-103 recordJob | |
| 279 /// Lean twin: `proof/ConRon/Arena/Justify.lean:333-341 recordJob` — **record `pd`'s | |
| 280 /// job, at position `k`**, with the solution `sol` if any: `record_check` from | |
| 281 /// fresh caches and an empty scratch tier (`enter_record`, the cited | |
| 282 /// `checkDeclStepC`'s fresh `{}`), the tier emptied again after it on both | |
| 283 /// paths. Nothing the job builds outlives it: the layer and the tier go. | |
| 284 pub fn record_job( | |
| 285 pers: &PersTier, | |
| 286 st: &mut AState, | |
| 287 mode: &CheckMode, | |
| 288 pins: &Vec<INatOpPinSet>, | |
| 289 sol: Option<&Solution>, | |
| 290 k: u64, | |
| 291 pd: &IDeclaration, | |
| 292 ) -> Result<(), CheckError> { | |
| 293 enter_record(st); | |
| 294 let r: Result<(), CheckError> = record_check(pers, st, mode, pins, sol, k, pd); | |
| == crates/con-ron-core/src/driver/check_main.rs#L177-L222 | |
| 177 pub fn olean_job<F: CheckerFs>( | |
| 178 fs: &F, | |
| 179 tier: &PersTier, | |
| 180 w: &mut AState, | |
| 181 cache: &mut ValueCache, | |
| 182 mode: &CheckMode, | |
| 183 pins: &Vec<INatOpPinSet>, | |
| 184 ds: &Vec<IDeclaration>, | |
| 185 pk: &OleanPins, | |
| 186 values: &Vec<ModRef>, | |
| 187 sp: &Roots, | |
| 188 sol: Option<&Solution>, | |
| 189 k: usize, | |
| 190 ) -> Result<(), (CheckError, u64)> { | |
| 191 let ku = k as u64; | |
| 192 if k >= ds.len() { | |
| 193 return checker::run_job(tier, w, mode, pins, sol, ds, ku); | |
| 194 } | |
| 195 match &ds[k] { | |
| 196 IDeclaration::ThmDecl(cv, v) => { | |
| 197 // a theorem's value is a reference only if its handle is a `bvar`: the | |
| 198 // store's projection reads the bvar table at the handle's slot whatever | |
| 199 // its tag | |
| 200 let code: Option<u64> = if v.tag() == ETAG_BVAR { w.store.view_bvar(tier, v) } else { None }; | |
| 201 match code { | |
| 202 None => checker::run_job(tier, w, mode, pins, sol, ds, ku), | |
| 203 Some(code) => { | |
| 204 enter_record(w); | |
| 205 let r = match records::read_value(fs, pk, tier, &mut w.store, sp, values, cache, code) { | |
| 206 Err(e) => Err((e, ku)), | |
| 207 Ok(v) => { | |
| 208 let pd = IDeclaration::ThmDecl(env::i_constant_val_dup(cv), v); | |
| 209 match stream_index::record_check(tier, w, mode, pins, sol, ku, &pd) { | |
| 210 Err(e) => Err((e, ku)), | |
| 211 Ok(()) => Ok(()), | |
| 212 } | |
| 213 } | |
| 214 }; | |
| 215 leave_record(w); | |
| 216 r | |
| 217 } | |
| 218 } | |
| 219 } | |
| 220 _ => checker::run_job(tier, w, mode, pins, sol, ds, ku), | |
| 221 } | |
| 222 } | |
| == crates/con-ron-core/src/driver/check_main.rs#L308-L345 | |
| 308 pub fn check_phase<I: CheckerIo>( | |
| 309 io: &mut I, | |
| 310 pers: &PersTier, | |
| 311 st: &mut AState, | |
| 312 mode: &CheckMode, | |
| 313 ipins: &Vec<INatOpPinSet>, | |
| 314 sol: Option<&Solution>, | |
| 315 ds: &Vec<IDeclaration>, | |
| 316 jobs: u64, | |
| 317 file_records: usize, | |
| 318 synthesised: u64, | |
| 319 ) -> Result<IStreamIndex, (CheckError, u64)> { | |
| 320 io.index_starts(); | |
| 321 let ix = match stream_index::build_index(pers, st, stream_index::stream_index_empty(), ds, 0) { | |
| 322 Err(e) => return Err(e), | |
| 323 Ok(ix) => ix, | |
| 324 }; | |
| 325 io.parse_done(pers, &st.store, ds.len(), file_records, synthesised); | |
| 326 let n = ds.len(); | |
| 327 let workers = workers_for(jobs, n); | |
| 328 io.check_starts(n, workers); | |
| 329 let tier: PersTier = checker::freeze_tier(&mut st.store, ix); | |
| 330 let r = { | |
| 331 let step = JobStep { tier: &tier, mode, pins: ipins, apins: &st.pins, sol, ds }; | |
| 332 io.par_map_workers(&step, n, workers) | |
| 333 }; | |
| 334 let ix: IStreamIndex = checker::thaw_tier(&mut st.store, tier); | |
| 335 match r { | |
| 336 Ok(()) => { | |
| 337 io.check_done(n, &None); | |
| 338 Ok(ix) | |
| 339 } | |
| 340 Err((e, pos)) => { | |
| 341 io.check_done(n, &Some(pos)); | |
| 342 Err((e, pos)) | |
| 343 } | |
| 344 } | |
| 345 } | |
| == crates/con-ron/src/pool.rs#L35-L48 | |
| 35 //! | |
| 36 //! ## What a worker is, in the check phase | |
| 37 //! | |
| 38 //! §8.3 has said since P1 what the check phase is: "the persistent tier is | |
| 39 //! immutable, each worker owns a scratch tier — **no atomics anywhere**" | |
| 40 //! (`record_job` is the bracket; nothing writes the persistent tier after the | |
| 41 //! index is built and frozen, and a worker never holds it `&mut`). So the | |
| 42 //! driver's `init` | |
| 43 //! builds `checker::worker_state(pins)` — an EMPTY store, FROZEN | |
| 44 //! (`EStore::empty_frozen`: every append a scratch append), its own `Memos` | |
| 45 //! and `Caches`, and a COPY of | |
| 46 //! the driver's `Pins` — and its `step` borrows the frozen `&PersTier`, which | |
| 47 //! holds the stream's index. A job reads it through an empty layer of its own | |
| 48 //! at its record's view and pushes into that layer. So a worker costs no | |
| == crates/con-ron-core/src/arena/checker.rs#L121-L135 | |
| 121 | |
| 122 /// con-leche: ConLeche/Driver/CheckPool.lean:211-239 checkPool | |
| 123 /// Lean twin: `proof/ConRon/Arena/Checker.lean:65-73 AState.worker` — the twin's | |
| 124 /// worker reads the persistent tier where it is. | |
| 125 /// **A worker's start state** (the cited `init`): the empty store, FROZEN | |
| 126 /// (`EStore::empty_frozen`, task #98-FREEZE), so that every persistent read goes | |
| 127 /// to the `PersTier` the boundary froze and every append is a scratch append; | |
| 128 /// fresh memos and caches; and a copy of the pins, the run's maximum `Nat` size | |
| 129 /// among them (con-leche's `checkPool mode maxNatSize`, which hands it to every | |
| 130 /// job's fresh state through `runAt` and `recordJob`). The store stays frozen for | |
| 131 /// the worker's life: `record_job` only empties its scratch tier. A run with a solution builds the same state: the solution is handed to every | |
| 132 /// job (`run_job`), not kept in the worker. | |
| 133 pub fn worker_state(pins: &Pins) -> AState { | |
| 134 let mut st = AState::init(EStore::empty_frozen()); | |
| 135 st.pins = pins_dup(pins); | |
| == crates/con-ron/src/pool.rs#L233-L294 | |
| 233 } | |
| 234 | |
| 235 /// con-leche: ConLeche/Frontend/CheckerIO.lean:486-512 parMapWorkersIO | |
| 236 /// con-leche: ConLeche/Driver/CheckPool.lean:211-239 checkPool | |
| 237 /// **`step` at every index of `0..n`, on a pool of `workers` threads** — the | |
| 238 /// module note's trusted claim is this function's contract: | |
| 239 /// | |
| 240 /// > If it returns `Ok(())`, every index in `0..n` was claimed by some worker, | |
| 241 /// > each worker built its state with `init()` once and folded `step` over its | |
| 242 /// > claimed indices in claim order, which is increasing, and every step | |
| 243 /// > returned `Ok(())`. | |
| 244 /// | |
| 245 /// On a failure it returns the LEAST failing index with its error | |
| 246 /// (`ParallelError::Step`), whatever the timing. `after(&st, k)` runs on the | |
| 247 /// worker's thread after each step it made, with the worker's state by `&` | |
| 248 /// (the driver's heartbeat); it cannot change an outcome. | |
| 249 /// | |
| 250 /// The workers are `std::thread::scope`d, with `stack_bytes()` of stack each. | |
| 251 /// `workers` is the count the caller has already clamped | |
| 252 /// (`driver::workers_for`: `max(1, min(jobs, n))`); if the OS refuses to | |
| 253 /// spawn one, the pool runs on those it has, and on the calling thread if it | |
| 254 /// has none — the contract holds at every worker count, so the answer does | |
| 255 /// not depend on it. | |
| 256 pub fn parallel_all<S, E: Send>( | |
| 257 n: usize, | |
| 258 workers: usize, | |
| 259 init: impl Fn() -> S + Sync, | |
| 260 step: impl Fn(&mut S, usize) -> Result<(), E> + Sync, | |
| 261 after: impl Fn(&S, usize) + Sync, | |
| 262 ) -> Result<(), ParallelError<E>> { | |
| 263 let next = AtomicUsize::new(0); | |
| 264 let limit = AtomicUsize::new(n); | |
| 265 let run = || worker(n, &next, &limit, &init, &step, &after); | |
| 266 let mut results: Vec<Vec<(usize, Result<(), E>)>> = Vec::with_capacity(workers); | |
| 267 let mut panicked = false; | |
| 268 std::thread::scope(|scope| { | |
| 269 let mut handles = Vec::with_capacity(workers); | |
| 270 for w in 0..workers { | |
| 271 let spawned = std::thread::Builder::new() | |
| 272 .stack_size(stack_bytes()) | |
| 273 .name(format!("check-{}", w)) | |
| 274 .spawn_scoped(scope, &run); | |
| 275 match spawned { | |
| 276 Ok(h) => handles.push(h), | |
| 277 // Out of threads, or out of address space for another stack: | |
| 278 // run on the workers already spawned (the module note). | |
| 279 Err(_) => break, | |
| 280 } | |
| 281 } | |
| 282 if handles.is_empty() { | |
| 283 results.push(run()); | |
| 284 } | |
| 285 for h in handles { | |
| 286 match h.join() { | |
| 287 Ok(rs) => results.push(rs), | |
| 288 Err(_) => panicked = true, | |
| 289 } | |
| 290 } | |
| 291 }); | |
| 292 if panicked { | |
| 293 return Err(ParallelError::Panicked); | |
| 294 } | |
| == crates/con-ron-core/src/kernel/core_types.rs#L86-L91 | |
| 86 pub enum CheckError { | |
| 87 NotImplemented(Vec<u32>), | |
| 88 Invalid(Vec<u32>), | |
| 89 Internal(Vec<u32>), | |
| 90 Native(Vec<u32>), | |
| 91 } | |
| == proof/ConRon/Refine2/Frontend/Shape.lean#L387-L389 | |
| 387 def ScanOverflowErr (ce : kernel.core_types.CheckError) : Prop := | |
| 388 ∃ e : frontend.scan_types.ScanErr, e.what = .IndexOverflow ∧ | |
| 389 frontend.export_c.scan_err_to_check e = ok ce | |
| == crates/con-ron-core/src/driver/check_main.rs#L108-L115 | |
| 108 pub fn exit_code(e: &CheckError) -> u8 { | |
| 109 match e { | |
| 110 CheckError::NotImplemented(_) => 2, | |
| 111 CheckError::Invalid(_) => 1, | |
| 112 CheckError::Internal(_) => 3, | |
| 113 CheckError::Native(_) => 2, | |
| 114 } | |
| 115 } | |
| == Cargo.toml#L22-L23 | |
| 22 [profile.release] | |
| 23 overflow-checks = true | |
| == proof/ConRon/Arena/Denote.lean#L185-L208 | |
| 185 /-- con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr — the fuel-indexed | |
| 186 readback of an expression handle. -/ | |
| 187 def denoteEAux (st : EStore) : Nat → EIdx → Option Expr | |
| 188 | 0, _ => none | |
| 189 | f + 1, i => | |
| 190 (st.view i).bind fun v => | |
| 191 match v with | |
| 192 | .bvar k => some (.bvar k) | |
| 193 | .fvar k ty => (denoteEAux st f ty).map (Expr.fvar k) | |
| 194 | .sort u => (denoteL st.ls u).map Expr.sort | |
| 195 | .const n us => opt2 Expr.const (denoteN st.ns n) (denoteLs st.lss us) | |
| 196 | .app g a => opt2 Expr.app (denoteEAux st f g) (denoteEAux st f a) | |
| 197 | .lam ty b => opt2 Expr.lam (denoteEAux st f ty) (denoteEAux st f b) | |
| 198 | .forallE ty b => opt2 Expr.forallE (denoteEAux st f ty) (denoteEAux st f b) | |
| 199 | .letE ty w b => | |
| 200 opt3 Expr.letE (denoteEAux st f ty) (denoteEAux st f w) (denoteEAux st f b) | |
| 201 | .lit l => some (.lit l) | |
| 202 | .proj n k e => | |
| 203 opt2 (fun nm x => Expr.proj nm k x) (denoteN st.ns n) (denoteEAux st f e) | |
| 204 | |
| 205 /-- con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr — the readback of an | |
| 206 expression handle, at the store's own node count as fuel. -/ | |
| 207 def denoteE (st : EStore) (i : EIdx) : Option Expr := | |
| 208 denoteEAux st (st.nodeCount + 1) i | |
| == proof/ConRon/Arena/WF.lean#L1-L39 | |
| 1 /- | |
| 2 # Store well-formedness and the store layer's theorems (DESIGN.md §8.3, P2a) | |
| 3 | |
| 4 `StoreWF` is the arena's own invariant — con-leche's `TWF` | |
| 5 (`Setlec/Kernel/ArenaWF.lean:900`, 28 clauses) redrawn for the | |
| 6 per-constructor, high-tag representation. It lives here, beside the | |
| 7 implementation, importing nothing from `ConRon.Refine`: con-leche's lesson 27, | |
| 8 "implementation may import a *self-contained* data-structure verification". | |
| 9 | |
| 10 Each store's invariant is `∃ rank, …WFAt st rank`. The rank is existential | |
| 11 because nothing at runtime stores it (DESIGN §8.3: "zero runtime cost, and no | |
| 12 global array order is needed with per-constructor arrays"); what it buys is | |
| 13 | |
| 14 * **acyclicity**, hence a terminating `denote`; | |
| 15 * **a fuel bound**: a persistent node's rank is below the persistent node | |
| 16 count and a scratch node's below the total, so `nodeCount + 1` — the fuel | |
| 17 `denoteE` uses — is always enough, and `dropScratch` shrinks both sides of | |
| 18 the persistent clause together. | |
| 19 | |
| 20 The clauses, in the order a reader meets them: | |
| 21 | |
| 22 | clause | what it says | | |
| 23 |---|---| | |
| 24 | `childOK` | every child is in range, ranked below its parent, and persistent if the parent is | | |
| 25 | `rankP` / `rankS` | ranks are below the tier's node count (the fuel bound) | | |
| 26 | `consP` / `consS` | each tier's cons table is exactly the inverse of that tier's `get` | | |
| 27 | `fresh` | a scratch cons entry never duplicates a persistent one (DESIGN §8.3's cross-tier canonicity; con-leche's `t_cons_fresh`) | | |
| 28 | `derExact` | the derived column is `derOfView` of the node — *locally*; the global `derived st i = e.data` is a theorem (`derived_exact`) | | |
| 29 | `sized` | the derived array is as long as the node array | | |
| 30 | `cap` | no constructor array exceeds its handle shape's index range (2^30 for `app`, 2^26 for the rest), so the index is injective on it | | |
| 31 | `scrOff` | the scratch tier is empty while the scratch flag is off | | |
| 32 | `sync` | the nesting's scratch flags move together (task #97a) | | |
| 33 | |
| 34 `childOK`'s third conjunct — *persistent parents have persistent children* — | |
| 35 is what makes `dropScratch` sound: without it a persistent node could point | |
| 36 into a tier that is about to vanish. It needs no hypothesis at `intern`, | |
| 37 because `scrOff` makes a scratch handle undecodable while the flag is off, so | |
| 38 a valid child of a node appended to the persistent tier is persistent already. | |
| 39 -/ | |
| == proof/ConRon/Arena/Denote.lean#L274-L278 | |
| 274 /-- con-leche: none — extension of the whole arena (DESIGN §8.3; con-leche's | |
| 275 `Ext`, `Verify/SimI.lean:244`, is the same conjunct of `SimAt`). -/ | |
| 276 structure Ext (st st' : EStore) : Prop where | |
| 277 lss : LsExt st.lss st'.lss | |
| 278 expr : ∀ i e, denoteE st i = some e → denoteE st' i = some e | |
| == proof/ConRon/Bridge/Checker/Fold.lean#L114-L121 | |
| 114 theorem Arena.checkDecl_bridge | |
| 115 {pins : List INatOpPinSet} {pinsP : List NatOpPinSet} {env : Env} | |
| 116 {fe fe' : IFEnv} {s s' : AState} {pd : IDeclaration} {d : Declaration} | |
| 117 (hk : CoreSpec Arena.checkFuel) (hind : IndSpec) | |
| 118 (hok : FoldOK env fe s) (hpins : PinsDenote s.store pins pinsP) | |
| 119 (hd : Frontend.denoteDecl s.store pd = some d) | |
| 120 (hrun : Arena.checkDecl .verified pins fe pd s = .ok (fe', s')) : | |
| 121 DeclOut pinsP env d s s' := by | |
| == proof/ConRon/Bridge/Checker/Pool.lean#L94-L109 | |
| 94 /-- con-leche: ConLeche/Driver/CheckPool.lean:211-239 checkPool | |
| 95 con-leche: ConLeche/Verify/Cached/StreamIndex.lean:527 checkDecls_of_jobs — **THEOREM 1 at the | |
| 96 check phase the driver runs**: from an accepting `Arena.PooledAccepts`, con-leche's pure fold | |
| 97 `checkDeclsPure` accepts the denoted stream, at the environment its records denote. Each | |
| 98 prefix's environment is well formed by con-leche's model-free `foldlM_checkDecl_envWF` | |
| 99 (`ConLeche/Semantics/DeclWF.lean`); no set theory is involved. -/ | |
| 100 theorem Arena.pooledAccepts_bridge | |
| 101 {pins : List INatOpPinSet} {pinsP : List NatOpPinSet} | |
| 102 {ds : Array IDeclaration} {dsP : List Declaration} {s s' : AState} {I : IStreamIndex} | |
| 103 (hk : CoreSpec Arena.checkFuel) (hind : IndSpec) | |
| 104 (hst : DriverOK s) (hoff : s.store.scratchOn = false) | |
| 105 (hpersPins : PersPins s) (hpp : PersPinSets pins) (hpins : PinsDenote s.store pins pinsP) | |
| 106 (hpd : ∀ x ∈ ds.toList, PersDecl x) (hden : denoteDecls s.store ds.toList = some dsP) | |
| 107 (hrun : Arena.PooledAccepts .verified pins ds s I s') : | |
| 108 ∃ F, ConLeche.checkDeclsPure .verified (ConLeche.fueledOps .verified F) pinsP dsP | |
| 109 = .ok (ConLeche.streamEnv dsP) := by | |
| == proof/ConRon/Bridge/Specs.lean#L1-L31 | |
| 1 /- | |
| 2 # `ConRon.Bridge.Specs` — one `@[spec]` theorem per `Monad.lean` primitive | |
| 3 | |
| 4 **One spec theorem per (B) primitive, in one shape**, so that the | |
| 5 verification-condition generator (`vcgen`, on native `Std.WP` triples) can | |
| 6 walk a twin's body without any store reasoning appearing in the proof text. | |
| 7 The shape is the seven-rule template (DESIGN §8.6, `P2s SPIKE`, and task | |
| 8 #97s's section): | |
| 9 | |
| 10 ```lean | |
| 11 @[spec] theorem f_spec (s₀ : AState) (args…) (pre…) : | |
| 12 ⦃fun s => s = s₀⦄ f args ⦃fun r s' => Post s₀ r s'; ⊤⦄ | |
| 13 ``` | |
| 14 | |
| 15 1. **the precondition is `s = s₀` and nothing else** — every real | |
| 16 precondition is an ordinary hypothesis of the theorem, so `vcgen` turns it | |
| 17 into a side goal instead of an entailment to discharge in the logic; | |
| 18 2. **exception postcondition `⊤` (partial correctness), never the default | |
| 19 `⊥`** (`⦃P⦄ x ⦃Q⦄` is TOTAL correctness in `Std.WP`) — a (B) function may | |
| 20 fail and Theorem 1 claims nothing then (con-leche's `SimAt`, | |
| 21 `Verify/SimI.lean:244`); | |
| 22 3. **the postcondition names `s₀`**, the only way to state | |
| 23 `Ext s₀.store s'.store` in a triple; | |
| 24 4. **"the subject denotes" is an `isSome`, never a named `Expr`**; | |
| 25 5. **the answer is a named relation or predicate** (`Rel.lean`'s `RelE` | |
| 26 family, `Grind.lean`'s `Ans`/`MapRel`), never a bare `∀ e, … → …`; | |
| 27 6. **a memo insert's spec states that the INVARIANT is preserved**, not that | |
| 28 the table grew — the rule that matters most; | |
| 29 7. **one named failure primitive** (`fail`): every failure site goes | |
| 30 through it, so one spec covers them all and the Rust has one function to | |
| 31 match. | |
| == proof/ConRon/Bridge/Inductives/Run.lean#L60-L76 | |
| 60 /-- con-leche: ConLeche/Verify/SimI.lean:244 SimAt — **the PURE grade's | |
| 61 statement**: from a well-formed store, an ACCEPTING run of the twin returns an | |
| 62 answer related to the pure side's by `R`, having only grown the arena. | |
| 63 | |
| 64 Partial correctness, as everywhere in this library: a (B) function may fail | |
| 65 and Theorem 1 claims nothing then — which is why the hypothesis is | |
| 66 `c s0 = .ok (r, s')` and not an unconditional equation. | |
| 67 | |
| 68 **RUN form rather than a Hoare triple** (DESIGN `### Task #97-P3-Checker` | |
| 69 §1): this tier's work is composition, inversion and list induction rather | |
| 70 than verification conditions, and the checker tier that consumes `IndSpec` | |
| 71 (`Bridge/Checker/Arms.lean`) is written in run form too (`AM.bind_ok` is its | |
| 72 inversion). -/ | |
| 73 @[expose] def PSpec {α : Type} (P : EStore → Prop) (c : AM α) (R : EStore → α → Prop) : | |
| 74 Prop := | |
| 75 ∀ (s₀ s' : AState) (r : α), StateOK s₀ → P s₀.store → c s₀ = .ok (r, s') → | |
| 76 PStep s₀ s' ∧ R s'.store r | |
| == proof/ConRon/Bridge/Inductives/Rel.lean#L61-L78 | |
| 61 /-! ## The core grade -/ | |
| 62 | |
| 63 /-- con-leche: none — **the bridge between the two grades**: a pure step | |
| 64 preserves the whole checking invariant, by `Bridge/StateOK.lean`'s | |
| 65 `CheckOK.mono`. This is what lets a core-grade function call a pure-grade one | |
| 66 and keep its own hypothesis. -/ | |
| 67 theorem PStep.toCore {env : Env} {fe : IFEnv} {s s' : AState} | |
| 68 (h : PStep s s') (hc : CheckOK false env fe s) : CoreStep env fe s s' := | |
| 69 ⟨hc.monoF h.ok h.ext h.cframe h.pins, h.ext, h.pins⟩ | |
| 70 | |
| 71 /-- con-leche: ConLeche/Verify/Cached/SimC.lean:366 SimC — **the CORE grade's | |
| 72 statement**: the same at a function that calls the knot, so the invariant is | |
| 73 `CheckOK` and the frame is `CoreStep`. The pure side's fuel existential lives | |
| 74 inside `R`, as `Bridge/Core/Knot.lean`'s `SimE` has it. -/ | |
| 75 @[expose] def CSpec (env : Env) (fe : IFEnv) {α : Type} | |
| 76 (P : EStore → Prop) (c : AM α) (R : EStore → α → Prop) : Prop := | |
| 77 ∀ (s₀ s' : AState) (r : α), CheckOK false env fe s₀ → P s₀.store → | |
| 78 c s₀ = .ok (r, s') → CoreStep env fe s₀ s' ∧ R s'.store r | |
| == proof/ConRon/Bridge/Inductives/StructParts.lean#L128-L174 | |
| 128 /-! ## The spines -/ | |
| 129 | |
| 130 /-- con-leche: ConLeche/Kernel/Inductives/StructParts.lean:52-53 structPsAt | |
| 131 The parameter variables as seen from under `o` extra binders. | |
| 132 | |
| 133 **Proof:** a `Nat` recursion over | |
| 134 `internBVarE_run` with the cursor `k` generalised. The pure side is a | |
| 135 `List.range` map, so the step is `List.range_succ_eq_map` and one `omega` on | |
| 136 the index arithmetic (`k + (j + 1) = k + 1 + j`). -/ | |
| 137 theorem structPsAt_go_run (o nP : Nat) : ∀ (n k : Nat) {s s' : AState} | |
| 138 {r : List EIdx}, StateOK s → Arena.structPsAt.go o nP n k s = .ok (r, s') → | |
| 139 PStep s s' ∧ Frontend.denoteEList s'.store r | |
| 140 = some ((List.range n).map fun j => Expr.bvar (o + nP - 1 - (k + j))) := by | |
| 141 intro n | |
| 142 induction n with | |
| 143 | zero => | |
| 144 intro k s s' r hok hrun | |
| 145 simp only [Arena.structPsAt.go] at hrun | |
| 146 obtain ⟨rfl, rfl⟩ := AM.pure_ok hrun | |
| 147 exact ⟨PStep.refl hok, rfl⟩ | |
| 148 | succ n ih => | |
| 149 intro k s s' r hok hrun | |
| 150 simp only [Arena.structPsAt.go] at hrun | |
| 151 obtain ⟨b, s₁, h1, h2⟩ := AM.bind_ok hrun | |
| 152 obtain ⟨rest, s₂, h3, h4⟩ := AM.bind_ok h2 | |
| 153 obtain ⟨hstep1, hb⟩ := internBVarE_run hok h1 | |
| 154 obtain ⟨hstep2, hrest⟩ := ih (k + 1) hstep1.ok h3 | |
| 155 obtain ⟨rfl, rfl⟩ := AM.pure_ok h4 | |
| 156 refine ⟨hstep1.trans hstep2, ?_⟩ | |
| 157 have hkey : ((List.range (n + 1)).map fun j => Expr.bvar (o + nP - 1 - (k + j))) | |
| 158 = Expr.bvar (o + nP - 1 - k) :: | |
| 159 ((List.range n).map fun j => Expr.bvar (o + nP - 1 - (k + 1 + j))) := by | |
| 160 rw [List.range_succ_eq_map, List.map_cons, List.map_map] | |
| 161 congr 1 | |
| 162 refine List.map_congr_left (fun j _ => ?_) | |
| 163 simp only [Function.comp_apply] | |
| 164 congr 1 | |
| 165 omega | |
| 166 rw [hkey] | |
| 167 simp only [Frontend.denoteEList, denote_ext hb hstep2.ext, hrest] | |
| 168 | |
| 169 theorem structPsAt_spec (o nP : Nat) : | |
| 170 PSpec PT (Arena.structPsAt o nP) (REL (ConLeche.structPsAt o nP)) := by | |
| 171 intro s₀ s' r hok _ hrun | |
| 172 obtain ⟨hstep, hd⟩ := structPsAt_go_run o nP nP 0 hok hrun | |
| 173 refine ⟨hstep, ?_⟩ | |
| 174 simpa only [ConLeche.structPsAt, Nat.zero_add] using hd | |
| == proof/ConRon/Bridge/Core/Knot.lean#L111-L128 | |
| 111 rule 8 — "the record of knot hypotheses costs nothing"). -/ | |
| 112 structure KnotSpec (eager : Bool) (env : Env) (fe : IFEnv) (f : Nat) : | |
| 113 Prop where | |
| 114 /-- Head normalization without delta, in either mode (`c` is the official | |
| 115 kernel's `cheap_proj`; con-leche's claims generalize the same way). -/ | |
| 116 whnfCore : ∀ {c : Bool} (s₀ : AState) (d : Nat) (i : EIdx) (e : Expr), | |
| 117 CheckOK eager env fe s₀ → denoteE s₀.store i = some e → | |
| 118 Expr.WScoped d e → | |
| 119 ⦃fun s => s = s₀⦄ (coreKnot .verified eager fe id f).whnfCore c d i | |
| 120 ⦃fun r s' => CheckOK eager env fe s' ∧ Ext s₀.store s'.store ∧ | |
| 121 s'.pins = s₀.pins ∧ | |
| 122 SimE (fun F d e => ConLeche.whnfCore .verified eager env F d e c) d e s'.store r; ⊤⦄ | |
| 123 /-- The full reduction loop. -/ | |
| 124 whnf : ∀ (s₀ : AState) (d : Nat) (i : EIdx) (e : Expr), | |
| 125 CheckOK eager env fe s₀ → denoteE s₀.store i = some e → | |
| 126 Expr.WScoped d e → | |
| 127 ⦃fun s => s = s₀⦄ (coreKnot .verified eager fe id f).whnf d i | |
| 128 ⦃fun r s' => CheckOK eager env fe s' ∧ Ext s₀.store s'.store ∧ | |
| == proof/ConRon/Bridge/Core/Induction.lean#L67-L91 | |
| 67 theorem knot_spec_all {env : Env} {fe : IFEnv} (henv : ConLeche.EnvWF env) : | |
| 68 ∀ f {eager : Bool}, KnotSpec eager env fe f | |
| 69 | 0, eager => knotSpec_zero eager env fe | |
| 70 | f + 1, _ => | |
| 71 { whnfCore := fun {c} s₀ d i e hok hden hw => | |
| 72 memoWhnfCore_step | |
| 73 (fun c => whnfCoreBody_spec henv (knot_spec_all henv f) c) (c := c) | |
| 74 s₀ d i e hok hden hw | |
| 75 whnf := fun s₀ d i e hok hden hw => | |
| 76 memoWhnf_step henv | |
| 77 (whnfBody_spec henv (knot_spec_all henv f)) s₀ d i e hok hden hw | |
| 78 infer := fun s₀ d i e hok hden hw => | |
| 79 memoInfer_step henv | |
| 80 (inferBody_spec henv (knot_spec_all henv f)) s₀ d i e hok hden hw | |
| 81 defeq := fun s₀ d i j a b hok hda hdb hwa hwb => | |
| 82 memoDefeq_step henv | |
| 83 (defeqBody_spec henv (knot_spec_all henv f)) s₀ d i j a b hok hda | |
| 84 hdb hwa hwb | |
| 85 defeqE := fun s₀ d i j a b hok hda hdb hwa hwb => | |
| 86 memoDefeqE_step henv | |
| 87 (defeqBody_spec henv (knot_spec_all henv f)) s₀ d i j a b hok hda | |
| 88 hdb hwa hwb | |
| 89 inferIO := fun s₀ d i e hok hden hw => | |
| 90 memoInferIO_step henv | |
| 91 (inferBodyIO_spec henv (knot_spec_all henv f)) s₀ d i e hok hden hw } | |
| == proof/ConRon/Refine2/AbsState.lean#L359-L373 | |
| 359 /-- **Finding 16**: the TWIN store is well formed — Theorem 1's invariant, | |
| 360 carried by Theorem 2's relation. -/ | |
| 361 storeWF : StoreWF ls.store | |
| 362 | |
| 363 /-- **The lockstep relation**: `AStateRel` without `storeWF` (task | |
| 364 #97-P5-Core round 4, the coordinator's ruling (i) on its finding). `storeWF` | |
| 365 is a statement about the TWIN's term DAG — Theorem 1 content — and it is what | |
| 366 made a knot statement false at a state both programs handle alike: the port | |
| 367 and the twin both intern `app d a` over a dangling `d` without looking at it, | |
| 368 their stores stay equal field for field, and only `StoreWF` fails. The Core | |
| 369 tier's `KnotRel`/`BodyRel` are stated over this; the rest of the tier moves to | |
| 370 it later (tier-wide migration, scheduled separately), and until then | |
| 371 `AStateRel` keeps its five fields and these two lemmas convert. -/ | |
| 372 structure AStateRel₀ (pers : arena.store.PersTier) (rs : arena.monad.AState) | |
| 373 (ls : AState) : Prop where | |
| == proof/ConRon/Refine2/AbsState.lean#L382-L387 | |
| 382 AStateRel pers rs ls := | |
| 383 ⟨h.store, h.memos, h.caches, h.pins, hwf⟩ | |
| 384 | |
| 385 | |
| 386 /-- The Rust-side invariant of the whole state. -/ | |
| 387 structure AStateInv (pers : arena.store.PersTier) (rs : arena.monad.AState) : | |
| == proof/ConRon/Refine2/Shape.lean#L205-L209 | |
| 205 /-- The lockstep simulation statement for a state-threading Rust function. -/ | |
| 206 def Sim₀ {α β : Type} (A : α → β) (pers : arena.store.PersTier) (lst : AState) | |
| 207 (o : core.result.Result α kernel.core_types.CheckError × arena.monad.AState) | |
| 208 (x : AM β) : Prop := | |
| 209 AOut₀ A pers o.1 o.2 (x.run lst) | |
| == proof/ConRon/Refine2/Checker/Shape.lean#L146-L150 | |
| 146 def SimRel₀ {α β : Type} (R : α → β → Prop) (pers : arena.store.PersTier) | |
| 147 (lst : AState) | |
| 148 (o : core.result.Result α kernel.core_types.CheckError × arena.monad.AState) | |
| 149 (x : AM β) : Prop := | |
| 150 AOutRel₀ R pers o.1 o.2 (x.run lst) | |
| == proof/ConRon/Refine2/Tactic/Lockstep.lean#L1-L30 | |
| 1 /- | |
| 2 # `ConRon.Refine2.Tactic.Lockstep` — the lockstep judgement and the `lockstep` tactic | |
| 3 | |
| 4 Task #97-T2-TACTIC. Theorem 2 in its lockstep shape (task #97-T2-AUDIT §6) | |
| 5 relates two programs doing the same operations in the same order, over a | |
| 6 state relation that says only "the same data in two representations". So a | |
| 7 proof of one `_refines` lemma is a ZIP of two do-blocks: peel one bind on each | |
| 8 side, close the correspondence of the two callees with a registered lemma, | |
| 9 continue with the related results. This file makes that zip a tactic. | |
| 10 | |
| 11 ## The judgement | |
| 12 | |
| 13 `LS pers R m lst x` — *every outcome of the Rust computation `m` is matched by | |
| 14 the twin action `x` run from `lst`*: an `Ok a` by an `ok (b, lst')` with | |
| 15 `R a b` in a related post-state, an `Err e` by the twin throwing at the same | |
| 16 kind (`AErrSim`). It is `Sim₀` with a relation for the answer instead of an | |
| 17 abstraction function, and with the Rust equation moved into the judgement, so | |
| 18 that the Rust program is visible in the GOAL beside the twin (`LS.toSim₀` is the | |
| 19 bridge back). Four companion judgements carry the other Rust callee shapes: | |
| 20 | |
| 21 | judgement | Rust callee shape | example | | |
| 22 |---|---|---| | |
| 23 | `LS` | `Result (Result α CheckError × AState)` — state threaded | `intern_e_app`, a recursive call | | |
| 24 | `LSR` | `Result (Result α CheckError)` — reads, may fail | `view` | | |
| 25 | `LSV` | `Result α` — reads, total | `lift_get`, `inst_list_cutoff` | | |
| 26 | `LSW` | `Result AState` — writes, total | `lift_set` | | |
| 27 | `LSP` | `Result α`, **Rust only** — no twin counterpart | `fuel - 1#u64`, `dup2`, `eidx_nat_key`, `fail` | | |
| 28 | `LSM` | `Result (Result α × AState × M)` — a memoised walk, memo beside the result | `consts_resolve_f_go`, `intern_expr_go` | | |
| 29 | `LSRM` | `Result (Result α × M)` — a memoised reader walk | `all_level_params_defined_go` | | |
| 30 | |
| == proof/ConRon/Refine2/Tactic/Lockstep.lean#L164-L168 | |
| 164 /-- **The lockstep judgement** for a state-threading Rust computation. -/ | |
| 165 def LS {α β : Type} (pers : arena.store.PersTier) (R : α → β → Prop) | |
| 166 (m : Result (core.result.Result α kernel.core_types.CheckError × arena.monad.AState)) | |
| 167 (lst : AState) (x : AM β) : Prop := | |
| 168 ∀ o st', m = ok (o, st') → LOut pers R o st' (x.run lst) | |
| == proof/ConRon/Refine2/Tactic/Lockstep.lean#L170-L174 | |
| 170 /-- A Rust READ that may fail: the state is `st` before and after. -/ | |
| 171 def LSR {α β : Type} (pers : arena.store.PersTier) (R : α → β → Prop) | |
| 172 (m : Result (core.result.Result α kernel.core_types.CheckError)) | |
| 173 (st : arena.monad.AState) (lst : AState) (x : AM β) : Prop := | |
| 174 ∀ o, m = ok o → LOut pers R o st (x.run lst) | |
| == proof/ConRon/Refine2/Tactic/Lockstep.lean#L633-L645 | |
| 633 /-- **The lockstep judgement of a memoised state walk**: `LS` of the walk with | |
| 634 its memo moved into the answer; `R` relates `(answer, memo)` to the twin's | |
| 635 answer (typically the twin's `(answer, memo)` pair). -/ | |
| 636 def LSM {α β M : Type} (pers : arena.store.PersTier) (R : α × M → β → Prop) | |
| 637 (m : Result (core.result.Result α kernel.core_types.CheckError × arena.monad.AState × M)) | |
| 638 (lst : AState) (x : AM β) : Prop := | |
| 639 LS pers R (packM m) lst x | |
| 640 | |
| 641 /-- **The lockstep judgement of a memoised reader walk** at the state `st`. -/ | |
| 642 def LSRM {α β M : Type} (pers : arena.store.PersTier) (R : α × M → β → Prop) | |
| 643 (m : Result (core.result.Result α kernel.core_types.CheckError × M)) | |
| 644 (st : arena.monad.AState) (lst : AState) (x : AM β) : Prop := | |
| 645 LS pers R (packRM st m) lst x | |
| == proof/ConRon/Refine2/Tactic/Lockstep.lean#L2661-L2662 | |
| 2661 /-- **The lockstep tactic**: step until every goal is closed or stuck. -/ | |
| 2662 macro "lockstep" : tactic => `(tactic| repeat' lockstep_step) | |
| == proof/ConRon/Refine2/Tactic/Attr.lean#L86-L94 | |
| 86 initialize registerBuiltinAttribute { | |
| 87 name := `lockstep | |
| 88 descr := "a lockstep correspondence lemma, keyed on its Rust callee; \ | |
| 89 `@[lockstep high]` / `@[lockstep <n>]` sets its priority" | |
| 90 add := fun decl stx kind => do | |
| 91 let info ← getConstInfo decl | |
| 92 let k ← (lemmaKey info.type).run' {} {} | |
| 93 let prio ← getAttrParamOptPrio stx[1] | |
| 94 lockstepExt.add (.add k decl prio) kind | |
| == proof/ConRon/Refine/Abs.lean#L488-L493 | |
| 488 def StrWF (s : alloc.vec.Vec Std.U32) : Prop := ∀ c ∈ s.val, Nat.isValidChar c.val | |
| 489 | |
| 490 inductive NameWF : name.Name → Prop where | |
| 491 | anonymous {n} : name.anonymous = ok n → NameWF n | |
| 492 | str {pre s n} : NameWF pre → StrWF s → name.mk_str pre s = ok n → NameWF n | |
| 493 | num {pre m n} : NameWF pre → name.mk_num pre m = ok n → NameWF n | |
| == proof/ConRon/Refine2/Core/LS/PrimsA1.lean#L1238-L1242 | |
| 1238 @[lockstep] theorem level_param_ls (n : kernel.name.Name) (hn : ConRon.Refine.NameWF n) : | |
| 1239 LSP (kernel.level.param n) | |
| 1240 (fun u => ConRon.Refine.LevelWF u ∧ | |
| 1241 TwinEq (.param (ConRon.Refine.absName n)) (ConRon.Refine.absLevel u)) := | |
| 1242 fun _ h => ⟨ConRon.Refine.Level.param_wf' h hn, (ConRon.Refine.Level.param_refines h).symm⟩ | |
| == proof/ConRon/Refine2/ExprOps/Mut.lean#L290-L319 | |
| 290 theorem instantiate1_go_aux (n : Nat) : | |
| 291 ∀ {pers : arena.store.PersTier} {st : arena.monad.AState} {lst : AState} | |
| 292 (v : arena.handle.EIdx) (fuel : Std.U64) (h : arena.handle.EIdx) (d : Std.U64), | |
| 293 fuel.val = n → AStateRel₀ pers st lst → AStateInv pers st → | |
| 294 LS pers (fun a b => b = absEIdx a) (arena.expr_ops.instantiate1_go pers st v fuel h d) lst | |
| 295 (instantiate1Go (absEIdx v) n (absEIdx h) (absU d)) := by | |
| 296 induction n with | |
| 297 | zero => | |
| 298 intro pers st lst v fuel h d hn hrel hinv | |
| 299 rw [arena.expr_ops.instantiate1_go, instantiate1Go_zero] | |
| 300 lockstep | |
| 301 | succ m ih => | |
| 302 intro pers st lst v fuel h d hn hrel hinv | |
| 303 rw [arena.expr_ops.instantiate1_go, instantiate1Go_succ] | |
| 304 lockstep | |
| 305 | |
| 306 @[lockstep] theorem instantiate1_go_ls {pers st lst} (hrel : AStateRel₀ pers st lst) (hinv : AStateInv pers st) | |
| 307 (v : arena.handle.EIdx) (fuel : Std.U64) (h : arena.handle.EIdx) (d : Std.U64) : | |
| 308 LS pers (fun a b => b = absEIdx a) (arena.expr_ops.instantiate1_go pers st v fuel h d) lst | |
| 309 (instantiate1Go (absEIdx v) (absU fuel) (absEIdx h) (absU d)) := | |
| 310 instantiate1_go_aux _ v fuel h d rfl hrel hinv | |
| 311 | |
| 312 end instantiate1_go | |
| 313 | |
| 314 @[lockstep] theorem instantiate1_fast_ls {pers st lst} (hrel : AStateRel₀ pers st lst) | |
| 315 (hinv : AStateInv pers st) (fuel : Std.U64) (e v : arena.handle.EIdx) (d : Std.U64) : | |
| 316 LS pers (fun a b => b = absEIdx a) (arena.expr_ops.instantiate1_fast pers st fuel e v d) lst | |
| 317 (instantiate1Fast (absU fuel) (absEIdx e) (absEIdx v) (absU d)) := by | |
| 318 rw [arena.expr_ops.instantiate1_fast, instantiate1Fast] | |
| 319 lockstep | |
| == proof/ConRon/Refine2/ExprOps/Mut.lean#L645-L665 | |
| 645 theorem inst_spine_from_aux (n : Nat) : | |
| 646 ∀ {pers : arena.store.PersTier} {st : arena.monad.AState} {lst : AState} | |
| 647 (fuel : Std.U64) (args : alloc.vec.Vec arena.handle.EIdx) (i : Std.Usize) (t : Std.U64) (e : arena.handle.EIdx), | |
| 648 args.val.length - i.val = n → AStateRel₀ pers st lst → AStateInv pers st → | |
| 649 LS pers (fun a b => b = absEIdx a) (arena.expr_ops.inst_spine_from pers st fuel args i t e) lst | |
| 650 (instSpine (absU fuel) (absEIdxListFrom args i) (absU t) (absEIdx e)) := by | |
| 651 induction n with | |
| 652 | zero => | |
| 653 intro pers st lst fuel args i t e hn hrel hinv | |
| 654 rw [arena.expr_ops.inst_spine_from, listFrom_nil args i (by omega), instSpine] | |
| 655 lockstep | |
| 656 | succ k ih => | |
| 657 intro pers st lst fuel args i t e hn hrel hinv | |
| 658 rw [arena.expr_ops.inst_spine_from, listFrom_cons args i (by omega), instSpine] | |
| 659 lockstep | |
| 660 | |
| 661 @[lockstep] theorem inst_spine_from_ls {pers st lst} (hrel : AStateRel₀ pers st lst) | |
| 662 (hinv : AStateInv pers st) (fuel : Std.U64) (args : alloc.vec.Vec arena.handle.EIdx) (i : Std.Usize) (t : Std.U64) (e : arena.handle.EIdx) : | |
| 663 LS pers (fun a b => b = absEIdx a) (arena.expr_ops.inst_spine_from pers st fuel args i t e) lst | |
| 664 (instSpine (absU fuel) (absEIdxListFrom args i) (absU t) (absEIdx e)) := | |
| 665 inst_spine_from_aux _ fuel args i t e rfl hrel hinv | |
| == proof/ConRon/Refine2/Core/Induction.lean#L905 | |
| 905 theorem knot_rel (hbody : ∀ f, KnotRel f → BodyRel f) : ∀ f, KnotRel f | |
| == proof/ConRon/MainTheorem/Stages.lean#L25-L95 | |
| 25 /-! | |
| 26 # `ConRon.MainTheorem.Stages` — the staged lemmas: Theorem 2 ∘ Theorem 1 ∘ con-leche | |
| 27 | |
| 28 The main theorems (`ConRon/MainTheorem.lean`) are proved from these lemmas. Each states, for | |
| 29 one mode of the binary, what follows from the verified calls the driver makes in that mode: | |
| 30 one premise per call, in the driver's order, each starting from the state the previous one | |
| 31 left and the first from the binary's own start values. The driver walks of | |
| 32 `MainTheorem/*.lean` take an exit 0 of the extracted driver `run_args` to exactly these | |
| 33 premises, and `MainTheorem/Conclusions.lean` turns the conclusions here into con-leche's words. | |
| 34 This is the one module that imports both `ConRon.Bridge` (Theorem 1, (B) ⇒ (A)) and | |
| 35 `ConRon.Refine2` (Theorem 2, (C) ⇒ (B)): | |
| 36 | |
| 37 * `model_exists` / `no_False_declaration` — a lean4export file (`driver::check_main`); | |
| 38 * `no_False_oleans` / `model_exists_oleans` — the same on `--olean` (`check_main::check_oleans`); | |
| 39 * `model_exists_compare` / `no_False_compare` and `model_exists_oleans_compare` / | |
| 40 `no_False_oleans_compare` — a challenge checked with its axioms justified by a solution | |
| 41 (`driver::compare_json`, `driver::compare`; §4b and §4c), about the challenge alone; | |
| 42 * `model_modular` and its compared forms — the graph check and a module's worker | |
| 43 (`driver::graph`, `driver::worker`, `driver::modular`, `driver::compare_module`). | |
| 44 | |
| 45 The calls are marked `// ConRon.MainTheorem.Stages: <premise>` in the driver's Rust. | |
| 46 | |
| 47 ## The pipeline, stage by stage | |
| 48 | |
| 49 On a lean4export file the driver (`crates/con-ron-core/src/driver/check_main.rs`) calls, in | |
| 50 this order, on one `AState` made from `AState::empty()` and one `PersTier::empty()`: | |
| 51 | |
| 52 intern_reserved_pins → builtin_prelude_e → parse_source (FileChunks) | |
| 53 → prepare_d → decode_embedded → intern_all_pins → (the check phase) | |
| 54 | |
| 55 **The check phase** (`check_main::check_phase`) builds the stream's index from the records | |
| 56 (`stream_index::build_index`), freezes the tier with the index in it (`checker::freeze_tier`), | |
| 57 runs every record's job on the instance's worker map, and thaws the tier. The lemmas take one | |
| 58 premise per step (`h6` the index, `h7` the freeze, `h8` the map), which `poolAccepts_intro` | |
| 59 assembles into `Refine2/Checker/Phased.lean`'s `PoolAccepts`. `h8` is the worker map's | |
| 60 contract (`PoolSound`) at the driver's step (`ParallelAll` at `jobStep`): index lists, one per | |
| 61 worker, covering every job, each in increasing order, and for each a fold of `run_job` over its | |
| 62 indices from `worker_state`, accepting. | |
| 63 | |
| 64 The proof: | |
| 65 | |
| 66 1. **Theorem 2, per stage** — `Refine2`'s `…_refines` lemmas walk the Rust runs | |
| 67 into twin runs from the twin's own start state `AState.init EStore.empty`, | |
| 68 related at every step (`AStateRel₀`/`AStateInv`: lockstep); `rust_stages`; | |
| 69 2. **Theorem 1** — `Bridge/Stages.lean` takes the twin runs: | |
| 70 `Arena.pooledAccepts_bridge` makes the check phase's accept con-leche's pure | |
| 71 fold `checkDeclsPure` accepting the denoted stream at `streamEnv` of it; | |
| 72 3. **con-leche** — `checkDeclsPure_sound_of` turns the pure accept into a model, | |
| 73 and `no_proof_of_False_pure` refutes a `False` theorem in the stream. | |
| 74 | |
| 75 ## The named hypotheses | |
| 76 | |
| 77 The lemmas start from the binary's own start values (`startState` = | |
| 78 `AState::empty()`, `emptyTier` = `PersTier::empty()`) and name the call the | |
| 79 driver makes at each step. Beside `[ConLeche.SetTheory V]`, the file's shape | |
| 80 `hfalse` and the one premise per call (`h1`…`h5`, `hpins`, `h6`…`h8`), what | |
| 81 they assume is exactly: | |
| 82 | |
| 83 * `hreads : ReadsAs sinst src chunks.val` — the reads are the chunks: the driver | |
| 84 parses with the verified reader loop `parse_source` over `FileChunks`, and | |
| 85 `Refine2/Frontend/Source.lean`'s `parse_source_eq` makes that `parse_chunks` over | |
| 86 the chunks the reads hand out; the walk proves the reads are the file's bytes in | |
| 87 the snapshot (`fileChunks_loop`); | |
| 88 * on `--olean`, `hsnap : SnapshotOf finst fsv F` — the file instance answers as | |
| 89 one snapshot `F`. | |
| 90 | |
| 91 `hpins` is the premise for the binary's pin step: the pin list is what the verified | |
| 92 decoder read, at any text (as con-leche's theorems hold at every pin list); | |
| 93 `model_exists_embedded` / `no_False_declaration_embedded` fix the text to the embedded | |
| 94 `PINS_TEXT`. | |
| 95 -/ | |
| == proof/ConRon/Refine2/Checker/Phased.lean#L291-L300 | |
| 291 (absIDeclL ds).toArray ks lst = .ok (.ok (), s'') | |
| 292 | [], _, lst, _, _, _ => ⟨by simp, lst, rfl⟩ | |
| 293 | k :: ks, _, lst, hidle, hinv, ⟨_, hs1, hf⟩ => by | |
| 294 unfold jobStepSol at hs1 | |
| 295 split at hs1 | |
| 296 · rename_i hk | |
| 297 have hu : (UScalar.cast .U64 (UScalar.ofNatCore (ty := .Usize) k hk)).val = k := by | |
| 298 rw [usize_cast_u64_val']; rfl | |
| 299 have hkU : (UScalar.cast .U64 (UScalar.ofNatCore (ty := .Usize) k hk)).val | |
| 300 ≤ Std.Usize.max := by | |
| == proof/ConRon/Generated/TypesExternal.lean#L41-L42 | |
| 41 @[reducible, rust_type "alloc::sync::Arc"] | |
| 42 def alloc.sync.Arc (T : Type) : Type := T | |
| == proof/ConRon/Generated/FunsExternal.lean#L25-L72 | |
| 25 @[rust_fun "alloc::sync::{alloc::sync::Arc<@T>}::new"] | |
| 26 def alloc.sync.Arc.new {T : Type} (x : T) : Result (alloc.sync.Arc T) := ok x | |
| 27 | |
| 28 /- Modeled as `false`: the model always takes the slow path (DESIGN.md | |
| 29 §3.2). Sound for the accept direction *provided* every walk that uses | |
| 30 `ptr_eq` as a shortcut is reflexive, which is an ordinary lemma about the | |
| 31 model, proved once per call site (Lean's own `withPtrEq` discipline). -/ | |
| 32 /-- [alloc::sync::{alloc::sync::Arc<T>}::ptr_eq]: | |
| 33 Source: '/rustc/library/alloc/src/sync.rs', lines 2172:4-2172:52 | |
| 34 Name pattern: [alloc::sync::{alloc::sync::Arc<@T>}::ptr_eq] | |
| 35 Visibility: public -/ | |
| 36 @[rust_fun "alloc::sync::{alloc::sync::Arc<@T>}::ptr_eq"] | |
| 37 def alloc.sync.Arc.ptr_eq | |
| 38 {T : Type} (_A : Type) (_a _b : alloc.sync.Arc T) : Result Bool := ok false | |
| 39 | |
| 40 /-- [alloc::sync::{impl core::clone::Clone for alloc::sync::Arc<T>}::clone]: | |
| 41 Source: '/rustc/library/alloc/src/sync.rs', lines 2405:4-2405:32 | |
| 42 Name pattern: [alloc::sync::{core::clone::Clone<alloc::sync::Arc<@T>>}::clone] | |
| 43 Visibility: public -/ | |
| 44 @[rust_fun "alloc::sync::{core::clone::Clone<alloc::sync::Arc<@T>>}::clone"] | |
| 45 def alloc.sync.Arc.Insts.CoreCloneClone.clone | |
| 46 {T : Type} {A : Type} (_coreallocAllocatorCloneInst : | |
| 47 core.alloc.AllocatorClone A) (x : alloc.sync.Arc T) : | |
| 48 Result (alloc.sync.Arc T) := ok x | |
| 49 | |
| 50 /-- [alloc::sync::{impl core::ops::deref::Deref<T> for alloc::sync::Arc<T>}::deref]: | |
| 51 Source: '/rustc/library/alloc/src/sync.rs', lines 2453:4-2453:25 | |
| 52 Name pattern: [alloc::sync::{core::ops::deref::Deref<alloc::sync::Arc<@T>, @T>}::deref] | |
| 53 Visibility: public -/ | |
| 54 @[rust_fun | |
| 55 "alloc::sync::{core::ops::deref::Deref<alloc::sync::Arc<@T>, @T>}::deref"] | |
| 56 def alloc.sync.Arc.Insts.CoreOpsDerefDeref.deref | |
| 57 {T : Type} (_A : Type) (x : alloc.sync.Arc T) : Result T := ok x | |
| 58 /- The fifth hole, and the only one that is not an `Rc` operation (task #43). | |
| 59 It is **not** a trust assumption: Aeneas models `Str` as `Slice U8` | |
| 60 (`Aeneas/Std/StringDef.lean`), so the bytes of a `&str` *are* the value, and | |
| 61 `as_bytes` is the identity. `kernel::pins_decode::decode_embedded` is the | |
| 62 only caller — `PINS_TEXT.as_bytes()`, the embedded pin text handed to the | |
| 63 byte decoder — and the hole exists because Rust offers no other way to index | |
| 64 a `&str`: the alternative, a `b"..."` byte constant, extracts to a | |
| 65 532 456-element array literal that Lean cannot elaborate (DESIGN.md, | |
| 66 task #43's measurement). -/ | |
| 67 /-- [core::str::{str}::as_bytes]: | |
| 68 Source: '/rustc/library/core/src/str/mod.rs', lines 514:4-514:41 | |
| 69 Name pattern: [core::str::{str}::as_bytes] | |
| 70 Visibility: public -/ | |
| 71 @[rust_fun "core::str::{str}::as_bytes"] | |
| 72 def core.str.Str.as_bytes (s : Str) : Result (Slice Std.U8) := ok s | |
| == proof/ConRon/Generated/TypesExternal.lean#L41-L42 | |
| 41 @[reducible, rust_type "alloc::sync::Arc"] | |
| 42 def alloc.sync.Arc (T : Type) : Type := T | |
| == crates/con-ron-core/src/ron/ptr.rs#L1-L8 | |
| 1 //! con-leche: none — the shared-pointer type of DESIGN.md §3.2; Lean's value semantics have no counterpart. | |
| 2 //! | |
| 3 //! `ron::ptr` — **the one place the core names its shared pointer** | |
| 4 //! (DESIGN.md §3.2, task #44). | |
| 5 //! | |
| 6 //! con-leche's terms are persistent trees with sharing, which the port gives | |
| 7 //! reference counting: `P<T>` is the handle, and the model erases it | |
| 8 //! (`Arc T := T`, plus four definitions). Which *concrete* counted pointer | |
| == proof/ConRon/Generated/FunsExternal.lean#L25-L26 | |
| 25 @[rust_fun "alloc::sync::{alloc::sync::Arc<@T>}::new"] | |
| 26 def alloc.sync.Arc.new {T : Type} (x : T) : Result (alloc.sync.Arc T) := ok x | |
| == proof/ConRon/Generated/FunsExternal.lean#L36-L38 | |
| 36 @[rust_fun "alloc::sync::{alloc::sync::Arc<@T>}::ptr_eq"] | |
| 37 def alloc.sync.Arc.ptr_eq | |
| 38 {T : Type} (_A : Type) (_a _b : alloc.sync.Arc T) : Result Bool := ok false | |
| == proof/ConRon/Generated/FunsExternal.lean#L71-L72 | |
| 71 @[rust_fun "core::str::{str}::as_bytes"] | |
| 72 def core.str.Str.as_bytes (s : Str) : Result (Slice Std.U8) := ok s | |
| == Cargo.toml#L22-L23 | |
| 22 [profile.release] | |
| 23 overflow-checks = true | |
| == crates/con-ron/src/std_io.rs#L1-L12 | |
| 1 //! `std_io` — the binary's instance of the core's `CheckerIo` (DESIGN.md §3.9, | |
| 2 //! task #171): the file reads, the worker map, the escapes, and the rendering | |
| 3 //! of every event the verified driver (`con_ron_core::driver`) hands it, in the | |
| 4 //! binary's words. All of it is outside the theorems, which are about the | |
| 5 //! model instance (`proof/ConRon/MainTheorem/Model.lean`); what they assume of | |
| 6 //! a run of this one is OVERVIEW §3.1: the file operations it performs answer | |
| 7 //! as one snapshot (each path opened once, `olean_fs::RunFiles`), its maps' runs | |
| 8 //! are an oracle's, its escapes write no file and do not end the process. | |
| 9 //! | |
| 10 //! The text of a usage error, of a help or a synopsis are the binary's | |
| 11 //! (`bin/con-ron.rs`), handed in as `StdIoHooks`; the scheduler is | |
| 12 //! `crate::modular::schedule`. | |
| == crates/con-ron/src/bin/con-ron.rs#L206-L243 | |
| 206 fn main() -> ! { | |
| 207 let mut argv: Vec<String> = Vec::new(); | |
| 208 for a in std::env::args_os().skip(1) { | |
| 209 match a.into_string() { | |
| 210 Ok(s) => argv.push(s), | |
| 211 Err(_) => { | |
| 212 eprintln!("con-ron: an argument is not valid UTF-8"); | |
| 213 exit_after_verdict(3) | |
| 214 } | |
| 215 } | |
| 216 } | |
| 217 let h = std::thread::Builder::new() | |
| 218 .stack_size(driver::stack_bytes()) | |
| 219 .spawn(move || -> u8 { | |
| 220 let cps: Vec<Vec<u32>> = argv.iter().map(|a| con_ron::render::cps(a)).collect(); | |
| 221 let mut io = con_ron::std_io::StdIo::new(con_ron::std_io::StdIoHooks { | |
| 222 help: print_help, | |
| 223 synopsis: print_synopsis, | |
| 224 usage: usage_error, | |
| 225 }); | |
| 226 let code = con_ron_core::driver::cli::run_args(&mut io, &cps); | |
| 227 // the instance (and what it kept) is never dropped: con-leche task #336 | |
| 228 exit_after_verdict(code) | |
| 229 }); | |
| 230 match h { | |
| 231 Err(e) => { | |
| 232 eprintln!("con-ron: cannot spawn the checking thread: {}", e); | |
| 233 exit_after_verdict(3) | |
| 234 } | |
| 235 Ok(h) => match h.join() { | |
| 236 Ok(code) => exit_after_verdict(code), | |
| 237 Err(_) => { | |
| 238 eprintln!("con-ron: the checking thread died"); | |
| 239 exit_after_verdict(3) | |
| 240 } | |
| 241 }, | |
| 242 } | |
| 243 } | |
| == crates/con-ron/src/pool.rs#L50-L102 | |
| 50 //! | |
| 51 //! ## THE TRUSTED CLAIM, and the whole of it | |
| 52 //! | |
| 53 //! **If `parallel_all(n, workers, init, step, after)` returns `Ok(())`, then | |
| 54 //! every index in `0..n` was claimed by some worker; each worker built its | |
| 55 //! state with `init()` exactly once and folded `step` over the indices it | |
| 56 //! claimed, in claim order, which is increasing; and every one of those | |
| 57 //! `step` calls returned `Ok(())`** — at every worker count. That is | |
| 58 //! `ParallelAll` in `proof/ConRon/Refine2/Checker/Phased.lean` (task | |
| 59 //! #98-POOL; the increasing order added at task #143), and it is a statement | |
| 60 //! about this module's control flow only — nothing about what `init` and | |
| 61 //! `step` compute. With the driver's closures it is the capstone's pool | |
| 62 //! premise: index lists covering `0..ds.len`, each increasing, and for each | |
| 63 //! list a fold of `run_job` over it from `worker_state pins`, accepting, | |
| 64 //! which the proof relates, worker by worker, to the twin | |
| 65 //! (`pool_accepts_refines`). | |
| 66 //! | |
| 67 //! The claim is weaker than what the code does: the counter below hands each | |
| 68 //! index to exactly ONE worker, but the contract does not promise that — the | |
| 69 //! proof needs coverage and each worker's increasing order, nothing about | |
| 70 //! repetition across workers. The argument: | |
| 71 //! | |
| 72 //! * **A claim is a `fetch_add` on one counter.** Each value `0, 1, 2, …` is | |
| 73 //! handed to exactly one caller, so every index in `0..n` is claimed (by | |
| 74 //! exactly one worker, in fact). A worker stops at its first claim `≥ n`. | |
| 75 //! * **A worker's claims increase.** The counter only grows, so each | |
| 76 //! `fetch_add` a worker makes returns more than the one before it: the | |
| 77 //! order a worker steps its indices in is increasing. | |
| 78 //! * **A worker is one fold.** `worker` calls `init()` once, then for each | |
| 79 //! claimed index `k` calls `step(&mut st, k)` on that one state — the fold, | |
| 80 //! in claim order. `after(&st, k)` sees the state by `&` only. A claimed | |
| 81 //! index at or above `limit` is skipped without a call, and on an accepting | |
| 82 //! run the limit never moves (only a failing step lowers it), so no claimed | |
| 83 //! index is skipped. | |
| 84 //! * **Merge by index — master's argument.** A worker hands back each index | |
| 85 //! it stepped with the step's result; the workers' arrays are merged *by | |
| 86 //! index* into one table and `first_failure` walks it in index order, | |
| 87 //! answering `Ok` only if every slot holds `Ok`. So an accept means every | |
| 88 //! index was stepped, successfully, by the worker that claimed it, whatever | |
| 89 //! the timing. An empty slot is `ParallelError::Missing`, never `Ok`. | |
| 90 //! | |
| 91 //! The failure side is not part of the claim the capstone uses, but the pool | |
| 92 //! keeps master's behaviour there: the walk stops at the first failing index, | |
| 93 //! and the table is complete below it. con-leche's argument: a worker whose | |
| 94 //! step fails at `f` lowers the shared `limit` to `f`, and a worker skips a | |
| 95 //! claimed index at or above the limit. Every value the limit ever holds is | |
| 96 //! `n` or a *failing* index, hence at least the first failing index `f`; so an | |
| 97 //! index below `f` is never skipped, and — the counter being monotone — it was | |
| 98 //! claimed before `f` was and is finished by the worker that claimed it. | |
| 99 //! `pool_reports_the_first_failure_at_every_jobs` is the test, at 1, 2, 3, 4 | |
| 100 //! and 8 workers on a list whose records 2 and 4 both fail; | |
| 101 //! `pool_is_the_one_worker_walk_at_every_jobs` checks that the check phase's verdict | |
| 102 //! is the one-worker walk's; `parallel_all_partitions_the_indices` checks the | |
| == proof/ConRon/Refine2/Checker/Jobs.lean#L170-L174 | |
| 170 claimed twice. An index `≥ n` needs no clause: the driver's `step` fails there | |
| 171 (`jobStep`), so an accepting fold never claims one. `init` and `step` are the Aeneas | |
| 172 models of the two closures; `after`, the heartbeat hook, holds the state by `&` and is not | |
| 173 in the contract. It holds at every worker count. -/ | |
| 174 def ParallelAll {S E : Type} (n : Nat) (init : Result S) | |
| == crates/con-ron-core/src/arena/handle.rs#L511-L514 | |
| 511 /// con-leche: ConLeche/Kernel/Expr.lean:369-488 Expr | |
| 512 /// Lean twin: `proof/ConRon/Arena/Handle.lean:264-266 ETag.bvar` — the `bvar` | |
| 513 /// constructor, line 401. | |
| 514 pub const ETAG_BVAR: u32 = 0; | |
| == scripts/gates.sh#L6-L45 | |
| 6 # Runs, in order, and stops at the first failure: | |
| 7 # 1. cargo build the crate compiles, warning-free | |
| 8 # 2. cargo test the unit tests pass | |
| 9 # 3. scripts/lint-rust-style.sh the Aeneas subset (§3.4), both crates | |
| 10 # scripts/dead-rust.py --check no `pub` Rust item without a caller | |
| 11 # (task #105) | |
| 12 # 4. scripts/provenance.py check every item cites con-leche (§3.7) | |
| 13 # 5. scripts/provenance-selftest.py the gate's Lean parser and the | |
| 14 # bump classifier, on their fixtures | |
| 15 # 6. scripts/twin-lines.py check every `Lean twin:` line names a | |
| 16 # declaration of `proof/ConRon/**` at | |
| 17 # its current lines (§3.7) | |
| 18 # 7. scripts/overview-links.sh OVERVIEW.md/DESIGN.md line anchors | |
| 19 # 8. scripts/holes.sh --check OVERVIEW.md §8.1 == the model's holes | |
| 20 # 9. scripts/gen-pins.sh --check embedded pin text == natOpPinSets | |
| 21 # 10. scripts/gen-prelude.sh --check embedded prelude text == con-leche's | |
| 22 # 11. scripts/gen-prelude-lean.sh --check (B)'s embedded prelude bytes, ditto | |
| 23 # 12. scripts/extract.sh --check committed generated Lean == crate; | |
| 24 # SKIPPED (OK, 0 s) when its inputs match | |
| 25 # a green stamp in `_tmp/extract-green/` | |
| 26 # (task #177; EXTRACT_NO_STAMP=1 forces it) | |
| 27 # 13. cd proof && lake build the default targets elaborate: every | |
| 28 # library of the chain, Theorem 1 | |
| 29 # (`ConRonBridge`), Theorem 2 | |
| 30 # (`ConRonRefine2`), the composition | |
| 31 # (`ConRonMainTheorem`) included; any | |
| 32 # warning from proof/'s own sources fails it (lake-build-wfail.sh, #102) | |
| 33 # (LAKE_JOBS=N caps lake's parallelism through LEAN_NUM_THREADS — Lake 5 | |
| 34 # has no jobs flag; the first con-leche build can exhaust memory, #74). | |
| 35 # The same build also compiles what dead-census needs beyond the | |
| 36 # default targets (its four executables and two index roots), so their | |
| 37 # C compile overlaps the elaboration (task #177). | |
| 38 # 14. lake-seed the green build's artifacts hard- | |
| 39 # linked into the shared Lake cache | |
| 40 # (`_tmp/lake-cache`, CLAUDE.md), for | |
| 41 # the next checkout with the same | |
| 42 # bytes; LAKE_SEED=0 skips it (#177) | |
| 43 # 15. scripts/dead-census-gate.sh no declaration of proof/ConRon/** | |
| 44 # unreachable from the headline | |
| 45 # theorems, Tests and tooling (#105) | |
| == crates/con-ron-core/src/arena/mod.rs#L1-L22 | |
| 1 //! The arena: handles and the four interned stores (DESIGN.md §8.3/§8.5). | |
| 2 //! | |
| 3 //! | Rust | Lean twin | | |
| 4 //! |---|---| | |
| 5 //! | `handle` | `proof/ConRon/Arena/Handle.lean` | | |
| 6 //! | `store` | `proof/ConRon/Arena/Store.lean` | | |
| 7 //! | `monad` | `proof/ConRon/Arena/Monad.lean` | | |
| 8 //! | `expr_ops` | `proof/ConRon/Arena/ExprOps.lean` | | |
| 9 //! | `env` | `proof/ConRon/Arena/Env.lean` | | |
| 10 //! | `core_state` | `proof/ConRon/Arena/CoreState.lean` | | |
| 11 //! | `prop_read` | `proof/ConRon/Arena/PropRead.lean` | | |
| 12 //! | `core` | `proof/ConRon/Arena/Core.lean` | | |
| 13 //! | `fenv` | `proof/ConRon/Arena/FEnv.lean` | | |
| 14 //! | `core_io` | `proof/ConRon/Arena/CoreIO.lean` | | |
| 15 //! | `inductives` | `proof/ConRon/Arena/Inductives.lean` and `Inductives/*` | | |
| 16 //! | `pins` | `proof/ConRon/Arena/Pins.lean` | | |
| 17 //! | `check_decl` | `proof/ConRon/Arena/CheckDecl.lean` | | |
| 18 //! | `install` | `proof/ConRon/Arena/Install.lean` | | |
| 19 //! | `stream_index` | `proof/ConRon/Arena/StreamIndex.lean` | | |
| 20 //! | `needs` | `proof/ConRon/Arena/Needs.lean` | | |
| 21 //! | `justify` | `proof/ConRon/Arena/Justify.lean` | | |
| 22 //! | |
| == crates/con-ron-core/src/frontend/mod.rs#L19-L30 | |
| 19 //! | Rust | Lean twin | con-leche | | |
| 20 //! |---|---|---| | |
| 21 //! | `text` | none | none — the port's message rendering (`String` is `Vec<u32>`) | | |
| 22 //! | `nat_decimal` | none | none — `String.toNat?` on a `natVal` literal (`ron::nat` has no decimal codec) | | |
| 23 //! | `scan_types` | imported, not twinned | `ConLeche/Frontend/Scan/Types.lean` | | |
| 24 //! | `scan_fast` | imported, not twinned | `ConLeche/Frontend/Scan/Fast.lean` (the `@[csimp]` twin the compiler *runs*; `Scan/Naive.lean` is the specification and is not ported) | | |
| 25 //! | `prelude_text` | `include_str` | `ConLeche/Frontend/Prelude.lean:57-62`'s `include_str` — **generated**, `scripts/gen-prelude.sh` | | |
| 26 //! | `types` | `Arena/Frontend/Types.lean` | `Frontend/Export.lean`'s verdicts | | |
| 27 //! | `export_c` | `Arena/Frontend/ExportC.lean` | `Frontend/ExportC.lean` | | |
| 28 //! | `nat_op_ground` | `Arena/Frontend/NatOpGround.lean` | `Frontend/NatOpGround.lean` | | |
| 29 //! | `prepare` | `Arena/Frontend/Prepare.lean` | `Frontend/Prepare.lean` | | |
| 30 //! | `prelude` | `Arena/Frontend/Prelude.lean` | `Frontend/Prelude.lean` | | |
| == crates/con-ron-core/src/lib.rs#L33-L54 | |
| 33 //! ## `kernel` — the types and the pinned data | |
| 34 //! | |
| 35 //! | Rust | Lean | | |
| 36 //! |---|---| | |
| 37 //! | `name` | `ConLeche/Kernel/Name.lean` | | |
| 38 //! | `level` | `ConLeche/Kernel/Expr.lean` (Level part), `Kernel/Level.lean` | | |
| 39 //! | `prop_when` | `ConLeche/Kernel/PropWhen.lean` | | |
| 40 //! | `prop_read` | `ConLeche/Kernel/PropRead.lean` | | |
| 41 //! | `expr` | `ConLeche/Kernel/Expr.lean` (everything but the `Level` part) — the VALUE representation the pinned data is written in | | |
| 42 //! | `expr_ops` | `ConLeche/Kernel/ExprOps.lean` (what the pinned data and `level` still need of it) | | |
| 43 //! | `core_types` | `ConLeche/Kernel/Core.lean:45-59` (`CheckError`, `CheckM`) | | |
| 44 //! | `core_k` | `ConLeche/Kernel/Core.lean` (the pinned `Nat`/`Bool` operator names and the decimal renderer) | | |
| 45 //! | `env` | `ConLeche/Kernel/Env.lean` (the `ConstantInfo`/`Declaration` the pinned data is expressed in, and the `CheckMode` gates) | | |
| 46 //! | `fenv` | `ConLeche/Kernel/FEnv.lean` (what the pin comparisons need) | | |
| 47 //! | `canon` | `ConLeche/Kernel/Canon.lean` (the raw-pin canonicaliser) | | |
| 48 //! | `basis_names` | `ConLeche/Kernel/Basis/Names.lean` | | |
| 49 //! | `basis_builder` | `ConLeche/Kernel/Basis/Builder.lean` (the raw-pin DSL) | | |
| 50 //! | `basis_raw` | `ConLeche/Kernel/Basis.lean`'s `BasisKind.decls` | | |
| 51 //! | `std_axioms` | `ConLeche/Kernel/StdAxioms.lean` | | |
| 52 //! | `trust_pins` | `ConLeche/Kernel/TrustPins.lean` | | |
| 53 //! | `trust_axioms` | `ConLeche/Kernel/TrustAxioms.lean` | | |
| 54 //! | `nat_op_pins` | `ConLeche/Kernel/NatOpPinSet.lean` + `Kernel/NatOpPins.lean` (the record only: `natOpPinSets` is data, the last argument of `checkDecls` on both sides — §3.6, tasks #31/#43/#74) | | |