Repository navigation
An application is inferable only when its arguments are, so a + let of Equal.cong over a function name goes to the kernel annotated - #1136
Conversation
…f Equal.cong over a function name goes to the kernel annotated inferable(o) said an application infers when its head does, whatever its arguments. But an argument of a function type goes out eta-long, a lambda, which the kernel cannot infer; and a + let, or a rewrite's evidence, is inferred. So `+h2 = Equal.cong(A, B, snd_of, x, mk(n), h)` went out as `!+x3 = (Equal.cong ... -λx3 => (snd_of x3) ...)`, bend2 accepted the file and the kernel answered "expected: an annotated term / observed: λx3 => (snd_of x3)" (bendlang#1133). With the arguments in the question, let_term and rwt_term annotate the value with the type bend2 knows: `!+x3 = {(Equal.cong ...) : {(snd_of x1) == ... : Bool}}`. tests/proof/cong_lambda_argument.bend is the issue's lemma: on main `bend f.bend` says ALL PROOFS CHECK and `--verdict` SOME PROOFS FAIL; here both say ALL PROOFS CHECK, and so does the kernel binary on the emitted .bendtt, with the function written as `snd_of` or as `p => snd_of(p)`. Over tests/proof, tests/check and tests/spec (338 files) `--verdict` answers the same on main and here, file by file; the new test prints True on the interpreted, JS and C lanes; gates/repo.ts passes 47 / 47. Co-Authored-By: Claude Fable 5.1 <[email protected]>
|
Another data point for this fix. On main b2111cf (Darwin arm64), this 3-line file passes import Base
def t3(a: Nat, e: {a == 0n : Nat}) -> {1n+a == 1n : Nat}:
+tr = Equal.cong(Nat, Nat, x => 1n+x, a, 0n, e)
trIt fails the same way with |
|
Thanks for the careful report and the repro. I'm closing this because the fix works against how the elaborator is meant to relate to the kernel: The kernel does infer this application
What actually fails: the
|
| variant | result |
|---|---|
as emitted (!+x3 = (Equal.cong … -λx3 => (snd_of x3) -x1 -(mk x0) x2)) |
FAIL, observed: λx3 => (snd_of x3) |
same value, !x3 (q = 1, no V : *2 check) |
CHECK |
| same value, no let | CHECK |
-snd_of instead of the λ (head of the redex is a Ref) |
CHECK |
+ let of Equal.cong … -x0 -x0 {==} (both redex arguments are Vars) |
CHECK |
+ let of Equal.cong … -(mk x0) -(mk x0) {==} |
FAIL, same error |
a bare {{((λx1 => snd_of x1) (mk x0)) == … : Bool} : *2} in a type |
FAIL, same error |
the same with x0 as the argument |
CHECK |
So the argument never needed to be inferable. Annotating the whole let works only because it replaces the kernel's un-β-reduced V with bend2's reduced one. A fix should keep inferable equal to Term.infer and target this directly. For example, annotate a let whose emitted quantity is 2 (including a q=1 let let_term promotes to 2) with bend2's type.
|
Thank you, @nicolas-abril, that was the explanation I was missing, and it also answers a variant I couldn't account for (a variable endpoint passing with the same emitted let: the |
Fixes #1133, on the elaborator's side.
What happens
inferable(o)insafe.tssays an application infers when its head does, whatever its arguments. But an argument of a function type goes out η-long, a lambda, which the kernel cannot infer; and a+let (or a rewrite's evidence) is inferred, not checked. Sowent out as
!+x3 = (Equal.cong … -λx3 => (snd_of x3) …), bend2 accepted the file and the kernel answeredexpected: an annotated term / observed: λx3 => (snd_of x3). Without the+the let is checked against its use and the same term passes, which is why #1133's table turns on the+.The change
One line: an application is inferable when its head and its arguments are. With that,
let_termandrwt_termdo what they already do for any other non-inferable value, annotate it with the type bend2 knows:I checked the kernel side too, in case you'd rather fix it there: on the emitted
.bendtt, the same lambda annotated by hand passes, a bare-snd_ofpasses, and annotating only the lambda's body does not. So the kernel wants the argument inferable, and the elaborator now makes the let so.Checks (Linux x86-64, kernel binary 7f6ef51c)
tests/proof/cong_lambda_argument.bendis the issue's lemma with amain. On main,bend f.bendsaysALL PROOFS CHECKand--verdictsaysSOME PROOFS FAIL; here both sayALL PROOFS CHECK, and so does the kernel binary on the emitted.bendtt, with the function written assnd_ofor asp => snd_of(p).tests/proof,tests/checkandtests/spec(338 files),--verdictanswers the same on main and here, file by file.Trueon the interpreted, JS and C lanes;gates/repo.tspasses 47 / 47.Not run:
gates/safe.tson a cluster, and macOS.