File: properties-testing.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 1,138,276 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,978; makefile: 3,840; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (164 lines) | stat: -rw-r--r-- 3,832 bytes parent folder | download | duplicates (2)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#|$ACL2s-Preamble$;
(include-book ;; Newline to fool ACL2/cert.pl dependency scanner
 "portcullis")
(begin-book t :ttags :all);$ACL2s-Preamble$|#

(in-package "ACL2S")
(include-book "acl2s/ccg/ccg" :uncertified-okp nil :dir :system :ttags
              ((:ccg)) :load-compiled-file nil)
(include-book "acl2s/base-theory" :dir :system :ttags :all)
(include-book "acl2s/custom" :dir :system :ttags :all)

(acl2s-defaults :set cgen-single-test-timeout 0)

#|

|#

(property (n :nat)
  (booleanp (nth-boolean-builtin n)))

(property (n :nat)
  :proofs? nil
  (booleanp (nth-boolean-builtin n)))

(property (n :nat)
  :testing? nil
  (booleanp (nth-boolean-builtin n)))

(property (n :nat)
  :proofs? nil
  :testing? nil
  (booleanp (nth-boolean-builtin n)))

(property (n :nat)
  (natp (+ 1 n))
  :hints (("goal" :do-not '(preprocess))))

; Checks to make sure we deal with hints
(must-fail
  (property (n :nat)
    (natp (+ 1 n))
    :hints (("goal" :do-not '(pre--process))))) ;misspelled

#|

test? is set up to succeed even if errors occur, as long
as we don't find counterexamples.

It should be changed to check hint syntax and return
an error so that the properties below fail.

(must-fail
  (property (n :nat)
    :proofs? nil
    (natp (+ 1 n))
    :hints (("goal" :do-not '(pre--process))))) ;misspelled

(must-fail
  (property (n :nat)
    :proofs? nil
    :testing? nil
    (natp (+ 1 n))
    :hints (("goal" :do-not '(pre--process))))) ;misspelled
|#

(must-fail
  (property (n :nat)
    :testing? nil
    (natp (+ 1 n))
    :hints (("goal" :do-not '(pre--process))))) ;misspelled

(property (n :nat)
  (negp (nth-neg-builtin n)))

(property (n :nat)
  (non-pos-integerp (nth-non-pos-integer-builtin n)))

(property (n :nat)
  (non-0-integerp (nth-non-0-integer-builtin n)))

(property (n :nat)
  (integerp (nth-integer-builtin n)))

(property (n :nat lo hi :int)
  :h (<= lo hi)
  :b (and (integerp (nth-integer-between n lo hi))
          (<= lo (nth-integer-between n lo hi))
          (>= hi (nth-integer-between n lo hi))))

(property (n :nat)
  :check-contracts? nil
  :proofs? nil
  (pos-ratiop (nth-pos-ratio-builtin n)))

(property (n :nat)
  :check-contracts? nil
  :proofs? nil
  (neg-ratiop (nth-neg-ratio-builtin n)))

(property (n :nat)
  (neg-rationalp (nth-neg-rational-builtin n)))

(property (n :nat)
  (pos-rationalp (nth-pos-rational-builtin n)))

(property (n :nat)
  (non-neg-rationalp (nth-non-neg-rational-builtin n)))

(property (n :nat)
  (non-pos-rationalp (nth-non-pos-rational-builtin n)))

(property (n :nat)
  (non-0-rationalp (nth-non-0-rational-builtin n)))

(property (n :nat)
  (rationalp (nth-rational-builtin n)))

(property (n :nat lo hi :rational)
  :proofs? nil
  :h (<= lo hi)
  :b (and (rationalp (nth-rational-between n lo hi))
          (<= lo (nth-rational-between n lo hi))
          (>= hi (nth-rational-between n lo hi))))


(defdata one 1)

(defdata loi (listof int))
(defdata r1 (record (a . loi)))

(defdata data (listof nat))
(defdata receiver-state (record (received . data)))

(definec bax (rs :data) :receiver-state
  (receiver-state rs))

(property (lo hi :int n :nat)
  :check-contracts? nil
  :h (<= lo hi)
  :b (^ (<= lo (geometric-int-between lo hi n))
        (>= hi (geometric-int-between lo hi n))))

(property (lo hi :rational n :nat)
  :check-contracts? nil
  :h (<= lo hi)
  (^ (<= lo (geometric-rat-between lo hi n))
     (>= hi (geometric-rat-between lo hi n))))

(property (lo hi :int)
  :check-contracts? nil
  :test-contracts? nil
  :proofs? nil
  :h (<= lo hi)
  (b* (((mv mid1 mid2) (defdata::int-midpoints lo hi)))
    (^ (<= lo mid1)
       (>= hi mid2))))

(property (lo hi :rational)
  :check-contracts? nil
  :test-contracts? nil
  :h (<= lo hi)
  (b* (((mv mid1 mid2) (defdata::rat-midpoints lo hi)))
    (^ (<= lo mid1)
       (>= hi mid2))))