| author | wenzelm | 
| Thu, 02 Feb 2006 12:52:16 +0100 | |
| changeset 18892 | 51360da418b2 | 
| parent 18415 | eb68dc98bda2 | 
| child 20898 | 113c9516a2d7 | 
| permissions | -rw-r--r-- | 
| 12610 | 1 | (* Title: ZF/Induct/Multiset.thy | 
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 2 | ID: $Id$ | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 3 | Author: Sidi O Ehmety, Cambridge University Computer Laboratory | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 4 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 5 | A definitional theory of multisets, | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 6 | including a wellfoundedness proof for the multiset order. | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 7 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 8 | The theory features ordinal multisets and the usual ordering. | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 9 | *) | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 10 | |
| 15201 | 11 | theory Multiset | 
| 12 | imports FoldSet Acc | |
| 13 | begin | |
| 14 | ||
| 12860 
7fc3fbfed8ef
  Multiset:  added the translation Mult(A) => A-||>nat-{0}
 paulson parents: 
12610diff
changeset | 15 | consts | 
| 
7fc3fbfed8ef
  Multiset:  added the translation Mult(A) => A-||>nat-{0}
 paulson parents: 
12610diff
changeset | 16 | (* Short cut for multiset space *) | 
| 15201 | 17 | Mult :: "i=>i" | 
| 18 | translations | |
| 14046 | 19 |   "Mult(A)" => "A -||> nat-{0}"
 | 
| 15201 | 20 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 21 | constdefs | 
| 15201 | 22 | |
| 12891 | 23 | (* This is the original "restrict" from ZF.thy. | 
| 15201 | 24 | Restricts the function f to the domain A | 
| 12891 | 25 | FIXME: adapt Multiset to the new "restrict". *) | 
| 26 | ||
| 27 | funrestrict :: "[i,i] => i" | |
| 15201 | 28 | "funrestrict(f,A) == \<lambda>x \<in> A. f`x" | 
| 12891 | 29 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 30 | (* M is a multiset *) | 
| 15201 | 31 | multiset :: "i => o" | 
| 32 |   "multiset(M) == \<exists>A. M \<in> A -> nat-{0} & Finite(A)"
 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 33 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 34 | mset_of :: "i=>i" | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 35 | "mset_of(M) == domain(M)" | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 36 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 37 | munion :: "[i, i] => i" (infixl "+#" 65) | 
| 15201 | 38 | "M +# N == \<lambda>x \<in> mset_of(M) Un mset_of(N). | 
| 39 | if x \<in> mset_of(M) Int mset_of(N) then (M`x) #+ (N`x) | |
| 40 | else (if x \<in> mset_of(M) then M`x else N`x)" | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 41 | |
| 14046 | 42 | (*convert a function to a multiset by eliminating 0*) | 
| 15201 | 43 | normalize :: "i => i" | 
| 14046 | 44 | "normalize(f) == | 
| 15201 | 45 | if (\<exists>A. f \<in> A -> nat & Finite(A)) then | 
| 46 |             funrestrict(f, {x \<in> mset_of(f). 0 < f`x})
 | |
| 14046 | 47 | else 0" | 
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 48 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 49 | mdiff :: "[i, i] => i" (infixl "-#" 65) | 
| 15201 | 50 | "M -# N == normalize(\<lambda>x \<in> mset_of(M). | 
| 51 | if x \<in> mset_of(N) then M`x #- N`x else M`x)" | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 52 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 53 | (* set of elements of a multiset *) | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 54 |   msingle :: "i => i"    ("{#_#}")
 | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 55 |   "{#a#} == {<a, 1>}"
 | 
| 15201 | 56 | |
| 57 | MCollect :: "[i, i=>o] => i" (*comprehension*) | |
| 58 |   "MCollect(M, P) == funrestrict(M, {x \<in> mset_of(M). P(x)})"
 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 59 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 60 | (* Counts the number of occurences of an element in a multiset *) | 
| 15201 | 61 | mcount :: "[i, i] => i" | 
| 62 | "mcount(M, a) == if a \<in> mset_of(M) then M`a else 0" | |
| 63 | ||
| 64 | msize :: "i => i" | |
| 65 | "msize(M) == setsum(%a. $# mcount(M,a), mset_of(M))" | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 66 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 67 | syntax | 
| 15201 | 68 |   melem :: "[i,i] => o"    ("(_/ :# _)" [50, 51] 50)
 | 
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 69 |   "@MColl" :: "[pttrn, i, o] => i" ("(1{# _ : _./ _#})")
 | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 70 | |
| 15201 | 71 | syntax (xsymbols) | 
| 72 |   "@MColl" :: "[pttrn, i, o] => i" ("(1{# _ \<in> _./ _#})")
 | |
| 73 | ||
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 74 | translations | 
| 15201 | 75 | "a :# M" == "a \<in> mset_of(M)" | 
| 76 |   "{#x \<in> M. P#}" == "MCollect(M, %x. P)"
 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 77 | |
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 78 | (* multiset orderings *) | 
| 15201 | 79 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 80 | constdefs | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 81 | (* multirel1 has to be a set (not a predicate) so that we can form | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 82 | its transitive closure and reason about wf(.) and acc(.) *) | 
| 15201 | 83 | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 84 | multirel1 :: "[i,i]=>i" | 
| 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 85 | "multirel1(A, r) == | 
| 15201 | 86 |      {<M, N> \<in> Mult(A)*Mult(A).
 | 
| 87 | \<exists>a \<in> A. \<exists>M0 \<in> Mult(A). \<exists>K \<in> Mult(A). | |
| 88 |       N=M0 +# {#a#} & M=M0 +# K & (\<forall>b \<in> mset_of(K). <b,a> \<in> r)}"
 | |
| 89 | ||
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 90 | multirel :: "[i, i] => i" | 
| 15201 | 91 | "multirel(A, r) == multirel1(A, r)^+" | 
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 92 | |
| 12860 
7fc3fbfed8ef
  Multiset:  added the translation Mult(A) => A-||>nat-{0}
 paulson parents: 
12610diff
changeset | 93 | (* ordinal multiset orderings *) | 
| 15201 | 94 | |
| 95 | omultiset :: "i => o" | |
| 96 | "omultiset(M) == \<exists>i. Ord(i) & M \<in> Mult(field(Memrel(i)))" | |
| 97 | ||
| 98 | mless :: "[i, i] => o" (infixl "<#" 50) | |
| 99 | "M <# N == \<exists>i. Ord(i) & <M, N> \<in> multirel(field(Memrel(i)), Memrel(i))" | |
| 100 | ||
| 101 | mle :: "[i, i] => o" (infixl "<#=" 50) | |
| 102 | "M <#= N == (omultiset(M) & M = N) | M <# N" | |
| 103 | ||
| 104 | ||
| 105 | subsection{*Properties of the original "restrict" from ZF.thy*}
 | |
| 106 | ||
| 107 | lemma funrestrict_subset: "[| f \<in> Pi(C,B); A\<subseteq>C |] ==> funrestrict(f,A) \<subseteq> f" | |
| 108 | by (auto simp add: funrestrict_def lam_def intro: apply_Pair) | |
| 109 | ||
| 110 | lemma funrestrict_type: | |
| 111 | "[| !!x. x \<in> A ==> f`x \<in> B(x) |] ==> funrestrict(f,A) \<in> Pi(A,B)" | |
| 112 | by (simp add: funrestrict_def lam_type) | |
| 113 | ||
| 114 | lemma funrestrict_type2: "[| f \<in> Pi(C,B); A\<subseteq>C |] ==> funrestrict(f,A) \<in> Pi(A,B)" | |
| 115 | by (blast intro: apply_type funrestrict_type) | |
| 116 | ||
| 117 | lemma funrestrict [simp]: "a \<in> A ==> funrestrict(f,A) ` a = f`a" | |
| 118 | by (simp add: funrestrict_def) | |
| 119 | ||
| 120 | lemma funrestrict_empty [simp]: "funrestrict(f,0) = 0" | |
| 121 | by (simp add: funrestrict_def) | |
| 122 | ||
| 123 | lemma domain_funrestrict [simp]: "domain(funrestrict(f,C)) = C" | |
| 124 | by (auto simp add: funrestrict_def lam_def) | |
| 125 | ||
| 126 | lemma fun_cons_funrestrict_eq: | |
| 127 | "f \<in> cons(a, b) -> B ==> f = cons(<a, f ` a>, funrestrict(f, b))" | |
| 128 | apply (rule equalityI) | |
| 129 | prefer 2 apply (blast intro: apply_Pair funrestrict_subset [THEN subsetD]) | |
| 130 | apply (auto dest!: Pi_memberD simp add: funrestrict_def lam_def) | |
| 131 | done | |
| 132 | ||
| 133 | declare domain_of_fun [simp] | |
| 134 | declare domainE [rule del] | |
| 135 | ||
| 136 | ||
| 137 | text{* A useful simplification rule *}
 | |
| 138 | lemma multiset_fun_iff: | |
| 139 |      "(f \<in> A -> nat-{0}) <-> f \<in> A->nat&(\<forall>a \<in> A. f`a \<in> nat & 0 < f`a)"
 | |
| 140 | apply safe | |
| 141 | apply (rule_tac [4] B1 = "range (f) " in Pi_mono [THEN subsetD]) | |
| 142 | apply (auto intro!: Ord_0_lt | |
| 143 | dest: apply_type Diff_subset [THEN Pi_mono, THEN subsetD] | |
| 144 | simp add: range_of_fun apply_iff) | |
| 145 | done | |
| 146 | ||
| 147 | (** The multiset space **) | |
| 148 | lemma multiset_into_Mult: "[| multiset(M); mset_of(M)\<subseteq>A |] ==> M \<in> Mult(A)" | |
| 149 | apply (simp add: multiset_def) | |
| 150 | apply (auto simp add: multiset_fun_iff mset_of_def) | |
| 151 | apply (rule_tac B1 = "nat-{0}" in FiniteFun_mono [THEN subsetD], simp_all)
 | |
| 152 | apply (rule Finite_into_Fin [THEN [2] Fin_mono [THEN subsetD], THEN fun_FiniteFunI]) | |
| 153 | apply (simp_all (no_asm_simp) add: multiset_fun_iff) | |
| 154 | done | |
| 155 | ||
| 156 | lemma Mult_into_multiset: "M \<in> Mult(A) ==> multiset(M) & mset_of(M)\<subseteq>A" | |
| 157 | apply (simp add: multiset_def mset_of_def) | |
| 158 | apply (frule FiniteFun_is_fun) | |
| 159 | apply (drule FiniteFun_domain_Fin) | |
| 160 | apply (frule FinD, clarify) | |
| 161 | apply (rule_tac x = "domain (M) " in exI) | |
| 162 | apply (blast intro: Fin_into_Finite) | |
| 163 | done | |
| 164 | ||
| 165 | lemma Mult_iff_multiset: "M \<in> Mult(A) <-> multiset(M) & mset_of(M)\<subseteq>A" | |
| 166 | by (blast dest: Mult_into_multiset intro: multiset_into_Mult) | |
| 167 | ||
| 168 | lemma multiset_iff_Mult_mset_of: "multiset(M) <-> M \<in> Mult(mset_of(M))" | |
| 169 | by (auto simp add: Mult_iff_multiset) | |
| 170 | ||
| 171 | ||
| 172 | text{*The @{term multiset} operator*}
 | |
| 173 | ||
| 174 | (* the empty multiset is 0 *) | |
| 175 | ||
| 176 | lemma multiset_0 [simp]: "multiset(0)" | |
| 177 | by (auto intro: FiniteFun.intros simp add: multiset_iff_Mult_mset_of) | |
| 178 | ||
| 179 | ||
| 180 | text{*The @{term mset_of} operator*}
 | |
| 181 | ||
| 182 | lemma multiset_set_of_Finite [simp]: "multiset(M) ==> Finite(mset_of(M))" | |
| 183 | by (simp add: multiset_def mset_of_def, auto) | |
| 184 | ||
| 185 | lemma mset_of_0 [iff]: "mset_of(0) = 0" | |
| 186 | by (simp add: mset_of_def) | |
| 187 | ||
| 188 | lemma mset_is_0_iff: "multiset(M) ==> mset_of(M)=0 <-> M=0" | |
| 189 | by (auto simp add: multiset_def mset_of_def) | |
| 190 | ||
| 191 | lemma mset_of_single [iff]: "mset_of({#a#}) = {a}"
 | |
| 192 | by (simp add: msingle_def mset_of_def) | |
| 193 | ||
| 194 | lemma mset_of_union [iff]: "mset_of(M +# N) = mset_of(M) Un mset_of(N)" | |
| 195 | by (simp add: mset_of_def munion_def) | |
| 196 | ||
| 197 | lemma mset_of_diff [simp]: "mset_of(M)\<subseteq>A ==> mset_of(M -# N) \<subseteq> A" | |
| 198 | by (auto simp add: mdiff_def multiset_def normalize_def mset_of_def) | |
| 199 | ||
| 200 | (* msingle *) | |
| 201 | ||
| 202 | lemma msingle_not_0 [iff]: "{#a#} \<noteq> 0 & 0 \<noteq> {#a#}"
 | |
| 203 | by (simp add: msingle_def) | |
| 204 | ||
| 205 | lemma msingle_eq_iff [iff]: "({#a#} = {#b#}) <->  (a = b)"
 | |
| 206 | by (simp add: msingle_def) | |
| 207 | ||
| 208 | lemma msingle_multiset [iff,TC]: "multiset({#a#})"
 | |
| 209 | apply (simp add: multiset_def msingle_def) | |
| 210 | apply (rule_tac x = "{a}" in exI)
 | |
| 211 | apply (auto intro: Finite_cons Finite_0 fun_extend3) | |
| 212 | done | |
| 213 | ||
| 214 | (** normalize **) | |
| 215 | ||
| 216 | lemmas Collect_Finite = Collect_subset [THEN subset_Finite, standard] | |
| 217 | ||
| 218 | lemma normalize_idem [simp]: "normalize(normalize(f)) = normalize(f)" | |
| 219 | apply (simp add: normalize_def funrestrict_def mset_of_def) | |
| 220 | apply (case_tac "\<exists>A. f \<in> A -> nat & Finite (A) ") | |
| 221 | apply clarify | |
| 222 | apply (drule_tac x = "{x \<in> domain (f) . 0 < f ` x}" in spec)
 | |
| 223 | apply auto | |
| 224 | apply (auto intro!: lam_type simp add: Collect_Finite) | |
| 225 | done | |
| 226 | ||
| 227 | lemma normalize_multiset [simp]: "multiset(M) ==> normalize(M) = M" | |
| 228 | by (auto simp add: multiset_def normalize_def mset_of_def funrestrict_def multiset_fun_iff) | |
| 229 | ||
| 230 | lemma multiset_normalize [simp]: "multiset(normalize(f))" | |
| 231 | apply (simp add: normalize_def) | |
| 232 | apply (simp add: normalize_def mset_of_def multiset_def, auto) | |
| 233 | apply (rule_tac x = "{x \<in> A . 0<f`x}" in exI)
 | |
| 234 | apply (auto intro: Collect_subset [THEN subset_Finite] funrestrict_type) | |
| 235 | done | |
| 236 | ||
| 237 | (** Typechecking rules for union and difference of multisets **) | |
| 238 | ||
| 239 | (* union *) | |
| 240 | ||
| 241 | lemma munion_multiset [simp]: "[| multiset(M); multiset(N) |] ==> multiset(M +# N)" | |
| 242 | apply (unfold multiset_def munion_def mset_of_def, auto) | |
| 243 | apply (rule_tac x = "A Un Aa" in exI) | |
| 244 | apply (auto intro!: lam_type intro: Finite_Un simp add: multiset_fun_iff zero_less_add) | |
| 245 | done | |
| 246 | ||
| 247 | (* difference *) | |
| 248 | ||
| 249 | lemma mdiff_multiset [simp]: "multiset(M -# N)" | |
| 250 | by (simp add: mdiff_def) | |
| 251 | ||
| 252 | (** Algebraic properties of multisets **) | |
| 253 | ||
| 254 | (* Union *) | |
| 255 | ||
| 256 | lemma munion_0 [simp]: "multiset(M) ==> M +# 0 = M & 0 +# M = M" | |
| 257 | apply (simp add: multiset_def) | |
| 258 | apply (auto simp add: munion_def mset_of_def) | |
| 259 | done | |
| 260 | ||
| 261 | lemma munion_commute: "M +# N = N +# M" | |
| 262 | by (auto intro!: lam_cong simp add: munion_def) | |
| 263 | ||
| 264 | lemma munion_assoc: "(M +# N) +# K = M +# (N +# K)" | |
| 265 | apply (unfold munion_def mset_of_def) | |
| 266 | apply (rule lam_cong, auto) | |
| 267 | done | |
| 268 | ||
| 269 | lemma munion_lcommute: "M +# (N +# K) = N +# (M +# K)" | |
| 270 | apply (unfold munion_def mset_of_def) | |
| 271 | apply (rule lam_cong, auto) | |
| 272 | done | |
| 273 | ||
| 274 | lemmas munion_ac = munion_commute munion_assoc munion_lcommute | |
| 275 | ||
| 276 | (* Difference *) | |
| 277 | ||
| 278 | lemma mdiff_self_eq_0 [simp]: "M -# M = 0" | |
| 279 | by (simp add: mdiff_def normalize_def mset_of_def) | |
| 280 | ||
| 281 | lemma mdiff_0 [simp]: "0 -# M = 0" | |
| 282 | by (simp add: mdiff_def normalize_def) | |
| 283 | ||
| 284 | lemma mdiff_0_right [simp]: "multiset(M) ==> M -# 0 = M" | |
| 285 | by (auto simp add: multiset_def mdiff_def normalize_def multiset_fun_iff mset_of_def funrestrict_def) | |
| 286 | ||
| 287 | lemma mdiff_union_inverse2 [simp]: "multiset(M) ==> M +# {#a#} -# {#a#} = M"
 | |
| 288 | apply (unfold multiset_def munion_def mdiff_def msingle_def normalize_def mset_of_def) | |
| 289 | apply (auto cong add: if_cong simp add: ltD multiset_fun_iff funrestrict_def subset_Un_iff2 [THEN iffD1]) | |
| 290 | prefer 2 apply (force intro!: lam_type) | |
| 291 | apply (subgoal_tac [2] "{x \<in> A \<union> {a} . x \<noteq> a \<and> x \<in> A} = A")
 | |
| 292 | apply (rule fun_extension, auto) | |
| 293 | apply (drule_tac x = "A Un {a}" in spec)
 | |
| 294 | apply (simp add: Finite_Un) | |
| 295 | apply (force intro!: lam_type) | |
| 296 | done | |
| 297 | ||
| 298 | (** Count of elements **) | |
| 299 | ||
| 300 | lemma mcount_type [simp,TC]: "multiset(M) ==> mcount(M, a) \<in> nat" | |
| 301 | by (auto simp add: multiset_def mcount_def mset_of_def multiset_fun_iff) | |
| 302 | ||
| 303 | lemma mcount_0 [simp]: "mcount(0, a) = 0" | |
| 304 | by (simp add: mcount_def) | |
| 305 | ||
| 306 | lemma mcount_single [simp]: "mcount({#b#}, a) = (if a=b then 1 else 0)"
 | |
| 307 | by (simp add: mcount_def mset_of_def msingle_def) | |
| 308 | ||
| 309 | lemma mcount_union [simp]: "[| multiset(M); multiset(N) |] | |
| 310 | ==> mcount(M +# N, a) = mcount(M, a) #+ mcount (N, a)" | |
| 311 | apply (auto simp add: multiset_def multiset_fun_iff mcount_def munion_def mset_of_def) | |
| 312 | done | |
| 313 | ||
| 314 | lemma mcount_diff [simp]: | |
| 315 | "multiset(M) ==> mcount(M -# N, a) = mcount(M, a) #- mcount(N, a)" | |
| 316 | apply (simp add: multiset_def) | |
| 317 | apply (auto dest!: not_lt_imp_le | |
| 318 | simp add: mdiff_def multiset_fun_iff mcount_def normalize_def mset_of_def) | |
| 319 | apply (force intro!: lam_type) | |
| 320 | apply (force intro!: lam_type) | |
| 321 | done | |
| 322 | ||
| 323 | lemma mcount_elem: "[| multiset(M); a \<in> mset_of(M) |] ==> 0 < mcount(M, a)" | |
| 324 | apply (simp add: multiset_def, clarify) | |
| 325 | apply (simp add: mcount_def mset_of_def) | |
| 326 | apply (simp add: multiset_fun_iff) | |
| 327 | done | |
| 328 | ||
| 329 | (** msize **) | |
| 330 | ||
| 331 | lemma msize_0 [simp]: "msize(0) = #0" | |
| 332 | by (simp add: msize_def) | |
| 333 | ||
| 334 | lemma msize_single [simp]: "msize({#a#}) = #1"
 | |
| 335 | by (simp add: msize_def) | |
| 336 | ||
| 337 | lemma msize_type [simp,TC]: "msize(M) \<in> int" | |
| 338 | by (simp add: msize_def) | |
| 339 | ||
| 340 | lemma msize_zpositive: "multiset(M)==> #0 $\<le> msize(M)" | |
| 341 | by (auto simp add: msize_def intro: g_zpos_imp_setsum_zpos) | |
| 342 | ||
| 343 | lemma msize_int_of_nat: "multiset(M) ==> \<exists>n \<in> nat. msize(M)= $# n" | |
| 344 | apply (rule not_zneg_int_of) | |
| 345 | apply (simp_all (no_asm_simp) add: msize_type [THEN znegative_iff_zless_0] not_zless_iff_zle msize_zpositive) | |
| 346 | done | |
| 347 | ||
| 348 | lemma not_empty_multiset_imp_exist: | |
| 349 | "[| M\<noteq>0; multiset(M) |] ==> \<exists>a \<in> mset_of(M). 0 < mcount(M, a)" | |
| 350 | apply (simp add: multiset_def) | |
| 351 | apply (erule not_emptyE) | |
| 352 | apply (auto simp add: mset_of_def mcount_def multiset_fun_iff) | |
| 353 | apply (blast dest!: fun_is_rel) | |
| 354 | done | |
| 355 | ||
| 356 | lemma msize_eq_0_iff: "multiset(M) ==> msize(M)=#0 <-> M=0" | |
| 357 | apply (simp add: msize_def, auto) | |
| 358 | apply (rule_tac Pa = "setsum (?u,?v) \<noteq> #0" in swap) | |
| 359 | apply blast | |
| 360 | apply (drule not_empty_multiset_imp_exist, assumption, clarify) | |
| 361 | apply (subgoal_tac "Finite (mset_of (M) - {a}) ")
 | |
| 362 | prefer 2 apply (simp add: Finite_Diff) | |
| 363 | apply (subgoal_tac "setsum (%x. $# mcount (M, x), cons (a, mset_of (M) -{a}))=#0")
 | |
| 364 | prefer 2 apply (simp add: cons_Diff, simp) | |
| 365 | apply (subgoal_tac "#0 $\<le> setsum (%x. $# mcount (M, x), mset_of (M) - {a}) ")
 | |
| 366 | apply (rule_tac [2] g_zpos_imp_setsum_zpos) | |
| 367 | apply (auto simp add: Finite_Diff not_zless_iff_zle [THEN iff_sym] znegative_iff_zless_0 [THEN iff_sym]) | |
| 368 | apply (rule not_zneg_int_of [THEN bexE]) | |
| 369 | apply (auto simp del: int_of_0 simp add: int_of_add [symmetric] int_of_0 [symmetric]) | |
| 370 | done | |
| 371 | ||
| 372 | lemma setsum_mcount_Int: | |
| 373 | "Finite(A) ==> setsum(%a. $# mcount(N, a), A Int mset_of(N)) | |
| 374 | = setsum(%a. $# mcount(N, a), A)" | |
| 18415 | 375 | apply (induct rule: Finite_induct) | 
| 376 | apply auto | |
| 15201 | 377 | apply (subgoal_tac "Finite (B Int mset_of (N))") | 
| 378 | prefer 2 apply (blast intro: subset_Finite) | |
| 379 | apply (auto simp add: mcount_def Int_cons_left) | |
| 380 | done | |
| 381 | ||
| 382 | lemma msize_union [simp]: | |
| 383 | "[| multiset(M); multiset(N) |] ==> msize(M +# N) = msize(M) $+ msize(N)" | |
| 384 | apply (simp add: msize_def setsum_Un setsum_addf int_of_add setsum_mcount_Int) | |
| 385 | apply (subst Int_commute) | |
| 386 | apply (simp add: setsum_mcount_Int) | |
| 387 | done | |
| 388 | ||
| 389 | lemma msize_eq_succ_imp_elem: "[|msize(M)= $# succ(n); n \<in> nat|] ==> \<exists>a. a \<in> mset_of(M)" | |
| 390 | apply (unfold msize_def) | |
| 391 | apply (blast dest: setsum_succD) | |
| 392 | done | |
| 393 | ||
| 394 | (** Equality of multisets **) | |
| 395 | ||
| 396 | lemma equality_lemma: | |
| 397 | "[| multiset(M); multiset(N); \<forall>a. mcount(M, a)=mcount(N, a) |] | |
| 398 | ==> mset_of(M)=mset_of(N)" | |
| 399 | apply (simp add: multiset_def) | |
| 400 | apply (rule sym, rule equalityI) | |
| 401 | apply (auto simp add: multiset_fun_iff mcount_def mset_of_def) | |
| 402 | apply (drule_tac [!] x=x in spec) | |
| 403 | apply (case_tac [2] "x \<in> Aa", case_tac "x \<in> A", auto) | |
| 404 | done | |
| 405 | ||
| 406 | lemma multiset_equality: | |
| 407 | "[| multiset(M); multiset(N) |]==> M=N<->(\<forall>a. mcount(M, a)=mcount(N, a))" | |
| 408 | apply auto | |
| 409 | apply (subgoal_tac "mset_of (M) = mset_of (N) ") | |
| 410 | prefer 2 apply (blast intro: equality_lemma) | |
| 411 | apply (simp add: multiset_def mset_of_def) | |
| 412 | apply (auto simp add: multiset_fun_iff) | |
| 413 | apply (rule fun_extension) | |
| 414 | apply (blast, blast) | |
| 415 | apply (drule_tac x = x in spec) | |
| 416 | apply (auto simp add: mcount_def mset_of_def) | |
| 417 | done | |
| 418 | ||
| 419 | (** More algebraic properties of multisets **) | |
| 420 | ||
| 421 | lemma munion_eq_0_iff [simp]: "[|multiset(M); multiset(N)|]==>(M +# N =0) <-> (M=0 & N=0)" | |
| 422 | by (auto simp add: multiset_equality) | |
| 423 | ||
| 424 | lemma empty_eq_munion_iff [simp]: "[|multiset(M); multiset(N)|]==>(0=M +# N) <-> (M=0 & N=0)" | |
| 425 | apply (rule iffI, drule sym) | |
| 426 | apply (simp_all add: multiset_equality) | |
| 427 | done | |
| 428 | ||
| 429 | lemma munion_right_cancel [simp]: | |
| 430 | "[| multiset(M); multiset(N); multiset(K) |]==>(M +# K = N +# K)<->(M=N)" | |
| 431 | by (auto simp add: multiset_equality) | |
| 432 | ||
| 433 | lemma munion_left_cancel [simp]: | |
| 434 | "[|multiset(K); multiset(M); multiset(N)|] ==>(K +# M = K +# N) <-> (M = N)" | |
| 435 | by (auto simp add: multiset_equality) | |
| 436 | ||
| 437 | lemma nat_add_eq_1_cases: "[| m \<in> nat; n \<in> nat |] ==> (m #+ n = 1) <-> (m=1 & n=0) | (m=0 & n=1)" | |
| 18415 | 438 | by (induct_tac n) auto | 
| 15201 | 439 | |
| 440 | lemma munion_is_single: | |
| 441 | "[|multiset(M); multiset(N)|] | |
| 442 |       ==> (M +# N = {#a#}) <->  (M={#a#} & N=0) | (M = 0 & N = {#a#})"
 | |
| 443 | apply (simp (no_asm_simp) add: multiset_equality) | |
| 444 | apply safe | |
| 445 | apply simp_all | |
| 446 | apply (case_tac "aa=a") | |
| 447 | apply (drule_tac [2] x = aa in spec) | |
| 448 | apply (drule_tac x = a in spec) | |
| 449 | apply (simp add: nat_add_eq_1_cases, simp) | |
| 450 | apply (case_tac "aaa=aa", simp) | |
| 451 | apply (drule_tac x = aa in spec) | |
| 452 | apply (simp add: nat_add_eq_1_cases) | |
| 453 | apply (case_tac "aaa=a") | |
| 454 | apply (drule_tac [4] x = aa in spec) | |
| 455 | apply (drule_tac [3] x = a in spec) | |
| 456 | apply (drule_tac [2] x = aaa in spec) | |
| 457 | apply (drule_tac x = aa in spec) | |
| 458 | apply (simp_all add: nat_add_eq_1_cases) | |
| 459 | done | |
| 460 | ||
| 461 | lemma msingle_is_union: "[| multiset(M); multiset(N) |] | |
| 462 |   ==> ({#a#} = M +# N) <-> ({#a#} = M  & N=0 | M = 0 & {#a#} = N)"
 | |
| 463 | apply (subgoal_tac " ({#a#} = M +# N) <-> (M +# N = {#a#}) ")
 | |
| 464 | apply (simp (no_asm_simp) add: munion_is_single) | |
| 465 | apply blast | |
| 466 | apply (blast dest: sym) | |
| 467 | done | |
| 468 | ||
| 469 | (** Towards induction over multisets **) | |
| 470 | ||
| 471 | lemma setsum_decr: | |
| 472 | "Finite(A) | |
| 473 | ==> (\<forall>M. multiset(M) --> | |
| 474 | (\<forall>a \<in> mset_of(M). setsum(%z. $# mcount(M(a:=M`a #- 1), z), A) = | |
| 475 | (if a \<in> A then setsum(%z. $# mcount(M, z), A) $- #1 | |
| 476 | else setsum(%z. $# mcount(M, z), A))))" | |
| 477 | apply (unfold multiset_def) | |
| 478 | apply (erule Finite_induct) | |
| 479 | apply (auto simp add: multiset_fun_iff) | |
| 480 | apply (unfold mset_of_def mcount_def) | |
| 481 | apply (case_tac "x \<in> A", auto) | |
| 482 | apply (subgoal_tac "$# M ` x $+ #-1 = $# M ` x $- $# 1") | |
| 483 | apply (erule ssubst) | |
| 484 | apply (rule int_of_diff, auto) | |
| 485 | done | |
| 486 | ||
| 487 | lemma setsum_decr2: | |
| 488 | "Finite(A) | |
| 489 | ==> \<forall>M. multiset(M) --> (\<forall>a \<in> mset_of(M). | |
| 16973 | 490 |            setsum(%x. $# mcount(funrestrict(M, mset_of(M)-{a}), x), A) =
 | 
| 491 | (if a \<in> A then setsum(%x. $# mcount(M, x), A) $- $# M`a | |
| 492 | else setsum(%x. $# mcount(M, x), A)))" | |
| 15201 | 493 | apply (simp add: multiset_def) | 
| 494 | apply (erule Finite_induct) | |
| 495 | apply (auto simp add: multiset_fun_iff mcount_def mset_of_def) | |
| 496 | done | |
| 497 | ||
| 498 | lemma setsum_decr3: "[| Finite(A); multiset(M); a \<in> mset_of(M) |] | |
| 499 |       ==> setsum(%x. $# mcount(funrestrict(M, mset_of(M)-{a}), x), A - {a}) =
 | |
| 500 | (if a \<in> A then setsum(%x. $# mcount(M, x), A) $- $# M`a | |
| 501 | else setsum(%x. $# mcount(M, x), A))" | |
| 502 | apply (subgoal_tac "setsum (%x. $# mcount (funrestrict (M, mset_of (M) -{a}),x),A-{a}) = setsum (%x. $# mcount (funrestrict (M, mset_of (M) -{a}),x),A) ")
 | |
| 503 | apply (rule_tac [2] setsum_Diff [symmetric]) | |
| 504 | apply (rule sym, rule ssubst, blast) | |
| 505 | apply (rule sym, drule setsum_decr2, auto) | |
| 506 | apply (simp add: mcount_def mset_of_def) | |
| 507 | done | |
| 508 | ||
| 509 | lemma nat_le_1_cases: "n \<in> nat ==> n le 1 <-> (n=0 | n=1)" | |
| 510 | by (auto elim: natE) | |
| 511 | ||
| 512 | lemma succ_pred_eq_self: "[| 0<n; n \<in> nat |] ==> succ(n #- 1) = n" | |
| 513 | apply (subgoal_tac "1 le n") | |
| 514 | apply (drule add_diff_inverse2, auto) | |
| 515 | done | |
| 516 | ||
| 517 | text{*Specialized for use in the proof below.*}
 | |
| 518 | lemma multiset_funrestict: | |
| 519 | "\<lbrakk>\<forall>a\<in>A. M ` a \<in> nat \<and> 0 < M ` a; Finite(A)\<rbrakk> | |
| 520 |       \<Longrightarrow> multiset(funrestrict(M, A - {a}))"
 | |
| 521 | apply (simp add: multiset_def multiset_fun_iff) | |
| 522 | apply (rule_tac x="A-{a}" in exI)
 | |
| 523 | apply (auto intro: Finite_Diff funrestrict_type) | |
| 524 | done | |
| 525 | ||
| 526 | lemma multiset_induct_aux: | |
| 527 | assumes prem1: "!!M a. [| multiset(M); a\<notin>mset_of(M); P(M) |] ==> P(cons(<a, 1>, M))" | |
| 528 | and prem2: "!!M b. [| multiset(M); b \<in> mset_of(M); P(M) |] ==> P(M(b:= M`b #+ 1))" | |
| 529 | shows | |
| 530 | "[| n \<in> nat; P(0) |] | |
| 531 | ==> (\<forall>M. multiset(M)--> | |
| 532 |   (setsum(%x. $# mcount(M, x), {x \<in> mset_of(M). 0 < M`x}) = $# n) --> P(M))"
 | |
| 533 | apply (erule nat_induct, clarify) | |
| 534 | apply (frule msize_eq_0_iff) | |
| 535 | apply (auto simp add: mset_of_def multiset_def multiset_fun_iff msize_def) | |
| 536 | apply (subgoal_tac "setsum (%x. $# mcount (M, x), A) =$# succ (x) ") | |
| 537 | apply (drule setsum_succD, auto) | |
| 538 | apply (case_tac "1 <M`a") | |
| 539 | apply (drule_tac [2] not_lt_imp_le) | |
| 540 | apply (simp_all add: nat_le_1_cases) | |
| 541 | apply (subgoal_tac "M= (M (a:=M`a #- 1)) (a:= (M (a:=M`a #- 1))`a #+ 1) ") | |
| 542 | apply (rule_tac [2] A = A and B = "%x. nat" and D = "%x. nat" in fun_extension) | |
| 543 | apply (rule_tac [3] update_type)+ | |
| 544 | apply (simp_all (no_asm_simp)) | |
| 545 | apply (rule_tac [2] impI) | |
| 546 | apply (rule_tac [2] succ_pred_eq_self [symmetric]) | |
| 547 | apply (simp_all (no_asm_simp)) | |
| 548 | apply (rule subst, rule sym, blast, rule prem2) | |
| 549 | apply (simp (no_asm) add: multiset_def multiset_fun_iff) | |
| 550 | apply (rule_tac x = A in exI) | |
| 551 | apply (force intro: update_type) | |
| 552 | apply (simp (no_asm_simp) add: mset_of_def mcount_def) | |
| 553 | apply (drule_tac x = "M (a := M ` a #- 1) " in spec) | |
| 554 | apply (drule mp, drule_tac [2] mp, simp_all) | |
| 555 | apply (rule_tac x = A in exI) | |
| 556 | apply (auto intro: update_type) | |
| 557 | apply (subgoal_tac "Finite ({x \<in> cons (a, A) . x\<noteq>a-->0<M`x}) ")
 | |
| 558 | prefer 2 apply (blast intro: Collect_subset [THEN subset_Finite] Finite_cons) | |
| 559 | apply (drule_tac A = "{x \<in> cons (a, A) . x\<noteq>a-->0<M`x}" in setsum_decr)
 | |
| 560 | apply (drule_tac x = M in spec) | |
| 561 | apply (subgoal_tac "multiset (M) ") | |
| 562 | prefer 2 | |
| 563 | apply (simp add: multiset_def multiset_fun_iff) | |
| 564 | apply (rule_tac x = A in exI, force) | |
| 565 | apply (simp_all add: mset_of_def) | |
| 566 | apply (drule_tac psi = "\<forall>x \<in> A. ?u (x) " in asm_rl) | |
| 567 | apply (drule_tac x = a in bspec) | |
| 568 | apply (simp (no_asm_simp)) | |
| 569 | apply (subgoal_tac "cons (a, A) = A") | |
| 570 | prefer 2 apply blast | |
| 571 | apply simp | |
| 572 | apply (subgoal_tac "M=cons (<a, M`a>, funrestrict (M, A-{a}))")
 | |
| 573 | prefer 2 | |
| 574 | apply (rule fun_cons_funrestrict_eq) | |
| 575 |  apply (subgoal_tac "cons (a, A-{a}) = A")
 | |
| 576 | apply force | |
| 577 | apply force | |
| 578 | apply (rule_tac a = "cons (<a, 1>, funrestrict (M, A - {a}))" in ssubst)
 | |
| 579 | apply simp | |
| 580 | apply (frule multiset_funrestict, assumption) | |
| 581 | apply (rule prem1, assumption) | |
| 582 | apply (simp add: mset_of_def) | |
| 583 | apply (drule_tac x = "funrestrict (M, A-{a}) " in spec)
 | |
| 584 | apply (drule mp) | |
| 585 | apply (rule_tac x = "A-{a}" in exI)
 | |
| 586 | apply (auto intro: Finite_Diff funrestrict_type simp add: funrestrict) | |
| 587 | apply (frule_tac A = A and M = M and a = a in setsum_decr3) | |
| 588 | apply (simp (no_asm_simp) add: multiset_def multiset_fun_iff) | |
| 589 | apply blast | |
| 590 | apply (simp (no_asm_simp) add: mset_of_def) | |
| 591 | apply (drule_tac b = "if ?u then ?v else ?w" in sym, simp_all) | |
| 592 | apply (subgoal_tac "{x \<in> A - {a} . 0 < funrestrict (M, A - {x}) ` x} = A - {a}")
 | |
| 593 | apply (auto intro!: setsum_cong simp add: zdiff_eq_iff zadd_commute multiset_def multiset_fun_iff mset_of_def) | |
| 594 | done | |
| 595 | ||
| 596 | lemma multiset_induct2: | |
| 597 | "[| multiset(M); P(0); | |
| 598 | (!!M a. [| multiset(M); a\<notin>mset_of(M); P(M) |] ==> P(cons(<a, 1>, M))); | |
| 599 | (!!M b. [| multiset(M); b \<in> mset_of(M); P(M) |] ==> P(M(b:= M`b #+ 1))) |] | |
| 600 | ==> P(M)" | |
| 601 | apply (subgoal_tac "\<exists>n \<in> nat. setsum (\<lambda>x. $# mcount (M, x), {x \<in> mset_of (M) . 0 < M ` x}) = $# n")
 | |
| 602 | apply (rule_tac [2] not_zneg_int_of) | |
| 603 | apply (simp_all (no_asm_simp) add: znegative_iff_zless_0 not_zless_iff_zle) | |
| 604 | apply (rule_tac [2] g_zpos_imp_setsum_zpos) | |
| 605 | prefer 2 apply (blast intro: multiset_set_of_Finite Collect_subset [THEN subset_Finite]) | |
| 606 | prefer 2 apply (simp add: multiset_def multiset_fun_iff, clarify) | |
| 607 | apply (rule multiset_induct_aux [rule_format], auto) | |
| 608 | done | |
| 609 | ||
| 610 | lemma munion_single_case1: | |
| 611 |      "[| multiset(M); a \<notin>mset_of(M) |] ==> M +# {#a#} = cons(<a, 1>, M)"
 | |
| 612 | apply (simp add: multiset_def msingle_def) | |
| 613 | apply (auto simp add: munion_def) | |
| 614 | apply (unfold mset_of_def, simp) | |
| 615 | apply (rule fun_extension, rule lam_type, simp_all) | |
| 616 | apply (auto simp add: multiset_fun_iff fun_extend_apply) | |
| 617 | apply (drule_tac c = a and b = 1 in fun_extend3) | |
| 618 | apply (auto simp add: cons_eq Un_commute [of _ "{a}"])
 | |
| 619 | done | |
| 620 | ||
| 621 | lemma munion_single_case2: | |
| 622 |      "[| multiset(M); a \<in> mset_of(M) |] ==> M +# {#a#} = M(a:=M`a #+ 1)"
 | |
| 623 | apply (simp add: multiset_def) | |
| 624 | apply (auto simp add: munion_def multiset_fun_iff msingle_def) | |
| 625 | apply (unfold mset_of_def, simp) | |
| 626 | apply (subgoal_tac "A Un {a} = A")
 | |
| 627 | apply (rule fun_extension) | |
| 628 | apply (auto dest: domain_type intro: lam_type update_type) | |
| 629 | done | |
| 630 | ||
| 631 | (* Induction principle for multisets *) | |
| 632 | ||
| 633 | lemma multiset_induct: | |
| 634 | assumes M: "multiset(M)" | |
| 635 | and P0: "P(0)" | |
| 636 |       and step: "!!M a. [| multiset(M); P(M) |] ==> P(M +# {#a#})"
 | |
| 637 | shows "P(M)" | |
| 638 | apply (rule multiset_induct2 [OF M]) | |
| 639 | apply (simp_all add: P0) | |
| 640 | apply (frule_tac [2] a1 = b in munion_single_case2 [symmetric]) | |
| 641 | apply (frule_tac a1 = a in munion_single_case1 [symmetric]) | |
| 642 | apply (auto intro: step) | |
| 643 | done | |
| 644 | ||
| 645 | (** MCollect **) | |
| 646 | ||
| 647 | lemma MCollect_multiset [simp]: | |
| 648 |      "multiset(M) ==> multiset({# x \<in> M. P(x)#})"
 | |
| 649 | apply (simp add: MCollect_def multiset_def mset_of_def, clarify) | |
| 650 | apply (rule_tac x = "{x \<in> A. P (x) }" in exI)
 | |
| 651 | apply (auto dest: CollectD1 [THEN [2] apply_type] | |
| 652 | intro: Collect_subset [THEN subset_Finite] funrestrict_type) | |
| 653 | done | |
| 654 | ||
| 655 | lemma mset_of_MCollect [simp]: | |
| 656 |      "multiset(M) ==> mset_of({# x \<in> M. P(x) #}) \<subseteq> mset_of(M)"
 | |
| 657 | by (auto simp add: mset_of_def MCollect_def multiset_def funrestrict_def) | |
| 658 | ||
| 659 | lemma MCollect_mem_iff [iff]: | |
| 660 |      "x \<in> mset_of({#x \<in> M. P(x)#}) <->  x \<in> mset_of(M) & P(x)"
 | |
| 661 | by (simp add: MCollect_def mset_of_def) | |
| 662 | ||
| 663 | lemma mcount_MCollect [simp]: | |
| 664 |      "mcount({# x \<in> M. P(x) #}, a) = (if P(a) then mcount(M,a) else 0)"
 | |
| 665 | by (simp add: mcount_def MCollect_def mset_of_def) | |
| 666 | ||
| 667 | lemma multiset_partition: "multiset(M) ==> M = {# x \<in> M. P(x) #} +# {# x \<in> M. ~ P(x) #}"
 | |
| 668 | by (simp add: multiset_equality) | |
| 669 | ||
| 670 | lemma natify_elem_is_self [simp]: | |
| 671 | "[| multiset(M); a \<in> mset_of(M) |] ==> natify(M`a) = M`a" | |
| 672 | by (auto simp add: multiset_def mset_of_def multiset_fun_iff) | |
| 673 | ||
| 674 | (* and more algebraic laws on multisets *) | |
| 675 | ||
| 676 | lemma munion_eq_conv_diff: "[| multiset(M); multiset(N) |] | |
| 677 |   ==>  (M +# {#a#} = N +# {#b#}) <->  (M = N & a = b |
 | |
| 678 |        M = N -# {#a#} +# {#b#} & N = M -# {#b#} +# {#a#})"
 | |
| 679 | apply (simp del: mcount_single add: multiset_equality) | |
| 680 | apply (rule iffI, erule_tac [2] disjE, erule_tac [3] conjE) | |
| 681 | apply (case_tac "a=b", auto) | |
| 682 | apply (drule_tac x = a in spec) | |
| 683 | apply (drule_tac [2] x = b in spec) | |
| 684 | apply (drule_tac [3] x = aa in spec) | |
| 685 | apply (drule_tac [4] x = a in spec, auto) | |
| 686 | apply (subgoal_tac [!] "mcount (N,a) :nat") | |
| 687 | apply (erule_tac [3] natE, erule natE, auto) | |
| 688 | done | |
| 689 | ||
| 690 | lemma melem_diff_single: | |
| 691 | "multiset(M) ==> | |
| 692 |   k \<in> mset_of(M -# {#a#}) <-> (k=a & 1 < mcount(M,a)) | (k\<noteq> a & k \<in> mset_of(M))"
 | |
| 693 | apply (simp add: multiset_def) | |
| 694 | apply (simp add: normalize_def mset_of_def msingle_def mdiff_def mcount_def) | |
| 695 | apply (auto dest: domain_type intro: zero_less_diff [THEN iffD1] | |
| 696 | simp add: multiset_fun_iff apply_iff) | |
| 697 | apply (force intro!: lam_type) | |
| 698 | apply (force intro!: lam_type) | |
| 699 | apply (force intro!: lam_type) | |
| 700 | done | |
| 701 | ||
| 702 | lemma munion_eq_conv_exist: | |
| 703 | "[| M \<in> Mult(A); N \<in> Mult(A) |] | |
| 704 |   ==> (M +# {#a#} = N +# {#b#}) <->
 | |
| 705 |       (M=N & a=b | (\<exists>K \<in> Mult(A). M= K +# {#b#} & N=K +# {#a#}))"
 | |
| 706 | by (auto simp add: Mult_iff_multiset melem_diff_single munion_eq_conv_diff) | |
| 707 | ||
| 708 | ||
| 709 | subsection{*Multiset Orderings*}
 | |
| 710 | ||
| 711 | (* multiset on a domain A are finite functions from A to nat-{0} *)
 | |
| 712 | ||
| 713 | ||
| 714 | (* multirel1 type *) | |
| 715 | ||
| 716 | lemma multirel1_type: "multirel1(A, r) \<subseteq> Mult(A)*Mult(A)" | |
| 717 | by (auto simp add: multirel1_def) | |
| 718 | ||
| 719 | lemma multirel1_0 [simp]: "multirel1(0, r) =0" | |
| 720 | by (auto simp add: multirel1_def) | |
| 721 | ||
| 722 | lemma multirel1_iff: | |
| 723 | " <N, M> \<in> multirel1(A, r) <-> | |
| 724 | (\<exists>a. a \<in> A & | |
| 725 | (\<exists>M0. M0 \<in> Mult(A) & (\<exists>K. K \<in> Mult(A) & | |
| 726 |    M=M0 +# {#a#} & N=M0 +# K & (\<forall>b \<in> mset_of(K). <b,a> \<in> r))))"
 | |
| 727 | by (auto simp add: multirel1_def Mult_iff_multiset Bex_def) | |
| 728 | ||
| 729 | ||
| 730 | text{*Monotonicity of @{term multirel1}*}
 | |
| 731 | ||
| 732 | lemma multirel1_mono1: "A\<subseteq>B ==> multirel1(A, r)\<subseteq>multirel1(B, r)" | |
| 733 | apply (auto simp add: multirel1_def) | |
| 734 | apply (auto simp add: Un_subset_iff Mult_iff_multiset) | |
| 735 | apply (rule_tac x = a in bexI) | |
| 736 | apply (rule_tac x = M0 in bexI, simp) | |
| 737 | apply (rule_tac x = K in bexI) | |
| 738 | apply (auto simp add: Mult_iff_multiset) | |
| 739 | done | |
| 740 | ||
| 741 | lemma multirel1_mono2: "r\<subseteq>s ==> multirel1(A,r)\<subseteq>multirel1(A, s)" | |
| 742 | apply (simp add: multirel1_def, auto) | |
| 743 | apply (rule_tac x = a in bexI) | |
| 744 | apply (rule_tac x = M0 in bexI) | |
| 745 | apply (simp_all add: Mult_iff_multiset) | |
| 746 | apply (rule_tac x = K in bexI) | |
| 747 | apply (simp_all add: Mult_iff_multiset, auto) | |
| 748 | done | |
| 749 | ||
| 750 | lemma multirel1_mono: | |
| 751 | "[| A\<subseteq>B; r\<subseteq>s |] ==> multirel1(A, r) \<subseteq> multirel1(B, s)" | |
| 752 | apply (rule subset_trans) | |
| 753 | apply (rule multirel1_mono1) | |
| 754 | apply (rule_tac [2] multirel1_mono2, auto) | |
| 755 | done | |
| 756 | ||
| 757 | subsection{* Toward the proof of well-foundedness of multirel1 *}
 | |
| 758 | ||
| 759 | lemma not_less_0 [iff]: "<M,0> \<notin> multirel1(A, r)" | |
| 760 | by (auto simp add: multirel1_def Mult_iff_multiset) | |
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 761 | |
| 15201 | 762 | lemma less_munion: "[| <N, M0 +# {#a#}> \<in> multirel1(A, r); M0 \<in> Mult(A) |] ==>
 | 
| 763 |   (\<exists>M. <M, M0> \<in> multirel1(A, r) & N = M +# {#a#}) |
 | |
| 764 | (\<exists>K. K \<in> Mult(A) & (\<forall>b \<in> mset_of(K). <b, a> \<in> r) & N = M0 +# K)" | |
| 765 | apply (frule multirel1_type [THEN subsetD]) | |
| 766 | apply (simp add: multirel1_iff) | |
| 767 | apply (auto simp add: munion_eq_conv_exist) | |
| 768 | apply (rule_tac x="Ka +# K" in exI, auto, simp add: Mult_iff_multiset) | |
| 769 | apply (simp (no_asm_simp) add: munion_left_cancel munion_assoc) | |
| 770 | apply (auto simp add: munion_commute) | |
| 771 | done | |
| 772 | ||
| 773 | lemma multirel1_base: "[| M \<in> Mult(A); a \<in> A |] ==> <M, M +# {#a#}> \<in> multirel1(A, r)"
 | |
| 774 | apply (auto simp add: multirel1_iff) | |
| 775 | apply (simp add: Mult_iff_multiset) | |
| 776 | apply (rule_tac x = a in exI, clarify) | |
| 777 | apply (rule_tac x = M in exI, simp) | |
| 778 | apply (rule_tac x = 0 in exI, auto) | |
| 779 | done | |
| 780 | ||
| 781 | lemma acc_0: "acc(0)=0" | |
| 782 | by (auto intro!: equalityI dest: acc.dom_subset [THEN subsetD]) | |
| 783 | ||
| 784 | lemma lemma1: "[| \<forall>b \<in> A. <b,a> \<in> r --> | |
| 785 |     (\<forall>M \<in> acc(multirel1(A, r)). M +# {#b#}:acc(multirel1(A, r)));
 | |
| 786 | M0 \<in> acc(multirel1(A, r)); a \<in> A; | |
| 787 |     \<forall>M. <M,M0> \<in> multirel1(A, r) --> M +# {#a#} \<in> acc(multirel1(A, r)) |]
 | |
| 788 |   ==> M0 +# {#a#} \<in> acc(multirel1(A, r))"
 | |
| 15481 | 789 | apply (subgoal_tac "M0 \<in> Mult(A) ") | 
| 15201 | 790 | prefer 2 | 
| 791 | apply (erule acc.cases) | |
| 792 | apply (erule fieldE) | |
| 793 | apply (auto dest: multirel1_type [THEN subsetD]) | |
| 794 | apply (rule accI) | |
| 795 | apply (rename_tac "N") | |
| 796 | apply (drule less_munion, blast) | |
| 797 | apply (auto simp add: Mult_iff_multiset) | |
| 798 | apply (erule_tac P = "\<forall>x \<in> mset_of (K) . <x, a> \<in> r" in rev_mp) | |
| 799 | apply (erule_tac P = "mset_of (K) \<subseteq>A" in rev_mp) | |
| 800 | apply (erule_tac M = K in multiset_induct) | |
| 801 | (* three subgoals *) | |
| 802 | (* subgoal 1: the induction base case *) | |
| 803 | apply (simp (no_asm_simp)) | |
| 804 | (* subgoal 2: the induction general case *) | |
| 805 | apply (simp add: Ball_def Un_subset_iff, clarify) | |
| 806 | apply (drule_tac x = aa in spec, simp) | |
| 807 | apply (subgoal_tac "aa \<in> A") | |
| 808 | prefer 2 apply blast | |
| 809 | apply (drule_tac x = "M0 +# M" and P = | |
| 810 | "%x. x \<in> acc(multirel1(A, r)) \<longrightarrow> ?Q(x)" in spec) | |
| 811 | apply (simp add: munion_assoc [symmetric]) | |
| 812 | (* subgoal 3: additional conditions *) | |
| 813 | apply (auto intro!: multirel1_base [THEN fieldI2] simp add: Mult_iff_multiset) | |
| 814 | done | |
| 815 | ||
| 816 | lemma lemma2: "[| \<forall>b \<in> A. <b,a> \<in> r | |
| 817 |    --> (\<forall>M \<in> acc(multirel1(A, r)). M +# {#b#} :acc(multirel1(A, r)));
 | |
| 818 |         M \<in> acc(multirel1(A, r)); a \<in> A|] ==> M +# {#a#} \<in> acc(multirel1(A, r))"
 | |
| 819 | apply (erule acc_induct) | |
| 820 | apply (blast intro: lemma1) | |
| 821 | done | |
| 822 | ||
| 823 | lemma lemma3: "[| wf[A](r); a \<in> A |] | |
| 824 |       ==> \<forall>M \<in> acc(multirel1(A, r)). M +# {#a#} \<in> acc(multirel1(A, r))"
 | |
| 825 | apply (erule_tac a = a in wf_on_induct, blast) | |
| 826 | apply (blast intro: lemma2) | |
| 827 | done | |
| 828 | ||
| 829 | lemma lemma4: "multiset(M) ==> mset_of(M)\<subseteq>A --> | |
| 830 | wf[A](r) --> M \<in> field(multirel1(A, r)) --> M \<in> acc(multirel1(A, r))" | |
| 831 | apply (erule multiset_induct) | |
| 832 | (* proving the base case *) | |
| 833 | apply clarify | |
| 834 | apply (rule accI, force) | |
| 835 | apply (simp add: multirel1_def) | |
| 836 | (* Proving the general case *) | |
| 837 | apply clarify | |
| 838 | apply simp | |
| 839 | apply (subgoal_tac "mset_of (M) \<subseteq>A") | |
| 840 | prefer 2 apply blast | |
| 841 | apply clarify | |
| 842 | apply (drule_tac a = a in lemma3, blast) | |
| 843 | apply (subgoal_tac "M \<in> field (multirel1 (A,r))") | |
| 844 | apply blast | |
| 845 | apply (rule multirel1_base [THEN fieldI1]) | |
| 846 | apply (auto simp add: Mult_iff_multiset) | |
| 847 | done | |
| 848 | ||
| 849 | lemma all_accessible: "[| wf[A](r); M \<in> Mult(A); A \<noteq> 0|] ==> M \<in> acc(multirel1(A, r))" | |
| 850 | apply (erule not_emptyE) | |
| 851 | apply (rule lemma4 [THEN mp, THEN mp, THEN mp]) | |
| 852 | apply (rule_tac [4] multirel1_base [THEN fieldI1]) | |
| 853 | apply (auto simp add: Mult_iff_multiset) | |
| 854 | done | |
| 855 | ||
| 856 | lemma wf_on_multirel1: "wf[A](r) ==> wf[A-||>nat-{0}](multirel1(A, r))"
 | |
| 857 | apply (case_tac "A=0") | |
| 858 | apply (simp (no_asm_simp)) | |
| 859 | apply (rule wf_imp_wf_on) | |
| 860 | apply (rule wf_on_field_imp_wf) | |
| 861 | apply (simp (no_asm_simp) add: wf_on_0) | |
| 862 | apply (rule_tac A = "acc (multirel1 (A,r))" in wf_on_subset_A) | |
| 863 | apply (rule wf_on_acc) | |
| 864 | apply (blast intro: all_accessible) | |
| 865 | done | |
| 866 | ||
| 867 | lemma wf_multirel1: "wf(r) ==>wf(multirel1(field(r), r))" | |
| 868 | apply (simp (no_asm_use) add: wf_iff_wf_on_field) | |
| 869 | apply (drule wf_on_multirel1) | |
| 870 | apply (rule_tac A = "field (r) -||> nat - {0}" in wf_on_subset_A)
 | |
| 871 | apply (simp (no_asm_simp)) | |
| 872 | apply (rule field_rel_subset) | |
| 873 | apply (rule multirel1_type) | |
| 874 | done | |
| 875 | ||
| 876 | (** multirel **) | |
| 877 | ||
| 878 | lemma multirel_type: "multirel(A, r) \<subseteq> Mult(A)*Mult(A)" | |
| 879 | apply (simp add: multirel_def) | |
| 880 | apply (rule trancl_type [THEN subset_trans]) | |
| 881 | apply (auto dest: multirel1_type [THEN subsetD]) | |
| 882 | done | |
| 883 | ||
| 884 | (* Monotonicity of multirel *) | |
| 885 | lemma multirel_mono: | |
| 886 | "[| A\<subseteq>B; r\<subseteq>s |] ==> multirel(A, r)\<subseteq>multirel(B,s)" | |
| 887 | apply (simp add: multirel_def) | |
| 888 | apply (rule trancl_mono) | |
| 889 | apply (rule multirel1_mono, auto) | |
| 890 | done | |
| 891 | ||
| 892 | (* Equivalence of multirel with the usual (closure-free) def *) | |
| 893 | ||
| 894 | lemma add_diff_eq: "k \<in> nat ==> 0 < k --> n #+ k #- 1 = n #+ (k #- 1)" | |
| 895 | by (erule nat_induct, auto) | |
| 896 | ||
| 897 | lemma mdiff_union_single_conv: "[|a \<in> mset_of(J); multiset(I); multiset(J) |] | |
| 898 |    ==> I +# J -# {#a#} = I +# (J-# {#a#})"
 | |
| 899 | apply (simp (no_asm_simp) add: multiset_equality) | |
| 900 | apply (case_tac "a \<notin> mset_of (I) ") | |
| 901 | apply (auto simp add: mcount_def mset_of_def multiset_def multiset_fun_iff) | |
| 902 | apply (auto dest: domain_type simp add: add_diff_eq) | |
| 903 | done | |
| 904 | ||
| 905 | lemma diff_add_commute: "[| n le m; m \<in> nat; n \<in> nat; k \<in> nat |] ==> m #- n #+ k = m #+ k #- n" | |
| 906 | by (auto simp add: le_iff less_iff_succ_add) | |
| 907 | ||
| 908 | (* One direction *) | |
| 909 | ||
| 910 | lemma multirel_implies_one_step: | |
| 911 | "<M,N> \<in> multirel(A, r) ==> | |
| 912 | trans[A](r) --> | |
| 913 | (\<exists>I J K. | |
| 914 | I \<in> Mult(A) & J \<in> Mult(A) & K \<in> Mult(A) & | |
| 915 | N = I +# J & M = I +# K & J \<noteq> 0 & | |
| 916 | (\<forall>k \<in> mset_of(K). \<exists>j \<in> mset_of(J). <k,j> \<in> r))" | |
| 917 | apply (simp add: multirel_def Ball_def Bex_def) | |
| 918 | apply (erule converse_trancl_induct) | |
| 919 | apply (simp_all add: multirel1_iff Mult_iff_multiset) | |
| 920 | (* Two subgoals remain *) | |
| 921 | (* Subgoal 1 *) | |
| 922 | apply clarify | |
| 923 | apply (rule_tac x = M0 in exI, force) | |
| 924 | (* Subgoal 2 *) | |
| 925 | apply clarify | |
| 926 | apply (case_tac "a \<in> mset_of (Ka) ") | |
| 927 | apply (rule_tac x = I in exI, simp (no_asm_simp)) | |
| 928 | apply (rule_tac x = J in exI, simp (no_asm_simp)) | |
| 929 | apply (rule_tac x = " (Ka -# {#a#}) +# K" in exI, simp (no_asm_simp))
 | |
| 930 | apply (simp_all add: Un_subset_iff) | |
| 931 | apply (simp (no_asm_simp) add: munion_assoc [symmetric]) | |
| 932 | apply (drule_tac t = "%M. M-#{#a#}" in subst_context)
 | |
| 933 | apply (simp add: mdiff_union_single_conv melem_diff_single, clarify) | |
| 934 | apply (erule disjE, simp) | |
| 935 | apply (erule disjE, simp) | |
| 936 | apply (drule_tac x = a and P = "%x. x :# Ka \<longrightarrow> ?Q(x)" in spec) | |
| 937 | apply clarify | |
| 938 | apply (rule_tac x = xa in exI) | |
| 939 | apply (simp (no_asm_simp)) | |
| 940 | apply (blast dest: trans_onD) | |
| 941 | (* new we know that a\<notin>mset_of(Ka) *) | |
| 942 | apply (subgoal_tac "a :# I") | |
| 943 | apply (rule_tac x = "I-#{#a#}" in exI, simp (no_asm_simp))
 | |
| 944 | apply (rule_tac x = "J+#{#a#}" in exI)
 | |
| 945 | apply (simp (no_asm_simp) add: Un_subset_iff) | |
| 946 | apply (rule_tac x = "Ka +# K" in exI) | |
| 947 | apply (simp (no_asm_simp) add: Un_subset_iff) | |
| 948 | apply (rule conjI) | |
| 949 | apply (simp (no_asm_simp) add: multiset_equality mcount_elem [THEN succ_pred_eq_self]) | |
| 950 | apply (rule conjI) | |
| 951 | apply (drule_tac t = "%M. M-#{#a#}" in subst_context)
 | |
| 952 | apply (simp add: mdiff_union_inverse2) | |
| 953 | apply (simp_all (no_asm_simp) add: multiset_equality) | |
| 954 | apply (rule diff_add_commute [symmetric]) | |
| 955 | apply (auto intro: mcount_elem) | |
| 956 | apply (subgoal_tac "a \<in> mset_of (I +# Ka) ") | |
| 957 | apply (drule_tac [2] sym, auto) | |
| 958 | done | |
| 959 | ||
| 960 | lemma melem_imp_eq_diff_union [simp]: "[| a \<in> mset_of(M); multiset(M) |] ==> M -# {#a#} +# {#a#} = M"
 | |
| 961 | by (simp add: multiset_equality mcount_elem [THEN succ_pred_eq_self]) | |
| 962 | ||
| 963 | lemma msize_eq_succ_imp_eq_union: | |
| 964 | "[| msize(M)=$# succ(n); M \<in> Mult(A); n \<in> nat |] | |
| 965 |       ==> \<exists>a N. M = N +# {#a#} & N \<in> Mult(A) & a \<in> A"
 | |
| 966 | apply (drule msize_eq_succ_imp_elem, auto) | |
| 967 | apply (rule_tac x = a in exI) | |
| 968 | apply (rule_tac x = "M -# {#a#}" in exI)
 | |
| 969 | apply (frule Mult_into_multiset) | |
| 970 | apply (simp (no_asm_simp)) | |
| 971 | apply (auto simp add: Mult_iff_multiset) | |
| 972 | done | |
| 973 | ||
| 974 | (* The second direction *) | |
| 975 | ||
| 976 | lemma one_step_implies_multirel_lemma [rule_format (no_asm)]: | |
| 977 | "n \<in> nat ==> | |
| 978 | (\<forall>I J K. | |
| 979 | I \<in> Mult(A) & J \<in> Mult(A) & K \<in> Mult(A) & | |
| 980 | (msize(J) = $# n & J \<noteq>0 & (\<forall>k \<in> mset_of(K). \<exists>j \<in> mset_of(J). <k, j> \<in> r)) | |
| 981 | --> <I +# K, I +# J> \<in> multirel(A, r))" | |
| 982 | apply (simp add: Mult_iff_multiset) | |
| 983 | apply (erule nat_induct, clarify) | |
| 984 | apply (drule_tac M = J in msize_eq_0_iff, auto) | |
| 985 | (* one subgoal remains *) | |
| 986 | apply (subgoal_tac "msize (J) =$# succ (x) ") | |
| 987 | prefer 2 apply simp | |
| 988 | apply (frule_tac A = A in msize_eq_succ_imp_eq_union) | |
| 989 | apply (simp_all add: Mult_iff_multiset, clarify) | |
| 990 | apply (rename_tac "J'", simp) | |
| 991 | apply (case_tac "J' = 0") | |
| 992 | apply (simp add: multirel_def) | |
| 993 | apply (rule r_into_trancl, clarify) | |
| 994 | apply (simp add: multirel1_iff Mult_iff_multiset, force) | |
| 995 | (*Now we know J' \<noteq> 0*) | |
| 996 | apply (drule sym, rotate_tac -1, simp) | |
| 997 | apply (erule_tac V = "$# x = msize (J') " in thin_rl) | |
| 998 | apply (frule_tac M = K and P = "%x. <x,a> \<in> r" in multiset_partition) | |
| 999 | apply (erule_tac P = "\<forall>k \<in> mset_of (K) . ?P (k) " in rev_mp) | |
| 1000 | apply (erule ssubst) | |
| 1001 | apply (simp add: Ball_def, auto) | |
| 15481 | 1002 | apply (subgoal_tac "< (I +# {# x \<in> K. <x, a> \<in> r#}) +# {# x \<in> K. <x, a> \<notin> r#}, (I +# {# x \<in> K. <x, a> \<in> r#}) +# J'> \<in> multirel(A, r) ")
 | 
| 15201 | 1003 | prefer 2 | 
| 1004 |  apply (drule_tac x = "I +# {# x \<in> K. <x, a> \<in> r#}" in spec)
 | |
| 1005 | apply (rotate_tac -1) | |
| 1006 | apply (drule_tac x = "J'" in spec) | |
| 1007 | apply (rotate_tac -1) | |
| 1008 |  apply (drule_tac x = "{# x \<in> K. <x, a> \<notin> r#}" in spec, simp) apply blast
 | |
| 1009 | apply (simp add: munion_assoc [symmetric] multirel_def) | |
| 1010 | apply (rule_tac b = "I +# {# x \<in> K. <x, a> \<in> r#} +# J'" in trancl_trans, blast)
 | |
| 1011 | apply (rule r_into_trancl) | |
| 1012 | apply (simp add: multirel1_iff Mult_iff_multiset) | |
| 1013 | apply (rule_tac x = a in exI) | |
| 1014 | apply (simp (no_asm_simp)) | |
| 1015 | apply (rule_tac x = "I +# J'" in exI) | |
| 1016 | apply (auto simp add: munion_ac Un_subset_iff) | |
| 1017 | done | |
| 1018 | ||
| 1019 | lemma one_step_implies_multirel: | |
| 1020 | "[| J \<noteq> 0; \<forall>k \<in> mset_of(K). \<exists>j \<in> mset_of(J). <k,j> \<in> r; | |
| 1021 | I \<in> Mult(A); J \<in> Mult(A); K \<in> Mult(A) |] | |
| 1022 | ==> <I+#K, I+#J> \<in> multirel(A, r)" | |
| 1023 | apply (subgoal_tac "multiset (J) ") | |
| 1024 | prefer 2 apply (simp add: Mult_iff_multiset) | |
| 1025 | apply (frule_tac M = J in msize_int_of_nat) | |
| 1026 | apply (auto intro: one_step_implies_multirel_lemma) | |
| 1027 | done | |
| 1028 | ||
| 1029 | (** Proving that multisets are partially ordered **) | |
| 1030 | ||
| 1031 | (*irreflexivity*) | |
| 1032 | ||
| 1033 | lemma multirel_irrefl_lemma: | |
| 1034 | "Finite(A) ==> part_ord(A, r) --> (\<forall>x \<in> A. \<exists>y \<in> A. <x,y> \<in> r) -->A=0" | |
| 1035 | apply (erule Finite_induct) | |
| 1036 | apply (auto dest: subset_consI [THEN [2] part_ord_subset]) | |
| 1037 | apply (auto simp add: part_ord_def irrefl_def) | |
| 1038 | apply (drule_tac x = xa in bspec) | |
| 1039 | apply (drule_tac [2] a = xa and b = x in trans_onD, auto) | |
| 1040 | done | |
| 1041 | ||
| 1042 | lemma irrefl_on_multirel: | |
| 1043 | "part_ord(A, r) ==> irrefl(Mult(A), multirel(A, r))" | |
| 1044 | apply (simp add: irrefl_def) | |
| 1045 | apply (subgoal_tac "trans[A](r) ") | |
| 1046 | prefer 2 apply (simp add: part_ord_def, clarify) | |
| 1047 | apply (drule multirel_implies_one_step, clarify) | |
| 1048 | apply (simp add: Mult_iff_multiset, clarify) | |
| 1049 | apply (subgoal_tac "Finite (mset_of (K))") | |
| 1050 | apply (frule_tac r = r in multirel_irrefl_lemma) | |
| 1051 | apply (frule_tac B = "mset_of (K) " in part_ord_subset) | |
| 1052 | apply simp_all | |
| 1053 | apply (auto simp add: multiset_def mset_of_def) | |
| 1054 | done | |
| 1055 | ||
| 1056 | lemma trans_on_multirel: "trans[Mult(A)](multirel(A, r))" | |
| 1057 | apply (simp add: multirel_def trans_on_def) | |
| 1058 | apply (blast intro: trancl_trans) | |
| 1059 | done | |
| 1060 | ||
| 1061 | lemma multirel_trans: | |
| 1062 | "[| <M, N> \<in> multirel(A, r); <N, K> \<in> multirel(A, r) |] ==> <M, K> \<in> multirel(A,r)" | |
| 1063 | apply (simp add: multirel_def) | |
| 1064 | apply (blast intro: trancl_trans) | |
| 1065 | done | |
| 1066 | ||
| 1067 | lemma trans_multirel: "trans(multirel(A,r))" | |
| 1068 | apply (simp add: multirel_def) | |
| 1069 | apply (rule trans_trancl) | |
| 1070 | done | |
| 1071 | ||
| 1072 | lemma part_ord_multirel: "part_ord(A,r) ==> part_ord(Mult(A), multirel(A, r))" | |
| 1073 | apply (simp (no_asm) add: part_ord_def) | |
| 1074 | apply (blast intro: irrefl_on_multirel trans_on_multirel) | |
| 1075 | done | |
| 1076 | ||
| 1077 | (** Monotonicity of multiset union **) | |
| 1078 | ||
| 1079 | lemma munion_multirel1_mono: | |
| 1080 | "[|<M,N> \<in> multirel1(A, r); K \<in> Mult(A) |] ==> <K +# M, K +# N> \<in> multirel1(A, r)" | |
| 1081 | apply (frule multirel1_type [THEN subsetD]) | |
| 1082 | apply (auto simp add: multirel1_iff Mult_iff_multiset) | |
| 1083 | apply (rule_tac x = a in exI) | |
| 1084 | apply (simp (no_asm_simp)) | |
| 1085 | apply (rule_tac x = "K+#M0" in exI) | |
| 1086 | apply (simp (no_asm_simp) add: Un_subset_iff) | |
| 1087 | apply (rule_tac x = Ka in exI) | |
| 1088 | apply (simp (no_asm_simp) add: munion_assoc) | |
| 1089 | done | |
| 1090 | ||
| 1091 | lemma munion_multirel_mono2: | |
| 1092 | "[| <M, N> \<in> multirel(A, r); K \<in> Mult(A) |]==><K +# M, K +# N> \<in> multirel(A, r)" | |
| 1093 | apply (frule multirel_type [THEN subsetD]) | |
| 1094 | apply (simp (no_asm_use) add: multirel_def) | |
| 1095 | apply clarify | |
| 1096 | apply (drule_tac psi = "<M,N> \<in> multirel1 (A, r) ^+" in asm_rl) | |
| 1097 | apply (erule rev_mp) | |
| 1098 | apply (erule rev_mp) | |
| 1099 | apply (erule rev_mp) | |
| 1100 | apply (erule trancl_induct, clarify) | |
| 1101 | apply (blast intro: munion_multirel1_mono r_into_trancl, clarify) | |
| 15481 | 1102 | apply (subgoal_tac "y \<in> Mult(A) ") | 
| 15201 | 1103 | prefer 2 | 
| 1104 | apply (blast dest: multirel_type [unfolded multirel_def, THEN subsetD]) | |
| 1105 | apply (subgoal_tac "<K +# y, K +# z> \<in> multirel1 (A, r) ") | |
| 1106 | prefer 2 apply (blast intro: munion_multirel1_mono) | |
| 1107 | apply (blast intro: r_into_trancl trancl_trans) | |
| 1108 | done | |
| 1109 | ||
| 1110 | lemma munion_multirel_mono1: | |
| 1111 | "[|<M, N> \<in> multirel(A, r); K \<in> Mult(A)|] ==> <M +# K, N +# K> \<in> multirel(A, r)" | |
| 1112 | apply (frule multirel_type [THEN subsetD]) | |
| 15481 | 1113 | apply (rule_tac P = "%x. <x,?u> \<in> multirel(A, r) " in munion_commute [THEN subst]) | 
| 1114 | apply (subst munion_commute [of N]) | |
| 15201 | 1115 | apply (rule munion_multirel_mono2) | 
| 1116 | apply (auto simp add: Mult_iff_multiset) | |
| 1117 | done | |
| 1118 | ||
| 1119 | lemma munion_multirel_mono: | |
| 1120 | "[|<M,K> \<in> multirel(A, r); <N,L> \<in> multirel(A, r)|] | |
| 1121 | ==> <M +# N, K +# L> \<in> multirel(A, r)" | |
| 15481 | 1122 | apply (subgoal_tac "M \<in> Mult(A) & N \<in> Mult(A) & K \<in> Mult(A) & L \<in> Mult(A) ") | 
| 15201 | 1123 | prefer 2 apply (blast dest: multirel_type [THEN subsetD]) | 
| 1124 | apply (blast intro: munion_multirel_mono1 multirel_trans munion_multirel_mono2) | |
| 1125 | done | |
| 1126 | ||
| 1127 | ||
| 1128 | subsection{*Ordinal Multisets*}
 | |
| 1129 | ||
| 1130 | (* A \<subseteq> B ==> field(Memrel(A)) \<subseteq> field(Memrel(B)) *) | |
| 1131 | lemmas field_Memrel_mono = Memrel_mono [THEN field_mono, standard] | |
| 1132 | ||
| 1133 | (* | |
| 1134 | [| Aa \<subseteq> Ba; A \<subseteq> B |] ==> | |
| 1135 | multirel(field(Memrel(Aa)), Memrel(A))\<subseteq> multirel(field(Memrel(Ba)), Memrel(B)) | |
| 1136 | *) | |
| 1137 | ||
| 1138 | lemmas multirel_Memrel_mono = multirel_mono [OF field_Memrel_mono Memrel_mono] | |
| 1139 | ||
| 1140 | lemma omultiset_is_multiset [simp]: "omultiset(M) ==> multiset(M)" | |
| 1141 | apply (simp add: omultiset_def) | |
| 1142 | apply (auto simp add: Mult_iff_multiset) | |
| 1143 | done | |
| 1144 | ||
| 1145 | lemma munion_omultiset [simp]: "[| omultiset(M); omultiset(N) |] ==> omultiset(M +# N)" | |
| 1146 | apply (simp add: omultiset_def, clarify) | |
| 1147 | apply (rule_tac x = "i Un ia" in exI) | |
| 1148 | apply (simp add: Mult_iff_multiset Ord_Un Un_subset_iff) | |
| 1149 | apply (blast intro: field_Memrel_mono) | |
| 1150 | done | |
| 1151 | ||
| 1152 | lemma mdiff_omultiset [simp]: "omultiset(M) ==> omultiset(M -# N)" | |
| 1153 | apply (simp add: omultiset_def, clarify) | |
| 1154 | apply (simp add: Mult_iff_multiset) | |
| 1155 | apply (rule_tac x = i in exI) | |
| 1156 | apply (simp (no_asm_simp)) | |
| 1157 | done | |
| 1158 | ||
| 1159 | (** Proving that Memrel is a partial order **) | |
| 1160 | ||
| 1161 | lemma irrefl_Memrel: "Ord(i) ==> irrefl(field(Memrel(i)), Memrel(i))" | |
| 1162 | apply (rule irreflI, clarify) | |
| 1163 | apply (subgoal_tac "Ord (x) ") | |
| 1164 | prefer 2 apply (blast intro: Ord_in_Ord) | |
| 1165 | apply (drule_tac i = x in ltI [THEN lt_irrefl], auto) | |
| 1166 | done | |
| 1167 | ||
| 1168 | lemma trans_iff_trans_on: "trans(r) <-> trans[field(r)](r)" | |
| 1169 | by (simp add: trans_on_def trans_def, auto) | |
| 1170 | ||
| 1171 | lemma part_ord_Memrel: "Ord(i) ==>part_ord(field(Memrel(i)), Memrel(i))" | |
| 1172 | apply (simp add: part_ord_def) | |
| 1173 | apply (simp (no_asm) add: trans_iff_trans_on [THEN iff_sym]) | |
| 1174 | apply (blast intro: trans_Memrel irrefl_Memrel) | |
| 1175 | done | |
| 1176 | ||
| 1177 | (* | |
| 1178 | Ord(i) ==> | |
| 1179 |   part_ord(field(Memrel(i))-||>nat-{0}, multirel(field(Memrel(i)), Memrel(i)))
 | |
| 1180 | *) | |
| 1181 | ||
| 1182 | lemmas part_ord_mless = part_ord_Memrel [THEN part_ord_multirel, standard] | |
| 1183 | ||
| 1184 | (*irreflexivity*) | |
| 1185 | ||
| 1186 | lemma mless_not_refl: "~(M <# M)" | |
| 1187 | apply (simp add: mless_def, clarify) | |
| 1188 | apply (frule multirel_type [THEN subsetD]) | |
| 1189 | apply (drule part_ord_mless) | |
| 1190 | apply (simp add: part_ord_def irrefl_def) | |
| 1191 | done | |
| 1192 | ||
| 1193 | (* N<N ==> R *) | |
| 1194 | lemmas mless_irrefl = mless_not_refl [THEN notE, standard, elim!] | |
| 1195 | ||
| 1196 | (*transitivity*) | |
| 1197 | lemma mless_trans: "[| K <# M; M <# N |] ==> K <# N" | |
| 1198 | apply (simp add: mless_def, clarify) | |
| 1199 | apply (rule_tac x = "i Un ia" in exI) | |
| 1200 | apply (blast dest: multirel_Memrel_mono [OF Un_upper1 Un_upper1, THEN subsetD] | |
| 1201 | multirel_Memrel_mono [OF Un_upper2 Un_upper2, THEN subsetD] | |
| 1202 | intro: multirel_trans Ord_Un) | |
| 1203 | done | |
| 1204 | ||
| 1205 | (*asymmetry*) | |
| 1206 | lemma mless_not_sym: "M <# N ==> ~ N <# M" | |
| 1207 | apply clarify | |
| 1208 | apply (rule mless_not_refl [THEN notE]) | |
| 1209 | apply (erule mless_trans, assumption) | |
| 1210 | done | |
| 1211 | ||
| 1212 | lemma mless_asym: "[| M <# N; ~P ==> N <# M |] ==> P" | |
| 1213 | by (blast dest: mless_not_sym) | |
| 1214 | ||
| 1215 | lemma mle_refl [simp]: "omultiset(M) ==> M <#= M" | |
| 1216 | by (simp add: mle_def) | |
| 1217 | ||
| 1218 | (*anti-symmetry*) | |
| 1219 | lemma mle_antisym: | |
| 1220 | "[| M <#= N; N <#= M |] ==> M = N" | |
| 1221 | apply (simp add: mle_def) | |
| 1222 | apply (blast dest: mless_not_sym) | |
| 1223 | done | |
| 1224 | ||
| 1225 | (*transitivity*) | |
| 1226 | lemma mle_trans: "[| K <#= M; M <#= N |] ==> K <#= N" | |
| 1227 | apply (simp add: mle_def) | |
| 1228 | apply (blast intro: mless_trans) | |
| 1229 | done | |
| 1230 | ||
| 1231 | lemma mless_le_iff: "M <# N <-> (M <#= N & M \<noteq> N)" | |
| 1232 | by (simp add: mle_def, auto) | |
| 1233 | ||
| 1234 | (** Monotonicity of mless **) | |
| 1235 | ||
| 1236 | lemma munion_less_mono2: "[| M <# N; omultiset(K) |] ==> K +# M <# K +# N" | |
| 1237 | apply (simp add: mless_def omultiset_def, clarify) | |
| 1238 | apply (rule_tac x = "i Un ia" in exI) | |
| 1239 | apply (simp add: Mult_iff_multiset Ord_Un Un_subset_iff) | |
| 1240 | apply (rule munion_multirel_mono2) | |
| 1241 | apply (blast intro: multirel_Memrel_mono [THEN subsetD]) | |
| 1242 | apply (simp add: Mult_iff_multiset) | |
| 1243 | apply (blast intro: field_Memrel_mono [THEN subsetD]) | |
| 1244 | done | |
| 1245 | ||
| 1246 | lemma munion_less_mono1: "[| M <# N; omultiset(K) |] ==> M +# K <# N +# K" | |
| 1247 | by (force dest: munion_less_mono2 simp add: munion_commute) | |
| 1248 | ||
| 1249 | lemma mless_imp_omultiset: "M <# N ==> omultiset(M) & omultiset(N)" | |
| 1250 | by (auto simp add: mless_def omultiset_def dest: multirel_type [THEN subsetD]) | |
| 1251 | ||
| 1252 | lemma munion_less_mono: "[| M <# K; N <# L |] ==> M +# N <# K +# L" | |
| 1253 | apply (frule_tac M = M in mless_imp_omultiset) | |
| 1254 | apply (frule_tac M = N in mless_imp_omultiset) | |
| 1255 | apply (blast intro: munion_less_mono1 munion_less_mono2 mless_trans) | |
| 1256 | done | |
| 1257 | ||
| 1258 | (* <#= *) | |
| 1259 | ||
| 1260 | lemma mle_imp_omultiset: "M <#= N ==> omultiset(M) & omultiset(N)" | |
| 1261 | by (auto simp add: mle_def mless_imp_omultiset) | |
| 1262 | ||
| 1263 | lemma mle_mono: "[| M <#= K; N <#= L |] ==> M +# N <#= K +# L" | |
| 1264 | apply (frule_tac M = M in mle_imp_omultiset) | |
| 1265 | apply (frule_tac M = N in mle_imp_omultiset) | |
| 1266 | apply (auto simp add: mle_def intro: munion_less_mono1 munion_less_mono2 munion_less_mono) | |
| 1267 | done | |
| 1268 | ||
| 1269 | lemma omultiset_0 [iff]: "omultiset(0)" | |
| 1270 | by (auto simp add: omultiset_def Mult_iff_multiset) | |
| 1271 | ||
| 1272 | lemma empty_leI [simp]: "omultiset(M) ==> 0 <#= M" | |
| 1273 | apply (simp add: mle_def mless_def) | |
| 15481 | 1274 | apply (subgoal_tac "\<exists>i. Ord (i) & M \<in> Mult(field(Memrel(i))) ") | 
| 15201 | 1275 | prefer 2 apply (simp add: omultiset_def) | 
| 1276 | apply (case_tac "M=0", simp_all, clarify) | |
| 15481 | 1277 | apply (subgoal_tac "<0 +# 0, 0 +# M> \<in> multirel(field (Memrel(i)), Memrel(i))") | 
| 15201 | 1278 | apply (rule_tac [2] one_step_implies_multirel) | 
| 1279 | apply (auto simp add: Mult_iff_multiset) | |
| 1280 | done | |
| 1281 | ||
| 1282 | lemma munion_upper1: "[| omultiset(M); omultiset(N) |] ==> M <#= M +# N" | |
| 1283 | apply (subgoal_tac "M +# 0 <#= M +# N") | |
| 1284 | apply (rule_tac [2] mle_mono, auto) | |
| 1285 | done | |
| 1286 | ||
| 1287 | ML | |
| 1288 | {*
 | |
| 1289 | val munion_ac = thms "munion_ac"; | |
| 1290 | val funrestrict_subset = thm "funrestrict_subset"; | |
| 1291 | val funrestrict_type = thm "funrestrict_type"; | |
| 1292 | val funrestrict_type2 = thm "funrestrict_type2"; | |
| 1293 | val funrestrict = thm "funrestrict"; | |
| 1294 | val funrestrict_empty = thm "funrestrict_empty"; | |
| 1295 | val domain_funrestrict = thm "domain_funrestrict"; | |
| 1296 | val fun_cons_funrestrict_eq = thm "fun_cons_funrestrict_eq"; | |
| 1297 | val multiset_fun_iff = thm "multiset_fun_iff"; | |
| 1298 | val multiset_into_Mult = thm "multiset_into_Mult"; | |
| 1299 | val Mult_into_multiset = thm "Mult_into_multiset"; | |
| 1300 | val Mult_iff_multiset = thm "Mult_iff_multiset"; | |
| 1301 | val multiset_iff_Mult_mset_of = thm "multiset_iff_Mult_mset_of"; | |
| 1302 | val multiset_0 = thm "multiset_0"; | |
| 1303 | val multiset_set_of_Finite = thm "multiset_set_of_Finite"; | |
| 1304 | val mset_of_0 = thm "mset_of_0"; | |
| 1305 | val mset_is_0_iff = thm "mset_is_0_iff"; | |
| 1306 | val mset_of_single = thm "mset_of_single"; | |
| 1307 | val mset_of_union = thm "mset_of_union"; | |
| 1308 | val mset_of_diff = thm "mset_of_diff"; | |
| 1309 | val msingle_not_0 = thm "msingle_not_0"; | |
| 1310 | val msingle_eq_iff = thm "msingle_eq_iff"; | |
| 1311 | val msingle_multiset = thm "msingle_multiset"; | |
| 1312 | val Collect_Finite = thms "Collect_Finite"; | |
| 1313 | val normalize_idem = thm "normalize_idem"; | |
| 1314 | val normalize_multiset = thm "normalize_multiset"; | |
| 1315 | val multiset_normalize = thm "multiset_normalize"; | |
| 1316 | val munion_multiset = thm "munion_multiset"; | |
| 1317 | val mdiff_multiset = thm "mdiff_multiset"; | |
| 1318 | val munion_0 = thm "munion_0"; | |
| 1319 | val munion_commute = thm "munion_commute"; | |
| 1320 | val munion_assoc = thm "munion_assoc"; | |
| 1321 | val munion_lcommute = thm "munion_lcommute"; | |
| 1322 | val mdiff_self_eq_0 = thm "mdiff_self_eq_0"; | |
| 1323 | val mdiff_0 = thm "mdiff_0"; | |
| 1324 | val mdiff_0_right = thm "mdiff_0_right"; | |
| 1325 | val mdiff_union_inverse2 = thm "mdiff_union_inverse2"; | |
| 1326 | val mcount_type = thm "mcount_type"; | |
| 1327 | val mcount_0 = thm "mcount_0"; | |
| 1328 | val mcount_single = thm "mcount_single"; | |
| 1329 | val mcount_union = thm "mcount_union"; | |
| 1330 | val mcount_diff = thm "mcount_diff"; | |
| 1331 | val mcount_elem = thm "mcount_elem"; | |
| 1332 | val msize_0 = thm "msize_0"; | |
| 1333 | val msize_single = thm "msize_single"; | |
| 1334 | val msize_type = thm "msize_type"; | |
| 1335 | val msize_zpositive = thm "msize_zpositive"; | |
| 1336 | val msize_int_of_nat = thm "msize_int_of_nat"; | |
| 1337 | val not_empty_multiset_imp_exist = thm "not_empty_multiset_imp_exist"; | |
| 1338 | val msize_eq_0_iff = thm "msize_eq_0_iff"; | |
| 1339 | val setsum_mcount_Int = thm "setsum_mcount_Int"; | |
| 1340 | val msize_union = thm "msize_union"; | |
| 1341 | val msize_eq_succ_imp_elem = thm "msize_eq_succ_imp_elem"; | |
| 1342 | val multiset_equality = thm "multiset_equality"; | |
| 1343 | val munion_eq_0_iff = thm "munion_eq_0_iff"; | |
| 1344 | val empty_eq_munion_iff = thm "empty_eq_munion_iff"; | |
| 1345 | val munion_right_cancel = thm "munion_right_cancel"; | |
| 1346 | val munion_left_cancel = thm "munion_left_cancel"; | |
| 1347 | val nat_add_eq_1_cases = thm "nat_add_eq_1_cases"; | |
| 1348 | val munion_is_single = thm "munion_is_single"; | |
| 1349 | val msingle_is_union = thm "msingle_is_union"; | |
| 1350 | val setsum_decr = thm "setsum_decr"; | |
| 1351 | val setsum_decr2 = thm "setsum_decr2"; | |
| 1352 | val setsum_decr3 = thm "setsum_decr3"; | |
| 1353 | val nat_le_1_cases = thm "nat_le_1_cases"; | |
| 1354 | val succ_pred_eq_self = thm "succ_pred_eq_self"; | |
| 1355 | val multiset_funrestict = thm "multiset_funrestict"; | |
| 1356 | val multiset_induct_aux = thm "multiset_induct_aux"; | |
| 1357 | val multiset_induct2 = thm "multiset_induct2"; | |
| 1358 | val munion_single_case1 = thm "munion_single_case1"; | |
| 1359 | val munion_single_case2 = thm "munion_single_case2"; | |
| 1360 | val multiset_induct = thm "multiset_induct"; | |
| 1361 | val MCollect_multiset = thm "MCollect_multiset"; | |
| 1362 | val mset_of_MCollect = thm "mset_of_MCollect"; | |
| 1363 | val MCollect_mem_iff = thm "MCollect_mem_iff"; | |
| 1364 | val mcount_MCollect = thm "mcount_MCollect"; | |
| 1365 | val multiset_partition = thm "multiset_partition"; | |
| 1366 | val natify_elem_is_self = thm "natify_elem_is_self"; | |
| 1367 | val munion_eq_conv_diff = thm "munion_eq_conv_diff"; | |
| 1368 | val melem_diff_single = thm "melem_diff_single"; | |
| 1369 | val munion_eq_conv_exist = thm "munion_eq_conv_exist"; | |
| 1370 | val multirel1_type = thm "multirel1_type"; | |
| 1371 | val multirel1_0 = thm "multirel1_0"; | |
| 1372 | val multirel1_iff = thm "multirel1_iff"; | |
| 1373 | val multirel1_mono1 = thm "multirel1_mono1"; | |
| 1374 | val multirel1_mono2 = thm "multirel1_mono2"; | |
| 1375 | val multirel1_mono = thm "multirel1_mono"; | |
| 1376 | val not_less_0 = thm "not_less_0"; | |
| 1377 | val less_munion = thm "less_munion"; | |
| 1378 | val multirel1_base = thm "multirel1_base"; | |
| 1379 | val acc_0 = thm "acc_0"; | |
| 1380 | val all_accessible = thm "all_accessible"; | |
| 1381 | val wf_on_multirel1 = thm "wf_on_multirel1"; | |
| 1382 | val wf_multirel1 = thm "wf_multirel1"; | |
| 1383 | val multirel_type = thm "multirel_type"; | |
| 1384 | val multirel_mono = thm "multirel_mono"; | |
| 1385 | val add_diff_eq = thm "add_diff_eq"; | |
| 1386 | val mdiff_union_single_conv = thm "mdiff_union_single_conv"; | |
| 1387 | val diff_add_commute = thm "diff_add_commute"; | |
| 1388 | val multirel_implies_one_step = thm "multirel_implies_one_step"; | |
| 1389 | val melem_imp_eq_diff_union = thm "melem_imp_eq_diff_union"; | |
| 1390 | val msize_eq_succ_imp_eq_union = thm "msize_eq_succ_imp_eq_union"; | |
| 1391 | val one_step_implies_multirel = thm "one_step_implies_multirel"; | |
| 1392 | val irrefl_on_multirel = thm "irrefl_on_multirel"; | |
| 1393 | val trans_on_multirel = thm "trans_on_multirel"; | |
| 1394 | val multirel_trans = thm "multirel_trans"; | |
| 1395 | val trans_multirel = thm "trans_multirel"; | |
| 1396 | val part_ord_multirel = thm "part_ord_multirel"; | |
| 1397 | val munion_multirel1_mono = thm "munion_multirel1_mono"; | |
| 1398 | val munion_multirel_mono2 = thm "munion_multirel_mono2"; | |
| 1399 | val munion_multirel_mono1 = thm "munion_multirel_mono1"; | |
| 1400 | val munion_multirel_mono = thm "munion_multirel_mono"; | |
| 1401 | val field_Memrel_mono = thms "field_Memrel_mono"; | |
| 1402 | val multirel_Memrel_mono = thms "multirel_Memrel_mono"; | |
| 1403 | val omultiset_is_multiset = thm "omultiset_is_multiset"; | |
| 1404 | val munion_omultiset = thm "munion_omultiset"; | |
| 1405 | val mdiff_omultiset = thm "mdiff_omultiset"; | |
| 1406 | val irrefl_Memrel = thm "irrefl_Memrel"; | |
| 1407 | val trans_iff_trans_on = thm "trans_iff_trans_on"; | |
| 1408 | val part_ord_Memrel = thm "part_ord_Memrel"; | |
| 1409 | val part_ord_mless = thms "part_ord_mless"; | |
| 1410 | val mless_not_refl = thm "mless_not_refl"; | |
| 1411 | val mless_irrefl = thms "mless_irrefl"; | |
| 1412 | val mless_trans = thm "mless_trans"; | |
| 1413 | val mless_not_sym = thm "mless_not_sym"; | |
| 1414 | val mless_asym = thm "mless_asym"; | |
| 1415 | val mle_refl = thm "mle_refl"; | |
| 1416 | val mle_antisym = thm "mle_antisym"; | |
| 1417 | val mle_trans = thm "mle_trans"; | |
| 1418 | val mless_le_iff = thm "mless_le_iff"; | |
| 1419 | val munion_less_mono2 = thm "munion_less_mono2"; | |
| 1420 | val munion_less_mono1 = thm "munion_less_mono1"; | |
| 1421 | val mless_imp_omultiset = thm "mless_imp_omultiset"; | |
| 1422 | val munion_less_mono = thm "munion_less_mono"; | |
| 1423 | val mle_imp_omultiset = thm "mle_imp_omultiset"; | |
| 1424 | val mle_mono = thm "mle_mono"; | |
| 1425 | val omultiset_0 = thm "omultiset_0"; | |
| 1426 | val empty_leI = thm "empty_leI"; | |
| 1427 | val munion_upper1 = thm "munion_upper1"; | |
| 1428 | *} | |
| 1429 | ||
| 12089 
34e7693271a9
Sidi Ehmety's port of the fold_set operator and multisets to ZF.
 paulson parents: diff
changeset | 1430 | end |