| author | wenzelm | 
| Wed, 21 Dec 2016 16:28:02 +0100 | |
| changeset 64645 | 0b513620d949 | 
| parent 64267 | b9a1486e79be | 
| child 65956 | 639eb3617a86 | 
| permissions | -rw-r--r-- | 
| 32960 
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
 wenzelm parents: 
24147diff
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: 
58889diff
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: 
63410diff
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 | |
| 64267 | 22 | lemma sum_fun_mono: | 
| 62608 | 23 | fixes f :: "nat \<Rightarrow> nat" | 
| 64267 | 24 |   shows "(\<And>i. i < n \<Longrightarrow> f i \<le> g i) \<Longrightarrow> sum f {..<n} \<le> sum g {..<n}"
 | 
| 62608 | 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: 
58889diff
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: 
63409diff
changeset | 44 | apply simp | 
| 13798 | 45 | done | 
| 46 | ||
| 64267 | 47 | (** sum **) | 
| 13798 | 48 | |
| 64267 | 49 | declare sum.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#})"
 | |
| 64267 | 54 | by (rule sum.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: 
57418diff
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: 
24147diff
changeset | 69 |                     (A Int {..<length l}) Int (B Int {..<length l}) ")
 | 
| 64267 | 70 | apply (simp add: bag_of_sublist Int_Un_distrib2 sum.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] | |
| 64267 | 85 | apply (subst sum.UNION_disjoint) | 
| 62608 | 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 |