Repository navigation
Description
Bug description
Bend 2.0.32's ordinary checker accepts a closed definition containing an opaque higher-order template parameter whose result type contains dependent equality, but --verdict cannot validate the same definition and reports a TypeScript/BendTT mismatch.
This is not being claimed as a soundness exploit or bounty submission. The kernel rejects it; the report is for the reproducible checker/formalization synchronization failure.
Environment
- Bend: 2.0.32
- Source revision tested:
v2.0.32, commit573002f01ec6c52416d44489543f69a9625facf8 - macOS arm64
Minimal reproducer
import Base
type N is Data:
Z{}
S{p: N}
def pred(n: N) -> N:
match n:
case Z{}: Z{}
case S{p}: p
def inj(a: N, b: N, e: {S{a} == S{b} : N}) -> {a == b : N}:
%x@e : {pred(S{a}) == pred(_) : N}
{==}
def use(~F: @a: N -> @b: N -> {S{a} == S{b} : N} -> {a == b : N}, a: N, b: N, e: {S{a} == S{b} : N}) -> {a == b : N}:
F(a, b, e)
def main() -> N:
Z{}
Save as higher_evidence_base.bend and run:
bend higher_evidence_base.bend --check-only
bend higher_evidence_base.bend --verdictObserved behavior
--check-only:
ALL PROOFS CHECK
Use --verdict for mathematical validity.
--verdict:
SOME PROOFS FAIL
Sorry - this is a mismatch between the TypeScript implementation, and the formalized BendTT kernel. Your proofs may or may not be correct, and we cannot validate them yet. This will be addressed in a future update. Meanwhile, feel free to open an issue to report this bug.
Minimization results
The mismatch disappears when any of these changes are made:
- Remove the
~fromFand make it an ordinary affine function parameter. - Remove dependent equality from the result type while retaining equality as an input.
- Use the standalone
injproof without the higher-order opaque template parameter.
Equality only as an input passes both checker and verdict. Equality in the result of an opaque ~F reproduces the mismatch.
I also tested direct, curried, let-bound, eta-expanded, and explicitly annotated applications. They all preserve the same mismatch. Making the result family reduce to an Empty branch does not produce an accepted proof: --verdict still rejects the definition.
Expected behavior
Either:
- the ordinary checker rejects this unsupported form before reporting
ALL PROOFS CHECK, or - BendTT accepts and validates the emitted term.
The current result is an explicit synchronization failure between the ordinary TypeScript checker and the formalized kernel.
Activity
leo-guinan commentedon Sep 29, 2026
Follow-up: we packaged the full investigation and reproducible receipts in a public repository:
https://github.com/leo-guinan/bend-verdict-investigation
Pinned environment:
573002f01ec6c52416d44489543f69a9625facf8The repository documents the negative result: no bounty-grade live
Emptyinhabitant was found. It includes the 1,508-file scan receipts, targeted probe harnesses, minimized Bend files, and the higher-order dependent-equality mismatch from this issue.For the minimized reproducer in the repository:
--check-onlyreturnsALL PROOFS CHECK--verdictrejects with the TypeScript/formalized BendTT mismatchSo this remains a synchronization bug report, not a false-proof or bounty claim.
MuhDur commentedon Sep 29, 2026
Same mismatch, still present on 2.0.34 (commit 7d8a3eb), with a smaller reproducer: the trigger is calling a higher-order
~parameter whose result is an equation with a non-variable side.--check-only→ALL PROOFS CHECK;--verdict→SOME PROOFS FAIL+ the mismatch message.Bisection: declaring
~stepwithout calling it passes, and so does calling it when it returns{le(x, y) == le(x, y) : Bool}or{x == x : A}.Impact: this is the usual shape of abstract order/algebra theorems (transitivity chains over a
~lewith its laws passed as~proofs). In the published hub packagebend-mathlib, 7 of 10 modules pass--verdicton 2.0.34, and the other three (algebra,order,sort) fail only on this. Happy to test a fix.CI: hold mathlib to Bend's proven kernel (bend --verdict)
docs: refresh Bend ecosystem for 30 September 2026
MuhDur commentedon Oct 1, 2026
Root cause and a proposed fix in #1263:
--verdictnever reached the kernel here.safe.tspicks a model for each~constant one at a time, solegotλx y. False{}and thenstephad none (bend f.bend -o f.bendttprintsno model for v_n~step). The PR backtracks over the root's constants until their models hold together; contradictory~laws still stay out of scope.A correction to my comment above: with the fix, bend-mathlib's
algebraandorderpass--verdict, butsortstill does not, for a second reason unrelated to this issue (20 defs reporta kind that depends on a run-time value).Release bend-mathlib 0.7.1.0 (0x3c446c5bcf57d1eef89775ba0b411fc6); ag…
The ~ constants of a root take models that hold together, so a ~ law …
The ~ constants of a root take models that hold together, so a ~ law …
The ~ constants of a root take models that hold together, so a ~ law …
nohzafk commentedon Oct 10, 2026
Another shape of the same mismatch, still present on 2.0.36. Here the
~function has a model only together with the other~constant: it is the step hypothesis of a generic invariant~P.What I found while narrowing it down:
~Pwith no~Hpasses--verdict.Han ordinary parameter (H:) also passes--verdictforlift. It cannot fixtwice, becausetwiceusesHtwice: an ordinary function parameter is linear, and+on a function type is refused (expected : Data / observed : Type). So once a proof uses its hypothesis in more than one place, a~parameter is the only way to write it.P := λn. True{},H := λn. λh. h), so this is the "constants that must fit together" case that The ~ constants of a root take models that hold together, so a ~ law of a ~ function reaches the kernel (#1182) #1263 addressed, not the injectivity case in the original report. Using checked defs as models, the direction suggested when The ~ constants of a root take models that hold together, so a ~ law of a ~ function reaches the kernel (#1182) #1263 was closed, would not cover it:His an abstract hypothesis, and no closed def of its type exists in the book.twice's entry nameslift~H, nottwice~H. That may be a separate labelling slip in the out-of-scope report.Impact: this is the usual shape of a preservation proof. You state an invariant once as
~P, take one~Hper operation saying the operation keepsP, and then induct over a run, applying eachHonce per step. In a scheduler core I am verifying, about 30 such lemmas sit under two top-level laws. Both pass--check-onlyand fail--verdictonly because of this. The workaround is to instantiate every lemma for each concrete invariant, which multiplies the proof by the number of invariants.Environment: bend 2.0.36, macOS arm64.
nohzafk commentedon Oct 11, 2026
Still reproduces on 2.0.36 (also 2.0.34 and 2.0.35). A smaller reproducer, and what
-osays about it:The
.bendttfile gives~Pthe modelopaque k_7e_P : Nat = (.Zero, ()). With that model, the type of~f,Nat -> {0 == 1 : Nat}, has no inhabitant, so the translation has no model for~fand leaveskout. Changing only the literal agrees with that reading:~f--verdict{P == 0n : Nat}{P == 1n : Nat}{1n == P : Nat}{P == P : Nat}{1n == 1n : Nat}(no~P){P == 1n : Nat},fnot a template{P == 1n : Nat},~fnever appliedThe Bool version,
~P: Boolwith~f: Nat -> {P == True{} : Bool}, fails the same way.Impact: bend-mathlib's
sort.bend(0.6.0.0 to 0.7.2.0) passes--check-onlyand fails--verdict.bend sort.bend -o sort.bendttreportsno model for internal_cons_ins_step~le_totalforinsert_by_sorted,isort_by_sortedand their helpers, because~le_total: @x: A -> @y: A -> {le(x, y) == False{} : Bool} -> {le(y, x) == True{} : Bool}is this shape. Any project that proves under--verdictcannot import it.Release bend-mathlib 0.7.3.0 (0xf8a2f05bbfb67041ce3d1eaece892a1a): so…
MuhDur commentedon Oct 12, 2026
A data point on how much of the "constants that only fit together" case is left, measured on a real library.
bend-mathlib 0.7.3.0 (
0xf8a2f05bbfb67041ce3d1eaece892a1a, published today) dropped the one #1483 shape it used, following bendlib/bendlib#25. On 2.0.36, everything it still leaves out of BendTT isno model foran abstract hypothesis that has a model only together with the other~constants of its def:algebrano model for internal_foldl_foldr~id(~id: @x: B -> {op(z, x) == x : B})orderno model for~le_total(3),~le_trans(2),~le_antisymm(1)sortno model for~le_trans(8),~le_total(5)nat,bool,list,string,maybe,equalandpermalready pass--verdict. With the backtracking model search from #1263 (its branch, based on 2.0.35),algebra,order,sortandallprintALL PROOFS CHECKtoo, so every module of the package reaches the kernel and passes.Like nohzafk's
~Hcase, these hypotheses are abstract, so the book has no closed def of their types to use as a model. A model exists in each case (le := λx y. True{}with reflexivity proofs for the order hypotheses,B := Unitfor~id), but only if the constants are chosen together.Because
--verdictrejects a file when any def of an imported module is out of scope, a project that gates on--verdictcan't importsort,order,algebraoralltoday, even to use only the Nat instances, which do translate.toolchain: move the pinned compiler to bend 2.0.37
docs(agents): list the template model bug and its workaround
aaaxn commentedon Oct 14, 2026
The
v_nreproducer in the comment above fails because of the model that--verdictpicks for~le.model_atinbend2/safe.tsbuilds a model for each~parameter. It fills a datatype with the first constructor whose fields all get a model, and it fills each field with the first model it finds.Bool's first constructor isFalse, so~legets the modelλx λy. False, and{le(x, y) == True{} : Bool}then has no model. With== False{}in both places, the same file passes--verdict, and its export shows the models:opaque v_n_7e_le ... = λx0 => λx1 => (.False, ())andopaque v_n_7e_step ... = λx0 => λx1 => λx2 => {==}.The same choice rejects an inhabited type when the equation sits in a datatype field:
At
32d23b43,--check-onlypasses and--verdictfails withno model for pick~make. The 2.0.37 release fails the same way; its--verdictprints only the mismatch banner, and-onames the same cause. The search setsn = 0and never triesPos{1n, {==}}. WithNat.is_lein place ofNat.is_lt, both pass. A type whose first constructor fails and whose second succeeds also passes, so the search does try other constructors, but not other field values. Callingpickwith a valid instance does not help.The first reproducer in this issue is a different gap: an equation gets the model
{==}only when its two sides convert, so{a == b}under{S{a} == S{b}}has no model, even thoughinjproves it.ci: kernel-check the in-scope defs of the modules --verdict cannot model
oxura commentedon Oct 29, 2026
The
injexample in the issue body already passes on main 4f99f4c (use~Fgetsinjas its model). The originallaw_higher_evidence_probe.bend, without that helper, still fails.Working branch derives a total constructor-field projection and uses ordinary rewrite/reflexivity as the model. The real kernel now accepts that law, both fields of a mixed Bool/N record, and an equation-hypothesis identity. Ten existing model/proof cases keep the same verdicts. The unrelated-field and Empty-result probes still stay out of scope; erased evidence keeps its existing exclusion.
No kernel changes or root-constant backtracking. Still holding the PR: safe.ts is 24599/24000, so this needs actual headroom from #1930. I haven't copied that unmerged patch or changed the cap. Checks were local
--verdictruns, not the cluster gate.MuhDur commentedon Oct 29, 2026
Results for the working branch at
99b5554, run locally with--verdict(Lean v4.34.0, Linux x64):4f99f4c99b5554lift/twice(~Pwith the step hypothesis~H)k(~P: Nat, ~f: Nat -> {P == 1n : Nat}, x)no model for k~f)pick(~make: Nat -> Pos, +p)no model for pick~make)So the branch also covers the preservation-proof shape (
lift/twice), which is not among the cases listed above.As a regression check on a larger book: every module of bend-mathlib 0.8.0.0 (
0x78e347bf8d0582a322c01b02c727566f:algebra,all,bool,equal,list,maybe,nat,order,perm,sort,string,u32) printsALL PROOFS CHECKwith--verdicton99b5554, as it does on 2.0.39.That also settles my data point from 2026-10-12: since 2.0.38 the package leaves nothing out of BendTT, so
algebra,order,sortandallno longer depend on this issue (-oreports no out-of-scope defs on 2.0.39). Of the reproducers in this thread,kandpickstill fail on the branch, besides the original probe you mention.oxura commentedon Oct 29, 2026
Thanks for checking the whole book. I'll keep the distinction clear: the branch covers
lift/twice, but it is not a general model-search fix;kandpickstill fail on it. Publication is still held on thesafe.tsbudget.oxura commentedon Oct 29, 2026
Published as #1943 now that #1930 has merged. Same scope as the working branch: constructor-field projections and available equation hypotheses, not general model search (
k/pickare not addressed). Requalified on4982c105: 17 real CLI/kernel cases kept the expected verdicts, and the repo gate is 54/54 with unchanged caps.