src/HOL/Library/Multiset.thy
changeset 74860 3e55e47a37e7
parent 74859 250ab1334309
child 74861 74ac414618e2
equal deleted inserted replaced
74859:250ab1334309 74860:3e55e47a37e7
  2787 qed
  2787 qed
  2788 
  2788 
  2789 
  2789 
  2790 subsection \<open>The multiset order\<close>
  2790 subsection \<open>The multiset order\<close>
  2791 
  2791 
  2792 subsubsection \<open>Well-foundedness\<close>
       
  2793 
       
  2794 definition mult1 :: "('a \<times> 'a) set \<Rightarrow> ('a multiset \<times> 'a multiset) set" where
  2792 definition mult1 :: "('a \<times> 'a) set \<Rightarrow> ('a multiset \<times> 'a multiset) set" where
  2795   "mult1 r = {(N, M). \<exists>a M0 K. M = add_mset a M0 \<and> N = M0 + K \<and>
  2793   "mult1 r = {(N, M). \<exists>a M0 K. M = add_mset a M0 \<and> N = M0 + K \<and>
  2796       (\<forall>b. b \<in># K \<longrightarrow> (b, a) \<in> r)}"
  2794       (\<forall>b. b \<in># K \<longrightarrow> (b, a) \<in> r)}"
  2797 
  2795 
  2798 definition mult :: "('a \<times> 'a) set \<Rightarrow> ('a multiset \<times> 'a multiset) set" where
  2796 definition mult :: "('a \<times> 'a) set \<Rightarrow> ('a multiset \<times> 'a multiset) set" where
  2831     by (fact mono_mult[THEN subsetD, rotated])
  2829     by (fact mono_mult[THEN subsetD, rotated])
  2832 qed
  2830 qed
  2833 
  2831 
  2834 lemma not_less_empty [iff]: "(M, {#}) \<notin> mult1 r"
  2832 lemma not_less_empty [iff]: "(M, {#}) \<notin> mult1 r"
  2835   by (simp add: mult1_def)
  2833   by (simp add: mult1_def)
       
  2834 
       
  2835 
       
  2836 subsubsection \<open>Well-foundedness\<close>
  2836 
  2837 
  2837 lemma less_add:
  2838 lemma less_add:
  2838   assumes mult1: "(N, add_mset a M0) \<in> mult1 r"
  2839   assumes mult1: "(N, add_mset a M0) \<in> mult1 r"
  2839   shows
  2840   shows
  2840     "(\<exists>M. (M, M0) \<in> mult1 r \<and> N = add_mset a M) \<or>
  2841     "(\<exists>M. (M, M0) \<in> mult1 r \<and> N = add_mset a M) \<or>
  2932     qed
  2933     qed
  2933     from this and \<open>M \<in> ?W\<close> show "add_mset a M \<in> ?W" ..
  2934     from this and \<open>M \<in> ?W\<close> show "add_mset a M \<in> ?W" ..
  2934   qed
  2935   qed
  2935 qed
  2936 qed
  2936 
  2937 
  2937 theorem wf_mult1: "wf r \<Longrightarrow> wf (mult1 r)"
  2938 lemma wf_mult1: "wf r \<Longrightarrow> wf (mult1 r)"
  2938 by (rule acc_wfI) (rule all_accessible)
  2939   by (rule acc_wfI) (rule all_accessible)
  2939 
  2940 
  2940 theorem wf_mult: "wf r \<Longrightarrow> wf (mult r)"
  2941 lemma wf_mult: "wf r \<Longrightarrow> wf (mult r)"
  2941 unfolding mult_def by (rule wf_trancl) (rule wf_mult1)
  2942   unfolding mult_def by (rule wf_trancl) (rule wf_mult1)
       
  2943 
       
  2944 lemma wfP_multp: "wfP r \<Longrightarrow> wfP (multp r)"
       
  2945   unfolding multp_def wfP_def
       
  2946   by (simp add: wf_mult)
  2942 
  2947 
  2943 
  2948 
  2944 subsubsection \<open>Closure-free presentation\<close>
  2949 subsubsection \<open>Closure-free presentation\<close>
  2945 
  2950 
  2946 text \<open>One direction.\<close>
  2951 text \<open>One direction.\<close>