diff --git a/VERIFICATION.md b/VERIFICATION.md index daa8dae0f8..e240b9823f 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -2350,7 +2350,7 @@ Plants of the gate, each applied alone to the finished module and restored, and Command and host: `cargo test -p repo-conformance --test conformance -- conformance_sp_29` (164.8 s, peak resident set of the pinned Lean 717,500 KiB, one `lean` at a time, sampled every three seconds, on the 4-core 15 GB container) and `conformance_rb_20` (passes in about 40 s after the build). `lexlean verify` of the scratch project with the five modules: 63 s, against 52 s for the four without the module and 48 s with the fourteen machine arms and no module (the arms cost nothing measurable; the fourteen theorems about 15 s, a second each). Measured on a host that was busier than the one of the figures for the first four functions (39 s, 39 s, 46 s), so the ratios and not the seconds compare. -Plants of the gate, each applied alone to the finished module or to the generated text and restored: a theorem for another function, a function without a theorem, and a theorem that runs another function are each refused by the listing before Lean runs; a machine call whose primitive is another (`Prim.natEq` in the open goal), and a theorem that states another runtime item (the goal `= RustSemantics.ROutcome.stuck` left open), are each left unproved by Lean, the diagnostic pointing at the declaration of `refines_length_list`; a function of the oracle taken out of the generated text (`length_bytes`) is refused by the check that none is lost; a machine call with two operands of a one-operand primitive is refused by the validator that checks every rendering; a walk that counts two for a cell (`length_list result`), a walk that ticks an extra time (`length_list work`), an append with the lists the other way (`append_list`), an index at the next position (`index_list`), a slice short by one cell (`slice_list`), a comparison that does not count its first unit (`compare_bytes work`), a join that does not count its delimiters (`join work`), a split that refuses the maximum itself (`split_exact`), a decoding that does not count its bytes (`utf8_decode work`), a slice of bytes that counts one more (`slice_bytes work`), and a signature without its type parameter (the pinned rustc: `cannot find type `T``) are each refused by the differential; and a module with no std crate, a std crate of another profile, a machine primitive or a type the syntax lacks is refused by the decoder for the rule it breaks. +Plants of the gate, each applied alone to the finished module or to the generated text and restored: a theorem for another function, a function without a theorem, and a theorem that runs another function are each refused by the listing before Lean runs; a machine call whose primitive is another (`Prim.natEq` in the open goal), and a theorem that states another runtime item (the outcome of `TargetSemantics.primitive TargetSyntax.Prim.length [TargetSyntax.Value.list items]` left open, refuted to `False` by the constructor rules of `term_cases` since SM-35), are each left unproved by Lean, the diagnostic pointing at the declaration of `refines_length_list`; a function of the oracle taken out of the generated text (`length_bytes`) is refused by the check that none is lost; a machine call with two operands of a one-operand primitive is refused by the validator that checks every rendering; a walk that counts two for a cell (`length_list result`), a walk that ticks an extra time (`length_list work`), an append with the lists the other way (`append_list`), an index at the next position (`index_list`), a slice short by one cell (`slice_list`), a comparison that does not count its first unit (`compare_bytes work`), a join that does not count its delimiters (`join work`), a split that refuses the maximum itself (`split_exact`), a decoding that does not count its bytes (`utf8_decode work`), a slice of bytes that counts one more (`slice_bytes work`), and a signature without its type parameter (the pinned rustc: `cannot find type `T``) are each refused by the differential; and a module with no std crate, a std crate of another profile, a machine primitive or a type the syntax lacks is refused by the decoder for the rule it breaks. The differential compares the result and the counted work of the fourteen functions on lists of every length from 0 to 70 and of 1,000, 4,096 and 200,000 cells (four shapes each), on nine byte strings (empty, one byte, three, seventy, a thousand and 4,096 bytes, valid UTF-8 with a two-byte scalar, invalid, truncated) and eight texts (empty, one letter, multi-byte, with empty fields, a separator, 2,000 two-byte fields, 4,500 bytes, a four-byte scalar), at the positions, counts, delimiters and maxima that include the ends and the largest `u64` and `u32`. diff --git a/crates/conformance/src/cases/rust_lists.rs b/crates/conformance/src/cases/rust_lists.rs index 3ccff11458..1ae097adb5 100644 --- a/crates/conformance/src/cases/rust_lists.rs +++ b/crates/conformance/src/cases/rust_lists.rs @@ -327,7 +327,9 @@ const PLANTS: [Plant; 10] = [ "a refusal that is the opposite of the capacity", &["full_is_capacity", "cons_in_place"], "unsolved goals", - "⊢ RustMemory.Flag.yes = RustMemory.Flag.no", + // `term_cases` refutes `Flag.yes = Flag.no` (SM-35), so the case of + // the capacity check that answers `yes` is left at `False`. + "(RustMemory.size buf.slots) = RustMemory.Flag.yes\\n⊢ False", " | Option.none => (ctor RustMemory::Flag.yes)\n | Option.some got => (ctor RustMemory::Flag.no))", " | Option.none => (ctor RustMemory::Flag.no)\n | Option.some got => (ctor RustMemory::Flag.yes))", ), diff --git a/crates/conformance/src/cases/rust_std.rs b/crates/conformance/src/cases/rust_std.rs index b5f2222829..52291c943a 100644 --- a/crates/conformance/src/cases/rust_std.rs +++ b/crates/conformance/src/cases/rust_std.rs @@ -680,7 +680,9 @@ fn refinement() { "a theorem that states another runtime item", "(ctor RustSyntax::Item.lengthList)", "(ctor RustSyntax::Item.lengthBytes)", - "= RustSemantics.ROutcome.stuck", + // `term_cases` refutes the equation of two outcome constructors + // (SM-35), so the open goal is the outcome of `length` on a list. + "TargetSemantics.primitive TargetSyntax.Prim.length [TargetSyntax.Value.list items]", ), ] { assert_eq!( diff --git a/spec/src/Chapter17.lex.tex b/spec/src/Chapter17.lex.tex index f55a88a7fe..b8deb84443 100644 --- a/spec/src/Chapter17.lex.tex +++ b/spec/src/Chapter17.lex.tex @@ -812,7 +812,7 @@ result: DocRows::Item, body: constructor{ arguments: [ - (cons "A `term_cases` proof (language 1.2, `SM-35`) names a document term and a" (cons "nonempty, strictly sorted, duplicate-free list of prior document definitions." (cons "The term's type must be an inductive type of the document. It lowers to" (cons "`set_option linter.unusedSimpArgs false in cases llCase : <;> simp (config := {decide := true}) only [, llCase, ite_true, ite_false]`:" (cons "the goal is split on every constructor of the term's type, `llCase` is the" (cons "hypothesis that equates the term to the constructor, and the definitions, that" (cons "hypothesis, and the reduction of a conditional on a decided condition are the" (cons "only rewrite rules, with closed propositions decided; the unused-argument linter is off for the one script, because the list of definitions is a superset the unfolding draws on and an unused name is not an error. It is" (cons "admitted because an evaluation that matches on the same term twice, once" (cons "through a wrapper that matches on the result of the first, is a case-of-case" (cons "that conversion does not commute, so such an equation cannot be proved by" (cons "`reflexivity` or by `cases` on a local, which needs a name for the value; the" (cons "runtime profile's refinement statements (§17.17, `SP-22`) are of this shape." (cons "The proof carries no tactic name, option, or lemma: the definitions are the" (cons "only free choice, and each must be a prior definition of the document, so the" (cons "rewrite set is the document's own text and the hypothesis. It adds no axiom of" (cons "its own: the theorem's policy states the exact set the pinned Lean observes," (cons "which `simp` with decided propositions draws from `propext` (and from" (cons "`Classical.choice` and `Quot.sound` where the unfolded definitions use them), as" (cons "for `simplify`. The name `llCase` is reserved, so a theorem parameter cannot" (cons "take it. The canonical LaTeX of a semantic module is a catalog of its" (cons "declarations that states a theorem's statement and axiom policy and no proof, for" (cons "every proof form, so the form adds nothing to it." (nil String)))))))))))))))))))))))) + (cons "A `term_cases` proof (language 1.2, `SM-35`) names a document term and a" (cons "nonempty, strictly sorted, duplicate-free list of prior document definitions." (cons "The term's type must be an inductive type of the document. It lowers to" (cons "`set_option linter.unusedSimpArgs false in cases llCase : <;> simp (config := {decide := true}) only [, llCase, ite_true, ite_false, reduceCtorEq, false_implies, imp_self, and_true, true_and, Option.some.injEq, Except.error.injEq, Except.ok.injEq, List.cons.injEq, ]`," (cons "where `` is `..injEq` for every constructor `c` with at least" (cons "one field of every inductive type `T` the module declares, in declaration order:" (cons "the goal is split on every constructor of the term's type, `llCase` is the" (cons "hypothesis that equates the term to the constructor, and the definitions, that" (cons "hypothesis, the reduction of a conditional on a decided condition, and the fixed" (cons "constructor rules are the only rewrite rules, with closed propositions decided." (cons "Deciding closed propositions does not decide an equation between constructors" (cons "over variables, such as `Verdict.good = Verdict.bad p` or" (cons "`Verdict.bad x = Verdict.bad p`; the constructor rules do. `reduceCtorEq`, the" (cons "pinned Lean's no-confusion simplification procedure, rewrites an equation between" (cons "two different constructors to `False`; each `injEq` lemma, which Lean generates for" (cons "every constructor with a field, rewrites an equation between two applications of" (cons "that constructor to the equations of their fields; `false_implies`, `imp_self`," (cons "`and_true`, and `true_and` close the implication and the conjunction those" (cons "equations leave. The" (cons "constructors of `Option`, of `Result` (Lean's `Except`), and of `List` are named" (cons "because a statement about a document term commonly returns one of them. So a" (cons "theorem such as \"if the check returns `bad p`, the report names `p`\" is proved, and" (cons "a case that is false is still left open and the theorem rejected. The rule set is" (cons "fixed by the module's declarations, and every rule is named in the script; none is" (cons "drawn from `simp`'s default set. The unused-argument linter is off for the one" (cons "script, because the list is a superset the unfolding draws on and an unused name is" (cons "not an error. It is" (cons "admitted because an evaluation that matches on the same term twice, once" (cons "through a wrapper that matches on the result of the first, is a case-of-case" (cons "that conversion does not commute, so such an equation cannot be proved by" (cons "`reflexivity` or by `cases` on a local, which needs a name for the value; the" (cons "runtime profile's refinement statements (§17.17, `SP-22`) are of this shape." (cons "The proof carries no tactic name, option, or lemma: the definitions are the" (cons "only free choice, and each must be a prior definition of the document, so the" (cons "rewrite set is the document's own text and the hypothesis. It adds no axiom of" (cons "its own: the theorem's policy states the exact set the pinned Lean observes," (cons "which `simp` with decided propositions draws from `propext` (and from" (cons "`Classical.choice` and `Quot.sound` where the unfolded definitions use them), as" (cons "for `simplify`. The name `llCase` is reserved, so a theorem parameter cannot" (cons "take it. The canonical LaTeX of a semantic module is a catalog of its" (cons "declarations that states a theorem's statement and axiom policy and no proof, for" (cons "every proof form, so the form adds nothing to it." (nil String))))))))))))))))))))))))))))))))))))))))))) ], constructor: DocRows::Item.para, type_arguments: [] diff --git a/spec/src/IdsSM.lex.tex b/spec/src/IdsSM.lex.tex index 56e14aeaa3..b747f7a160 100644 --- a/spec/src/IdsSM.lex.tex +++ b/spec/src/IdsSM.lex.tex @@ -280,7 +280,7 @@ name: sm35, parameters: [], result: Rows::IdRow, - body: (record Rows::IdRow {id := "SM-35", level := "build", suite := "semantic-ir", statement := "A language-1.2 theorem may be proved by `term_cases`, a split on the value of a document term: the proof names a term and a nonempty, strictly sorted, duplicate-free list of prior document definitions, the term's type is an inductive type of the document, and the backend lowers the proof to a split of the goal on every constructor of that type with the hypothesis that equates the term to the constructor, then `simp only` over the named definitions, that hypothesis, and the reduction of a conditional on a decided condition, with closed propositions decided, which uses exactly the axioms the theorem's policy states; the schema, the linker, the notation, the Lean backend, the canonical LaTeX, and the formatter accept it, and a use in language 1.1, a term whose type is not an inductive type of the document, an empty list, an unsorted or repeated name, a name that is not a prior definition, and a theorem parameter that takes the hypothesis's name are each refused.", sections := "§17.10"}), + body: (record Rows::IdRow {id := "SM-35", level := "build", suite := "semantic-ir", statement := "A language-1.2 theorem may be proved by `term_cases`, a split on the value of a document term: the proof names a term and a nonempty, strictly sorted, duplicate-free list of prior document definitions, the term's type is an inductive type of the document, and the backend lowers the proof to a split of the goal on every constructor of that type with the hypothesis that equates the term to the constructor, then `simp only` over the named definitions, that hypothesis, the reduction of a conditional on a decided condition, the refutation of an equation between two different constructors, the injectivity equation of every constructor with a field of `Option`, `Result`, `List`, and each inductive type the module declares, and the fixed rules that close an implication from `False` or of a proposition by itself and drop `True` from a conjunction, with closed propositions decided, which uses exactly the axioms the theorem's policy states, so a theorem whose cases need constructor disjointness or injectivity verifies and a false one is rejected by Lean; the schema, the linker, the notation, the Lean backend, the canonical LaTeX, and the formatter accept it, and a use in language 1.1, a term whose type is not an inductive type of the document, an empty list, an unsorted or repeated name, a name that is not a prior definition, and a theorem parameter that takes the hypothesis's name are each refused.", sections := "§17.10"}), executable: true }