Skip to content

--verdict passes a def that the kernel never checks #1186

Closed

Description

@awilson9

What you did

bend root_cols_repro.bend --verdict && bend root_cols_repro.bend - root_cols_repro.bendtt

What happened

## Repro


bend root_cols_repro.bend --verdict
bend root_cols_repro.bend - root_cols_repro.bendtt


## Result


ALL PROOFS CHECK


The verdict passes, but the def `skipped` is missing from the kernel text.
The `.bendtt` output holds these defs only:


Void.arms
Void
seen
Nat.arms
Nat


`skipped` is not there, and it is not reported as out of scope either.

## Expectation

One of these:

1. `skipped` goes to the kernel, or
2. `--verdict` fails and names `skipped` as out of scope.

`safe.ts` states the rule itself: "What the kernel cannot express is out of
scope: it goes, with every def that names it, and --verdict fails."

## Cause

The cause is in `root_cols` in `bend2/safe.ts`.

1. `v` is a `~` parameter, so `spec_of` marks it as specialized.
2. Its type `Void` is a datatype with no parameters, and every constructor
   has no fields. With zero constructors, that test is true by default.
3. So `vs` is the empty list: `adt.c.map(...)` over zero constructors.
4. `vs !== null`, so the function returns `vs.flatMap(at)`, which is `[]`.
5. `safe_book` pushes one root per entry. Zero entries give zero roots.
6. With no root, the def is never emitted, and `oos` never lists it.

The relevant lines:


const vs = A.$ === "Qnt" ? [B.None(), B.Lone(), B.Many()].map((q) => B.Qua(q))
  : adt !== null && adt.c.every((c) => B.term_wnf(e.book, c.T).$ !== "All") ? adt.c.map((c) => B.Ctr(c.k, [])) : null;
if (vs !== null) {
  return vs.flatMap(at);
}


## Impact

- The claim itself is sound. A def that takes a value of an empty type holds
  for every argument, because there are none.
- The problem is the guarantee. `--verdict` reports that the kernel checked
  every def, and here it checked none of the body of `skipped`. Only bend2
  checked it.
- So any bend2 checker bug that sits inside such a def would pass
  `--verdict` without the kernel seeing it.
- I did not find a way to turn this into a proof of `Empty`. A caller must
  pass a closed value of the empty type, and none exists.

## Suggested fix

Treat an empty enumeration as out of scope, so the verdict fails loudly:


if (vs !== null) {
  if (vs.length === 0) {
    oos("a specialized parameter of an empty type");
  }
  return vs.flatMap(at);
}


An alternative is to emit the def once at an opaque constant, as the code
already does for a specialized parameter of any other type.

## Environment

| Field | Value |
|---|---|
| `bend version` | bend 2.0.32 |
| Commit | 3378e623 |
| `uname -sm` | Darwin arm64 |
| `clang --version` | Apple clang version 21.0.0 (clang-2100.1.1.101) |
| Lean | v4.34.0 |

The file

# root_cols_repro.bend
import Base

type Void is Data:

law skipped:
  for ~v: Void
  for n: Nat
  Nat

def skipped(v, n):
  n

def seen(n: Nat) -> Nat:
  n

bend --version

bend 2.0.32

uname -sm

Darwin arm64

clang --version (the first line)

Apple clang version 21.0.0 (clang-2100.1.1.101)

Activity

  1. added
    bug
    on Sep 29, 2026
  2. liampwll commented on Sep 29, 2026

    @liampwll

    What's the usecase for proving dead code of that form? I don't think it should be marked out-of-scope because it's not and that generates noise, there's just nothing there to prove.

  3. awilson9 commented on Sep 29, 2026

    @awilson9
    Author

    Not much of one, just calling it out bc the docs slightly (although trivially so) contradict the observed output

    from GUIDE.md

    bend PROOF.bend --verdict checks the proofs a second time, with a small kernel that has a proof in Lean: it prints ALL PROOFS CHECK only when every def outside Base is a valid proof, which bend2 and the kernel both accept, and which relies on no @unsafe or foreign code. -o PROOF.bendtt writes the translation the kernel reads; the translation has no proof, so read it to confirm a law.

    is not completely true since the kernel never sees skipped and checks 0 lines of it

    feel free to close just thought i'd flag

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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions