Repository navigation
Description
What you did
Compared Claim.consistent (bend2/bendtt.lean) with what safe.ts emits for Empty (bend empty.bend -o empty.bendtt)
What happened
Claim.consistent (bendtt.lean L1529-1531) states that no checked def's type converts to Enu []:
∀ bk k d, Book.check bk = .ok () → Book.get bk k = some d → ¬ Conv bk d.T (Enu [])
But safe.ts never emits Enu [] for Empty. It emits every datatype, Empty included, as a Σ over its
constructor labels:
$ bend empty.bend -o empty.bendtt
$ grep -A1 '^Empty' empty.bendtt
Empty.arms : ∀x0 : <> -> *2 =
λ{}
--
Empty : *2 =
Σx0 : <> -> (Empty.arms x0)
So "no def the kernel accepts has type Empty" (GUIDE.md, CHANGELOG.md, AGENTS.md) doesn't follow from
Claim.consistent as stated. It is true, but it needs a corollary that isn't in bendtt.lean. The
corollary is proved in the first comment, against an unmodified bendtt.lean.
The file
import Base
def id_empty(x: Empty) -> Empty:
xClaim.consistent
says that no checked def's type converts to Enu []. But adt_emit
(safe.ts#L316)
emits every datatype, Empty included, as Σ1 t:<Ctrs> -> D.arms t, which is a different type former.
GUIDE.md
(L658-L659),
CHANGELOG.md
(L57-L58)
and AGENTS.md
(L16-L17)
say that no def the kernel accepts has type Empty. That's true, but it takes a corollary of the same
argument consistent uses (halts, progress, canon_pair, empty). Here it is. Appended to an
unmodified bendtt.lean (2.0.32), lean bendtt.lean succeeds, and
#print axioms consistent_empty_adt gives [propext, Classical.choice, Quot.sound]:
-- A live Σ over the empty enumeration is uninhabited: `consistent`'s argument (halts, progress,
-- canon_pair, empty) for the type every emptied datatype elaborates to, `Σ1 t:<> -> D.arms t`.
theorem consistent_sig (bk : Book) (k : String) (d : Def) (q : Quan) (B : Term)
(ok : Book.check bk = .ok ()) (get : Book.get bk k = some d) (hq : q.live = true) :
¬ Conv bk d.T (.Sig q (.Enu []) B) := by
intro c
have ⟨wt, lv⟩ := book_check bk ok
have ⟨i, hi⟩ := index_of_get get
have hl : Term.Live bk (.Ref k) := by
simp [Term.Live, Term.live, Term.called, Term.unspine, hi,
(List.findIdx?_eq_some_iff_findIdx_eq.1 hi).1]
have hr : Typed bk [] (.Ref k) d.T := by
have := Typed.ref (Γ := []) (σ := Term.Var) get; rwa [sub_var] at this
have ht : Typed bk [] (.Ref k) (.Sig q (.Enu []) B) := .conv hr (.inl c)
suffices ∀ t, Acc (fun u t => Eval bk t u) t → ¬ Typed bk [] t (.Sig q (.Enu []) B) from
this _ (halts bk _ lv (fun _ => rfl) hl) ht
intro t a; induction a with
| intro t _ ih =>
intro ht; rcases progress bk t _ wt lv ht with v | ⟨u, e⟩
· obtain ⟨a, b, rfl⟩ := (canon_pair (r := q) (ks := []) (a := .Rfl) (b := .Rfl) wt v ht).1 ⟨_, .refl, .refl⟩
obtain ⟨_, ⟨A, B', rfl, ha, _⟩, f, _⟩ := gen ht
exact empty bk a wt ((value_tup v).1 hq) (.conv ha (.inl (conv_sig (fits_conv f)).2.1))
· exact ih u e (pars_sr wt ht (eval_pars lv.1 e))
-- The datatype itself: no checked def's type converts to a `Ref` whose body is `Σ1 <> -> X`
-- (safe.ts's adt_emit shape), so no def has type `Empty`, or any other emptied datatype.
theorem consistent_empty_adt (bk : Book) (n k : String) (dn d : Def) (X : Term)
(ok : Book.check bk = .ok ()) (gn : Book.get bk n = some dn) (hv : dn.v = .Sig .Q1 (.Enu []) X)
(get : Book.get bk k = some d) : ¬ Conv bk d.T (.Ref n) := by
intro c
have ⟨_, lv⟩ := book_check bk ok
have hd : Conv bk (.Ref n) (.Sig .Q1 (.Enu []) X) := hv ▸ pconv (.delta gn (lv.1 n dn gn))
exact consistent_sig bk k d .Q1 X ok get rfl (conv_trans c hd)The Σ has to be live (q.live). A dead Σ over <> isn't empty in the kernel, by design, since nothing
dead counts as live evidence: the kernel accepts bad : Σ-x0 : <> -> <()> with the dead field filled by
an erased self-reference. adt_emit always uses Σ1, so the corollary covers what safe.ts emits.
Suggestion. Add these two theorems (or an equivalent Claim) to bendtt.lean, so that the claim
the docs make is the one the kernel states.
This isn't a soundness report. Nothing here inhabits Empty. It is a gap between what the docs promise
and what the shipped theorem states, and the corollary closes it for Empty and every other emptied
datatype.
bend --version
bend 2.0.32
uname -sm
Linux x86_64
clang --version (the first line)
No response
Activity
nicolas-abril commentedon Sep 30, 2026
bendtt.leanis a self contained theory, the encoding of the datatypes into it are the elaborator's concern.To me it makes more sense that the elaborator generates some proof that the types it encodes are equivalent to
<>, could be something simple like inserting defs likeEmpty.absurd : ∀x : Empty -> <> = …which can only type-check ifEmptyis empty-likeA datatype with no constructors goes to BendTT with D.efq : D -> <>, …
nicolas-abril commentedon Sep 30, 2026
Closed by #1221 using the mechanism i mentioned above. Do you find this sufficient?
Vacrin commentedon Sep 30, 2026
Agreed that should be sufficient. Elaborator is the better place for it. D.efq pins the encoding in every checked book, so it can't drift silently.