File: reductions.lisp

package info (click to toggle)
acl2 8.5dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 991,452 kB
  • sloc: lisp: 15,567,759; javascript: 22,820; cpp: 13,929; ansic: 12,092; perl: 7,150; java: 4,405; xml: 3,884; makefile: 3,507; sh: 3,187; ruby: 2,633; ml: 763; python: 746; yacc: 723; awk: 295; csh: 186; php: 171; lex: 154; tcl: 49; asm: 23; haskell: 17
file content (392 lines) | stat: -rw-r--r-- 12,124 bytes parent folder | download | duplicates (6)
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
(in-package "ACL2")

#|

  reductions.lisp
  ~~~~~~~~~~~~~~~

In this book, we use the conjunctive reduction and cone of influence reduction
compositionally to provide reduction algorithms for circuits.

|#

(local
(include-book "conjunction")
)

(include-book "cone-of-influence")


(defun ltl-semantics-for-circuit (C f)
  (ltl-semantics f (create-kripke C)))

(defun ltl-semantics-for-circuits* (list)
  (if (endp list) T
    (and (ltl-semantics-for-circuit (second (first list))
                                    (first (first list)))
         (ltl-semantics-for-circuits* (rest list)))))


(defun reduce-problem-conjunction (f C)
  (if (and (equal (len f) 3)
           (equal (second f) '&))
      (append (reduce-problem-conjunction (first f) C)
              (reduce-problem-conjunction (third f) C))
    (list (list f C))))

(defun reduce-problem-cone (f C)
  (let ((vars (create-restricted-var-set f)))
    (cone-of-influence-reduction C vars)))

(defun reduce-problem-cone* (list)
  (if (endp list) nil
    (cons (list (first (first list))
                (reduce-problem-cone (first (first list)) (second (first list))))
            (reduce-problem-cone* (rest list)))))


(defun compositional-reduction (C f)
  (let ((list (reduce-problem-conjunction f C)))
    (reduce-problem-cone* list)))

;; OK, so let us dispatch the obligations for conjunction first.

(local
(in-theory (disable ltl-semantics create-kripke ltl-formulap))
)

(local
(defthm ltl-semantics*-append-reduction
  (equal (ltl-semantics-for-circuits* (append x y))
         (and (ltl-semantics-for-circuits* x)
              (ltl-semantics-for-circuits* y))))
)

(local
(defthm conjunction-produces-correct-list
  (implies (ltl-formulap f)
           (equal (ltl-semantics-for-circuits*
                   (reduce-problem-conjunction f C))
                  (ltl-semantics-for-circuit C f)))
  :otf-flg t
  :hints (("Goal"
           :induct (reduce-problem-conjunction f C)
           :do-not-induct t
           :in-theory (enable ltl-formulap)
           :do-not '(eliminate-destructors generalize))))
)

;; To work with reduce-problems-cone, we need to assume that the variables in f
;; are subsets of the variables in cone of influence reduction. We show that
;; assuming that the variables are subsets of variables of the circuit. We need
;; to show though that the variables of cone will be a superset of vars if we
;; start with a collection of vars that are subset of the variables of the
;; circuit.

(local
(encapsulate
 ()
 (defthm not-memberp-union-reduction
   (implies (and (not (memberp e x))
                 (not (memberp e y)))
            (not (memberp e (set-union x y))))
   :hints (("Goal"
            :in-theory (enable set-union))))

 (local
 (defthm uniquep-set-union-reduction
   (implies (and (uniquep x)
                 (uniquep y))
            (uniquep (set-union x y)))
   :hints (("Goal"
            :in-theory (enable set-union))))
 )

 (local
 (in-theory (disable consistent-equation-record-p))
 )

 (local
 (defthm consistent-equation-record-p-expanded
   (implies (and (consistent-equation-record-p vars equations)
                 (uniquep vars)
                 (memberp v vars)
                 (memberp equation (<- equations v)))
            (subset (find-variables equation)
                    vars))
   :hints (("Goal"
            :use consistent-equation-record-p-necc)))
 )

 (local
 (in-theory (disable consistent-equation-record-p-necc))
 )

 (local
 (defthm set-union-subset-reduction
   (implies (and (subset x z)
                 (subset y z))
            (subset (set-union x y) z))
   :hints (("Goal"
            :in-theory (enable set-union))))
 )

 (local
 (defthm find-variables*-subset-of-variables
   (implies (and (consistent-equation-record-p variables equations)
                 (uniquep variables)
                 (memberp v variables)
                 (subset equation-list (<- equations v)))
            (subset (find-variables* equation-list)
                    variables))
   :hints (("Goal"
            :in-theory (disable find-variables)
            :induct (find-variables* equation-list)
            :do-not '(eliminate-destructors generalize)
            :do-not-induct t)))
 )

 (local
 (defthm find-variables*-is-subset-concretized
   (implies (and (consistent-equation-record-p variables equations)
                 (memberp v variables)
                 (uniquep variables))
            (subset (find-variables* (<- equations v)) variables)))
 )

 (local
 (in-theory (disable find-variables*-subset-of-variables))
 )

 (local
 (defthm find-variables-1-pass-is-subset
   (implies (and (consistent-equation-record-p variables equations)
                 (subset vars variables)
                 (uniquep variables))
            (subset (find-all-variables-1-pass vars equations)
                    variables)))
 )

 (local
 (defthm memberp-union-reduction-1
   (implies (memberp e x)
            (memberp e (set-union y x)))
   :hints (("Goal"
            :in-theory (enable set-union))))
 )

 (local
 (defthm memberp-find-all-variables-reduction
   (implies (and (consistent-equation-record-p variables equations)
                 (subset vars variables)
                 (memberp v vars))
            (memberp v (find-all-variables vars variables equations)))
   :otf-flg t
   :hints (("Goal"
            :induct (find-all-variables vars variables equations)
            :do-not '(eliminate-destructors generalize)
            :do-not-induct t)))
 )

 (local
 (defthm find-all-variables-produces-subset
   (implies (and (consistent-equation-record-p variables equations)
                 (subset vars variables)
                 (subset vars-prime vars))
            (subset vars-prime (find-all-variables vars variables equations))))
 )

 (local
 (defthm set-intersect-is-subset
   (implies (and (subset vars variables)
                 (subset vars vars-prime))
            (subset vars (set-intersect vars-prime variables))))
 )

 (local
 (defthm memberp-remove-reduction
   (equal (memberp e (remove-duplicate-occurrences variables))
          (memberp e variables)))
 )

 (local
 (defthm remove-duplicates-is-subset
   (implies (subset vars variables)
            (subset vars (remove-duplicate-occurrences variables))))
 )

 (local
 (defthm cone-variables-are-subset
   (implies (and (consistent-equation-record-p variables equations)
                 (subset vars variables))
            (subset vars (find-all-variables
                          (set-intersect
                           (remove-duplicate-occurrences vars)
                           variables)
                          variables equations)))
   :hints (("Goal"
            :do-not-induct t
            :in-theory (disable find-all-variables-produces-subset)
            :use ((:instance find-all-variables-produces-subset
                             (vars-prime vars)
                             (vars (set-intersect
                                    (remove-duplicate-occurrences vars)
                                    variables)))))))
 )

 (local
 (defthm circuitp-to-cone-variables
   (implies (and (circuitp C)
                 (subset vars (variables C)))
            (subset vars (cone-variables vars C))))
 )

 (local
 (in-theory (disable circuitp cone-variables cone-of-influence-reduction))
 )

 (defthm cone-of-influence-reduction-for-specific
   (implies (and (circuitp C)
                 (ltl-formulap f)
                 (subset (create-restricted-var-set f)
                         (variables C)))
            (equal (ltl-semantics-for-circuit  (cone-of-influence-reduction
                                                C (create-restricted-var-set
                                                   f))
                                               f)
                   (ltl-semantics-for-circuit C f)))
   :hints (("Goal"
            :do-not-induct t
            :in-theory (disable cone-of-influence-reduction-is-sound-generalized)
            :use ((:instance cone-of-influence-reduction-is-sound-generalized
                             (interesting-vars (create-restricted-var-set f))
                             (vars (create-restricted-var-set f)))))))

 )
)

(local
(in-theory (disable ltl-semantics-for-circuit create-restricted-var-set
                    cone-of-influence-reduction
                    circuitp ltl-formulap))
)

(local
(defthm reduce-problem-cone-reduction
  (implies (and (circuitp C)
                (ltl-formulap f)
                (subset (create-restricted-var-set f) (variables C)))
           (equal (ltl-semantics-for-circuit (reduce-problem-cone f C)
                                             f)
                  (ltl-semantics-for-circuit C f))))
)

(local
(in-theory (disable reduce-problem-cone))
)

(local
(defun well-formed-problems-p (list)
  (if (endp list) T
    (and (ltl-formulap (first (first list)))
         (circuitp (second (first list)))
         (subset (create-restricted-var-set (first (first list)))
                 (variables (second (first list))))
         (well-formed-problems-p (rest list)))))
)

(local
(defthm reduce-problem-cone*-reduction
  (implies (well-formed-problems-p list)
           (equal (ltl-semantics-for-circuits* (reduce-problem-cone* list))
                  (ltl-semantics-for-circuits* list)))
  :otf-flg t
  :hints (("Goal"
           :in-theory (enable reduce-problem-cone*)
           :do-not '(eliminate-destructors generalize))))
)

(local
(defthm subset-member-reduction
  (implies (and (subset (set-union x y) z)
                (memberp e x))
           (memberp e z))
  :hints (("Goal"
           :in-theory (enable set-union))))
)

(local
(defthm subset-member-reduction-2
  (implies (and (subset (set-union x y) z)
                (memberp e y))
           (memberp e z))
  :hints (("Goal"
           :in-theory (enable set-union))))
)

(local
(defthm set-union-subset-reduction
  (implies (subset (set-union x y) z)
           (subset x z))
  :hints (("Goal"
           :in-theory (enable set-union))))
)

(local
(defthm set-union-subset-reduction-2
  (implies (subset (set-union x y) z)
           (subset y z))
  :hints (("Goal"
           :in-theory (enable set-union))))
)

(local
(defthm conjunction-has-variables-subset-1
  (implies (and (ltl-formulap f)
                (equal (len f) 3)
                (subset (create-restricted-var-set f) vars))
           (subset (create-restricted-var-set (first f)) vars))
  :hints (("Goal"
           :do-not '(eliminate-destructors generalize)
           :do-not-induct t
           :in-theory (enable create-restricted-var-set ltl-formulap)
           :expand (create-restricted-var-set f))))
)
(local
(defthm conjunction-has-variables-subset-2
   (implies (and (ltl-formulap f)
                (equal (len f) 3)
                (subset (create-restricted-var-set f) vars))
           (subset (create-restricted-var-set (third f)) vars))
  :hints (("Goal"
           :do-not '(eliminate-destructors generalize)
           :do-not-induct t
           :in-theory (enable create-restricted-var-set ltl-formulap)
           :expand (create-restricted-var-set f))))
)

(local
(defthm well-formed-append-reduction
  (implies (and (force (well-formed-problems-p first))
                (force (well-formed-problems-p second)))
           (well-formed-problems-p (append first second))))
)

(local
(defthm conjunction-produces-well-formed-problems
  (implies (and (circuitp C)
                (ltl-formulap f)
                (subset (create-restricted-var-set f) (variables C)))
           (well-formed-problems-p (reduce-problem-conjunction f C)))
  :hints (("Goal"
           :do-not-induct t
           :do-not '(eliminate-destructors generalize)
           :induct (reduce-problem-conjunction f C))))
)

(DEFTHM compositional-reduction-is-sound
  (implies (and (circuitp C)
                (ltl-formulap f)
                (subset (create-restricted-var-set f) (variables C)))
           (equal (ltl-semantics-for-circuits* (compositional-reduction C f))
                  (ltl-semantics-for-circuit C f))))