author | haftmann |
Sat, 05 Jul 2014 11:01:53 +0200 | |
changeset 57514 | bdc2c6b40bf2 |
parent 57418 | 6ab1c7cb0b8d |
child 58889 | 5b7a9633cfa8 |
permissions | -rw-r--r-- |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
24147
diff
changeset
|
1 |
(* Title: HOL/UNITY/Comp/AllocBase.thy |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
2 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
3 |
Copyright 1998 University of Cambridge |
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
4 |
*) |
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
5 |
|
13798 | 6 |
header{*Common Declarations for Chandy and Charpentier's Allocator*} |
7 |
||
18556 | 8 |
theory AllocBase imports "../UNITY_Main" begin |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
9 |
|
45827 | 10 |
consts Nclients :: nat (*Number of clients*) |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
11 |
|
45827 | 12 |
axiomatization NbT :: nat (*Number of tokens in system*) |
13 |
where NbT_pos: "0 < NbT" |
|
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
14 |
|
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
15 |
(*This function merely sums the elements of a list*) |
39246 | 16 |
primrec tokens :: "nat list => nat" where |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
17 |
"tokens [] = 0" |
39246 | 18 |
| "tokens (x#xs) = x + tokens xs" |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
19 |
|
39246 | 20 |
abbreviation (input) "bag_of \<equiv> multiset_of" |
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
21 |
|
13798 | 22 |
lemma setsum_fun_mono [rule_format]: |
23 |
"!!f :: nat=>nat. |
|
24 |
(ALL i. i<n --> f i <= g i) --> |
|
25 |
setsum f (lessThan n) <= setsum g (lessThan n)" |
|
26 |
apply (induct_tac "n") |
|
27 |
apply (auto simp add: lessThan_Suc) |
|
28 |
done |
|
29 |
||
46911 | 30 |
lemma tokens_mono_prefix: "xs <= ys ==> tokens xs <= tokens ys" |
31 |
by (induct ys arbitrary: xs) (auto simp add: prefix_Cons) |
|
13798 | 32 |
|
33 |
lemma mono_tokens: "mono tokens" |
|
34 |
apply (unfold mono_def) |
|
35 |
apply (blast intro: tokens_mono_prefix) |
|
36 |
done |
|
37 |
||
38 |
||
39 |
(** bag_of **) |
|
40 |
||
41 |
lemma bag_of_append [simp]: "bag_of (l@l') = bag_of l + bag_of l'" |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57418
diff
changeset
|
42 |
by (induct l) (simp_all add: ac_simps) |
13798 | 43 |
|
44 |
lemma mono_bag_of: "mono (bag_of :: 'a list => ('a::order) multiset)" |
|
45 |
apply (rule monoI) |
|
46 |
apply (unfold prefix_def) |
|
47 |
apply (erule genPrefix.induct, auto) |
|
48 |
apply (erule order_trans) |
|
35274 | 49 |
apply simp |
13798 | 50 |
done |
51 |
||
52 |
(** setsum **) |
|
53 |
||
57418 | 54 |
declare setsum.cong [cong] |
13798 | 55 |
|
56 |
lemma bag_of_sublist_lemma: |
|
15074 | 57 |
"(\<Sum>i\<in> A Int lessThan k. {#if i<k then f i else g i#}) = |
58 |
(\<Sum>i\<in> A Int lessThan k. {#f i#})" |
|
57418 | 59 |
by (rule setsum.cong, auto) |
13798 | 60 |
|
61 |
lemma bag_of_sublist: |
|
62 |
"bag_of (sublist l A) = |
|
15074 | 63 |
(\<Sum>i\<in> A Int lessThan (length l). {# l!i #})" |
13798 | 64 |
apply (rule_tac xs = l in rev_induct, simp) |
65 |
apply (simp add: sublist_append Int_insert_right lessThan_Suc nth_append |
|
57514
bdc2c6b40bf2
prefer ac_simps collections over separate name bindings for add and mult
haftmann
parents:
57418
diff
changeset
|
66 |
bag_of_sublist_lemma ac_simps) |
13798 | 67 |
done |
68 |
||
69 |
||
70 |
lemma bag_of_sublist_Un_Int: |
|
71 |
"bag_of (sublist l (A Un B)) + bag_of (sublist l (A Int B)) = |
|
72 |
bag_of (sublist l A) + bag_of (sublist l B)" |
|
15045 | 73 |
apply (subgoal_tac "A Int B Int {..<length l} = |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
24147
diff
changeset
|
74 |
(A Int {..<length l}) Int (B Int {..<length l}) ") |
57418 | 75 |
apply (simp add: bag_of_sublist Int_Un_distrib2 setsum.union_inter, blast) |
13798 | 76 |
done |
77 |
||
78 |
lemma bag_of_sublist_Un_disjoint: |
|
79 |
"A Int B = {} |
|
80 |
==> bag_of (sublist l (A Un B)) = |
|
81 |
bag_of (sublist l A) + bag_of (sublist l B)" |
|
14114 | 82 |
by (simp add: bag_of_sublist_Un_Int [symmetric]) |
13798 | 83 |
|
84 |
lemma bag_of_sublist_UN_disjoint [rule_format]: |
|
85 |
"[| finite I; ALL i:I. ALL j:I. i~=j --> A i Int A j = {} |] |
|
86 |
==> bag_of (sublist l (UNION I A)) = |
|
15074 | 87 |
(\<Sum>i\<in>I. bag_of (sublist l (A i)))" |
13798 | 88 |
apply (simp del: UN_simps |
89 |
add: UN_simps [symmetric] add: bag_of_sublist) |
|
57418 | 90 |
apply (subst setsum.UNION_disjoint, auto) |
13798 | 91 |
done |
92 |
||
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
93 |
end |