Whiley / WhileyTheoremProver

The Whiley Theorem Prover (WyTP) is an automatic and interactive theorem prover designed to discharge verification conditions generated by the Whiley Compiler. WyTP operates over a variant of first-order logic which includes integer arithmetic, arrays and quantification.
Apache License 2.0
8 stars 2 forks source link

NullPointerException in WyalFilePrinter #87

Closed DavePearce closed 7 years ago

DavePearce commented 7 years ago

The following Whiley generates a NullPointerException in WyalFilePrinter:

function permute(int[] xs) -> (int[] rs, int[] witness)
ensures |rs| == |witness|
ensures |xs| == |witness|:
    //
    int[] ws = [0; |xs|] // ghost "witness"
    //
    return xs,ws

public export method test():
    int[] ys
    int[] ws
    //
    ys,ws = permute([1,2,3])
    assume ys == [1,2,3] && ws == [0,1,2]

This looks like it has something to do with multiple returns.

DavePearce commented 7 years ago

UPDATE. Yes, this is to do with the postcondition macro permute_ensures_0 which is presumably failing.

DavePearce commented 7 years ago

Here is a smaller example:

function f(int x) -> (int r1, int r2)
ensures r1 >= r2:
    //
    return x, (x+1)

function g(int x) -> (int r):
    int a
    int b
    a,b = f(x)
    return a+b
DavePearce commented 7 years ago

The problem here is that we need syntax for extracting the result of a function which has multiple returns.