Skip to content

A let the kernel reads at quantity 2 goes out with bend2's type, since the kernel checks the type it infers against *2 before any β-reduction - #1159

Closed
aldeni wants to merge 1 commit into
bendlang:mainfrom
aldeni:verdict-plus-let-annotated

Conversation

@aldeni

@aldeni aldeni commented Sep 28, 2026

Copy link
Copy Markdown
Contributor

Fixes #1133, the way @nicolas-abril's analysis on #1136 lays out; thank you for it, it was the explanation I was missing. inferable stays as it is, the mirror of Term.infer.

What happens

For a let at quantity 2 (a + let, or one let_term promotes when the kernel counts more than one use), the kernel infers the value and checks the type it inferred against *2. That type comes from plain substitution, with no β-reduction, so a + let of Equal.cong(A, B, f, x, mk(n), h) gives {((λx => f x) x) == ((λx => f x) (mk n)) : B}: the left side passes by the elim rule for a Var argument, the right side sends the kernel to infer the λ, and it refuses expected: an annotated term. bend2's instantiation β-reduces as it builds, so it never meets that term.

The change

let_term annotates a let whose emitted quantity is 2, the promoted case included, with the type bend2 knows for its value, unless the value already carries one. The type's elaboration is kept as a thunk from the let's own scope, so nothing is built for the lets that don't need it. Nothing else moves: inferable, the self-call re-binding and the "no known type" refusal are as on main.

!+x2 = {(Equal.cong -Nat -Nat -λx2 => (.Succ, (x2, ())) -x0 -(.Zero, ()) x1) : {(.Succ, (x0, ())) == (.Succ, ((.Zero, ()), ())) : Nat}}; x2

Checks (Linux x86-64, kernel binary 7f6ef51c)

Not run: gates/safe.ts on a cluster, and macOS.

…e the kernel checks the type it infers against *2 before any β-reduction

For a let at quantity 2 (a + let, or one let_term promotes when the
kernel counts more than one use), the kernel infers the value and
checks the type it inferred against *2. That type is plain
substitution, with no β-reduction, so a + let of
Equal.cong(A, B, f, x, mk(n), h) gives {((λx => f x) x) == ((λx => f x)
(mk n)) : B}: the left side passes by the elim rule for a Var argument,
the right side sends the kernel to infer the λ, and it refuses "an
annotated term" for a file bend2 accepts (bendlang#1133; the analysis on bendlang#1136
by Nicolas Abril). bend2's instantiation β-reduces as it builds and
never meets that term.

let_term now annotates a let whose emitted quantity is 2, the promoted
case included, with the type bend2 knows for its value, unless it
already carries one; the type's elaboration is a thunk from the let's
own scope, so nothing is built for the lets that need none. inferable
stays the mirror of Term.infer; the self-call re-binding and the "no
known type" refusal are as before.

tests/proof/cong_plus_let.bend holds both shapes reported: the pair
domain with a def as the function, and the Nat case with a λ at the
source. On main 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. Over tests/proof, tests/check and tests/spec (338
files) --verdict answers the same on main and here, file by file; the
test prints True on the interpreted, JS and C lanes; gates/repo.ts
passes 49 / 49.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@nicolas-abril

Copy link
Copy Markdown
Collaborator

Thanks for this! #1133 is now fixed in the kernel by #1158: Term.infer's App rule puts a λ argument into the type annotated with its domain, so the calls it makes there infer, with no change to the elaborator. I ran your tests/proof/cong_plus_let.bend against it and --verdict says ALL PROOFS CHECK, so closing this one in favor of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--verdict: the kernel rejects a +-bound Equal.cong over a pair whose endpoint is a call (an unannotated eta-expansion), and the verdict does not say why

2 participants