src/ZF/UNITY/AllocBase.thy
author paulson
Fri, 27 Jun 2003 13:15:40 +0200
changeset 14076 5cfc8b9fb880
parent 14054 dc281bd5ca0a
child 14084 ccb48f3239f7
permissions -rw-r--r--
Conversion of AllocBase to new-style
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     1
(*  Title:      ZF/UNITY/AllocBase.thy
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     2
    ID:         $Id$
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     3
    Author:     Sidi O Ehmety, Cambridge University Computer Laboratory
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     4
    Copyright   2001  University of Cambridge
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     5
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     6
*)
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
     7
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
     8
header{*Common declarations for Chandy and Charpentier's Allocator*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
     9
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    10
theory AllocBase = Follows + MultisetSum + Guar:
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    11
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    12
consts
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    13
  tokbag   :: i  (* tokbags could be multisets...or any ordered type?*)
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    14
  NbT      :: i  (* Number of tokens in system *)
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    15
  Nclients :: i  (* Number of clients *)
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    16
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    17
translations "tokbag" => "nat" 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    18
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    19
axioms
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    20
  NbT_pos:      "NbT \<in> nat-{0}"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    21
  Nclients_pos: "Nclients \<in> nat-{0}"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    22
  
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    23
text{*This function merely sums the elements of a list*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    24
consts tokens :: "i =>i"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    25
       item :: i (* Items to be merged/distributed *)
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    26
primrec 
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    27
  "tokens(Nil) = 0"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    28
  "tokens (Cons(x,xs)) = x #+ tokens(xs)"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    29
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    30
consts
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    31
  bag_of :: "i => i"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    32
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    33
primrec
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    34
  "bag_of(Nil)    = 0"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    35
  "bag_of(Cons(x,xs)) = {#x#} +# bag_of(xs)"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    36
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    37
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    38
text{*Definitions needed in Client.thy.  We define a recursive predicate
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    39
using 0 and 1 to code the truth values.*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    40
consts all_distinct0 :: "i=>i"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    41
 primrec
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    42
  "all_distinct0(Nil) = 1"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    43
  "all_distinct0(Cons(a, l)) =
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    44
     (if a \<in> set_of_list(l) then 0 else all_distinct0(l))"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    45
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    46
constdefs
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    47
  all_distinct  :: "i=>o"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    48
   "all_distinct(l) == all_distinct0(l)=1"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    49
  
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    50
constdefs  
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    51
  state_of :: "i =>i" --{* coersion from anyting to state *}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    52
   "state_of(s) == if s \<in> state then s else st0"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    53
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    54
  lift :: "i =>(i=>i)" --{* simplifies the expression of programs*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    55
   "lift(x) == %s. s`x"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    56
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    57
text{* function to show that the set of variables is infinite *}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    58
consts
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    59
  nat_list_inj :: "i=>i"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    60
  nat_var_inj  :: "i=>i"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    61
  var_inj      :: "i=>i"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    62
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    63
defs
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    64
  nat_var_inj_def: "nat_var_inj(n) == Var(nat_list_inj(n))"
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    65
primrec
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    66
  "nat_list_inj(0) = Nil"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    67
  "nat_list_inj(succ(n)) = Cons(n, nat_list_inj(n))"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    68
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    69
primrec
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    70
  "var_inj(Var(l)) = length(l)"
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
    71
14076
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    72
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    73
subsection{*Various simple lemmas*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    74
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    75
lemma Nclients_NbT_gt_0 [simp]: "0 < Nclients & 0 < NbT"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    76
apply (cut_tac Nclients_pos NbT_pos)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    77
apply (auto intro: Ord_0_lt)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    78
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    79
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    80
lemma Nclients_NbT_not_0 [simp]: "Nclients \<noteq> 0 & NbT \<noteq> 0"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    81
by (cut_tac Nclients_pos NbT_pos, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    82
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    83
lemma Nclients_type [simp,TC]: "Nclients\<in>nat"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    84
by (cut_tac Nclients_pos NbT_pos, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    85
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    86
lemma NbT_type [simp,TC]: "NbT\<in>nat"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    87
by (cut_tac Nclients_pos NbT_pos, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    88
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    89
lemma INT_Nclient_iff [iff]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    90
     "b\<in>Inter(RepFun(Nclients, B)) <-> (\<forall>x\<in>Nclients. b\<in>B(x))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    91
apply (auto simp add: INT_iff)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    92
apply (rule_tac x = 0 in exI)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    93
apply (rule ltD, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    94
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    95
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    96
lemma setsum_fun_mono [rule_format]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    97
     "n\<in>nat ==>  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    98
      (\<forall>i\<in>nat. i<n --> f(i) $<= g(i)) -->  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
    99
      setsum(f, n) $<= setsum(g,n)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   100
apply (induct_tac "n", simp_all)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   101
apply (subgoal_tac "Finite(x) & x\<notin>x")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   102
 prefer 2 apply (simp add: nat_into_Finite mem_not_refl, clarify)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   103
apply (simp (no_asm_simp) add: succ_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   104
apply (subgoal_tac "\<forall>i\<in>nat. i<x--> f(i) $<= g(i) ")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   105
 prefer 2 apply (force dest: leI) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   106
apply (rule zadd_zle_mono, simp_all)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   107
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   108
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   109
lemma tokens_type [simp,TC]: "l\<in>list(A) ==> tokens(l)\<in>nat"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   110
by (erule list.induct, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   111
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   112
lemma tokens_mono_aux [rule_format]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   113
     "xs\<in>list(A) ==> \<forall>ys\<in>list(A). <xs, ys>\<in>prefix(A)  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   114
   --> tokens(xs) \<le> tokens(ys)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   115
apply (induct_tac "xs")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   116
apply (auto dest: gen_prefix.dom_subset [THEN subsetD] simp add: prefix_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   117
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   118
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   119
lemma tokens_mono: "<xs, ys>\<in>prefix(A) ==> tokens(xs) \<le> tokens(ys)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   120
apply (cut_tac prefix_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   121
apply (blast intro: tokens_mono_aux)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   122
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   123
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   124
lemma mono_tokens [iff]: "mono1(list(A), prefix(A), nat, Le,tokens)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   125
apply (unfold mono1_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   126
apply (auto intro: tokens_mono simp add: Le_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   127
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   128
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   129
lemma tokens_append [simp]: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   130
"[| xs\<in>list(A); ys\<in>list(A) |] ==> tokens(xs@ys) = tokens(xs) #+ tokens(ys)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   131
apply (induct_tac "xs", auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   132
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   133
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   134
subsection{*The function @{term bag_of}*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   135
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   136
lemma bag_of_type [simp,TC]: "l\<in>list(A) ==>bag_of(l)\<in>Mult(A)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   137
apply (induct_tac "l")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   138
apply (auto simp add: Mult_iff_multiset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   139
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   140
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   141
lemma bag_of_multiset:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   142
     "l\<in>list(A) ==> multiset(bag_of(l)) & mset_of(bag_of(l))<=A"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   143
apply (drule bag_of_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   144
apply (auto simp add: Mult_iff_multiset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   145
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   146
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   147
lemma bag_of_append [simp]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   148
    "[| xs\<in>list(A); ys\<in>list(A)|] ==> bag_of(xs@ys) = bag_of(xs) +# bag_of(ys)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   149
apply (induct_tac "xs")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   150
apply (auto simp add: bag_of_multiset munion_assoc)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   151
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   152
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   153
lemma bag_of_mono_aux [rule_format]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   154
     "xs\<in>list(A) ==> \<forall>ys\<in>list(A). <xs, ys>\<in>prefix(A)  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   155
      --> <bag_of(xs), bag_of(ys)>\<in>MultLe(A, r)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   156
apply (induct_tac "xs", simp_all, clarify) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   157
apply (frule_tac l = ys in bag_of_multiset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   158
apply (auto intro: empty_le_MultLe simp add: prefix_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   159
apply (rule munion_mono)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   160
apply (force simp add: MultLe_def Mult_iff_multiset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   161
apply (blast dest: gen_prefix.dom_subset [THEN subsetD])
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   162
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   163
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   164
lemma bag_of_mono [intro]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   165
     "[|  <xs, ys>\<in>prefix(A); xs\<in>list(A); ys\<in>list(A) |]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   166
      ==> <bag_of(xs), bag_of(ys)>\<in>MultLe(A, r)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   167
apply (blast intro: bag_of_mono_aux)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   168
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   169
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   170
lemma mono_bag_of [simp]: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   171
     "mono1(list(A), prefix(A), Mult(A), MultLe(A,r), bag_of)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   172
by (auto simp add:  mono1_def bag_of_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   173
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   174
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   175
subsection{*The function @{term msetsum}*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   176
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   177
lemmas nat_into_Fin = eqpoll_refl [THEN [2] Fin_lemma]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   178
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   179
lemma list_Int_length_Fin: "l \<in> list(A) ==> C Int length(l) \<in> Fin(length(l))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   180
apply (drule length_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   181
apply (rule Fin_subset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   182
apply (rule Int_lower2)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   183
apply (erule nat_into_Fin)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   184
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   185
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   186
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   187
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   188
lemma mem_Int_imp_lt_length:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   189
     "[|xs \<in> list(A); k \<in> C \<inter> length(xs)|] ==> k < length(xs)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   190
apply (simp add: ltI)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   191
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   192
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   193
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   194
lemma bag_of_sublist_lemma:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   195
     "[|C \<subseteq> nat; x \<in> A; xs \<in> list(A)|]   
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   196
  ==>  msetsum(\<lambda>i. {#nth(i, xs @ [x])#}, C \<inter> succ(length(xs)), A) =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   197
       (if length(xs) \<in> C then  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   198
          {#x#} +# msetsum(\<lambda>x. {#nth(x, xs)#}, C \<inter> length(xs), A)  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   199
        else msetsum(\<lambda>x. {#nth(x, xs)#}, C \<inter> length(xs), A))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   200
apply (simp add: subsetD nth_append lt_not_refl mem_Int_imp_lt_length cong add: msetsum_cong)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   201
apply (simp add: Int_succ_right)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   202
apply (simp add: lt_not_refl mem_Int_imp_lt_length cong add: msetsum_cong, clarify)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   203
apply (subst msetsum_cons)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   204
apply (rule_tac [3] succI1)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   205
apply (blast intro: list_Int_length_Fin subset_succI [THEN Fin_mono, THEN subsetD])
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   206
apply (simp add: mem_not_refl)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   207
apply (simp add: nth_type lt_not_refl)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   208
apply (blast intro: nat_into_Ord ltI length_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   209
apply (simp add: lt_not_refl mem_Int_imp_lt_length cong add: msetsum_cong)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   210
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   211
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   212
lemma bag_of_sublist_lemma2:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   213
     "l\<in>list(A) ==>  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   214
  C <= nat ==>  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   215
  bag_of(sublist(l, C)) =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   216
      msetsum(%i. {#nth(i, l)#}, C Int length(l), A)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   217
apply (erule list_append_induct)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   218
apply (simp (no_asm))
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   219
apply (simp (no_asm_simp) add: sublist_append nth_append bag_of_sublist_lemma munion_commute bag_of_sublist_lemma msetsum_multiset munion_0)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   220
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   221
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   222
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   223
lemma nat_Int_length_eq: "l \<in> list(A) ==> nat \<inter> length(l) = length(l)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   224
apply (rule Int_absorb1)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   225
apply (rule OrdmemD, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   226
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   227
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   228
(*eliminating the assumption C<=nat*)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   229
lemma bag_of_sublist:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   230
     "l\<in>list(A) ==>  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   231
  bag_of(sublist(l, C)) = msetsum(%i. {#nth(i, l)#}, C Int length(l), A)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   232
apply (subgoal_tac " bag_of (sublist (l, C Int nat)) = msetsum (%i. {#nth (i, l) #}, C Int length (l), A) ")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   233
apply (simp add: sublist_Int_eq)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   234
apply (simp add: bag_of_sublist_lemma2 Int_lower2 Int_assoc nat_Int_length_eq)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   235
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   236
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   237
lemma bag_of_sublist_Un_Int: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   238
"l\<in>list(A) ==>  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   239
  bag_of(sublist(l, B Un C)) +# bag_of(sublist(l, B Int C)) =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   240
      bag_of(sublist(l, B)) +# bag_of(sublist(l, C))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   241
apply (subgoal_tac "B Int C Int length (l) = (B Int length (l)) Int (C Int length (l))")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   242
prefer 2 apply blast
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   243
apply (simp (no_asm_simp) add: bag_of_sublist Int_Un_distrib2 msetsum_Un_Int)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   244
apply (rule msetsum_Un_Int)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   245
apply (erule list_Int_length_Fin)+
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   246
 apply (simp add: ltI nth_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   247
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   248
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   249
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   250
lemma bag_of_sublist_Un_disjoint:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   251
     "[| l\<in>list(A); B Int C = 0  |] 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   252
      ==> bag_of(sublist(l, B Un C)) =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   253
          bag_of(sublist(l, B)) +# bag_of(sublist(l, C))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   254
by (simp add: bag_of_sublist_Un_Int [symmetric] bag_of_multiset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   255
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   256
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   257
lemma bag_of_sublist_UN_disjoint [rule_format]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   258
     "[|Finite(I); \<forall>i\<in>I. \<forall>j\<in>I. i\<noteq>j --> A(i) \<inter> A(j) = 0;  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   259
        l\<in>list(B) |]  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   260
      ==> bag_of(sublist(l, \<Union>i\<in>I. A(i))) =   
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   261
          (msetsum(%i. bag_of(sublist(l, A(i))), I, B)) "
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   262
apply (simp (no_asm_simp) del: UN_simps
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   263
           add: UN_simps [symmetric] bag_of_sublist)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   264
apply (subst  msetsum_UN_disjoint [of _ _ _ "length (l)"])
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   265
apply (drule Finite_into_Fin, assumption)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   266
prefer 3 apply force
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   267
apply (auto intro!: Fin_IntI2 Finite_into_Fin simp add: ltI nth_type length_type nat_into_Finite)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   268
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   269
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   270
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   271
lemma part_ord_Lt [simp]: "part_ord(nat, Lt)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   272
apply (unfold part_ord_def Lt_def irrefl_def trans_on_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   273
apply (auto intro: lt_trans)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   274
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   275
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   276
subsubsection{*The function @{term all_distinct}*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   277
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   278
lemma all_distinct_Nil [simp]: "all_distinct(Nil)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   279
by (unfold all_distinct_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   280
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   281
lemma all_distinct_Cons [simp]: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   282
    "all_distinct(Cons(a,l)) <->  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   283
      (a\<in>set_of_list(l) --> False) & (a \<notin> set_of_list(l) --> all_distinct(l))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   284
apply (unfold all_distinct_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   285
apply (auto elim: list.cases)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   286
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   287
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   288
subsubsection{*The function @{term state_of}*}
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   289
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   290
lemma state_of_state: "s\<in>state ==> state_of(s)=s"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   291
by (unfold state_of_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   292
declare state_of_state [simp]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   293
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   294
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   295
lemma state_of_idem: "state_of(state_of(s))=state_of(s)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   296
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   297
apply (unfold state_of_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   298
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   299
declare state_of_idem [simp]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   300
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   301
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   302
lemma state_of_type [simp,TC]: "state_of(s)\<in>state"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   303
by (unfold state_of_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   304
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   305
lemma lift_apply [simp]: "lift(x, s)=s`x"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   306
by (simp add: lift_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   307
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   308
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   309
(** Used in ClientImp **)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   310
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   311
lemma gen_Increains_state_of_eq: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   312
     "Increasing(A, r, %s. f(state_of(s))) = Increasing(A, r, f)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   313
apply (unfold Increasing_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   314
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   315
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   316
lemmas Increasing_state_ofD1 =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   317
      gen_Increains_state_of_eq [THEN equalityD1, THEN subsetD, standard]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   318
lemmas Increasing_state_ofD2 =  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   319
      gen_Increains_state_of_eq [THEN equalityD2, THEN subsetD, standard]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   320
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   321
lemma Follows_state_of_eq: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   322
     "Follows(A, r, %s. f(state_of(s)), %s. g(state_of(s))) =   
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   323
      Follows(A, r, f, g)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   324
apply (unfold Follows_def Increasing_def, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   325
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   326
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   327
lemmas Follows_state_ofD1 =
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   328
      Follows_state_of_eq [THEN equalityD1, THEN subsetD, standard]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   329
lemmas Follows_state_ofD2 =
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   330
      Follows_state_of_eq [THEN equalityD2, THEN subsetD, standard]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   331
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   332
lemma nat_list_inj_type: "n\<in>nat ==> nat_list_inj(n)\<in>list(nat)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   333
by (induct_tac "n", auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   334
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   335
lemma length_nat_list_inj: "n\<in>nat ==> length(nat_list_inj(n)) = n"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   336
by (induct_tac "n", auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   337
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   338
lemma var_infinite_lemma: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   339
  "(\<lambda>x\<in>nat. nat_var_inj(x))\<in>inj(nat, var)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   340
apply (unfold nat_var_inj_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   341
apply (rule_tac d = var_inj in lam_injective)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   342
apply (auto simp add: var.intros nat_list_inj_type)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   343
apply (simp add: length_nat_list_inj)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   344
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   345
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   346
lemma nat_lepoll_var: "nat lepoll var"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   347
apply (unfold lepoll_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   348
apply (rule_tac x = " (\<lambda>x\<in>nat. nat_var_inj (x))" in exI)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   349
apply (rule var_infinite_lemma)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   350
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   351
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   352
(*Surely a simpler proof uses lepoll_Finite and the following lemma:*)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   353
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   354
    (*????Cardinal*)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   355
    lemma nat_not_Finite: "~Finite(nat)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   356
    apply (unfold Finite_def, clarify) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   357
    apply (drule eqpoll_imp_lepoll [THEN lepoll_cardinal_le], simp) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   358
    apply (insert Card_nat) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   359
    apply (simp add: Card_def)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   360
    apply (drule le_imp_subset)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   361
    apply (blast elim: mem_irrefl)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   362
    done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   363
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   364
lemma var_not_Finite: "~Finite(var)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   365
apply (insert nat_not_Finite) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   366
apply (blast intro: lepoll_Finite [OF 	nat_lepoll_var]) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   367
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   368
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   369
lemma not_Finite_imp_exist: "~Finite(A) ==> \<exists>x. x\<in>A"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   370
apply (subgoal_tac "A\<noteq>0")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   371
apply (auto simp add: Finite_0)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   372
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   373
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   374
lemma Inter_Diff_var_iff:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   375
     "Finite(A) ==> b\<in>(Inter(RepFun(var-A, B))) <-> (\<forall>x\<in>var-A. b\<in>B(x))"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   376
apply (subgoal_tac "\<exists>x. x\<in>var-A", auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   377
apply (subgoal_tac "~Finite (var-A) ")
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   378
apply (drule not_Finite_imp_exist, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   379
apply (cut_tac var_not_Finite)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   380
apply (erule swap)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   381
apply (rule_tac B = A in Diff_Finite, auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   382
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   383
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   384
lemma Inter_var_DiffD:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   385
     "[| b\<in>Inter(RepFun(var-A, B)); Finite(A); x\<in>var-A |] ==> b\<in>B(x)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   386
by (simp add: Inter_Diff_var_iff)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   387
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   388
(* [| Finite(A); (\<forall>x\<in>var-A. b\<in>B(x)) |] ==> b\<in>Inter(RepFun(var-A, B)) *)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   389
lemmas Inter_var_DiffI = Inter_Diff_var_iff [THEN iffD2, standard]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   390
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   391
declare Inter_var_DiffI [intro!]
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   392
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   393
lemma Acts_subset_Int_Pow_simp [simp]:
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   394
     "Acts(F)<= A \<inter> Pow(state*state)  <-> Acts(F)<=A"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   395
by (insert Acts_type [of F], auto)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   396
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   397
lemma setsum_nsetsum_eq: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   398
     "[| Finite(A); \<forall>x\<in>A. g(x)\<in>nat |] 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   399
      ==> setsum(%x. $#(g(x)), A) = $# nsetsum(%x. g(x), A)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   400
apply (erule Finite_induct)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   401
apply (auto simp add: int_of_add)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   402
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   403
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   404
lemma nsetsum_cong: 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   405
     "[| A=B;  \<forall>x\<in>A. f(x)=g(x);  \<forall>x\<in>A. g(x)\<in>nat;  Finite(A) |]  
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   406
      ==> nsetsum(f, A) = nsetsum(g, B)"
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   407
apply (subgoal_tac "$# nsetsum (f, A) = $# nsetsum (g, B)", simp)
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   408
apply (simp add: setsum_nsetsum_eq [symmetric] cong: setsum_cong) 
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   409
done
5cfc8b9fb880 Conversion of AllocBase to new-style
paulson
parents: 14054
diff changeset
   410
14052
e9c9f69e4f63 some new ZF/UNITY material from Sidi Ehmety
paulson
parents:
diff changeset
   411
end