src/HOL/MicroJava/BV/LBVSpec.ML
author wenzelm
Tue, 30 May 2000 16:08:38 +0200
changeset 9000 c20d58286a51
parent 8442 96023903c2df
permissions -rw-r--r--
cleaned up;
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/BVLightSpec.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
Goal "\\<lbrakk>length a = n; length x = n; rev a @ b # c = rev x @ y # z\\<rbrakk> \\<Longrightarrow> a = x \\<and> b = y \\<and> c = z";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     8
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
     9
qed "rev_eq";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    10
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    11
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    12
Goal "\\<lbrakk>wtl_inst i G rT s0 s1 cert max_pc pc; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    13
\      wtl_inst i G rT s0 s1' cert max_pc pc\\<rbrakk> \\<Longrightarrow> s1 = s1'";
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    14
by (case_tac "i" 1);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    15
by (case_tac "branch" 8);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    16
by (case_tac "op_stack" 7);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    17
by (case_tac "meth_ret" 6);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    18
by (case_tac "meth_inv" 5);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    19
by (case_tac "check_object" 4);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    20
by (case_tac "manipulate_object" 3);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    21
by (case_tac "create_object" 2);
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    22
by (case_tac "load_and_store" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    23
by Auto_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    24
by (ALLGOALS (dtac rev_eq));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    25
by (TRYALL atac);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    26
by (ALLGOALS Asm_full_simp_tac);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    27
qed "wtl_inst_unique";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    28
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    29
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    30
Goal "\\<lbrakk>wtl_inst_option i G rT s0 s1 cert max_pc pc; \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    31
\      wtl_inst_option i G rT s0 s1' cert max_pc pc\\<rbrakk> \\<Longrightarrow> s1 = s1'";
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    32
by (case_tac "cert!pc" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    33
by (auto_tac (claset(), simpset() addsimps [wtl_inst_unique, wtl_inst_option_def]));
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    34
qed "wtl_inst_option_unique";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    35
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    36
Goal "\\<forall> s0 pc. wtl_inst_list is G rT s0 s1 cert max_pc pc \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    37
\              wtl_inst_list is G rT s0 s1' cert max_pc pc \\<longrightarrow> s1=s1'";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    38
by (induct_tac "is" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    39
 by Auto_tac;
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
qed "wtl_inst_list_unique";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    43
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    44
Goal "\\<forall> pc' pc s. \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    45
\       wtl_inst_list is G rT s s' cert mpc pc \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    46
\       pc' < length is \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    47
\       (\\<exists> a b s1. a @ b = is \\<and> length a = pc' \\<and> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    48
\                  wtl_inst_list a G rT s  s1 cert mpc pc \\<and> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    49
\                  wtl_inst_list b G rT s1 s' cert mpc (pc+length a))";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    50
by(induct_tac "is" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    51
 by Auto_tac;
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    52
by (case_tac "pc'" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    53
 by (dres_inst_tac [("x","pc'")] spec 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    54
 by (smp_tac 3 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    55
 by (res_inst_tac [("x","[]")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    56
 by (Asm_full_simp_tac 1);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    57
 by (case_tac "cert!pc" 1);
8245
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    58
  by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    59
 by (force_tac (claset(), simpset() addsimps [wtl_inst_option_def]) 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    60
by (dres_inst_tac [("x","nat")] spec 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    61
by (smp_tac 3 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    62
by Safe_tac;
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    63
 by (res_inst_tac [("x","a#list")] exI 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    64
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    65
by (res_inst_tac [("x","a#ac")] exI 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
qed_spec_mp "wtl_partial";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    68
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    69
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    70
Goal "\\<forall> s0 pc. wtl_inst_list a G rT s0 s1 cert (pc+length (a@i#b)) pc \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    71
\       wtl_inst_option i G rT s1 s2 cert (pc+length (a@i#b)) (pc + length a) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    72
\       wtl_inst_list b G rT s2 s3 cert (pc+length (a@i#b)) (Suc (pc + length a)) \\<longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    73
\         wtl_inst_list (a@[i]) G rT s0 s2 cert (pc+length (a@i#b)) pc";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    74
by (induct_tac "a" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    75
 by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    76
 by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    77
 by (pair_tac "s2" 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    78
 by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    79
by (Clarify_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    80
by (Asm_full_simp_tac 1);
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","ab")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    83
by (eres_inst_tac [("x","baa")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    84
by (eres_inst_tac [("x","Suc pc")] allE 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    85
by (Force_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    86
bind_thm ("wtl_append_lemma", result() RS spec RS spec);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    87
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    88
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
    89
\      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
    90
\      wtl_inst_list b G rT s2 s3 cert (length (a@i#b)) (Suc (length a))\\<rbrakk> \\<Longrightarrow> \
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    91
\      wtl_inst_list (a@[i]) G rT s0 s2 cert (length (a@i#b)) 0";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    92
by (cut_inst_tac [("a","a"),("G","G"),("rT","rT"),("xa","s0"),("s1.0","s1"),("cert","cert"),("x","0"),("i","i"),("b","b"),("s2.0","s2"),("s3.0","s3")] wtl_append_lemma 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    93
by (Asm_full_simp_tac 1);
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    94
qed "wtl_append";
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    95
6acc80f7f36f lightweight bytecode verifier with correctness proof
kleing
parents:
diff changeset
    96