File: soundness.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 (176 lines) | stat: -rw-r--r-- 6,777 bytes parent folder | download | duplicates (5)
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
; Copyright (C) 2017, Regents of the University of Texas
; Marijn Heule, Warren A. Hunt, Jr., and Matt Kaufmann
; License: A 3-clause BSD license.  See the LICENSE file distributed with ACL2.

; See ../README.

(in-package "LRAT")

(include-book "incremental")

(deflabel soundness-start)

(in-theory (theory 'ground-zero))

(defthm ordered-formula-p-forward-to-true-listp
  (implies (ordered-formula-p formula)
           (true-listp formula))
  :hints (("Goal" :in-theory (enable ordered-formula-p)))
  :rule-classes :forward-chaining)

(defun proved-formula (cnf-file clrat-file chunk-size debug incomplete-okp ctx
                                state)
  (declare (xargs :stobjs state
                  :guard-hints
                  (("Goal" :in-theory (enable incl-valid-proofp$-top
                                              acl2::error1-logic)))))
  (mv-let (erp val/formula state)
    (incl-valid-proofp$-top cnf-file clrat-file
                            incomplete-okp
                            chunk-size debug ctx state)
    (value (and (null erp)
                (consp val/formula)
                (eq (car val/formula) t)

; The formula returned by incl-valid-proofp$-top is in reverse order.  We
; prefer to return a formula that we expect to agree with the formula
; represented in the input cnf-file.

                (reverse (cdr val/formula))))))

(in-theory (disable reverse))

(encapsulate
  ()
  (local (include-book "soundness-main"))
  (set-enforce-redundancy t)
  (defthm soundness-main
    (implies
     (and (equal (car (incl-valid-proofp$-top-rec formula
                                                  clrat-file posn chunk-size
                                                  clrat-file-length
                                                  old-suffix debug max-var a$ ctx
                                                  state))
                 :complete)
          (formula-p formula)
          (a$p a$)
          (equal (a$ptr a$) 0)
          (integerp max-var)
          (<= (formula-max-var formula 0) max-var))
     (not (satisfiable formula)))))

(defthm a$p-initial-a$
  (a$p (resize-a$arr 2 (create-a$)))
  :hints (("Goal" :in-theory (current-theory 'soundness-start))))

(defthm a$ptr-initial-a$
  (equal (a$ptr (resize-a$arr 2 (create-a$)))
         0)
  :hints (("Goal" :in-theory (current-theory 'soundness-start))))


(defthm soundness-helper-1
  (implies
   (and (formula-p formula)
        (posp clrat-file-length)
        (equal (car (incl-valid-proofp$-top-rec formula
                                                clrat-file 0 chunk-size
                                                clrat-file-length
                                                "" debug
                                                (formula-max-var formula 0)
                                                (resize-a$arr 2 (create-a$))
                                                ctx state))
               :complete))
   (not (satisfiable formula)))
  :hints (("Goal" :in-theory (enable natp-formula-max-var))))

(encapsulate ; Prove satisfiable-reverse.
  ()

  (local
   (progn ; Prove hons-assoc-equal-reverse.

     (defthm hons-assoc-equal-revappend-lemma-1
       (implies (and (ordered-formula-p1 formula i)
                     (natp i)
                     (natp j)
                     (<= i j))
                (equal (hons-assoc-equal j (revappend formula acc))
                       (hons-assoc-equal j acc)))
       :hints (("Goal"
                :in-theory (enable ordered-formula-p1))))

     (defthm hons-assoc-equal-revappend-lemma-2
       (implies (and (ordered-formula-p1 formula i)
                     (natp i)
                     (natp j)
                     (<= i j))
                (equal (hons-assoc-equal j formula)
                       nil))
       :hints (("Goal"
                :in-theory (enable ordered-formula-p1))))

     (defthm hons-assoc-equal-revappend
       (implies (ordered-formula-p1 formula start)
                (equal (hons-assoc-equal index (revappend formula acc))
                       (or (hons-assoc-equal index formula)
                           (hons-assoc-equal index acc))))
       :hints (("Goal"
                :in-theory (enable ordered-formula-p1))))

     (defthm hons-assoc-equal-reverse
       (implies (ordered-formula-p formula)
                (equal (hons-assoc-equal index (reverse formula))
                       (hons-assoc-equal index formula)))
       :hints (("Goal" :in-theory (enable reverse ordered-formula-p))))))

  (local
   (defthm solution-p-reverse-implies-solution-p
     (implies (and (ordered-formula-p formula)
                   (solution-p assignment (reverse formula)))
              (solution-p assignment formula))
     :hints (("Goal"
              :in-theory (enable formula-truep-necc solution-p)
              :restrict ((formula-truep-necc
                          ((index (formula-truep-witness formula assignment)))))
              :expand ((formula-truep formula assignment))))))

  (defthm satisfiable-reverse
    (implies (and (ordered-formula-p formula)
                  (not (satisfiable formula)))
             (not (satisfiable (reverse formula))))
    :hints (("Goal"
             :in-theory (enable satisfiable-suff)
             :restrict ((satisfiable-suff
                         ((assignment (satisfiable-witness (reverse formula))))))
             :expand ((satisfiable (reverse formula)))))))

(defthm soundness-helper-2
  (implies (mv-let (erp val/formula state)
             (incl-valid-proofp$-top cnf-file clrat-file nil
                                     chunk-size debug ctx state)
             (declare (ignore state))
             (and (not erp)
                  (equal formula (reverse (cdr val/formula)))
                  (car val/formula)))
           (not (satisfiable formula)))
  :hints (("Goal"
           :in-theory (enable incl-valid-proofp$-top
                              acl2::error1-logic
                              incl-valid-proofp$-top-aux
                              ordered-formula-p-implies-formula-p))))

(defthm soundness
  (let ((formula (mv-nth 1
                         (proved-formula cnf-file clrat-file chunk-size debug
                                         nil ; incomplete-okp
                                         ctx state))))
    (implies formula
             (not (satisfiable formula))))
  :hints (("Goal" :restrict ((soundness-helper-2
                              ((state state)
                               (ctx ctx)
                               (debug debug)
                               (chunk-size chunk-size)
                               (clrat-file clrat-file)
                               (cnf-file cnf-file)))))))