blob: 38e01c85383ee15d03dc262850df5e06682b12fd (
plain)
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
|
#lang rosette
(define (check-spec-len prop pre spec xs)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs)))))
(define (check-spec-is-empty prop pre spec xs)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs)))))
(define (check-spec-first prop pre spec xs)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs)))))
(define (check-spec-last prop pre spec xs)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs)))))
(define (check-spec-contains prop pre spec xs x)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs x)))))
(define (check-spec-insert prop pre spec xs x)
(assume (and (prop xs) (pre xs)))
(assert (prop (spec xs x))))
(define (check-spec-remove prop pre spec xs x)
(assume (and (prop xs) (pre xs)))
(assert (prop (car (spec xs x)))))
(define (check-spec-clear prop pre spec xs)
(assume (and (prop xs) (pre xs)))
(assert (prop (spec xs))))
(define (check-not-contradict prop pre xs)
(assert (and (prop xs) (pre xs) (> (length xs) 1))))
(define (check prop pres specs xs x . rest)
(cond
[(or (unsat? (solve (check-not-contradict prop (first pres) xs)))
(unsat? (solve (check-not-contradict prop (second pres) xs)))
(unsat? (solve (check-not-contradict prop (third pres) xs)))
(unsat? (solve (check-not-contradict prop (fourth pres) xs)))
(unsat? (solve (check-not-contradict prop (fifth pres) xs)))
(unsat? (solve (check-not-contradict prop (sixth pres) xs)))
) #f]
[else (and (unsat? (verify (check-spec-clear prop (first pres) (first specs) xs)))
(unsat? (verify (check-spec-contains prop (second pres) (second specs) xs x)))
(unsat? (verify (check-spec-insert prop (third pres) (third specs) xs x)))
(unsat? (verify (check-spec-is-empty prop (fourth pres) (fourth specs) xs)))
(unsat? (verify (check-spec-len prop (fifth pres) (fifth specs) xs)))
(unsat? (verify (check-spec-remove prop (sixth pres) (sixth specs) xs x)))
)]))
(provide check)
|