src/HOL/BCV/Orders.ML
author nipkow
Mon, 13 Mar 2000 12:51:10 +0100
changeset 8423 3c19160b6432
parent 8288 ebf874fcbff2
child 8442 96023903c2df
permissions -rw-r--r--
exhaust_tac -> cases_tac
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/Orders.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
Delrules[le_maxI1, le_maxI2];
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
(** option **)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    10
section "option";
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
Goalw [option_def] "None : option A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    13
by (Simp_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    14
qed "None_in_option";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    15
AddIffs [None_in_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    16
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    17
Goalw [option_def] "(Some x : option A) = (x:A)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    18
by (Auto_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    19
qed "Some_in_option";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    20
AddIffs [Some_in_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    21
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    22
Goalw [less_option,le_option]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    23
 "Some x < opt = (? y. opt = Some y & x < (y::'a::order))";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    24
by (simp_tac (simpset() addsimps [order_less_le] addsplits [option.split]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    25
qed_spec_mp "Some_less_conv";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    26
AddIffs [Some_less_conv];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    27
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    28
Goalw [less_option,le_option] "None < x = (? a. x = Some a)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    29
by (asm_simp_tac (simpset() addsplits [option.split]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    30
qed_spec_mp "None_less_iff";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    31
AddIffs [None_less_iff];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    32
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 [acc_def] "acc A ==> acc(option A)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    35
by (asm_full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    36
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    37
by (case_tac "? a. Some a : Q" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    38
 by (eres_inst_tac [("x","{a . Some a : Q}")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    39
 by (Blast_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8288
diff changeset
    40
by (cases_tac "x" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    41
 by (Fast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    42
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    43
qed "acc_option";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    44
Addsimps [acc_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    45
AddSIs [acc_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    46
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    47
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    48
(** list **)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    49
section "list";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    50
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    51
Goalw [le_list] "~ [] <= x#xs";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    52
by (Simp_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    53
qed "Nil_notle_Cons";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    54
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    55
Goalw [le_list] "~ x#xs <= []";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    56
by (Simp_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    57
qed "Cons_notle_Nil";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    58
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    59
AddIffs [Nil_notle_Cons,Cons_notle_Nil];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    60
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    61
Goalw [le_list] "x#xs <= y#ys = (x <= y & xs <= ys)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    62
by (rtac iffI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    63
 by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    64
 by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    65
 by (rtac conjI 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    66
  by (eres_inst_tac [("x","0")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    67
  by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    68
 by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    69
 by (eres_inst_tac [("x","Suc i")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    70
 by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    71
by (Asm_full_simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    72
by (Clarify_tac 1);
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8288
diff changeset
    73
by (cases_tac "i" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    74
by (ALLGOALS Asm_simp_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    75
qed "Cons_le_Cons";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    76
AddIffs [Cons_le_Cons];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    77
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    78
Goal "(x#xs <= ys) = (? z zs. ys = z#zs & x <= z & xs <= zs)";
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8288
diff changeset
    79
by (cases_tac "ys" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    80
by (ALLGOALS Asm_simp_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    81
qed "Cons_le_iff";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    82
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    83
Goal "(xs <= y#ys) = (? z zs. xs = z#zs & z <= y & zs <= ys)";
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8288
diff changeset
    84
by (cases_tac "xs" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    85
by (ALLGOALS Asm_simp_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    86
qed "le_Cons_iff";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    87
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    88
Goalw [less_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    89
 "x#xs < y#ys = (x < (y::'a::order) & xs <= ys  |  x = y & xs < ys)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    90
by (simp_tac (simpset() addsimps [order_less_le]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    91
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    92
qed "Cons_less_Cons";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    93
AddIffs [Cons_less_Cons];
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 [le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    96
 "[| i<size xs; xs <= ys; x <= y |] ==> xs[i:=x] <= ys[i:=y]";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
    97
by (asm_full_simp_tac (simpset() addsimps [nth_list_update]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    98
qed "list_update_le_cong";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    99
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   100
Goal "!i < length xs. (xs[i := x] <= xs) = ((x::'a::order) <= xs!i)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   101
by (induct_tac "xs" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   102
 by (Simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   103
by (asm_simp_tac (simpset() addsplits [nat.split]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   104
qed_spec_mp "list_update_le_conv";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   105
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   106
Goalw [listsn_def] "xs : listsn n A ==> length xs = n";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   107
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   108
qed "listsnE_length";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   109
Addsimps [listsnE_length];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   110
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   111
Goalw [listsn_def] "xs : listsn n A ==> set xs <= A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   112
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   113
qed "listsnE_set";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   114
Addsimps [listsnE_set];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   115
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   116
Goalw [listsn_def] "listsn 0 A = {[]}";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   117
by (Auto_tac); 
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   118
qed "listsn_0";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   119
Addsimps [listsn_0];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   120
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   121
Goalw [listsn_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   122
 "(xs : listsn (Suc n) A) = (? y:A. ? ys:listsn n A. xs = y#ys)";
8423
3c19160b6432 exhaust_tac -> cases_tac
nipkow
parents: 8288
diff changeset
   123
by (cases_tac "xs" 1);
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   124
by (Auto_tac);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   125
qed "in_listsn_Suc_iff";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   126
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   127
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   128
Goal "? a. a:A ==> ? xs. xs : listsn n A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   129
by (induct_tac "n" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   130
 by (Simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   131
by (asm_simp_tac (simpset() addsimps [in_listsn_Suc_iff]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   132
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   133
qed "listsn_not_empty";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   134
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   135
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   136
Goal "!i n. length xs = n --> set xs <= A --> i < n --> (xs!i) : A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   137
by (induct_tac "xs" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   138
 by (Simp_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   139
by (asm_full_simp_tac (simpset() addsimps [nth_Cons] addsplits [nat.split]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   140
qed_spec_mp "nth_in";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   141
Addsimps [nth_in];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   142
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   143
Goal "[| xs : listsn n A; i < n |] ==> (xs!i) : A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   144
by (blast_tac (HOL_cs addIs [nth_in,listsnE_length,listsnE_set]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   145
qed "listsnE_nth_in";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   146
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   147
Goalw [listsn_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   148
 "[| xs : listsn n A; x:A; i < n |] ==> xs[i := x] : listsn n A";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   149
by (Asm_full_simp_tac 1);
8288
ebf874fcbff2 renamed a lemma
nipkow
parents: 7961
diff changeset
   150
by (blast_tac (claset() addDs [set_update_subset_insert RS subsetD]) 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   151
qed "list_update_in_listsn";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   152
Addsimps [list_update_in_listsn];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   153
AddSIs [list_update_in_listsn];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   154
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   155
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   156
Goalw [acc_def] "acc(A) ==> acc(listsn n A)";
7961
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   157
by (asm_full_simp_tac (simpset() addsimps [wf_eq_minimal]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   158
by (induct_tac "n" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   159
 by (simp_tac (simpset() addcongs [conj_cong]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   160
by (simp_tac (simpset() addsimps [in_listsn_Suc_iff]) 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   161
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   162
by (rename_tac "M m" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   163
by (case_tac "? x xs. x:A & xs:listsn n A & x#xs : M" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   164
 by (etac thin_rl 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   165
 by (etac thin_rl 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   166
 by (Blast_tac 2);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   167
by (eres_inst_tac [("x","{a. a:A & (? xs. xs:listsn n A & a#xs:M)}")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   168
by (etac impE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   169
 by (Blast_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   170
by (thin_tac "? x xs. ?P x xs" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   171
by (Clarify_tac 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   172
by (rename_tac "maxA xs" 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   173
by (eres_inst_tac [("x","{xs. xs:listsn n A & maxA#xs : M}")] allE 1);
422ac6888c7f expandshort
paulson
parents: 7626
diff changeset
   174
by (Blast_tac 1);
7626
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   175
qed "acc_listsn";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   176
Addsimps [acc_listsn];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   177
AddSIs [acc_listsn];