Open DavePearce opened 5 years ago
As Whiley/WhileyCompiler#445 shows, this can arise for both property
and function
declarations. How do we check for this? Is this a sufficient characterisation:
Therefore, to check for it, we start from types and their invariants and look for cycles. This must include indirect type invariant as well. Examples:
type X is (T y) where f(y)
property f(X x) where e
type Y is (T y) where f(y)
type X is (Y y)
property f(X x) where e
type X is (T y) where y is X
Next step: write up RFC
(see also Whiley/WhileyCompiler#425)
There is an inherent problem with recursively defined types and properties. The following illustrates the smallest example I can come up with:
The problem is that, on entry to
valid()
the interpreter currently checks thatarr
has typenatarray
and this causes it to recursively call itself infinitely. The fix is actually very easy. Just restate the property as follows:Now there is no loop!