src/HOL/BCV/Machine.ML
author wenzelm
Mon, 03 Apr 2000 14:02:40 +0200
changeset 8662 f9679ddbc492
parent 8442 96023903c2df
permissions -rw-r--r--
isapar, isamarkuptext, isamarkuptxt turned into environments;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     1
(*  Title:      HOL/BCV/Machine.ML
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     2
    ID:         $Id$
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     3
    Author:     Tobias Nipkow
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     4
    Copyright   1999 TUM
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     5
*)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     6
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     7
Addsimps [Let_def];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     8
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     9
Addsimps [stype_def];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    10
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    11
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    12
(*** Machine specific ***)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    13
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    14
Goal "!p. p<size(bs) --> maxreg(bs!p) < maxregs(bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    15
by (induct_tac "bs" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    16
by (auto_tac (claset(), simpset() addsimps [nth_Cons,less_max_iff_disj]
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    17
                                 addsplits [nat.split]));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    18
qed_spec_mp "maxreg_less_maxregs";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    19
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    20
Goalw [le_typ] "(t <= Ctyp) = (t = Ctyp)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    21
by (Simp_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    22
qed "le_Ctyp_conv";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    23
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    24
Goalw [le_typ] "(t ~= Top) = (t = Atyp | t = Btyp | t = Ctyp)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    25
by (induct_tac "t" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    26
by (ALLGOALS Simp_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    27
qed "le_Top_conv";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    28
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    29
Goalw [step_pres_type_def,listsn_def,exec_def,stype_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    30
 "step_pres_type (%p. exec (bs!p)) (length bs) (stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    31
by (force_tac (claset(), simpset() addsplits [instr.split_asm,split_if_asm]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    32
qed "exec_pres_type";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    33
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    34
Goalw [wti_is_fix_step_def,stable_def,wt_instr_def,exec_def,succs_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    35
 "wti_is_fix_step (%p. exec (bs!p)) (%u. wt_instr (bs ! u) u) \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    36
\     (%p. succs (bs ! p) p) (length bs) (stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    37
by (force_tac (claset() addDs [maxreg_less_maxregs,
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    38
                              le_Top_conv RS iffD1,le_Ctyp_conv RS iffD1],
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    39
              simpset() addsplits [option.split,instr.split]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    40
qed "wt_instr_is_fix_exec";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    41
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    42
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    43
Goalw [step_mono_None_def,exec_def,succs_def,le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    44
 "step_mono_None (%p. exec (bs!p)) (length bs) (stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    45
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    46
by (ftac maxreg_less_maxregs 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    47
by (split_asm_tac [instr.split_asm] 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    48
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    49
by (ALLGOALS (asm_full_simp_tac (simpset() addsplits [split_if_asm])));
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    50
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    51
by (rotate_tac 1 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    52
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    53
by (blast_tac (claset() addIs [order_trans]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    54
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    55
by (rotate_tac 1 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    56
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    57
by (blast_tac (claset() addIs [order_trans]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    58
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    59
by (rotate_tac 1 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    60
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    61
by (blast_tac (claset() addIs [order_trans]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    62
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    63
by (rotate_tac 1 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    64
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    65
by (subgoal_tac "s!nat1 <= t!nat1" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    66
by (Blast_tac 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    67
by (subgoal_tac "s!nat2 <= t!nat2" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    68
by (Blast_tac 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    69
by (etac thin_rl 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    70
by (asm_full_simp_tac (simpset() addsimps [le_typ])1);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    71
by (case_tac "t!nat1" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    72
by (ALLGOALS Asm_full_simp_tac);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    73
by (case_tac "t!nat2" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    74
by (ALLGOALS Asm_full_simp_tac);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    75
by (case_tac "t!nat2" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    76
by (ALLGOALS Asm_full_simp_tac);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    77
by (case_tac "s!nat1" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    78
by (ALLGOALS Asm_full_simp_tac);
8442
96023903c2df case_tac now subsumes both boolean and datatype cases;
wenzelm
parents: 8423
diff changeset
    79
by (case_tac "t!nat2" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    80
by (ALLGOALS Asm_full_simp_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    81
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    82
qed "exec_mono_None";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    83
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    84
Goalw [step_mono_def,exec_def,succs_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    85
 "step_mono (%p. exec (bs!p)) (length bs) (stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    86
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    87
by (ftac maxreg_less_maxregs 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    88
by (split_asm_tac [instr.split_asm] 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    89
by (ALLGOALS
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    90
   (fast_tac (claset() addIs [list_update_le_cong,le_listD]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    91
               addss (simpset() addsplits [split_if_asm]))));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    92
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    93
qed_spec_mp "exec_mono_Some";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    94
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    95
Goalw [stype_def] "semilat(stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    96
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    97
qed "lat_stype";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    98
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    99
Goalw [stype_def] "acc(stype bs)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   100
by (Simp_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   101
qed "acc_stype";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   102
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   103
Delsimps [stype_def];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   104
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   105
Goal
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   106
 "[| is_next next; \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   107
\    succs_bounded (%p. succs (bs!p) p) (size bs); \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   108
\    sos : listsn (size bs) (option(stype bs)) |] ==> \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   109
\ fix(next (%p. exec (bs!p)) (%p. succs (bs!p) p), sos) = \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   110
\ (? tos : listsn (size bs) (option(stype bs)). \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   111
\      sos <= tos & welltyping (%p. wt_instr (bs!p) p) tos)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   112
by (simp_tac (simpset() delsimps [not_None_eq]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   113
by (REPEAT(ares_tac [fix_next_iff_welltyping,exec_pres_type,
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   114
                    exec_mono_None,exec_mono_Some,
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   115
                    wt_instr_is_fix_exec,lat_stype,acc_stype] 1));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   116
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   117
qed "fix_iff_welltyped";