-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathexists.vpr
More file actions
51 lines (42 loc) · 1.26 KB
/
Copy pathexists.vpr
File metadata and controls
51 lines (42 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
import <decreases/declaration.vpr>
field f: Int
function test(x: Ref): Bool
decreases
{
//:: ExpectedOutput(termination.failed:termination.condition.false)
exists x2: Ref :: x == x2 && nonTerminating(x2)
}
function test2(): Bool
decreases
{
// in general `partiallyTerminating` is non-terminating
//:: ExpectedOutput(termination.failed:termination.condition.false)
exists x2: Int :: partiallyTerminating(x2)
}
function test3(x: Int): Bool
decreases
requires x == 42
{
// `partiallyTerminating` terminates for input `42` so this is fine
exists x2: Int :: x == x2 && partiallyTerminating(x2)
}
function test4(x: Int): Bool
decreases
{
// in general `partiallyTerminating` is non-terminating
//:: ExpectedOutput(termination.failed:termination.condition.false)
(exists x2: Int :: x == x2) && partiallyTerminating(x)
}
function test5(x: Int): Bool
decreases
{
// this is fine due to short-circuiting
(exists x2: Int :: x == x2 && x != x2) && partiallyTerminating(x)
}
function nonTerminating(x: Ref): Bool
decreases *
function partiallyTerminating(x: Int): Bool
decreases if x == 42
decreases *