File: test2.lsp

package info (click to toggle)
acl2 8.6%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: 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 (205 lines) | stat: -rw-r--r-- 6,761 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
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
(in-package "SAT")

(include-book "assignment-equiv")
(include-book "create-farray")
(include-book "reader")

(defun create-rat-checker (nVars st)
  (declare (xargs :guard (posp nVars)
                  :stobjs (st)))
  (create-farray
   (list 1
         1
         (1+ nVars)
         (+ 2 (* 2 nVars)))
   0 st))


;; create a new farray for rat-checker
(create-rat-checker 1227 st)

;; write number of variables to rat-checker
(fwrite *num-vars* 0 1227 *s* st)


(defttag t)

(remove-untouchable acl2::create-state t)

(defun read-and-parse-local-state (filename)
  ;; This function requires the STATE, so we use the next form
  (with-local-state
   ;; "Powerful" macro that provides access to the state, but
   ;; requires the two events above.
   (mv-let (err num-vars num-clauses formula state)
           (ACL2::read-and-parse filename)
           (mv err num-vars num-clauses formula))))

;; Example Read -- filename can be changed.

;; (defconst *cnf*
;;   (mv-let (err num-vars num-clauses formula)
;;           (read-and-parse-local-state "small-unsat.cnf")
;;           (list err num-vars num-clauses formula)))

(defconst *cnf*
  (mv-let (err num-vars num-clauses formula)
          (read-and-parse-local-state "rbcl_xits_06_UNSAT-10-new.cnf")
          (list err num-vars num-clauses formula)))


(defun read-and-parse-proof-local-state (filename)
  ;; This function requires the STATE, so we use the next form
  (with-local-state
   ;; "Powerful" macro that provides access to the state, but
   ;; requires the two events above.
   (mv-let (err num-clauses proof state)
           (ACL2::read-and-parse-proof filename)
           (mv err num-clauses proof))))


;; (defconst *proof*
;;   (mv-let (err num-clauses proof)
;;           (read-and-parse-proof-local-state "small-unsat.rat")
;;           (list err num-clauses proof)))

(defconst *proof*
  (mv-let (err num-clauses proof)
          (read-and-parse-proof-local-state "rbcl_xits_06_UNSAT-10-combined-lemmas-no-d-head-100.cnf")
          (list err num-clauses proof)))


;; (assignment-stp st)
;; (clause-listp (caddr *proof*))
;; (formulap (cadddr *cnf*))

(defun verify-proof-st-count (clause-list formula count max st)
  (declare (xargs :guard (and (assignment-stp st)
                              (clause-listp clause-list)
                              (clause-list-in-rangep clause-list st)
                              (formulap formula)
                              (formula-in-rangep formula st)
                              (natp count)
                              (posp max))
                  :stobjs (st)))
  (if (atom clause-list)
      (mv t st)
    (mv-let (vc st)
            (verify-clause-st (car clause-list) formula st)
            (if (not vc)
                (mv nil st)
              (if (equal (mod count 100) 0)
                  (b* ((percent (floor (* 100 count) max))
                       (- (cw "~x0% (~x1 / ~x2) ~%" percent count max)))
                      (verify-proof-st-count (cdr clause-list)
                                             (cons (car clause-list) formula)
                                             (1+ count)
                                             max
                                             st))
                (verify-proof-st-count (cdr clause-list)
                                       (cons (car clause-list) formula)
                                       (1+ count)
                                       max
                                       st))))))


(i-am-here)
;; ===================================================================

(profile 'evaluate-literal-st)

(time$
 (verify-proof-st-count (caddr *proof*)
                        (cadddr *cnf*)
                        0
                        (cadr *proof*)
                        st))

(memsum)
;; =
;; (ACL2::EV-REC ACL2::*RETURN-LAST-ARG3* ...) took 
;; 143.51 seconds realtime, 138.73 seconds runtime
;; (60,880 bytes allocated).
;; (EVALUATE-LITERAL-ST
;;  Calls                                                    8.97E+8
;;  Time of all outermost calls                               124.77
;;  Time per call                                            1.39E-7
;;  From other functions          8.97E+8 calls took 1.25E+2; 100.0%)


;; ===================================================================

(clear-memoize-statistics)
(unmemoize 'evaluate-literal-st)

(profile 'evaluate-literal)

(time$
 (verify-proof (caddr *proof*)
               (cadddr *cnf*)))


(memsum)
;; =
;; (ACL2::EV-REC ACL2::*RETURN-LAST-ARG3* ...) took 
;; 1126.50 seconds realtime, 1105.15 seconds runtime
;; (1,867,856 bytes allocated).
;; (EVALUATE-LITERAL
;;  Calls                                                                  8.97E+8
;;  Time of all outermost calls                                            1.61E+3
;;  Time per call                                                         1.799E-6
;;  From other functions                        8.97E+8 calls took 1.61E+3; 100.0%)


;; ===================================================================

(clear-memoize-statistics)
(unmemoize 'evaluate-literal)


(profile 'unit-propagation-st)

(time$
 (verify-proof-st-count (caddr *proof*)
                        (cadddr *cnf*)
                        0
                        (cadr *proof*)
                        st))

(memsum)
;; =
;; (ACL2::EV-REC ACL2::*RETURN-LAST-ARG3* ...) took 
;; 53.13 seconds realtime, 52.99 seconds runtime
;; (60,880 bytes allocated).
;; (UNIT-PROPAGATION-ST
;;  Calls                                                                      836
;;  Time of all outermost calls                                              78.61
;;  Time per call                                                             0.09
;;  From other functions                        8.36E+2 calls took 7.86E+1; 100.0%)


;; ===================================================================

(clear-memoize-statistics)
(unmemoize 'unit-propagation-st)

(profile 'unit-propagation)

(time$
 (verify-proof (caddr *proof*)
               (cadddr *cnf*)))


(memsum)
;; =
;; (ACL2::EV-REC ACL2::*RETURN-LAST-ARG3* ...) took 
;; 1045.40 seconds realtime, 1036.13 seconds runtime
;; (1,867,856 bytes allocated).
;; (UNIT-PROPAGATION
;;  Calls                                                                      836
;;  Time of all outermost calls                                            1.55E+3
;;  Time per call                                                             1.86
;;  Heap bytes allocated                                           1.73E+6; 100.0%
;;  Heap bytes allocated per call                                          2.07E+3
;;  From other functions                        8.36E+2 calls took 1.55E+3; 100.0%)