From 06055fdd22eeb9015d215e71996e4714c183ef19 Mon Sep 17 00:00:00 2001 From: Unknown Date: Wed, 30 Jan 2013 12:43:15 -0800 Subject: handling old() in stable assertions bug fix in linear --- Test/linear/Maps.bpl | 24 ++++++++++++++++++++++++ Test/linear/list.bpl | 39 +++++++++++++++++++++++++++++++++++++++ Test/linear/runtest.bat | 11 +++++++++++ 3 files changed, 74 insertions(+) create mode 100644 Test/linear/Maps.bpl create mode 100644 Test/linear/list.bpl create mode 100644 Test/linear/runtest.bat (limited to 'Test/linear') diff --git a/Test/linear/Maps.bpl b/Test/linear/Maps.bpl new file mode 100644 index 00000000..5f302034 --- /dev/null +++ b/Test/linear/Maps.bpl @@ -0,0 +1,24 @@ +type X; + +function {:builtin "MapAdd"} MapAdd([X]int, [X]int) : [X]int; +function {:builtin "MapSub"} MapSub([X]int, [X]int) : [X]int; +function {:builtin "MapMul"} MapMul([X]int, [X]int) : [X]int; +function {:builtin "MapDiv"} MapDiv([X]int, [X]int) : [X]int; +function {:builtin "MapMod"} MapMod([X]int, [X]int) : [X]int; +function {:builtin "MapConst"} MapConstInt(int) : [X]int; +function {:builtin "MapConst"} MapConstBool(bool) : [X]bool; +function {:builtin "MapAnd"} MapAnd([X]bool, [X]bool) : [X]bool; +function {:builtin "MapOr"} MapOr([X]bool, [X]bool) : [X]bool; +function {:builtin "MapNot"} MapNot([X]bool) : [X]bool; +function {:builtin "MapIte"} MapIteInt([X]bool, [X]int, [X]int) : [X]int; +function {:builtin "MapIte"} MapIteBool([X]bool, [X]bool, [X]bool) : [X]bool; +function {:builtin "MapLe"} MapLe([X]int, [X]int) : [X]bool; +function {:builtin "MapLt"} MapLt([X]int, [X]int) : [X]bool; +function {:builtin "MapGe"} MapGe([X]int, [X]int) : [X]bool; +function {:builtin "MapGt"} MapGt([X]int, [X]int) : [X]bool; +function {:builtin "MapEq"} MapEq([X]int, [X]int) : [X]bool; +function {:builtin "MapIff"} MapIff([X]bool, [X]bool) : [X]bool; +function {:builtin "MapImp"} MapImp([X]bool, [X]bool) : [X]bool; + + + diff --git a/Test/linear/list.bpl b/Test/linear/list.bpl new file mode 100644 index 00000000..9a333351 --- /dev/null +++ b/Test/linear/list.bpl @@ -0,0 +1,39 @@ +var head: X; +var tail: X; +var {:linear "Mem"} D: [X]bool; +var Next:[X]X; +const nil: X; + +procedure malloc() returns (x: X, {:linear "Mem"} M: [X]bool); +ensures M == MapConstBool(false)[x := true]; + +procedure Join({:linear "Mem"} A: [X]bool); +modifies D; +ensures MapOr(old(D), A) == D; + +procedure one() +requires D[head] && D[tail]; +requires (forall d: X :: {D[d]} D[d] ==> D[Next[d]] || d == tail); +ensures D[head] && D[tail]; +ensures (forall d: X :: {D[d]} D[d] ==> D[Next[d]] || d == tail); +ensures head != tail; +{ + var x: X; + var {:linear "Mem"} M: [X]bool; + + call x, M := malloc(); + call Join(M); + Next[tail] := x; + tail := x; + Next[tail] := nil; +} + +procedure two() +requires head != tail; +requires D[head] && D[tail]; +requires (forall d: X :: {D[d]} D[d] ==> D[Next[d]] || d == tail); +ensures (forall d: X :: {D[d]} D[d] ==> D[Next[d]] || d == tail); +ensures D[head] && D[tail]; +{ + head := Next[head]; +} diff --git a/Test/linear/runtest.bat b/Test/linear/runtest.bat new file mode 100644 index 00000000..28c91996 --- /dev/null +++ b/Test/linear/runtest.bat @@ -0,0 +1,11 @@ +@echo off +setlocal + +set BGEXE=..\..\Binaries\Boogie.exe + +for %%f in (list.bpl) do ( + echo. + echo -------------------- %%f -------------------- + %BGEXE% %* /nologo /noinfer /typeEncoding:m /useArrayTheory /doModSetAnalysis %%f Maps.bpl +) + -- cgit v1.2.3