-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathadt.vpr
More file actions
84 lines (61 loc) · 1.89 KB
/
Copy pathadt.vpr
File metadata and controls
84 lines (61 loc) · 1.89 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// Any copyright is dedicated to the Public Domain.
// http://creativecommons.org/publicdomain/zero/1.0/
domain list {
/* Constructors */
function Nil(): list
function Cons(head: Int, tail: list): list
/* Deconstructors */
function head_Cons(xs: list): Int // requires is_Cons(xs)
function tail_Cons(xs: list): list // requires is_Cons(xs)
/* Constructor types */
function type(xs: list): Int
unique function type_Nil(): Int
unique function type_Cons(): Int
function is_Nil(xs: list): Bool
function is_Cons(xs: list): Bool
function size(xs:list): Int
/* Axioms */
axiom eitherConsorNil{
forall xs: list ::
is_Nil(xs) <==> !is_Cons(xs)
}
axiom numberOfElem{
forall xs: list ::
is_Nil(xs) == (size(xs) == 0)
&& is_Cons(xs) == (size(xs) > 0)
&& is_Cons(xs) == size(xs) > size(tail_Cons(xs))
&& is_Cons(xs) == (size(xs) == 1 + size(tail_Cons(xs)))
}
axiom destruct_over_construct_Cons {
forall head: Int, tail: list :: {Cons(head, tail)}
head_Cons(Cons(head, tail)) == head
&& tail_Cons(Cons(head, tail)) == tail
}
axiom construct_over_destruct_Cons {
forall xs: list :: {head_Cons(xs)} {tail_Cons(xs)}
is_Cons(xs) ==> xs == Cons(head_Cons(xs), tail_Cons(xs))
}
axiom type_of_Nil {
type(Nil()) == type_Nil()
}
axiom type_of_Cons {
forall head: Int, tail: list :: type(Cons(head, tail)) == type_Cons()
}
axiom type_existence {
forall xs: list ::
type(xs) == type_Nil()
|| type(xs) == type_Cons()
}
axiom type_is_Nil {
forall xs: list :: type(xs) == type_Nil() <==> is_Nil(xs)
}
axiom type_IsElem {
forall xs: list :: type(xs) == type_Cons() <==> is_Cons(xs)
}
}
function f(xs:list) : Int
decreases size(xs)
requires size(xs)>=0
{
size(xs) > 0 ? f(tail_Cons(xs)) : 6
}