You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--verdict overflows the stack on a ~ parameter of some datatypes: model_at's cycle check misses cycles through ∀-typed fields #1181
$ bend model.bend --check-only
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bend model.bend --verdict
Error: the machine stack overflowed (a deep recursion, or a literal too large to expand)
The file
importBase
type W<-F: Nat->Type>isType:
C{g: Nat->W<F>}
deff(~w: W<(n=>Nat)>, y: Nat) ->Nat:
y
A root with a ~ parameter needs a model of the parameter's type. model_at
(safe.ts#L431)
builds one by walking constructors, and stops cycles with a path of datatype keys
(L446).
The key is term_key(term_lower(F, d))
(L443).
It includes the levels of binders inside F's arguments, so the same datatype gets a different key at
depth d and at d+1. The ∀-typed field g: Nat -> W<F> bumps d
(L439),
so the path never repeats. This isn't a deep-but-finite recursion like #993: the walk never ends.
Control: with W<-F: Type> at W<Nat> (no binder in the argument), the same program gets ALL PROOFS CHECK from --verdict.
A second shape grows memory instead. In a nested datatype, the keys grow without bound, and
constructor-first order tries NCons forever:
importBase
type Nest<-A: Type>isType:
NCons{x: A, rest: Nest<Pair(A, A)>}
NNil{}
deff(~n: Nest<Nat>, y: Nat) ->Nat:
y
--verdict on this passed 32 GB before it was killed. Run it only under a memory cap.
Fix direction. Key a datatype without its binder levels (or lower it at a fixed depth), and bound
the walk, treating exhaustion as "no model" (out of scope) instead of crashing.
Impact. A crash, or unbounded memory, on programs bend2 accepts. It fails closed: no verdict is
printed. Like any unbounded run, it is a resource-exhaustion risk for tools that run --verdict on
untrusted files without a cap.
Activity
A ~ parameter's model search ends: its path keys a datatype by binder…
Bound BendTT model search and retain finite alternatives (#1181) (#1218)