4
;; (include-book "/projects/hvg/SULFA/books/sat/sat")
6
;; This file contains the examples from our paper that we
7
;; were able to prove using our SAT based hint.
8
;; The theorems are given in block comments, since our
9
;; SAT extension is not available without modifying the
12
;; For a description of the example and a description of
13
;; how this relates to our SAT system see our workshop paper,
14
;; A SAT-Based Procedure for Verifying Finite State Machines in ACL2.
19
(and (iff (car x) (car y))
20
(n-bleq (1- n) (cdr x) (cdr y)))))
29
;; Returns a n+1 length sum of the first
30
;; n bits of a and b (plus the carray).
31
(defun v-adder (n c a b)
34
(cons (xor3 c (car a) (car b))
36
(maj3 c (car a) (car b))
39
;; 4 Bit Adder Associativity
41
;; (n-bleq 4 (v-adder 4 nil (v-adder 4 nil a b) c)
42
;; (v-adder 4 nil a (v-adder 4 nil b c)))
43
;; :hints (("Goal" :external (sat nil sat::$sat))))
45
;; 32 bit adder associativity
47
;; (n-bleq 32 (v-adder 32 nil (v-adder 32 nil a b) c)
48
;; (v-adder 32 nil a (v-adder 32 nil b c)))
49
;; :hints (("Goal" :external (sat nil sat::$sat))))
51
;; 200 Bit adder associativity
53
;; (n-bleq 200 (v-adder 200 nil (v-adder 200 nil a b) c)
54
;; (v-adder 200 nil a (v-adder 200 nil b c)))
55
;; :hints (("Goal" :external (sat nil sat::$sat))))
60
(nth-cdr (1- n) (cdr x))))
62
(defun nth-sublist (n lst)
65
(cons (car lst) (nth-sublist (1- n) (cdr lst)))))
67
(defun append-n (n x y)
70
(cons (car x) (append-n (1- n) (cdr x) y))))
75
(cons nil (n-nills (1- n)))))
77
(defun rev-n (n x ans)
80
(rev-n (1- n) (cdr x) (cons (car x) ans))))
82
(defun mux-n-help (n in rsel)
86
(mux-n-help (1- n) (nth-cdr (expt 2 (1- n)) in) (cdr rsel))
87
(mux-n-help (1- n) in (cdr rsel)))))
89
(defun mux-n (n in sel)
90
(mux-n-help n in (rev-n n sel nil)))
92
(defun mux-n-w-help (n w in)
95
(cons (car in) (mux-n-w-help (1- n) w (nth-cdr w in)))))
97
(defun mux-n-w1 (nw sn w in sel)
100
(cons (mux-n sn (mux-n-w-help (expt 2 sn) w in) sel)
101
(mux-n-w1 (1- nw) sn w (cdr in) sel))))
103
(defun mux-n-w (n w in sel)
104
(mux-n-w1 w n w in sel))
106
(defun shift-mux-help (n w reg)
109
(append-n w reg (shift-mux-help (1- n) w (cons nil reg)))))
111
(defun shifter (sn rn rshift reg)
114
(mux-n-w sn rn (shift-mux-help (expt 2 sn) rn reg) rshift)))
119
;; (car (nth-cdr 5 shift0))
121
;; (shifter 6 32 shift0 reg)
123
;; :hints (("Goal" :external (sat nil sat::$sat))))
128
;; (car (nth-cdr 6 shift0))
129
;; (n-bleq 64 (shifter 7 64 shift0 reg)
131
;; :hints (("Goal" :external (sat nil sat::$sat))))
136
;; (shifter 4 32 shift0 (shifter 4 32 shift1 reg))
137
;; (shifter 5 32 (v-adder 4 nil shift0 shift1) reg))
138
;; :hints (("Goal" :external (sat nil sat::$sat))))
143
;; (shifter 6 64 shift0 (shifter 6 64 shift1 reg))
144
;; (shifter 7 64 (v-adder 6 nil shift0 shift1) reg))
145
;; :hints (("Goal" :external (sat nil sat::$sat))))
147
(defun increment (n x)
151
(cons nil (increment (1- n) (cdr x)))
154
(defun next_digit_counter_state (x)
155
(if (n-bleq 4 x '(t nil nil t))
156
(list '(nil nil nil nil) t)
157
(list (increment 4 x) nil)))
159
(defun next_counter_state (n x)
160
(let* ((curr_d_out (next_digit_counter_state (car x)))
161
(curr_d_val (car curr_d_out))
162
(curr_d_reset (cadr curr_d_out)))
166
(cons curr_d_val (next_counter_state (1- n) (cdr x)))
167
(cons curr_d_val (cdr x))))))
169
(defun valid_digit (a)
173
(not (and a3 (or a2 a1)))))
175
(defun valid_digits (n x)
178
(and (valid_digit (car x))
179
(valid_digits (1- n) (cdr x)))))
181
;; 100 Digit Counter Invariant
184
;; (valid_digits 100 x)
185
;; (valid_digits 100 (next_counter_state 100 x)))
186
;; :hints (("Goal" :external (sat nil sat::$sat))))