Repository navigation
--verdict takes a ~ constant's model from the template's instances, not from a search - #1580
Conversation
…ot from a search
safe.ts checks a template root once, each ~ parameter an opaque constant
that needs a closed model. The model is now the argument a bend2 instance
of the root passes at that parameter, checked at the constant's type in
the model book, so it fits the constants before it. The search builds a
model only for a root with no instance that fits. The constant stays
opaque in the root, and the kernel checks every model.
A root whose ~ argument no constructor, {==} or projection model proves
(an injectivity proof, bendlang#1182's use~F) now reaches the kernel when a call
instantiates it. Its constants come from one call, so they fit together
without backtracking.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Nice, the instance-as-model idea is clean and the kernel still checks every model. One issue: since #1358, roots share a main: ALL PROOFS CHECK; this PR: One fix: put the instance model in the sharing key, so roots share a constant only when they share its model (+9/-6, safe.ts 23,863). It costs some of #1358's sharing when roots pass different arguments. Another option is to keep sharing and redo a root with its own constants when a reused one leaves a later constant without a model. Which do you prefer? Gates on this PR merged with main: repo 54/54, test 1636, ping 58, perf 124/124, safe 0 false rejects. |
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Since bendlang#1358 a root reuses the constant an earlier root made at the same place and type. With instance models, that constant's model came from the earlier root's instance, so an unrelated template could leave a later constant without a model (use4~R in the test, from app~f := pred). The model is now part of the sharing key, so a root's models are its own whatever the order of the book. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Thanks, good catch. I went with the first option, the model in the sharing key (d913fa4, 23,794 ttok). A reused constant then always has the model the root would have given it alone, so a root's verdict doesn't depend on other templates or on the order of the book. The second option re-runs a root when a choice fails, which is the backtracking we're trying to keep out of safe.ts.
Could you check the square-packing book from #1358? That's where losing sharing would actually show. |
A projection model took a λ variable before a constructor, for a ~ law no constant satisfies. With models taken from instances, no test and no bend-mathlib module that reaches the kernel needs one, on this branch or on main: every verdict is unchanged without them. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
|
Reviewed the new head (90a03b6). The instance-as-model idea works on the PR's own test: on main Two problems: 1. The verdict depends on the order of calls. With 2. 90a03b6 breaks uncalled templates. Dropping the projection models removed the fallback, so a The PR gives "no model for tk~p" and SOME PROOFS FAIL. Main gives ALL PROOFS CHECK. A realistic version is an Iso record's identity law, which the PR now rejects even though it's true. It's a false reject, not unsoundness, but no test covers it. Smaller things, not blocking:
|
This reverts 90a03b6. A template nothing calls still needs a model of each ~ parameter, and some laws hold only of a projection, e.g. a record whose field g must satisfy {g(S{Z{}}) == S{Z{}}}.
inst_pick takes the first instance of the root whose ~ arguments all fit, each at its parameter's type after the ones before it, so models from different instances never mix and the verdict does not depend on the order of the calls. The check runs as the root's own code, so an argument that calls a template no longer throws, and only bend2's check errors count as "does not fit".
Thanks. I pushed c7c96fb and d08a415. 1. Order of calls. All of a root's models now come from one instance, as you suggested. 2. Uncalled templates. c7c96fb reverts 90a03b6, so projection models are back and Both of your cases are now in The bare Not changed:
Checks at d08a415:
I've updated the PR body. |
sorted_cons_cons_elim_le/tail called internal_all_cons_test with a variable pair head, which --verdict reports as a TypeScript/BendTT mismatch. internal_sorted_cons_test states the step with the head written as (x, y), like internal_sorted_cons_true/false. 2.0.38 takes a ~ constant's model from a concrete call of its law (bendlang/bend#1580), so algebra, order, sort and all now pass --verdict too: the verdict job checks every module with it and the kernel-only fallback for them goes. README, SKILL and PLAN F38 follow.
…nd 2.0.38, every module passes --verdict Bend 2.0.38 changed Base (List.all/any/find/contains short-circuit through a thunk, String.order defined directly), so 0.7.3.0 no longer checks on it; PR #26 from @nohzafk re-proved the internal bridges, with no statement changes. 2.0.38 also includes bendlang/bend#1580, so algebra, order, sort and all pass `bend --verdict` like the other modules: a --verdict project can import any of them (issue #25). release.ts now requires a clean --verdict on every module. Verified from an empty BEND_LIB: importing 0.7.4.0's nat, sort and all prints ALL PROOFS CHECK under --check-only and --verdict; the README and SKILL examples check against the hub package. Closes bend-3ev Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NJjQ47v3mvnKmc8XojZitg
…-verdict (#59) * fix(intrusive list): rename Root's Ready to RootReady, for Bend 2.0.36+ Bend 2.0.36 added `type Poll ... Ready{value} Wait{rest}` to Base (bendlang/bend#1259), and Base's names are global, so `type Root is Data: Ready{} Waiting{}` fails with "duplicate declaration: Ready" on 2.0.36 and 2.0.37. That stops the intrusive list's proof, its example and every root that imports them (laws_containers.bend, proofs/PROOF.bend). array_adapter.bend is regenerated from array_adapter.src with tools/generators/mac.py (which reproduces the committed file byte for byte before the change). Co-Authored-By: Claude Opus 5.5 <[email protected]> * proofs: concrete calls of the generic laws --verdict needs a model for From bendlang/bend#1580 (on bend main, after 2.0.37), --verdict takes a ~ constant's model from a call of its def at concrete ~ arguments, and no longer searches for one. Nothing called prepend_valid, remove_head_valid, optional_suffix, remove_nonhead_valid, prepend_preserves, remove_head_preserves or remove_nonhead_preserves (at ~reflex) or set_post (at ~hp) at any, so the kernel never saw them. One call each, at Bool (with a local bool_eq) and at the empty map with m2 = set(m, key, x), gives them models; the laws still hold for every argument. On 2.0.37 these calls check and change nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]> * fix(proofs): preserve verdict instances in edits source template --------- Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Giulio Rebuffo <[email protected]>
Supersedes #1444. Refs #1182.
Problem
--verdictchecks a template root once, with each~parameter as an opaque constantk~p. The kernel has no axioms, so each constant needs a closed model of its type. Today the model is searched for: constructors,{==}, projections, in bounded rounds. That search can't prove an injectivity law (#1182'suse~F), and it picks models one constant at a time, so later ones may not fit (#1263).#1444 adds a lookup: any def in the book whose type is definitionally equal. That fixes the reported case, but it makes a root's verdict depend on unrelated defs, and it starts selecting premises by type, the first step of a prover. Each case it misses invites another rule. safe.ts should translate the program, not solve for terms.
Change
A constant's model is the argument that a bend2 instance of the root passes at that parameter (
book.tmps, already read ase.inst). It is the user's own term, and bend2 already checked it at that type. All of a root's models come from one instance:inst_picktakes the first instance whose~arguments all fit, each checked in the model book at its parameter's type after the ones before it. Each model is checked again at its constant's type. The search builds a model only for a root with no instance that fits, e.g. a law nobody calls.use2(~pred, ~inj2, …)in the new test: a built modelf := n => Z{}leaves no model forP, and pred plus inj2 fit. Int,ia'sg(n => pp(n, n)) usesntwice, soiadoesn't fit, andttakesf,gandPall fromib, in either order.~(n => app(~pred, n))) used to throw a TypeError, which was read as "doesn't fit". It now checks. Only bend2's check errors count as "doesn't fit", and any other error is thrown.def_emitreuses the model chosen inroot_emitinstead of searching again, androot_emitfits the instance's argument before it searches, so the search runs only for a constant with no fitting argument.~constant (Roots share their ~ constants, so a template goes to the kernel once instead of once per root that uses it #1358) only where they give it the same model (d913fa4), so a root's models are its own whatever the order of the book. Ontests/that loses a little sharing: the BendTT is 33.70 MB against 33.58 MB on main.tkin the test is an example: its~p: Pkrecord needsg := n => n.Checks
tests/proof/template_inst_model.bend: on main,--verdictgivesno model for use~Fandno model for use2~P. Here it givesALL PROOFS CHECK. Running it prints({==}, {==}, Z{}). It also covers both of @Lorenzobattistela's review cases (use4, andt/ia/ib), plus the uncalledtk. On 90a03b6,tfails withiafirst (no model for t~P) andtkfails (no model for tk~p).tests/**/*.bend(1,648 files) ran under--verdictwith the local Lean 4.34.0 kernel, at d08a415 (5363880 gives the same verdicts):tests/check/safe_parameterized_unit.bend, which goes from out of scope (no model for idt~A; no Base, so noUnitmodel) toALL PROOFS CHECK, withA := Infrommain's call.gates/safe.ts tests: agree 1060, unsafe 93, bend2 rejects 492, out of scope 3, 0 false rejects.safe.ts: 23,978 / 24,000 ttok.tsc: same diagnostics insafe.tsas 90a03b6.Limits
injbut never callsuse, souse~Fstill has no model and stays out of scope. That is deliberate: nothing in the program says which term stands forF.@unsafecode), its root now goes out of scope where a built model used to reach the kernel. No test intests/does this; the hub corpus was not run.--verdictondemos/app_slash_boss_3d/bend3d.bendtakes 0.26 s against 0.28 s on main;nat_literal_no_arithmetic.bendtakes 0.12 s against 0.06 s.🤖 Generated with Claude Code