File: ACONST_NULL.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 (259 lines) | stat: -rw-r--r-- 9,595 bytes parent folder | download | duplicates (2)
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
(in-package "DJVM")

(include-book "base")
(include-book "base-consistent-state")
(include-book "base-extra")


;-----------------------------------------------------------------
;
;  ACONST_NULL
;
; 

;-- Define guard first -------------------------------------------



(acl2::set-verify-guards-eagerness 2)

(defun wff-ACONST_NULL (inst)
  (wff-inst inst))

(defun ACONST_NULL-guard (inst s)
  (and (consistent-state-strong s)
       (wff-inst inst)
       (not (mem '*abstract* (method-accessflags (current-method s))))
       (not (mem '*native* (method-accessflags (current-method s))))
       (<= (+ (len (operand-stack (current-frame s))) 1)
           (max-stack s))))

;-- Definition of ACONST_NULL -------------------------------------


(defun execute-ACONST_NULL (inst s)
  (declare (xargs :guard (ACONST_NULL-guard inst s)))
  (ADVANCE-PC (safe-pushStack '(REF . -1) s)))


;-- Runtime checking of the ACONST_NULL ----------------------

; Note the difference between *-guard and check-* 
; 
; Tue Apr 19 10:10:29 2005


(defun check-ACONST_NULL (inst s)
  (declare (xargs :guard (consistent-state s)))
  (and (wff-inst inst)
       (not (mem '*abstract* (method-accessflags (current-method s))))
       (not (mem '*native* (method-accessflags (current-method s))))
       ;; we could add the check for max stack!!
       (<= (+ (len (operand-stack (current-frame s))) 1)
           (max-stack s))))


;----------------------------------------------------------------------
;----------------------------------------------------------------------


;;; Strive to make sure that the proof of these theorems depend only on lemma
;;; in base-* !!
;;; 

;-- ACONST_NULL-guard implies state consistency perserved -----------------

;; (i-am-here) ;; Sun Aug  7 22:21:15 2005


(defthm ACONST_NULL-guard-implies-execute-ACONST_NULL-perserve-consistency
  (implies (ACONST_NULL-guard inst s)
           (consistent-state-strong (execute-ACONST_NULL inst s))))


;-- check-ACONST_NULL implies ACONST_NULL-guard in a consistent state ----------

(defthm check-ACONST_NULL-implies-guard-succeeds
  (implies (and (consistent-state-strong s)
                (check-ACONST_NULL inst s))
          (ACONST_NULL-guard inst s)))


;-- BCV::check-ACONST_NULL implies DJVM::check-ACONST_NULL on a corresponding state -----

(encapsulate ()
 (local (include-book "base-bcv"))
 (defthm bcv-check-ACONST_NULL-ensures-djvm-check-ACONST_NULL
   (implies (and (bcv::check-ACONST_NULL inst (env-sig s) 
                                         (frame-sig  (current-frame s)
                                                     (instance-class-table s)
                                                     (heap s)
                                                     (heap-init-map (aux s))))
                 (wff-inst inst)
                 (not (mem '*native* (method-accessflags (current-method s))))
                 (consistent-state s))
            (djvm::check-ACONST_NULL inst s))))


;-- BCV::check-ACONST_NULL monotonic   -------------------------------------

(encapsulate () 
  (local (include-book "base-bcv-check-monotonic"))
  (defthm sig-check-ACONST_NULL-on-more-general-implies-more-specific
    (implies (and (bcv::sig-frame-more-general gframe sframe env)
                  (bcv::check-ACONST_NULL inst env gframe))
             (bcv::check-ACONST_NULL inst env sframe))))


; avoided loading base-bcv-check-monotonic.lisp
;-- BCV::execute-ACONST_NULL monotonic  ------------------------------------


(encapsulate () 
  (local (include-book "base-bcv-step-monotonic"))
  (defthm ACONST_NULL-monotonicity
  (implies (and (bcv::sig-frame-more-general gframe sframe env)
                (bcv::check-ACONST_NULL inst env gframe))
           (bcv::sig-frame-more-general 
            (bcv::normal-frame (bcv::execute-ACONST_NULL inst env gframe))
            (bcv::normal-frame (bcv::execute-ACONST_NULL inst env sframe)) env))))


;-- DJVM::step frame expansion  ---------------------------




(encapsulate ()
    (local (include-book "base-frame-sig-expansion"))
    (defthm execute-ACONST_NULL-frame-sig-is
      (mylet* ((ns (execute-ACONST_NULL inst s))
               (index (topStack s))
               (array-ref (topStack (popStack s))))
              (implies 
               (and (consistent-state s)
                    (check-ACONST_NULL inst s))
               (equal (frame-sig (current-frame ns)
                                 (instance-class-table ns)
                                 (heap ns)
                                 (heap-init-map (aux ns)))
                      (frame-push-value-sig  'NULL
                       (frame-sig (current-frame s)
                                  (instance-class-table s)
                                  (heap s)
                                  (heap-init-map (aux s)))))))))

;----------------------------------------------------------------------

;-- BCV::step frame expansion  ---------------------------

(encapsulate ()
       (local (include-book "base-bcv-frame-sig-expansion"))
       (defthm bcv-execute-ACONST_NULL-is
         (implies (and 
            (consistent-state s)
            (check-ACONST_NULL inst s)
            (bcv::check-ACONST_NULL inst (env-sig s) 
                                    (frame-sig (current-frame s)
                                               (instance-class-table s)
                                               (heap s)
                                               (heap-init-map (aux s)))))
           (equal (car (bcv::execute-ACONST_NULL inst (env-sig s) 
                                                 (frame-sig (current-frame s)
                                                            (instance-class-table s)
                                                            (heap s)
                                                            (heap-init-map (aux s)))))
                  (frame-push-value-sig 'NULL
                                        (frame-sig (current-frame s)
                                                   (instance-class-table s)
                                                   (heap s)
                                                   (heap-init-map (aux s))))))))

;----------------------------------------------------------------------

;;(i-am-here) ;; Mon Jul 25 16:50:01 2005. some proof break this!! 

(encapsulate ()
 (local (include-book "base-next-state-more-specific"))
 (defthm next-state-no-more-general-ACONST_NULL
  (mylet* ((oframe (frame-sig (current-frame s)
                              (instance-class-table s)
                              (heap s)
                              (heap-init-map (aux s))))
           (ns   (djvm::execute-ACONST_NULL inst s))
           (nframe (frame-sig (current-frame ns)
                              (instance-class-table ns)
                              (heap ns)
                              (heap-init-map (aux ns)))))
          (implies (and (consistent-state s)
                        (bcv::check-ACONST_NULL inst (env-sig s) oframe)
                        (djvm::check-ACONST_NULL inst s)
                        (not (check-null (topStack (popStack s)))))
                   (bcv::sig-frame-more-general 
                    (mv-nth 0 (bcv::execute-ACONST_NULL inst 
                                                        (env-sig s)
                                                        oframe))
                    nframe
                    (env-sig s))))))



             
;-- M6-DJVM-equal-when-check-succeeds.lisp ------------------------------

;; Tue Aug  2 16:10:50 2005

;; (i-am-here) ;; Tue Aug  2 16:10:56 2005

(include-book "../../M6/m6-bytecode")
(include-book "../../DJVM/consistent-state-to-untag-state")



;; (encapsulate ()
;;    (local (include-book "base-untag-state"))
;;    (defthm equal-ACONST_NULL-when-guard-succeeds
;;      (implies (ACONST_NULL-guard inst s)
;;               (equal (untag-state (djvm::execute-ACONST_NULL inst s))
;;                      (m6::execute-ACONST_NULL inst (untag-state s))))))



(encapsulate ()
   (local (include-book "base-state-equiv"))
   (defthm equal-ACONST_NULL-when-guard-succeeds
      (implies (and (state-equiv M6::m6-s DJVM::djvm-s)
                    (ACONST_NULL-guard inst DJVM::djvm-s))
               (state-equiv (m6::execute-ACONST_NULL inst M6::m6-s)
                            (djvm::execute-ACONST_NULL inst DJVM::djvm-s)))
      :hints (("Goal" :do-not '(generalize fertilize)))))


;;; Tue Aug  2 16:12:55 2005

;;; take only two minutes. compare with the time it takes to replay ALOAD.lisp
;;; proof! 

;----------------------------------------------------------------------


(encapsulate () 
  (local (include-book "base-method-ptr-no-change"))
  (defthm execute-ACONST_NULL-change-no-method-ptr
    (equal (method-ptr (current-frame (djvm::execute-ACONST_NULL inst s)))
           (method-ptr (current-frame s)))))

;;; next need to prove loaded class method-does-not-change! 


(encapsulate () 
  (local (include-book "base-method-no-change"))
  (defthm deref-method-no-change-if-already-loaded-ACONST_NULL
    (implies (consistent-state s)
             (equal (deref-method (method-ptr (current-frame s))
                                  (instance-class-table 
                                   (djvm::execute-ACONST_NULL inst s)))
                    (deref-method (method-ptr (current-frame s))
                                  (instance-class-table s))))))

(in-theory (disable check-ACONST_NULL ACONST_NULL-guard execute-ACONST_NULL wff-ACONST_NULL))