src/HOL/BCV/SemiLattice.ML
author nipkow
Tue, 28 Sep 1999 16:36:12 +0200
changeset 7626 5997f35954d7
child 7961 422ac6888c7f
permissions -rw-r--r--
A new theory: a model of bytecode verification.
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/SemiLattice.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
Goalw [semilat_def] "[| x:A; y:A; semilat A |] ==> x <= x+y";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     8
by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
     9
qed "semilat_ub1";
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
Goalw [semilat_def] "[| x:A; y:A; semilat A |] ==> y <= x+y";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    12
by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    13
qed "semilat_ub2";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    14
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    15
Goalw [semilat_def] "[| x:A; y:A; z:A; x <= z; y <= z; semilat A |] ==> x+y <= z";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    16
by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    17
qed "semilat_lub";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    18
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    19
Goalw [semilat_def] "[| x:A; y:A; semilat A |] ==> x+y : A";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    20
by(Blast_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    21
qed "semilat_plus";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    22
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    23
Addsimps [semilat_ub1,semilat_ub2,semilat_lub,semilat_plus];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    24
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    25
Goal "[| x:A; y:A; semilat A |] ==> (x <= y) = (x+y = y)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    26
br iffI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    27
 by(REPEAT(ares_tac [order_antisym,semilat_lub,order_refl,semilat_ub2] 1));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    28
be subst 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    29
by(Asm_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    30
qed "le_iff_plus_unchanged";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    31
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    32
Goal "[| x:A; y:A; semilat A |] ==> (x <= y) = (y = x+y)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    33
br iffI 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    34
 by(REPEAT(ares_tac [order_antisym,semilat_lub,order_refl,semilat_ub2] 1));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    35
be ssubst 1;
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    36
by(Asm_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    37
qed "le_iff_plus_unchanged2";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    38
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    39
Goal "[| x:A; y:A; z:A; semilat A; x <= y | x <= z |] ==> x <= y+z";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    40
by(blast_tac (claset() addIs [order_trans,semilat_ub1,semilat_ub2]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    41
qed "plus_mono";
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
Goal "[| x:A; semilat A |] ==> x+x = x";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    44
by(REPEAT(ares_tac [order_refl RSN (4,le_iff_plus_unchanged RS iffD1)] 1));
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    45
qed "semilat_idemp";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    46
Addsimps [semilat_idemp];
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
Goal "[| x:A; y:A; z:A; semilat A |] ==> (x+y)+z = x+(y+z)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    49
by(blast_tac (HOL_cs addSIs [order_refl,order_antisym,semilat_lub,semilat_plus]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    50
                     addIs [plus_mono]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    51
qed "semilat_assoc";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    52
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    53
Goal "[| x:A; y:A; semilat A |] ==> x+(x+y) = x+y";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    54
by(asm_simp_tac (simpset() addsimps [semilat_assoc RS sym]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    55
qed "semilat_assoc_idemp";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    56
Addsimps [semilat_assoc_idemp];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    57
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    58
Goal "[| x:A; y:A; z:A; semilat A |] ==> (x+y <= z) = (x <= z & y <= z)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    59
by(blast_tac (claset() addIs [semilat_ub1,semilat_ub2,semilat_lub,order_trans]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    60
qed "plus_le_conv";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    61
Addsimps [plus_le_conv];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    62
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    63
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    64
(** option **)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    65
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    66
Goal "semilat A ==> semilat (option A)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    67
by(simp_tac (simpset() addsimps [semilat_def,le_option,plus_option]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    68
                       addsplits [option.split]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    69
by(blast_tac (claset() addIs [semilat_ub1,semilat_ub2,semilat_lub,semilat_plus]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    70
qed "semilat_option";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    71
Addsimps [semilat_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    72
AddSIs [semilat_option];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    73
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    74
(** list **)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    75
Goalw [plus_list] "[] + [] = []";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    76
by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    77
qed "plus_Nil_Nil";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    78
Addsimps [plus_Nil_Nil];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    79
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    80
Goalw [plus_list] "(x#xs) + (y#ys) = (x+y)#(xs+ys)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    81
by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    82
qed "plus_Cons_Cons";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    83
Addsimps [plus_Cons_Cons];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    84
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    85
Goal
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    86
 "!xs ys i. length xs = n--> length ys = n--> i<n--> (xs+ys)!i = xs!i + ys!i";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    87
by(induct_tac "n" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    88
 by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    89
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    90
by(exhaust_tac "xs" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    91
 by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    92
by(exhaust_tac "ys" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    93
 by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    94
by(asm_full_simp_tac (simpset() addsimps [nth_Cons] addsplits [nat.split]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    95
qed_spec_mp "nth_plus";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    96
Addsimps [nth_plus];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    97
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    98
Goalw [le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
    99
 "semilat A ==> !xs:listsn n A. !ys:listsn n A. xs <= xs+ys";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   100
by(asm_simp_tac (simpset() addsimps [le_max_iff_disj]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   101
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   102
by(blast_tac (HOL_cs addIs [nth_in,nth_plus,listsnE_length,listsnE_set,semilat_ub1]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   103
qed_spec_mp "plus_list_ub1";
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
Goalw [le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   106
 "semilat A ==> !xs:listsn n A. !ys:listsn n A. ys <= xs+ys";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   107
by(asm_simp_tac (simpset() addsimps [le_max_iff_disj]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   108
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   109
by(blast_tac (HOL_cs addIs [nth_in,nth_plus,listsnE_length,listsnE_set,semilat_ub2]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   110
qed_spec_mp "plus_list_ub2";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   111
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   112
Goalw [le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   113
 "semilat A ==> !xs:listsn n A. !ys:listsn n A. !zs:listsn n A. \
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   114
\              xs <= zs & ys <= zs --> xs+ys <= zs";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   115
by(asm_simp_tac (simpset() addsimps [le_max_iff_disj] addcongs [conj_cong]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   116
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   117
by(blast_tac (HOL_cs addIs [nth_in,nth_plus,listsnE_length,listsnE_set,semilat_lub]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   118
qed_spec_mp "plus_list_lub";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   119
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   120
Goalw [listsn_def]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   121
 "semilat A ==> !xs:listsn n A. !ys:listsn n A. xs+ys : listsn n A";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   122
by(induct_tac "n" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   123
 by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   124
by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   125
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   126
by(exhaust_tac "xs" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   127
 by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   128
by(exhaust_tac "ys" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   129
 by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   130
by(Asm_full_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   131
by(blast_tac (claset() addIs [semilat_plus]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   132
qed_spec_mp "plus_list_closed";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   133
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   134
Goal "semilat A ==> semilat (listsn n A)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   135
by(simp_tac (HOL_basic_ss addsimps [semilat_def]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   136
by(asm_simp_tac (HOL_ss addsimps [plus_list_ub1,plus_list_ub2,plus_list_lub,plus_list_closed]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   137
qed "semilat_listsn";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   138
Addsimps [semilat_listsn];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   139
AddSIs [semilat_listsn];
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   140
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   141
Goalw [le_list]
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   142
 "!i xs. xs : listsn n A --> x:A --> semilat A --> i<n --> xs <= xs[i := x + xs!i]";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   143
by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   144
by(induct_tac "n" 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   145
 by(Simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   146
by(asm_simp_tac (simpset() addsimps [in_listsn_Suc_iff]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   147
by(Clarify_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   148
by(asm_simp_tac (simpset() addsimps [nth_Cons] addsplits [nat.split]) 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   149
qed_spec_mp "list_update_incr";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   150
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   151
(* product *)
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   152
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   153
Goalw [semilat_def,plus_prod] "[| semilat A; semilat B |] ==> semilat (A Times B)";
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   154
by(Asm_simp_tac 1);
5997f35954d7 A new theory: a model of bytecode verification.
nipkow
parents:
diff changeset
   155
qed "semilat_Times";