src/HOL/MicroJava/BV/LBVCorrect.ML
author nipkow
Mon, 13 Mar 2000 12:51:10 +0100
changeset 8423 3c19160b6432
parent 8390 e5b618f6824e
child 8442 96023903c2df
permissions -rw-r--r--
exhaust_tac -> cases_tac
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
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
     8
Goal "\\<exists> l. n < length l";
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     9
by (induct_tac "n" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    10
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    11
by (res_inst_tac [("x","x#l")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    12
by (Simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    13
qed "exists_list";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    14
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    15
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    16
Goal "\\<forall> s0 pc. wtl_inst_list is G rT s0 s2 cert (pc+length is) pc \
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    17
\     \\<longrightarrow> (\\<exists> phi. pc + length is < length phi \\<and> fits_partial phi pc is G rT s0 s2 cert)";
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    18
by (induct_tac "is" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    19
 by (asm_full_simp_tac (simpset() addsimps [fits_partial_def, exists_list]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    20
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    21
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    22
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    23
by (eres_inst_tac [("x","ab")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    24
by (eres_inst_tac [("x","ba")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    25
by (eres_inst_tac [("x","Suc pc")] allE 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);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
    28
by (cases_tac "cert ! pc" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    29
 by (res_inst_tac [("x","phi[pc:=(aa, b)]")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    30
 by (asm_full_simp_tac (simpset() addsimps [fits_partial_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    31
 by (Clarify_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
    32
 by (cases_tac "ac" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    33
  by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    34
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    35
 by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    36
 by (eres_inst_tac [("x","lista")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    37
 by (eres_inst_tac [("x","bb")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    38
 by (eres_inst_tac [("x","i")] allE 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 (datac wtl_inst_option_unique 1 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    41
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    42
 by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    43
 be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    44
  by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    45
 ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    46
by (res_inst_tac [("x","phi[pc:=ac]")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    47
by (asm_full_simp_tac (simpset() addsimps [fits_partial_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    48
by (Clarify_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
    49
by (cases_tac "ad" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    50
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    51
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    52
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    53
by (eres_inst_tac [("x","lista")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    54
by (eres_inst_tac [("x","bc")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    55
by (eres_inst_tac [("x","i")] allE 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 (datac wtl_inst_option_unique 1 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    58
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    59
by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    60
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    61
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    62
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    63
bind_thm ("exists_phi_partial", result() RS spec RS spec);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    64
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    65
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    66
Goal "wtl_inst_list is G rT s0 s2 cert (length is) 0 \\<Longrightarrow> \\<exists> phi. fits phi is G rT s0 s2 cert \\<and> length is < length phi";
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    67
by (cut_inst_tac [("is","is"),("G","G"),("rT","rT"),("s2.0","s2"),("x","0"),("xa","s0"),("cert","cert")] exists_phi_partial 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    68
by (asm_full_simp_tac (simpset() addsimps [fits_def]) 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    69
by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    70
qed "exists_phi";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    71
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    72
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    73
Goal "\\<lbrakk>wtl_inst_list is G rT s0 s3 cert (length is) 0; \
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    74
\      fits phi is G rT s0 s3 cert\\<rbrakk> \\<Longrightarrow> \ 
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    75
\     \\<forall> pc t. pc < length is \\<longrightarrow> (cert ! pc) = Some t \\<longrightarrow> (phi ! pc) = t";
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    76
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    77
by (forward_tac [wtl_partial] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    78
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    79
by (Clarify_tac 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
    80
by (asm_full_simp_tac (simpset() addsimps [fits_def, fits_partial_def ,neq_Nil_conv]) 1);
8245
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 (eres_inst_tac [("x","aa")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    83
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    84
by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    85
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    86
qed "fits_lemma1";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    87
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    88
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    89
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
    90
\     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
    91
\     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
    92
\     fits phi (a@i#b) G rT s0 s3 cert \\<rbrakk> \\<Longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    93
\ b \\<noteq> [] \\<longrightarrow> G \\<turnstile> s2 <=s (phi ! (Suc (length a)))";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    94
by (forward_tac [wtl_append] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    95
  ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    96
 ba 1;
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
    97
by (case_tac "b=[]" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    98
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    99
by (asm_full_simp_tac (simpset() addsimps [neq_Nil_conv]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   100
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   101
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   102
by (Clarify_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   103
by (cases_tac "cert!(Suc (length a))" 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   104
 by (asm_full_simp_tac (simpset() addsimps [fits_def, fits_partial_def]) 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   105
 by (eres_inst_tac [("x","a@[i]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   106
 by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   107
 by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   108
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   109
 by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   110
 by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   111
 be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   112
  by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   113
 by (Asm_full_simp_tac 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   114
by (asm_full_simp_tac (simpset() addsimps [fits_def, fits_partial_def]) 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   115
by (eres_inst_tac [("x","a@[i]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   116
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   117
by (eres_inst_tac [("x","y")] allE 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 (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   120
by (smp_tac 2 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   121
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   122
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   123
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   124
by (asm_full_simp_tac (simpset() addsimps [wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   125
qed "wtl_suc_pc";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   126
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   127
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   128
Goal "\\<lbrakk>wtl_inst_list a G rT s0 s1 cert (length (a@i#b)) 0; \
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   129
\      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
   130
\      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
   131
\      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
   132
\    \\<Longrightarrow>  phi!(length a) = s1";
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   133
by (asm_full_simp_tac (simpset() addsimps [fits_def, fits_partial_def]) 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   134
by (eres_inst_tac [("x","a")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   135
by (eres_inst_tac [("x","b")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   136
by (eres_inst_tac [("x","i")] allE 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   137
by (Asm_full_simp_tac 1);
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   138
by (pair_tac "s1" 1);
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   139
by (eres_inst_tac [("x","x")] allE 1);
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   140
by (eres_inst_tac [("x","y")] allE 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   141
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   142
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   143
 by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   144
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   145
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   146
qed "fits_lemma2";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   147
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   148
fun ls g1 g2 = if g1 > g2 then ls g2 g1
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   149
               else if g1 = g2 then [g1]
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   150
               else g2::(ls g1 (g2-1))
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   151
fun GOALS t g1 g2 = EVERY (map t (ls g1 g2));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   152
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   153
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
   154
\     wtl_inst_list i1 G rT s0 s1 cert (length is) 0 \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   155
\     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
   156
\     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
   157
\     fits phi (i1@i#i2) G rT s0 s3 cert \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   158
\       wt_instr i G rT phi (length is) (length i1)";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   159
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   160
by (forward_tac [wtl_suc_pc] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   161
by (TRYALL atac);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   162
by (forward_tac [fits_lemma1] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   163
 ba 1;
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   164
by (cases_tac "cert!(length i1)" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   165
 by (forward_tac [fits_lemma2] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   166
     by (TRYALL atac);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   167
 by (cases_tac "i" 1);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   168
        by (cases_tac "check_object" 4);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   169
        by (cases_tac "manipulate_object" 3);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   170
         by (cases_tac "create_object" 2);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   171
         by (cases_tac "load_and_store" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   172
            by (GOALS (force_tac (claset(), 
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   173
                simpset() addsimps [wt_instr_def,wtl_inst_option_def])) 1 8);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   174
    by (cases_tac "meth_inv" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   175
    by (thin_tac "\\<forall>pc t.\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   176
\                 pc < length (i1 @ i # i2) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   177
\                 cert ! pc = Some t \\<longrightarrow> phi ! pc = t" 1);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   178
    by (pair_tac "s1" 1);
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   179
    by (asm_full_simp_tac (simpset() addsimps [wt_instr_def,wtl_inst_option_def]) 1);    
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   180
    by (Force_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   181
   by (cases_tac "meth_ret" 1);
8245
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);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   183
  by (cases_tac "branch" 2);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   184
   by (cases_tac "op_stack" 1);
8245
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);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   189
by (cases_tac "i" 1);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   190
       by (cases_tac "check_object" 4);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   191
       by (cases_tac "manipulate_object" 3);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   192
        by (cases_tac "create_object" 2);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   193
        by (cases_tac "load_and_store" 1);
8245
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);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   196
   by (cases_tac "meth_inv" 1);
8245
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);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   201
  by (cases_tac "branch" 3);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   202
   by (cases_tac "op_stack" 2);
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   203
       by (cases_tac "meth_ret" 1);
8245
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
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   233
Goal "\\<lbrakk>is \\<noteq> []; wtl_inst_list is G rT s0 s2 cert (length is) 0; \
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   234
\     fits phi is G rT s0 s2 cert\\<rbrakk> \\<Longrightarrow> G \\<turnstile> s0 <=s phi ! 0";
8245
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);
8390
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   237
by (asm_full_simp_tac (simpset() addsimps [fits_def, fits_partial_def, neq_Nil_conv]) 1);
e5b618f6824e tuned for completeness of LBV
kleing
parents: 8245
diff changeset
   238
by (Clarsimp_tac 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   239
by (eres_inst_tac [("x","[]")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   240
by (eres_inst_tac [("x","ys")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   241
by (eres_inst_tac [("x","y")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   242
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   243
be impE 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   244
by (Force_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8390
diff changeset
   245
by (cases_tac "cert ! 0" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   246
by (auto_tac (claset(), simpset() addsimps [wtl_inst_option_def]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   247
qed "fits_first";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   248
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   249
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   250
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
   251
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
   252
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   253
by (forward_tac [exists_phi] 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 [wtl_fits_wt] 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   256
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   257
by (res_inst_tac [("x","phi")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   258
by (auto_tac (claset(), simpset() addsimps [fits_first]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   259
qed "wtl_method_correct";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   260
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   261
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
   262
by (induct_tac "l" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   263
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   264
qed_spec_mp "unique_set";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   265
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   266
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
   267
by (auto_tac (claset(), simpset() addsimps [unique_set]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   268
qed_spec_mp "unique_epsilon";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   269
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   270
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
   271
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
   272
by (res_inst_tac [("x",
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   273
  "\\<lambda> C sig.\
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   274
\    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
   275
\      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
   276
\        \\<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
   277
by Safe_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   278
by (GOALS Force_tac 1 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   279
by (GOALS Force_tac 2 3);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   280
by (eres_inst_tac [("x","(a, aa, ab, b)")] BallE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   281
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   282
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   283
by (eres_inst_tac [("x","((ac, ba), ad, ae, bb)")] BallE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   284
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   285
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   286
bd wtl_method_correct 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
by (asm_full_simp_tac (simpset() addsimps [unique_epsilon]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   289
br selectI 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   290
ba 1;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   291
qed "wtl_correct";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
   292