src/HOL/MicroJava/BV/Listn.thy
author wenzelm
Tue, 16 Jan 2001 00:40:57 +0100
changeset 10918 9679326489cd
parent 10496 f2d304bdf3cc
child 11225 01181fdbc9f0
permissions -rw-r--r--
renamed Product_Type.split to split_conv;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     1
(*  Title:      HOL/BCV/Listn.thy
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     2
    ID:         $Id$
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     3
    Author:     Tobias Nipkow
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     4
    Copyright   2000 TUM
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     5
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     6
Lists of a fixed length
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     7
*)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     8
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
     9
header "Fixed Length Lists"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    10
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    11
theory Listn = Err:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    12
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    13
constdefs
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    14
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    15
 list :: "nat => 'a set => 'a list set"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    16
"list n A == {xs. length xs = n & set xs <= A}"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    17
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    18
 le :: "'a ord => ('a list)ord"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    19
"le r == list_all2 (%x y. x <=_r y)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    20
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    21
syntax "@lesublist" :: "'a list => 'a ord => 'a list => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    22
       ("(_ /<=[_] _)" [50, 0, 51] 50)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    23
syntax "@lesssublist" :: "'a list => 'a ord => 'a list => bool"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    24
       ("(_ /<[_] _)" [50, 0, 51] 50)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    25
translations
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    26
 "x <=[r] y" == "x <=_(Listn.le r) y"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    27
 "x <[r] y"  == "x <_(Listn.le r) y"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    28
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    29
constdefs
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    30
 map2 :: "('a => 'b => 'c) => 'a list => 'b list => 'c list"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    31
"map2 f == (%xs ys. map (split f) (zip xs ys))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    32
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    33
syntax "@plussublist" :: "'a list => ('a => 'b => 'c) => 'b list => 'c list"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    34
       ("(_ /+[_] _)" [65, 0, 66] 65)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    35
translations  "x +[f] y" == "x +_(map2 f) y"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    36
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    37
consts coalesce :: "'a err list => 'a list err"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    38
primrec
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    39
"coalesce [] = OK[]"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    40
"coalesce (ex#exs) = Err.sup (op #) ex (coalesce exs)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    41
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    42
constdefs
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    43
 sl :: "nat => 'a sl => 'a list sl"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    44
"sl n == %(A,r,f). (list n A, le r, map2 f)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    45
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    46
 sup :: "('a => 'b => 'c err) => 'a list => 'b list => 'c list err"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    47
"sup f == %xs ys. if size xs = size ys then coalesce(xs +[f] ys) else Err"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    48
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    49
 upto_esl :: "nat => 'a esl => 'a list esl"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    50
"upto_esl m == %(A,r,f). (Union{list n A |n. n <= m}, le r, sup f)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    51
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    52
lemmas [simp] = set_update_subsetI
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    53
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    54
lemma unfold_lesub_list:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    55
  "xs <=[r] ys == Listn.le r xs ys"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    56
  by (simp add: lesub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    57
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    58
lemma Nil_le_conv [iff]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    59
  "([] <=[r] ys) = (ys = [])"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    60
apply (unfold lesub_def Listn.le_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    61
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    62
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    63
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    64
lemma Cons_notle_Nil [iff]: 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    65
  "~ x#xs <=[r] []"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    66
apply (unfold lesub_def Listn.le_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    67
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    68
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    69
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    70
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    71
lemma Cons_le_Cons [iff]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    72
  "x#xs <=[r] y#ys = (x <=_r y & xs <=[r] ys)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    73
apply (unfold lesub_def Listn.le_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    74
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    75
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    76
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    77
lemma Cons_less_Conss [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    78
  "order r ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    79
  x#xs <_(Listn.le r) y#ys = 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    80
  (x <_r y & xs <=[r] ys  |  x = y & xs <_(Listn.le r) ys)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    81
apply (unfold lesssub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    82
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    83
done  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    84
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    85
lemma list_update_le_cong:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    86
  "[| i<size xs; xs <=[r] ys; x <=_r y |] ==> xs[i:=x] <=[r] ys[i:=y]";
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    87
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    88
apply (unfold Listn.le_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    89
apply (simp add: list_all2_conv_all_nth nth_list_update)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    90
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    91
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    92
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    93
lemma le_listD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    94
  "[| xs <=[r] ys; p < size xs |] ==> xs!p <=_r ys!p"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    95
apply (unfold Listn.le_def lesub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    96
apply (simp add: list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    97
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    98
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
    99
lemma le_list_refl:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   100
  "!x. x <=_r x ==> xs <=[r] xs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   101
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   102
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   103
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   104
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   105
lemma le_list_trans:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   106
  "[| order r; xs <=[r] ys; ys <=[r] zs |] ==> xs <=[r] zs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   107
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   108
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   109
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   110
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   111
apply (blast intro: order_trans)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   112
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   113
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   114
lemma le_list_antisym:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   115
  "[| order r; xs <=[r] ys; ys <=[r] xs |] ==> xs = ys"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   116
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   117
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   118
apply (rule nth_equalityI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   119
 apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   120
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   121
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   122
apply (blast intro: order_antisym)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   123
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   124
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   125
lemma order_listI [simp, intro!]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   126
  "order r ==> order(Listn.le r)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   127
apply (subst order_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   128
apply (blast intro: le_list_refl le_list_trans le_list_antisym
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   129
             dest: order_refl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   130
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   131
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   132
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   133
lemma lesub_list_impl_same_size [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   134
  "xs <=[r] ys ==> size ys = size xs"  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   135
apply (unfold Listn.le_def lesub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   136
apply (simp add: list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   137
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   138
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   139
lemma lesssub_list_impl_same_size:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   140
  "xs <_(Listn.le r) ys ==> size ys = size xs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   141
apply (unfold lesssub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   142
apply auto
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   143
done  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   144
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   145
lemma listI:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   146
  "[| length xs = n; set xs <= A |] ==> xs : list n A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   147
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   148
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   149
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   150
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   151
lemma listE_length [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   152
   "xs : list n A ==> length xs = n"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   153
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   154
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   155
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   156
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   157
lemma less_lengthI:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   158
  "[| xs : list n A; p < n |] ==> p < length xs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   159
  by simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   160
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   161
lemma listE_set [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   162
  "xs : list n A ==> set xs <= A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   163
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   164
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   165
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   166
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   167
lemma list_0 [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   168
  "list 0 A = {[]}"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   169
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   170
apply auto
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   171
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   172
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   173
lemma in_list_Suc_iff: 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   174
  "(xs : list (Suc n) A) = (? y:A. ? ys:list n A. xs = y#ys)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   175
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   176
apply (case_tac "xs")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   177
apply auto
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   178
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   179
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   180
lemma Cons_in_list_Suc [iff]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   181
  "(x#xs : list (Suc n) A) = (x:A & xs : list n A)";
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   182
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   183
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   184
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   185
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   186
lemma list_not_empty:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   187
  "? a. a:A ==> ? xs. xs : list n A";
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   188
apply (induct "n")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   189
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   190
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   191
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   192
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   193
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   194
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   195
lemma nth_in [rule_format, simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   196
  "!i n. length xs = n --> set xs <= A --> i < n --> (xs!i) : A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   197
apply (induct "xs")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   198
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   199
apply (simp add: nth_Cons split: nat.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   200
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   201
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   202
lemma listE_nth_in:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   203
  "[| xs : list n A; i < n |] ==> (xs!i) : A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   204
  by auto
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   205
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   206
lemma listt_update_in_list [simp, intro!]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   207
  "[| xs : list n A; x:A |] ==> xs[i := x] : list n A"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   208
apply (unfold list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   209
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   210
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   211
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   212
lemma plus_list_Nil [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   213
  "[] +[f] xs = []"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   214
apply (unfold plussub_def map2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   215
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   216
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   217
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   218
lemma plus_list_Cons [simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   219
  "(x#xs) +[f] ys = (case ys of [] => [] | y#ys => (x +_f y)#(xs +[f] ys))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   220
  by (simp add: plussub_def map2_def split: list.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   221
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   222
lemma length_plus_list [rule_format, simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   223
  "!ys. length(xs +[f] ys) = min(length xs) (length ys)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   224
apply (induct xs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   225
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   226
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   227
apply (simp (no_asm_simp) split: list.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   228
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   229
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   230
lemma nth_plus_list [rule_format, simp]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   231
  "!xs ys i. length xs = n --> length ys = n --> i<n --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   232
  (xs +[f] ys)!i = (xs!i) +_f (ys!i)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   233
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   234
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   235
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   236
apply (case_tac xs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   237
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   238
apply (force simp add: nth_Cons split: list.split nat.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   239
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   240
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   241
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   242
lemma plus_list_ub1 [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   243
  "[| semilat(A,r,f); set xs <= A; set ys <= A; size xs = size ys |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   244
  ==> xs <=[r] xs +[f] ys"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   245
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   246
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   247
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   248
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   249
lemma plus_list_ub2:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   250
  "[| semilat(A,r,f); set xs <= A; set ys <= A; size xs = size ys |]
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   251
  ==> ys <=[r] xs +[f] ys"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   252
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   253
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   254
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   255
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   256
lemma plus_list_lub [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   257
  "semilat(A,r,f) ==> !xs ys zs. set xs <= A --> set ys <= A --> set zs <= A 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   258
  --> size xs = n & size ys = n --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   259
  xs <=[r] zs & ys <=[r] zs --> xs +[f] ys <=[r] zs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   260
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   261
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   262
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   263
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   264
lemma list_update_incr [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   265
  "[| semilat(A,r,f); x:A |] ==> set xs <= A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   266
  (!i. i<size xs --> xs <=[r] xs[i := x +_f xs!i])"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   267
apply (unfold unfold_lesub_list)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   268
apply (simp add: Listn.le_def list_all2_conv_all_nth)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   269
apply (induct xs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   270
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   271
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   272
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   273
apply (simp add: nth_Cons split: nat.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   274
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   275
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   276
lemma acc_le_listI [intro!]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   277
  "[| order r; acc r |] ==> acc(Listn.le r)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   278
apply (unfold acc_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   279
apply (subgoal_tac
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   280
 "wf(UN n. {(ys,xs). size xs = n & size ys = n & xs <_(Listn.le r) ys})")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   281
 apply (erule wf_subset)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   282
 apply (blast intro: lesssub_list_impl_same_size)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   283
apply (rule wf_UN)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   284
 prefer 2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   285
 apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   286
 apply (rename_tac m n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   287
 apply (case_tac "m=n")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   288
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   289
 apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   290
  apply (fast intro!: equals0I dest: not_sym)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   291
 apply (fast intro!: equals0I dest: not_sym)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   292
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   293
apply (rename_tac n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   294
apply (induct_tac n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   295
 apply (simp add: lesssub_def cong: conj_cong)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   296
apply (rename_tac k)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   297
apply (simp add: wf_eq_minimal)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   298
apply (simp (no_asm) add: length_Suc_conv cong: conj_cong)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   299
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   300
apply (rename_tac M m)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   301
apply (case_tac "? x xs. size xs = k & x#xs : M")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   302
 prefer 2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   303
 apply (erule thin_rl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   304
 apply (erule thin_rl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   305
 apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   306
apply (erule_tac x = "{a. ? xs. size xs = k & a#xs:M}" in allE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   307
apply (erule impE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   308
 apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   309
apply (thin_tac "? x xs. ?P x xs")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   310
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   311
apply (rename_tac maxA xs)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   312
apply (erule_tac x = "{ys. size ys = size xs & maxA#ys : M}" in allE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   313
apply (erule impE)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   314
 apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   315
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   316
apply (thin_tac "m : M")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   317
apply (thin_tac "maxA#xs : M")
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   318
apply (rule bexI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   319
 prefer 2
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   320
 apply assumption
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   321
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   322
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   323
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   324
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   325
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   326
lemma closed_listI:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   327
  "closed S f ==> closed (list n S) (map2 f)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   328
apply (unfold closed_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   329
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   330
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   331
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   332
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   333
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   334
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   335
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   336
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   337
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   338
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   339
lemma semilat_Listn_sl:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   340
  "!!L. semilat L ==> semilat (Listn.sl n L)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   341
apply (unfold Listn.sl_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   342
apply (simp (no_asm_simp) only: split_tupled_all)
10918
9679326489cd renamed Product_Type.split to split_conv;
wenzelm
parents: 10496
diff changeset
   343
apply (simp (no_asm) only: semilat_Def split_conv)
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   344
apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   345
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   346
apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   347
 apply (simp only: semilatDclosedI closed_listI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   348
apply (simp (no_asm) only: list_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   349
apply (simp (no_asm_simp) add: plus_list_ub1 plus_list_ub2 plus_list_lub)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   350
done  
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   351
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   352
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   353
lemma coalesce_in_err_list [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   354
  "!xes. xes : list n (err A) --> coalesce xes : err(list n A)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   355
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   356
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   357
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   358
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   359
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   360
apply (simp (no_asm) add: plussub_def Err.sup_def lift2_def split: err.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   361
apply force
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   362
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   363
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   364
lemma lem: "!!x xs. x +_(op #) xs = x#xs"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   365
  by (simp add: plussub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   366
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   367
lemma coalesce_eq_OK1_D [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   368
  "semilat(err A, Err.le r, lift2 f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   369
  !xs. xs : list n A --> (!ys. ys : list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   370
  (!zs. coalesce (xs +[f] ys) = OK zs --> xs <=[r] zs))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   371
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   372
  apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   373
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   374
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   375
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   376
apply (simp split: err.split_asm add: lem Err.sup_def lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   377
apply (force simp add: semilat_le_err_OK1)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   378
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   379
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   380
lemma coalesce_eq_OK2_D [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   381
  "semilat(err A, Err.le r, lift2 f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   382
  !xs. xs : list n A --> (!ys. ys : list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   383
  (!zs. coalesce (xs +[f] ys) = OK zs --> ys <=[r] zs))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   384
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   385
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   386
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   387
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   388
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   389
apply (simp split: err.split_asm add: lem Err.sup_def lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   390
apply (force simp add: semilat_le_err_OK2)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   391
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   392
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   393
lemma lift2_le_ub:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   394
  "[| semilat(err A, Err.le r, lift2 f); x:A; y:A; x +_f y = OK z; 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   395
      u:A; x <=_r u; y <=_r u |] ==> z <=_r u"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   396
apply (unfold semilat_Def plussub_def err_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   397
apply (simp add: lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   398
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   399
apply (rotate_tac -3)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   400
apply (erule thin_rl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   401
apply (erule thin_rl)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   402
apply force
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   403
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   404
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   405
lemma coalesce_eq_OK_ub_D [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   406
  "semilat(err A, Err.le r, lift2 f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   407
  !xs. xs : list n A --> (!ys. ys : list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   408
  (!zs us. coalesce (xs +[f] ys) = OK zs & xs <=[r] us & ys <=[r] us 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   409
           & us : list n A --> zs <=[r] us))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   410
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   411
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   412
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   413
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   414
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   415
apply (simp (no_asm_use) split: err.split_asm add: lem Err.sup_def lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   416
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   417
apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   418
 apply (blast intro: lift2_le_ub)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   419
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   420
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   421
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   422
lemma lift2_eq_ErrD:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   423
  "[| x +_f y = Err; semilat(err A, Err.le r, lift2 f); x:A; y:A |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   424
  ==> ~(? u:A. x <=_r u & y <=_r u)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   425
  by (simp add: OK_plus_OK_eq_Err_conv [THEN iffD1])
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   426
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   427
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   428
lemma coalesce_eq_Err_D [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   429
  "[| semilat(err A, Err.le r, lift2 f) |] 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   430
  ==> !xs. xs:list n A --> (!ys. ys:list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   431
      coalesce (xs +[f] ys) = Err --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   432
      ~(? zs:list n A. xs <=[r] zs & ys <=[r] zs))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   433
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   434
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   435
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   436
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   437
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   438
apply (simp split: err.split_asm add: lem Err.sup_def lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   439
 apply (blast dest: lift2_eq_ErrD)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   440
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   441
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   442
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   443
lemma closed_err_lift2_conv:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   444
  "closed (err A) (lift2 f) = (!x:A. !y:A. x +_f y : err A)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   445
apply (unfold closed_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   446
apply (simp add: err_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   447
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   448
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   449
lemma closed_map2_list [rule_format]:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   450
  "closed (err A) (lift2 f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   451
  !xs. xs : list n A --> (!ys. ys : list n A --> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   452
  map2 f xs ys : list n (err A))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   453
apply (unfold map2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   454
apply (induct n)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   455
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   456
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   457
apply (simp add: in_list_Suc_iff)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   458
apply clarify
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   459
apply (simp add: plussub_def closed_err_lift2_conv)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   460
apply blast
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   461
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   462
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   463
lemma closed_lift2_sup:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   464
  "closed (err A) (lift2 f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   465
  closed (err (list n A)) (lift2 (sup f))"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   466
  by (fastsimp  simp add: closed_def plussub_def sup_def lift2_def
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   467
                          coalesce_in_err_list closed_map2_list
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   468
                split: err.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   469
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   470
lemma err_semilat_sup:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   471
  "err_semilat (A,r,f) ==> 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   472
  err_semilat (list n A, Listn.le r, sup f)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   473
apply (unfold Err.sl_def)
10918
9679326489cd renamed Product_Type.split to split_conv;
wenzelm
parents: 10496
diff changeset
   474
apply (simp only: split_conv)
10496
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   475
apply (simp (no_asm) only: semilat_Def plussub_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   476
apply (simp (no_asm_simp) only: semilatDclosedI closed_lift2_sup)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   477
apply (rule conjI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   478
 apply (drule semilatDorderI)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   479
 apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   480
apply (simp (no_asm) only: unfold_lesub_err Err.le_def err_def sup_def lift2_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   481
apply (simp (no_asm_simp) add: coalesce_eq_OK1_D coalesce_eq_OK2_D split: err.split)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   482
apply (blast intro: coalesce_eq_OK_ub_D dest: coalesce_eq_Err_D)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   483
done 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   484
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   485
lemma err_semilat_upto_esl:
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   486
  "!!L. err_semilat L ==> err_semilat(upto_esl m L)"
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   487
apply (unfold Listn.upto_esl_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   488
apply (simp (no_asm_simp) only: split_tupled_all)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   489
apply simp
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   490
apply (fastsimp intro!: err_semilat_UnionI err_semilat_sup
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   491
                dest: lesub_list_impl_same_size 
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   492
                simp add: plussub_def Listn.sup_def)
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   493
done
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   494
f2d304bdf3cc BCV integration (first step)
kleing
parents:
diff changeset
   495
end