Repository navigation
Description
What you did
bend ab.bend --verdict (then the same with ba.bend, the file with the two types swapped)
What happened
$ bend ab.bend --check-only
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bend ab.bend --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.
$ bend ab.bend -o ab.bendtt
BendTT: out of scope, so not in ab.bendtt:
- A: names A.qv.arms, out of scope: names B, out of scope: a kind that depends on a run-time value
- B: a kind that depends on a run-time value
$ bend ba.bend --verdict
ALL PROOFS CHECK
A self-recursive type (self.bend, the second file below) fails in every order:
$ bend self.bend --check-only
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bend self.bend --verdict
SOME PROOFS FAIL
Sorry - this is a mismatch between the TypeScript implementation, and the formalized BendTT kernel. [...]
$ bend self.bend -o self.bendtt
BendTT: out of scope, so not in self.bendtt:
- A: a kind that depends on a run-time value
The file
# ab.bend (ba.bend is the same file with `type B` declared before `type A`)
def qof(n: Type) -> Quant:
&1
type A<n: Type> is Kind(qof(n)):
A1{b: B<n>}
type B<m: Type> is Type:
B1{a: A<m>}
# ---- self.bend (a separate file) ----
def qof(n: Type) -> Quant:
&1
type A<n: Type, m: Type> is Kind(qof(n)):
A1{a: A<m, n>}Cause. spec_of
(safe.ts#L347-L373)
caches one result per name:
- its cycle guard
(L350)
answers[]("nothing specialized") for a name whose computation is still in progress; - L362
reads that placeholder when the DFS reaches a name on the stack; - L370
caches every answer permanently, including answers derived from the placeholder.
The rule is monotone, so the intended answer is its least fixpoint. The code runs one DFS pass seeded
with bottom, which under-approximates the fixpoint on any cycle. Roots are visited in declaration
order. So with A first, B caches [false] and keeps m live, and A<m> then puts a run-time value
at A's specialized parameter, which is out of scope (spec_val,
L376-L384).
With B first, B reads A's finished answer and everything is specialized consistently. On the
self-cycle, A reads its own placeholder and answers [true, false] instead of [true, true], so it
fails in every order.
Fix direction (tested). Compute spec_of as a least fixpoint. Re-run the DFS pass while any
in-progress read came out lower than that name's final answer in the pass, and cache only the answers of
a consistent pass. It terminates, since answers only grow and are bounded by the parameter count. It
costs one pass when no read comes out low. It fixes all three files, and the kernel accepts the output.
It is about 35 lines, and -o output is byte-identical on every tests/** and demos/** file whose .bendtt the kernel
already accepts (1057 of the 1558).
The simpler alternative, "don't cache a result that read an in-progress entry", fixes ab.bend but
not self.bend, so I'd avoid it.
Impact. A false FAIL, and it fails closed: the defect only removes specializations, and any kind
that depends on a parameter left live goes out of scope. None of the files under tests/ or
demos/ hits it, but a verdict that flips when two declarations are swapped is a real usability bug.
bend --version
2.0.32
uname -sm
Linux x86_64
clang --version (the first line)
No response
Activity
Which parameters are specialized is a reachability, and an instance w…
BendTT: kinds as quantity terms, meets, Σ at any kind and subsumption…