src/HOL/MicroJava/BV/LBVCorrect.ML
author kleing
Tue, 15 Feb 2000 17:51:11 +0100
changeset 8245 6acc80f7f36f
child 8390 e5b618f6824e
permissions -rw-r--r--
lightweight bytecode verifier with correctness proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     1
(*  Title:      HOL/MicroJava/BV/BVLcorrect.ML
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     2
    ID:         $Id$
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     3
    Author:     Gerwin Klein
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     4
    Copyright   1999 Technische Universitaet Muenchen
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     5
*)
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     6
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     7
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     8
Goalw[fits_def,fits_partial_def] "fits_partial phi 0 is G rT s0 s2 cert = fits phi is G rT s0 s2 cert";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     9
by (Simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    10
qed "fits_eq_fits_partial";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    11
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    12
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    13
Goal "\\<exists> l. n = length l";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    14
by (induct_tac "n" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    15
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    16
by (res_inst_tac [("x","x#l")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    17
by (Simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    18
qed "exists_list";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    19
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    20
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    21
Goal "\\<forall> s0 pc. wtl_inst_list is G rT s0 s2 cert (pc+length is) pc \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    22
\     \\<longrightarrow> (\\<exists> phi. pc + length is = length phi \\<and> fits_partial phi pc is G rT s0 s2 cert)";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    23
by (induct_tac "is" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    24
 by (asm_full_simp_tac (simpset() addsimps [fits_partial_def, exists_list]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    25
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    26
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    27
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    28
by (eres_inst_tac [("x","ab")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    29
by (eres_inst_tac [("x","ba")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    30
by (eres_inst_tac [("x","Suc pc")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    31
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    32
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    33
by (exhaust_tac "cert ! pc" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    34
 by (res_inst_tac [("x","phi[pc:=(aa, b)]")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    35
 by (asm_full_simp_tac (simpset() addsimps [fits_partial_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    36
 by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    37
 by (exhaust_tac "ac" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    38
  by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    39
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    40
 by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    41
 by (eres_inst_tac [("x","lista")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    42
 by (eres_inst_tac [("x","bb")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    43
 by (eres_inst_tac [("x","i")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    44
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    45
 by (datac wtl_inst_option_unique 1 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    46
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    47
 by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    48
 be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    49
  by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    50
 ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    51
by (res_inst_tac [("x","phi[pc:=ac]")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    52
by (asm_full_simp_tac (simpset() addsimps [fits_partial_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    53
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    54
by (exhaust_tac "ad" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    55
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    56
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    57
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    58
by (eres_inst_tac [("x","lista")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    59
by (eres_inst_tac [("x","bc")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    60
by (eres_inst_tac [("x","i")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    61
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    62
by (datac wtl_inst_option_unique 1 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    63
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    64
by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    65
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    66
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    67
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    68
bind_thm ("exists_phi_partial", result() RS spec RS spec);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    69
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    70
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    71
Goal "wtl_inst_list is G rT s0 s2 cert (length is) 0 \\<Longrightarrow> \\<exists> phi. fits phi is G rT s0 s2 cert";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    72
by (cut_inst_tac [("is","is"),("G","G"),("rT","rT"),("s2.0","s2"),("x","0"),("xa","s0"),("cert","cert")] exists_phi_partial 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    73
by (asm_full_simp_tac (simpset() addsimps [fits_eq_fits_partial]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    74
by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    75
qed "exists_phi";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    76
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    77
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    78
Goal "\\<lbrakk>wtl_inst_list is G rT s0 s3 cert (length is) 0; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    79
\fits phi is G rT s0 s3 cert\\<rbrakk> \\<Longrightarrow> \ 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    80
\ \\<forall> pc t. pc < length is \\<longrightarrow> (cert ! pc) = Some t \\<longrightarrow> (phi ! pc) = t";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    81
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    82
by (forward_tac [wtl_partial] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    83
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    84
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    85
by (asm_full_simp_tac (simpset() addsimps [fits_def,neq_Nil_conv]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    86
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    87
by (eres_inst_tac [("x","aa")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    88
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    89
by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    90
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    91
qed "fits_lemma1";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    92
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    93
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    94
Goal "\\<lbrakk>wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    95
\     wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a); \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    96
\     wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a)); \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    97
\     fits phi (a@i#b) G rT s0 s3 cert \\<rbrakk> \\<Longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    98
\ b \\<noteq> [] \\<longrightarrow> G \\<turnstile> s2 <=s (phi ! (Suc (length a)))";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    99
by (forward_tac [wtl_append] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   100
  ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   101
 ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   102
by (exhaust_tac "b=[]" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   103
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   104
by (asm_full_simp_tac (simpset() addsimps [neq_Nil_conv]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   105
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   106
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   107
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   108
by (exhaust_tac "cert!(Suc (length a))" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   109
 by (asm_full_simp_tac (simpset() addsimps [fits_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   110
 by (eres_inst_tac [("x","a@[i]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   111
 by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   112
 by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   113
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   114
 by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   115
 by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   116
 be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   117
  by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   118
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   119
by (asm_full_simp_tac (simpset() addsimps [fits_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   120
by (eres_inst_tac [("x","a@[i]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   121
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   122
by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   123
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   124
by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   125
by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   126
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   127
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   128
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   129
by (asm_full_simp_tac (simpset() addsimps [wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   130
qed "wtl_suc_pc";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   131
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   132
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   133
Goalw[fits_def] "\\<lbrakk>wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   134
\      wtl_inst_option i G rT s1 s2 cert (length (a@i#b)) (length a); \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   135
\      fits phi (a@i#b) G rT s0 s3 cert; cert!(length a) = None; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   136
\      wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))\\<rbrakk> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   137
\    \\<Longrightarrow>  phi!(length a) = s1";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   138
by (eres_inst_tac [("x","a")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   139
by (eres_inst_tac [("x","b")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   140
by (eres_inst_tac [("x","i")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   141
by (eres_inst_tac [("x","s1")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   142
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   143
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   144
 by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   145
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   146
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   147
qed "fits_lemma2";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   148
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   149
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   150
fun ls g1 g2 = if g1 > g2 then ls g2 g1
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   151
               else if g1 = g2 then [g1]
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   152
               else g2::(ls g1 (g2-1))
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   153
fun GOALS t g1 g2 = EVERY (map t (ls g1 g2));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   154
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   155
Goal "is=(i1@i#i2) \\<longrightarrow> wtl_inst_list (i1@i#i2) G rT s0 s3 cert (length is) 0 \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   156
\     wtl_inst_list i1 G rT s0 s1 cert (length is) 0 \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   157
\     wtl_inst_option i G rT s1 s2 cert (length is) (length i1) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   158
\     wtl_inst_list i2 G rT s2 s3 cert (length is) (Suc (length i1)) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   159
\     fits phi (i1@i#i2) G rT s0 s3 cert \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   160
\       wt_instr i G rT phi (length is) (length i1)";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   161
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   162
by (forward_tac [wtl_suc_pc] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   163
by (TRYALL atac);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   164
by (forward_tac [fits_lemma1] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   165
 ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   166
by (exhaust_tac "cert!(length i1)" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   167
 by (forward_tac [fits_lemma2] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   168
     by (TRYALL atac);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   169
 by (exhaust_tac "i" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   170
        by (exhaust_tac "check_object" 4);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   171
        by (exhaust_tac "manipulate_object" 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   172
         by (exhaust_tac "create_object" 2);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   173
         by (exhaust_tac "load_and_store" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   174
            by (GOALS (force_tac (claset(), 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   175
                simpset() addsimps [wt_instr_def,wtl_inst_option_def])) 1 8);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   176
    by (exhaust_tac "meth_inv" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   177
    by (thin_tac "\\<forall>pc t.\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   178
\                 pc < length (i1 @ i # i2) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   179
\                 cert ! pc = Some t \\<longrightarrow> phi ! pc = t" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   180
    by (force_tac (claset(), simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   181
   by (exhaust_tac "meth_ret" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   182
   by (asm_full_simp_tac (simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   183
  by (exhaust_tac "branch" 2);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   184
   by (exhaust_tac "op_stack" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   185
       by (GOALS (asm_full_simp_tac (simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   186
                  THEN_MAYBE' Force_tac) 1 7);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   187
by (forw_inst_tac [("x","length i1")] spec 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   188
by (eres_inst_tac [("x","a")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   189
by (exhaust_tac "i" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   190
       by (exhaust_tac "check_object" 4);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   191
       by (exhaust_tac "manipulate_object" 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   192
        by (exhaust_tac "create_object" 2);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   193
        by (exhaust_tac "load_and_store" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   194
           by (GOALS (asm_full_simp_tac (simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   195
                      THEN' Force_tac) 1 8);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   196
   by (exhaust_tac "meth_inv" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   197
   by (thin_tac "\\<forall>pc t.\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   198
\                pc < length (i1 @ i # i2) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   199
\                cert ! pc = Some t \\<longrightarrow> phi ! pc = t" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   200
   by (force_tac (claset(), simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   201
  by (exhaust_tac "branch" 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   202
   by (exhaust_tac "op_stack" 2);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   203
       by (exhaust_tac "meth_ret" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   204
       by (GOALS (asm_full_simp_tac (simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   205
                  THEN_MAYBE' Force_tac) 1 8);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   206
qed "wtl_lemma";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   207
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   208
Goal "\\<lbrakk>wtl_inst_list is G rT s0 s2 cert (length is) 0; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   209
\     fits phi is G rT s0 s2 cert\\<rbrakk> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   210
\ \\<Longrightarrow> \\<forall>pc. pc < length is \\<longrightarrow> wt_instr (is ! pc) G rT phi (length is) pc";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   211
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   212
by (forward_tac [wtl_partial] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   213
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   214
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   215
by (asm_full_simp_tac (simpset() addsimps [neq_Nil_conv]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   216
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   217
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   218
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   219
by (cut_inst_tac [("is","a@y#ys"),("i1.0","a"),("i2.0","ys"),("i","y"),("G","G"),("rT","rT"),("s0.0","s0"),("cert","cert"),("phi","phi"),("s1.0","(aa,ba)"),("s2.0","(ab,b)"),("s3.0","s2")] wtl_lemma 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   220
by (asm_full_simp_tac (simpset() addsimps [nth_append]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   221
qed "wtl_fits_wt";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   222
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   223
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   224
Goal "wtl_inst_list is G rT s0 s2 cert (length is) 0 \\<Longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   225
\     \\<exists> phi. \\<forall>pc. pc < length is \\<longrightarrow> wt_instr (is ! pc) G rT phi (length is) pc";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   226
by (forward_tac [exists_phi] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   227
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   228
by (forward_tac [wtl_fits_wt] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   229
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   230
by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   231
qed "wtl_inst_list_correct";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   232
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   233
Goalw[fits_def] "\\<lbrakk>is \\<noteq> []; wtl_inst_list is G rT s0 s2 cert (length is) 0; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   234
\                 fits phi is G rT s0 s2 cert\\<rbrakk> \\<Longrightarrow> G \\<turnstile> s0 <=s phi ! 0";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   235
by (forw_inst_tac [("pc'","0")] wtl_partial 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   236
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   237
by (asm_full_simp_tac (simpset() addsimps [neq_Nil_conv]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   238
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   239
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   240
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   241
by (eres_inst_tac [("x","[]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   242
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   243
by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   244
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   245
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   246
by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   247
by (exhaust_tac "cert ! 0" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   248
by (auto_tac (claset(), simpset() addsimps [wtl_inst_option_def]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   249
qed "fits_first";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   250
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   251
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   252
Goal "wtl_method G C pTs rT mxl ins cert \\<Longrightarrow> \\<exists> phi. wt_method G C pTs rT mxl ins phi";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   253
by (asm_full_simp_tac (simpset() addsimps [wtl_method_def, wt_method_def, wt_start_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   254
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   255
by (forward_tac [exists_phi] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   256
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   257
by (forward_tac [wtl_fits_wt] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   258
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   259
by (res_inst_tac [("x","phi")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   260
by (auto_tac (claset(), simpset() addsimps [fits_first]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   261
qed "wtl_method_correct";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   262
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   263
Goal "(a,b,c,d)\\<in>set l \\<longrightarrow> unique l \\<longrightarrow> (a',b',c',d') \\<in> set l \\<longrightarrow> a = a' \\<longrightarrow> b=b' \\<and> c=c' \\<and> d=d'";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   264
by (induct_tac "l" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   265
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   266
qed_spec_mp "unique_set";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   267
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   268
Goal "(a,b,c,d)\\<in>set l \\<longrightarrow> unique l \\<longrightarrow> (\\<epsilon> (a',b',c',d'). (a',b',c',d') \\<in> set l \\<and> a'=a) = (a,b,c,d)";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   269
by (auto_tac (claset(), simpset() addsimps [unique_set]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   270
qed_spec_mp "unique_epsilon";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   271
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   272
Goalw[wtl_jvm_prog_def,wt_jvm_prog_def] "wtl_jvm_prog G cert ==> \\<exists> Phi. wt_jvm_prog G Phi";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   273
by (asm_full_simp_tac (simpset() addsimps [wf_prog_def, wf_cdecl_def, wf_mdecl_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   274
by (res_inst_tac [("x",
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   275
  "\\<lambda> C sig.\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   276
\    let (C,x,y,mdecls) = \\<epsilon> (Cl,x,y,mdecls). (Cl,x,y,mdecls) \\<in> set G \\<and> Cl = C in\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   277
\      let (sig,rT,maxl,b) = \\<epsilon> (sg,rT,maxl,b). (sg,rT,maxl,b) \\<in> set mdecls \\<and> sg = sig in\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   278
\        \\<epsilon> phi. wt_method G C (snd sig) rT maxl b phi")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   279
by Safe_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   280
by (GOALS Force_tac 1 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   281
by (GOALS Force_tac 2 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   282
by (eres_inst_tac [("x","(a, aa, ab, b)")] BallE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   283
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   284
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   285
by (eres_inst_tac [("x","((ac, ba), ad, ae, bb)")] BallE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   286
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   287
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   288
bd wtl_method_correct 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   289
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   290
by (asm_full_simp_tac (simpset() addsimps [unique_epsilon]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   291
br selectI 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   292
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   293
qed "wtl_correct";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   294