src/HOL/Library/Multiset.thy
changeset 66425 8756322dc5de
parent 66313 604616b627f2
child 66434 5d7e770c7d5d
equal deleted inserted replaced
66423:df186e69b651 66425:8756322dc5de
   384 qed
   384 qed
   385 
   385 
   386 lemma union_iff:
   386 lemma union_iff:
   387   "a \<in># A + B \<longleftrightarrow> a \<in># A \<or> a \<in># B"
   387   "a \<in># A + B \<longleftrightarrow> a \<in># A \<or> a \<in># B"
   388   by auto
   388   by auto
       
   389 
       
   390 
       
   391 subsubsection \<open>Min and Max\<close>
       
   392 
       
   393 abbreviation Min_mset :: "'a::linorder multiset \<Rightarrow> 'a" where
       
   394 "Min_mset m \<equiv> Min (set_mset m)"
       
   395 
       
   396 abbreviation Max_mset :: "'a::linorder multiset \<Rightarrow> 'a" where
       
   397 "Max_mset m \<equiv> Max (set_mset m)"
   389 
   398 
   390 
   399 
   391 subsubsection \<open>Equality of multisets\<close>
   400 subsubsection \<open>Equality of multisets\<close>
   392 
   401 
   393 lemma single_eq_single [simp]: "{#a#} = {#b#} \<longleftrightarrow> a = b"
   402 lemma single_eq_single [simp]: "{#a#} = {#b#} \<longleftrightarrow> a = b"
  1467   shows "P M"
  1476   shows "P M"
  1468 proof (induct "size M" arbitrary: M)
  1477 proof (induct "size M" arbitrary: M)
  1469   case (Suc k)
  1478   case (Suc k)
  1470   note ih = this(1) and Sk_eq_sz_M = this(2)
  1479   note ih = this(1) and Sk_eq_sz_M = this(2)
  1471 
  1480 
  1472   let ?y = "Min (set_mset M)"
  1481   let ?y = "Min_mset M"
  1473   let ?N = "M - {#?y#}"
  1482   let ?N = "M - {#?y#}"
  1474 
  1483 
  1475   have M: "M = add_mset ?y ?N"
  1484   have M: "M = add_mset ?y ?N"
  1476     by (metis Min_in Sk_eq_sz_M finite_set_mset insert_DiffM lessI not_less_zero
  1485     by (metis Min_in Sk_eq_sz_M finite_set_mset insert_DiffM lessI not_less_zero
  1477       set_mset_eq_empty_iff size_empty)
  1486       set_mset_eq_empty_iff size_empty)
  1488   shows "P M"
  1497   shows "P M"
  1489 proof (induct "size M" arbitrary: M)
  1498 proof (induct "size M" arbitrary: M)
  1490   case (Suc k)
  1499   case (Suc k)
  1491   note ih = this(1) and Sk_eq_sz_M = this(2)
  1500   note ih = this(1) and Sk_eq_sz_M = this(2)
  1492 
  1501 
  1493   let ?y = "Max (set_mset M)"
  1502   let ?y = "Max_mset M"
  1494   let ?N = "M - {#?y#}"
  1503   let ?N = "M - {#?y#}"
  1495 
  1504 
  1496   have M: "M = add_mset ?y ?N"
  1505   have M: "M = add_mset ?y ?N"
  1497     by (metis Max_in Sk_eq_sz_M finite_set_mset insert_DiffM lessI not_less_zero
  1506     by (metis Max_in Sk_eq_sz_M finite_set_mset insert_DiffM lessI not_less_zero
  1498       set_mset_eq_empty_iff size_empty)
  1507       set_mset_eq_empty_iff size_empty)