| author | haftmann |
| Mon, 26 Sep 2016 07:56:54 +0200 | |
| changeset 63949 | e7e41db7221b |
| parent 63882 | 018998c00003 |
| child 64267 | b9a1486e79be |
| 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 |
|
| 63146 | 6 |
section\<open>Common Declarations for Chandy and Charpentier's Allocator\<close> |
| 13798 | 7 |
|
|
60397
f8a513fedb31
Renaming multiset operators < ~> <#,...
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
58889
diff
changeset
|
8 |
theory AllocBase imports "../UNITY_Main" "~~/src/HOL/Library/Multiset_Order" 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 |
|
| 62608 | 15 |
abbreviation (input) tokens :: "nat list \<Rightarrow> nat" |
16 |
where |
|
|
63882
018998c00003
renamed listsum -> sum_list, listprod ~> prod_list
nipkow
parents:
63410
diff
changeset
|
17 |
"tokens \<equiv> sum_list" |
|
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
18 |
|
| 62608 | 19 |
abbreviation (input) |
20 |
"bag_of \<equiv> mset" |
|
|
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
21 |
|
| 62608 | 22 |
lemma setsum_fun_mono: |
23 |
fixes f :: "nat \<Rightarrow> nat" |
|
24 |
shows "(\<And>i. i < n \<Longrightarrow> f i \<le> g i) \<Longrightarrow> setsum f {..<n} \<le> setsum g {..<n}"
|
|
25 |
by (induct n) (auto simp add: lessThan_Suc add_le_mono) |
|
| 13798 | 26 |
|
| 62608 | 27 |
lemma tokens_mono_prefix: "xs \<le> ys \<Longrightarrow> tokens xs \<le> tokens ys" |
| 46911 | 28 |
by (induct ys arbitrary: xs) (auto simp add: prefix_Cons) |
| 13798 | 29 |
|
30 |
lemma mono_tokens: "mono tokens" |
|
| 62608 | 31 |
using tokens_mono_prefix by (rule monoI) |
| 13798 | 32 |
|
33 |
||
34 |
(** bag_of **) |
|
35 |
||
36 |
lemma bag_of_append [simp]: "bag_of (l@l') = bag_of l + bag_of l'" |
|
| 62608 | 37 |
by (fact mset_append) |
| 13798 | 38 |
|
39 |
lemma mono_bag_of: "mono (bag_of :: 'a list => ('a::order) multiset)"
|
|
40 |
apply (rule monoI) |
|
41 |
apply (unfold prefix_def) |
|
|
60397
f8a513fedb31
Renaming multiset operators < ~> <#,...
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
58889
diff
changeset
|
42 |
apply (erule genPrefix.induct, simp_all add: add_right_mono) |
| 13798 | 43 |
apply (erule order_trans) |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
44 |
apply simp |
| 13798 | 45 |
done |
46 |
||
47 |
(** setsum **) |
|
48 |
||
| 57418 | 49 |
declare setsum.cong [cong] |
| 13798 | 50 |
|
51 |
lemma bag_of_sublist_lemma: |
|
| 15074 | 52 |
"(\<Sum>i\<in> A Int lessThan k. {#if i<k then f i else g i#}) =
|
53 |
(\<Sum>i\<in> A Int lessThan k. {#f i#})"
|
|
| 57418 | 54 |
by (rule setsum.cong, auto) |
| 13798 | 55 |
|
56 |
lemma bag_of_sublist: |
|
57 |
"bag_of (sublist l A) = |
|
| 15074 | 58 |
(\<Sum>i\<in> A Int lessThan (length l). {# l!i #})"
|
| 13798 | 59 |
apply (rule_tac xs = l in rev_induct, simp) |
60 |
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
|
61 |
bag_of_sublist_lemma ac_simps) |
| 13798 | 62 |
done |
63 |
||
64 |
||
65 |
lemma bag_of_sublist_Un_Int: |
|
66 |
"bag_of (sublist l (A Un B)) + bag_of (sublist l (A Int B)) = |
|
67 |
bag_of (sublist l A) + bag_of (sublist l B)" |
|
| 15045 | 68 |
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
|
69 |
(A Int {..<length l}) Int (B Int {..<length l}) ")
|
| 57418 | 70 |
apply (simp add: bag_of_sublist Int_Un_distrib2 setsum.union_inter, blast) |
| 13798 | 71 |
done |
72 |
||
73 |
lemma bag_of_sublist_Un_disjoint: |
|
74 |
"A Int B = {}
|
|
75 |
==> bag_of (sublist l (A Un B)) = |
|
76 |
bag_of (sublist l A) + bag_of (sublist l B)" |
|
| 14114 | 77 |
by (simp add: bag_of_sublist_Un_Int [symmetric]) |
| 13798 | 78 |
|
79 |
lemma bag_of_sublist_UN_disjoint [rule_format]: |
|
80 |
"[| finite I; ALL i:I. ALL j:I. i~=j --> A i Int A j = {} |]
|
|
81 |
==> bag_of (sublist l (UNION I A)) = |
|
| 15074 | 82 |
(\<Sum>i\<in>I. bag_of (sublist l (A i)))" |
| 62608 | 83 |
apply (auto simp add: bag_of_sublist) |
84 |
unfolding UN_simps [symmetric] |
|
85 |
apply (subst setsum.UNION_disjoint) |
|
86 |
apply auto |
|
| 13798 | 87 |
done |
88 |
||
|
11194
ea13ff5a26d1
reorganization of HOL/UNITY, moving examples to subdirectories Simple and Comp
paulson
parents:
diff
changeset
|
89 |
end |