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