File: jvm-loader-inv.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 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,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (101 lines) | stat: -rw-r--r-- 4,265 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
;; this file comes necessary definitions to introduce the class loading
;; invariant. Which will be introduced in the guard of
;; build-a-java-visible-instance, and load_class2

(in-package "JVM")
(include-book "../M6-DJVM-shared/jvm-loader-primitives")
(include-book "../M6-DJVM-shared/jvm-loader-constant-pool-primitives")

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

(defun class-is-loaded? (classname class-table)
  (declare (xargs :guard (wff-instance-class-table class-table)))
  (isClassTerm (class-by-name classname class-table)))

;; now class-is-loaded-from only check that classname, superclass, interfaces
;; because we only care about the loader's property that if a class is loaded,
;; its super classes are also loaded.
;;
(defun class-is-loaded-from (class-rep class-rep-static)
  (declare (xargs :guard (and (wff-class-rep class-rep)
                              (wff-class-rep-static class-rep-static))))
  (and (equal (classname  class-rep) (classname-s  class-rep-static))
       (equal (super      class-rep) (super-s      class-rep-static))
       (equal (interfaces class-rep) (interfaces-s class-rep-static))))
       

               ;(wff-class-rep (class-by-name classname class-table))
               ;(wff-class-rep (class-by-name classname class-table))

(defthm loaded-from-wff-implies-wff
  (implies (and (class-is-loaded? classname cl)
                (wff-instance-class-table-strong cl))
           (wff-class-rep (class-by-name classname cl))))


(defthm loaded-from-wff-implies-wff-static
  (implies (and (mv-nth 0 (class-by-name-s classname env-cl))
                (wff-static-class-table-strong env-cl))
           (wff-class-rep-static (mv-nth 1 (class-by-name-s classname env-cl)))))
           

(defun correctly-loaded? (classname class-table env-class-table)
  (declare (xargs :guard (and (wff-instance-class-table-strong class-table)
                              (wff-static-class-table-strong env-class-table))
                  :guard-hints (("Goal" :in-theory (disable wff-class-rep 
                                                            wff-class-rep-static)))))
  (mv-let (found class-rep-static)
          (class-by-name-s classname env-class-table)
          (and found ;; should we move this into the guard??. We can. 
               (class-is-loaded? classname class-table)
               (class-is-loaded-from 
                                 (class-by-name classname class-table) 
                                 class-rep-static))))


(defun all-correctly-loaded? (supers class-table env-class-table)
  (declare (xargs :guard (and (wff-instance-class-table-strong class-table)
                              (wff-static-class-table-strong env-class-table))))
  (if (not (consp supers))
      t
    (and (correctly-loaded? (car supers) class-table env-class-table)
         (all-correctly-loaded? (cdr supers) class-table env-class-table))))



(defun loader-inv-helper1 (class-rep class-table env-class-table)
  (declare (xargs :guard (and (wff-class-rep class-rep)
                              (wff-instance-class-table-strong class-table)
                              (wff-static-class-table-strong env-class-table))))
  (let* ((classname (classname class-rep))
         (supers    (collect-assignableToName classname env-class-table)))
    (all-correctly-loaded? supers class-table env-class-table))) 


(defun loader-inv-helper (classes class-table env-class-table)
  (declare (xargs :guard (and (wff-instance-class-table-strong classes)
                              (wff-instance-class-table-strong class-table)
                              (wff-static-class-table-strong env-class-table))))
  (if (not (consp classes))
      t
    (and (loader-inv-helper1 (car classes) class-table env-class-table)
         (loader-inv-helper (cdr classes) class-table env-class-table))))


(defun loader-inv (s)
 (and (wff-state s)
      (wff-class-table (class-table s))
      (wff-env (env s))
      (wff-instance-class-table-strong (instance-class-table s))
      (wff-static-class-table-strong (external-class-table s))
      (or (not (no-fatal-error? s))
          (loader-inv-helper (instance-class-table s) (instance-class-table s)
                             (env-class-table (env s))))))