aboutsummaryrefslogtreecommitdiff
path: root/src/racket_specs/indexable-setup.rkt
blob: 913544fbf1e1612ad63f4e26c384063b0ccef63d (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
#lang rosette

(define (check-not-contradict prop pre xs)
  (assert (and (prop xs) (pre xs) (> (length xs) 1))))

(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-nth prop pre spec xs n)
  (assume (and (prop xs) (pre xs)))
  (assert (prop (car (spec xs n)))))


(define (check prop pres specs xs n . 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)))
         ) #f]
    [else (and (unsat? (verify (check-spec-first prop (first pres) (first specs) xs)))
               (unsat? (verify (check-spec-last prop (second pres) (second specs) xs)))
               (unsat? (verify (check-spec-nth prop (third pres) (third specs) xs n)))
               )]))

(provide check)