Repository navigation
Conversation
56977b6 to
a44617d
Compare
Lorenzobattistela
left a comment
There was a problem hiding this comment.
Thanks for this. #1483 still reproduces on main, and the approach of lifting captures into kernel parameters is the right direction. I rebased the branch onto main (2e9722d): safe.ts conflicted with #1225, #1580, #1666 and #1704, so please pull before you push again. I ran the gates on the rebase and probed --verdict. These must change before merge:
-
The kernel can check a different statement from the one bend2 checked. A capture's name is keyed by (level, type) across the whole pass, so inside a lifted instance a local variable at the same level and type gets the same name as an outer capture:
def T(
f: Nat -> Bool, h: Nat, xs: List<&2, Nat>) -> Data:&2, ~Nat, ~(y => Bool.and(f(y), Nat.is_le(y, h))), xs) == True{} : Bool}
{List.all(def thm(lo: Nat, h: Nat) -> T(~(y => Nat.is_le(lo, y)), h, []):
{==}lo and h both become \0capture0, and the emitted predicate is
is_le(x0, y) && is_le(y, x0), so lo is gone. Please name captures by their position in the instance's cols instead. That also removes the duplicate instances:leastandshiftedin your test emit byte-identical List.all instances. -
This adds a new false reject. Main passes this with --verdict, and the PR fails it:
law refl_all:
forb: Bool&2, ~Bool,
for xs: List<&2, Bool>
{List.all((y => Bool.and(y, b)), xs) == List.all(&2, ~Bool, ~(y => Bool.and(y, b)), xs) : Bool}def refl_all(b, xs):
{==}spec_val no longer throws Open_Error, so root_emit's fallback (#1225: when G calls a template at one of k's ~ parameters, the arms name the instances bare) never fires. G lifts the law's own ~b as a capture, and the kernel cannot equate the lifted recursive instance with the closed one. Please keep the Open_Error path there, or don't lift a root's own ~ parameters.
-
safe.ts is now 25,001 ttok, and its cap is 24,000. Main is at exactly 24,000, so the PR has to fit inside the current budget.
-
tests/check/template_type_capture.bend fails the test gate: bend2 also prints
Use --verdict for mathematical validity., so the file needs that second#|line. Note that this test prints the same thing on main, so the test gate cannot catch a regression here; only gates/safe.ts tells main and the PR apart.
Should change:
-
spec_val no longer re-checks that the closed argument is closed. A variable with a value (
s.c[i].v) is replaced by that value without closing the variables free inside it, so an open Var can reach an instance's cols. Before, this case went out of scope cleanly. Please re-run thementionscheck afterclose. -
args lifts captures in live positions too. The WONTFIX text ("does not admit runtime captures in live template applications") then rests only on bend2's checker. Please keep the oos(..., Open_Error) when
liveis true. -
The
wrapcomment in tests/check/spec_finite_match.bend is stale: its emission changes on this PR. The same goes for the Open_Error comment and the Scope/Safe field comments in safe.ts. The code lifts any typed variable, not only Data, so "Data captures" in the header and in WONTFIX overstates it.
Minor: capkeys and captypes are not in Trail/undo. Once a pass has one capture, every item reference re-walks its cols in spec_caps. Nothing tests the group (mutual recursion) capture path.
Gates on the rebase: ping 73/73; perf 122/124, the same as main; safe has 0 false rejects on tests/ (finding 2 is not in the suite).
|
Thanks — pulled a44617d. I’m fixing the capture-name collision and the root |
|
The collision and root Still 25,029/24,000 tokens, so I put this back in draft. I tried retaining open |
|
Checked the mutual case through a real temporary Prelude, not a constructed Book. Both the captured predicate and a fully closed control stop at The ordinary capture regression and the 1,721-file corpus pass, but this stays draft at 25,029/24,000. The generic-parameter alternative failed the actual kernel, so I dropped it rather than weaken the check. Would you rather hold this until there’s room, or is there a simplification you’d prefer here? I’ll leave the cap alone. |
|
Closing in favor of #1959, which fixes #1483 with the same idea (lift the template argument's run-time captures into the instance's parameters) but numbers captures by position inside closed_val, so it needs no pass-global maps and stays much smaller. It also covers the two issues from the earlier review here (capture name collisions and the ~b root fallback). Thanks for the groundwork on this one. |
|
Thanks for carrying the idea forward in #1959. Positional capture numbering is a better fit than the global maps here. |
Addresses #1483; still draft.
A predicate used in a type can capture a runtime value without turning it into a global constant. Each instance now owns its typed captures in
cols, and its cache key names them by position. This fixes the collision between an outer capture and a local at the same frontend level.The root
~probe keeps its closed-instance fallback. Live runtime capture lifting still raisesOpen_Error; closing an argument also checks for leftover free variables.The new dependent-proof regression failed in BendTT before and now checks. The full local safe corpus has 1,721 files: 1,111 agree, 492 frontend rejections, 115 unsafe, 3 out of scope, and no false rejects, timeouts or infrastructure errors.
Not ready to merge:
safe.tsis 25,029 / 24,000 tokens. No cap changes. The mutually recursive capture-group case is not qualified yet.