Skip to content

A spliced inline lambda applied to a rebuilt column emits an un-annotated beta-redex, so --verdict rejects what bend2 accepts #1175

Closed

Description

@yavuzerayut

What you did

BEND_NO_TELEMETRY=1 bend inl2b.bend --check-only, then --verdict

What happened

--check-only prints ALL PROOFS CHECK; --verdict fails with the TypeScript/kernel mismatch banner. The emitted BendTT contains an un-annotated beta-redex: a Kind-specialized parameter's inline-lambda value is spliced into the instance body and applied to a column-rebuilt tuple, emitting App(Lam, Tup) with no Ann around the lambda — the kernel's inference then fails with "expected an annotated term". When the same spliced lambda is applied to a plain variable instead, the kernel's bidirectional App-on-Var rule handles it and the file passes both gates.

Minimal shape (the erased -A: Kind(q1(f)) parameter forces f's field to specialize, splicing (y: Nat) => 1n into the body of run3's instance):

import Base

type Box is Type:
  Mk{fn: Nat -> Nat}

def q1(f: Box) -> Quant:
  match f:
    case Mk{g}: &1

def run3(f: Box, -A: Kind(q1(f)), +x: Nat) -> Nat:
  match f:
    case Mk{g}:
      match x:
        case 0n: g(x)
        case 1n+p: g(p)

def obs() -> Nat: run3(Mk{(y: Nat) => 1n}, Nat, 0n)

Emitted (the case 0n arm): (λx0 => (.Succ, ((.Zero, ()), ())) (.Zero, ())) — the lambda applied to the rebuilt tuple with no annotation, which the kernel rejects; the 1n+p arm's (λx0 => ...) x1 (variable argument) is accepted via the kernel's special App-on-Var rule.

Both gates agree on the trivial non-specialized variant, so this is specifically the spliced-lambda-at-non-Var-argument emission path.

bend --version

bend 2.0.32

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 17.0.0 (clang-1700.0.13.5)

Activity

  1. yavuzerayut commented on Sep 29, 2026

    @yavuzerayut
    Author

    Related divergence in the same splice machinery (fail-closed, same "Sorry" class as this one): at an erased (q0) specialized column, the splice path skips the η-demotion that the ordinary application path applies — the emitted instance keeps a live λ binder under an App q0 ((λx0 => 7n) -x1), so the kernel rejects "a λ of its binder's liveness" while the same lambda at a non-specialized call is demoted and passes. Minimal matrix: a def with a Kind-specialized param whose column value is an inline λ, called at a q0 argument vs a plain one — the q0 cell is check-only PASS / verdict FAIL, the plain cell is green.

  2. yavuzerayut commented on Sep 29, 2026

    @yavuzerayut
    Author

    Follow-up with the verbatim contrast pair for the η-demotion divergence above (both verified as-is on 2.0.32, 573002f):

    The mismatch cell — a Kind-specialized param whose column value is an inline λ, called at an erased (@-y) domain. --check-only passes, --verdict fails with the mismatch banner, and the kernel rejects the emitted instance with "a λ of its binder's liveness":

    import Base
    
    def qof2(f: @-y: Nat -> Nat) -> Quant:
      &1
    
    def R(f: @-y: Nat -> Nat, b: Bool) -> Kind(&2):
      Nat
    
    def k(f: @-y: Nat -> Nat, g: Nat, h: Nat, -A: Kind(qof2(f)), b: Bool) -> R(f, b):
      match b:
        case True{}: f(h)
        case False{}: f(h)
    
    def use() -> Nat: k((y => 7n), 1n, 3n, Unit, True{})
    
    def chk() -> {use() == 7n : Nat}: {==}

    The green control — the same inline lambda at a NON-specialized call is η-demoted by the emitter (λ-x0 => 5n) and passes everything:

    import Base
    
    def k9m(-y: Nat) -> Nat:
      7n
    
    def tst(f: @-y: Nat -> Nat, x: Nat) -> Nat:
      f(x)
    
    def a() -> Nat: tst(k9m, 3n)
    def b() -> Nat: tst((y => 5n), 3n)

    So the splice path (spec_val) keeps the source binder quantity while the ordinary argument path (arg_term → eta) requantifies to the domain — the same lambda is live at one call site and demoted at the other. A dead-only-use variant (y => (-u = y; 7n)) behaves like the first file: check-only passes, verdict fails, kernel "a λ of its binder's liveness".

  3. nicolas-abril commented on Sep 29, 2026

    @nicolas-abril
    Collaborator

    Reopening: 0187512 closed this by accident (its message says "fixes #1175's un-annotated head"). That commit fixes this issue's missing head annotation: run3.qv_ now emits ({λx1 => (.Succ, ((.Zero, ()), ())) : ∀x1 : Nat -> Nat} (.Zero, ())) and the kernel accepts it. But --verdict on the file still fails, because the generic root is out of scope: run3: a Quant that is not a literal. That part is still open.

  4. added a commit that references this issue on Sep 29, 2026
    0187512
  5. added a commit that references this issue on Oct 5, 2026
    ffeddf0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions