Skip to content

A datatype with no constructors goes to BendTT with D.efq : D -> <>, so the kernel checks that bend2's empty is BendTT's empty (#1183) - #1221

Merged
nicolas-abril merged 1 commit into
bendlang:mainfrom
nicolas-abril:empty-efq
Sep 30, 2026

Conversation

@nicolas-abril

@nicolas-abril nicolas-abril commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Refs #1183.

Context

Claim.consistent in bend2/bendtt.lean says no checked def has a type that converts to <>. safe.ts doesn't emit bend2's Empty as <>, though. Like every datatype, it goes out as Σt:<> -> Empty.arms t. So the kernel's claim covers Empty only through the meta-level step "an Empty gives a <>". #1183 proposes adding encoding-specific theorems to bendtt.lean to close that gap. This PR keeps the kernel self-contained, still stated only for <>, and moves the step into the elaborator, where the encoding lives.

Change

adt_emit now emits, for a datatype with no constructors, one more def that the kernel checks like any other:

Empty.efq : ∀x0 : Empty -> <> =
  λ{(,): λ{}}

Void.efq : ∀-x0 : *(.Q1) -> ∀x1 : (Void -x0) -> <> =
  λ-x0 => λ{(,): λ{}}

Its body is always λ{(,): λ{}}, the same term safe.ts already emits for an empty match. If the datatype encoding ever changes, D.efq has to keep checking, so the link to <> can't silently break. A datatype with a live field of an empty type is empty through that field, so it gets no efq of its own.

The spine that applies a def to the datatype's parameters is now a small helper, at(k), shared by D.arms and D.efq. The header doc of safe.ts mentions D.efq. The change adds 128 ttok to safe.ts.

Checks

  • tests/proof/empty_efq.bend (new) covers a plain and a parameterized empty type, plus a type with an Emp field that must get no efq. It passes plainly and under --verdict.
  • Running the kernel directly: it accepts the generated defs, and it rejects Emp.efq when its argument type is edited by hand to <()> (expected: a Σ type).
  • --verdict on every test (1525 files) gives identical results on main and on this branch.
  • bun gates/repo.ts passes. The cluster gates (gates/test.ts, gates/safe.ts) weren't run.

🤖 Generated with Claude Code

…so the kernel checks that bend2's empty is BendTT's empty (bendlang#1183)

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
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.

1 participant