File: consistent-state-obj-init.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 (178 lines) | stat: -rw-r--r-- 7,395 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
(in-package "DJVM")
(include-book "../DJVM/consistent-state")


;; (include-book "../DJVM/djvm-env")
;; (include-book "../DJVM/djvm-class-table")
;; (include-book "../DJVM/djvm-thread")
;; (include-book "../DJVM/djvm-obj")
;; (include-book "../DJVM/djvm-type-value")
;; (include-book "../DJVM/djvm-linker")


;;; The predicate defined in this section: asserts that if local or operand
;;; stack contains uninitialized reference, then, these references should be
;;; kept tracked of in frame-obj-init-map.
;;; 
;;; Mon Oct 24 13:52:01 2005

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

(defun frame-obj-init-map (frame) 
  (declare (xargs :guard (wff-call-frame frame)))
  (acl2::g 'frame-obj-init-map (frame-aux frame)))

(defun collect-keys (obj-init-map) 
  (declare (xargs :guard (alistp obj-init-map)))
  (if (endp obj-init-map) nil
    (cons (car (car obj-init-map))
          (collect-keys (cdr obj-init-map)))))

(defun collect-values (obj-init-map)
  (declare (xargs :guard (and (alistp obj-init-map)
                              (nodup-set (collect-keys obj-init-map)))))
  (if (endp obj-init-map) nil
    (cons (cdr (car obj-init-map))
          (collect-values (cdr obj-init-map)))))


(defun initialized-ref (ref hp-init)
  (declare (xargs :guard (wff-heap-init-map-strong hp-init)))
  (or (not (bound? ref hp-init))
      (not (consp (binding ref hp-init)))))


;; (defun consistent-locals-obj-init (locals hp-init valid-obj-refs)
;;   (declare (xargs :guard (and (wff-heap-init-map-strong hp-init)
;;                               (true-listp valid-obj-refs))))
;;   (if (not (consp locals)) t
;;     (cond ((category1loc locals)
;;            (and (or (not (equal (tag-of (car locals)) 'REF)) 
;;                     ;; not a reference value! 
;;                     (NULLp (car locals))
;;                     (initialized-ref (value-of (car locals)) hp-init)
;;                     (mem (value-of (car locals)) valid-obj-refs))
;;                 (consistent-locals-obj-init (shift1slot locals) hp-init 
;;                                             valid-obj-refs)))
;;           ((category2loc locals)
;;            (consistent-locals-obj-init (shift2slot locals) hp-init valid-obj-refs)))))
      

;; (defun wff-tagged-locals (l)
;;   (if (not (consp l)) t
;;     (and (wff-tagged-value (car l))
;;          (wff-tagged-locals (cdr l)))))

;; ;;;
;; ;;; this will make the guard verification for consistent-state-strong 
;; ;;; a bit complicated! 
;; ;;; 
;; ;;; the benefit is that we can have some nice lemma about pushStack and
;; ;;; popStack without thinking too much about the guard! --- by ignoring the
;; ;;; difference between size two value and size one value!! 
;; ;;; 
;;;;;; 

(defun consistent-locals-obj-init (locals hp-init valid-obj-refs)
   (declare (xargs :guard (and (wff-heap-init-map-strong hp-init)
                               (true-listp valid-obj-refs))))
   (if (not (consp locals)) t
     (and (wff-tagged-value (car locals))
          (or (not (equal (tag-of (car locals)) 'REF))
              (NULLp (car locals))
              (initialized-ref (value-of (car locals)) hp-init)
              (mem (value-of (car locals)) valid-obj-refs))
          (consistent-locals-obj-init (cdr locals) hp-init valid-obj-refs))))


;; (defun consistent-opstack-obj-init (stack hp-init valid-obj-refs)
;;   (declare (xargs :guard (and (wff-heap-init-map-strong hp-init)
;;                               (true-listp valid-obj-refs))))
;;   (if (not (consp stack)) t
;;     (cond ((canPopCategory1 stack)
;;            (and (or (not (equal (tag-of (topCategory1 stack)) 'REF))
;;                     ;; not a reference value! 
;;                     (NULLp (topCategory1 stack))
;;                     (initialized-ref (value-of (topCategory1 stack)) hp-init)
;;                     (mem (value-of (topCategory1 stack)) valid-obj-refs))
;;                 (consistent-opstack-obj-init (popCategory1 stack) hp-init 
;;                                             valid-obj-refs)))
;;           ((canPopCategory2 stack)
;;            (consistent-opstack-obj-init (popCategory2 stack) hp-init valid-obj-refs)))))

(defun consistent-opstack-obj-init (stack hp-init valid-obj-refs)
  (declare (xargs :guard (and (wff-heap-init-map-strong hp-init)
                              (true-listp valid-obj-refs))))
  (if (not (consp stack)) t
    (and (wff-tagged-value (car stack))
         (or (not (equal (tag-of (car stack)) 'REF))
             (NULLp (car stack))
             (initialized-ref (value-of (car stack)) hp-init)
             (mem (value-of (car stack)) valid-obj-refs))
         (consistent-opstack-obj-init (cdr stack) hp-init 
                                      valid-obj-refs))))

      
(defun isConstructorFrame (frame)
  (declare (xargs :guard (wff-call-frame frame)
                  :guard-hints (("Goal" :in-theory (enable wff-call-frame)))))
  (equal (method-ptr-methodname (method-ptr frame))
         "<init>"))
          
(defun consistent-frame-obj-init (frame hp-init)
  (declare (xargs :guard (and (wff-call-frame frame)
                              (wff-heap-init-map-strong hp-init))))
  (mylet* ((obj-refs  (collect-values (frame-obj-init-map frame)))
           (this      (acl2::g 'this (frame-aux frame)))
           (vars      (locals frame))
           (stack     (operand-stack frame)))
    (and (alistp (frame-obj-init-map frame))
       (nodup-set (collect-keys (frame-obj-init-map frame)))
       (cond ((isConstructorFrame frame)
               (and (consistent-locals-obj-init vars hp-init (cons this obj-refs))
                    (consistent-opstack-obj-init stack hp-init (cons this obj-refs))))
             (t (and (consistent-locals-obj-init vars hp-init obj-refs)
                     (consistent-opstack-obj-init stack hp-init obj-refs)))))))


          
(defun consistent-call-stack-obj-init (call-stack hp-init)
  (declare (xargs :guard (wff-heap-init-map-strong hp-init)))
  (if (not (consp call-stack)) t
    (and (wff-call-frame (car call-stack))
         (consistent-frame-obj-init (car call-stack) hp-init)
         (consistent-call-stack-obj-init (cdr call-stack) hp-init))))

          
(defun consistent-thread-entry-obj-init (thread-entry hp-init)
  (declare (xargs :guard (wff-heap-init-map-strong hp-init)))
  (and (wff-thread thread-entry)
       (consistent-call-stack-obj-init (thread-call-stack thread-entry)
                                       hp-init)))


(defun consistent-thread-table-obj-init (tt hp-init)
  (declare (xargs :guard (wff-heap-init-map-strong hp-init)))
  (if (not (consp tt)) t
    (and (consistent-thread-entry-obj-init (car tt) hp-init)
         (consistent-thread-table-obj-init (cdr tt) hp-init))))



(defun consistent-state-obj-init (s)
  (declare (xargs :guard (and (wff-state s)
                              (wff-heap-init-map-strong (heap-init-map (aux s))))))
  (consistent-thread-table-obj-init (thread-table s) (heap-init-map (aux s))))


(in-theory (disable consistent-state-obj-init
                    consistent-thread-table-obj-init
                    consistent-thread-entry-obj-init
                    consistent-call-stack-obj-init
                    consistent-frame-obj-init
                    consistent-opstack-obj-init
                    consistent-locals-obj-init))

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