Repository navigation
The kernel puts a λ argument into a type annotated with its domain, so a + let of Equal.cong over a function checks (#1133) - #1158
Merged
Conversation
…o a + let of Equal.cong over a function checks (bendlang#1133) The App rule gave B[x]. When x is a λ or λ-match (the η-long form of a function argument), B's calls of it become redexes with a λ head, which Term.infer rejects ("an annotated term"). A + let checks its inferred type as Data, which infers those calls: Equal.cong(A, B, f, a, mk(n), h) failed there while bend2, which β-reduces as it substitutes, accepted it. The rule now gives B[{x : A}] for such an x (Term.arg): the call infers through the annotation, at any arity, partially applied, with arguments that do not infer (constructors) and with types that depend on them. {x : A} is a Par reduct away from x (unann), so chk lands on the same Typed.app plus one conversion; Typed and every other proof are unchanged. tests/proof/cong_lambda_argument.bend covers one and two arguments, a partial application and a constructor argument. Over the tests, the kernel's verdict changes only on it (1026 others agree). Of the 6560 arguments annotated over the tests, 46 land in a type (the others go into a B that does not mention them); the kernel retires 98.16G instructions over the suite against main's 98.27G. bendtt.lean is at 63901 ttok. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
nicolas-abril
force-pushed
the
kernel-annotated-arg
branch
from
September 28, 2026 12:23
35b7530 to
c7fd476
Compare
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1133 in the kernel. Supersedes #1136, which annotated in the elaborator and made
inferablestricter thanTerm.infer.What fails
Term.infer's App rule returnsB[x]. Whenxis a λ or λ-match (the η-long formsafe.tsgives a function argument), each call(f a)inBbecomes a redex with a λ head.Term.infercan't type a bare λ, andelimonly covers a variable argument. A+let checks its inferred type as Data, which infers those calls:V = {((λx3 => snd_of x3) x1) == ((λx3 => snd_of x3) (mk x0)) : Bool}. CheckingV : *2reachesinfer (λx3 => …)on the right side and fails withexpected: an annotated term. bend2 accepts, because its HOAS substitution β-reduces.The change
The rule has just checked
x : A, so it puts{x : A}intoB. Every such call then has an annotated head, which the ordinary App rule infers. That covers any arity, partial applications, arguments that don't infer (constructors), and types that depend on the argument.Proofs
Typedis unchanged.{x : A}reduces toxin onePar.unannstep, sochk's App case adds one conversion.lean bendtt.leanelaborates with nosorry, andconsistent,book_check,sr,progress,halts,emptyandconfluentdepend only onpropext,Classical.choiceandQuot.sound.Checks (macOS arm64, Lean 4.34.1)
tests/proof/cong_lambda_argument.bendcovers one and two arguments, a partial application (fst_snd(x) : U32 & Bool -> Bool) and a constructor argument (Bool.not(True{})). It printsTrueand--verdictsaysALL PROOFS CHECK. The kernel onmainrejects it..bendtt(1026) except the new test.Bthat doesn't mention the argument, so the type comes out the same as without it. Over the suite the kernel retires 98.16G instructions againstmain's 98.27G (−0.11%). A build that never annotates is at +0.05%, so the difference is noise.bendtt.leanis at 63901 ttok.gates/repo.tspasses 49 / 49.Not run:
gates/safe.tsandgates/test.tson the cluster.A λ-headed redex written directly into
.bendtttext still doesn't infer, as onmain. The elaborator never emits one, because bend2's checked terms are already β-reduced.🤖 Generated with Claude Code