author | wenzelm |
Mon, 01 Jul 2024 12:59:46 +0200 | |
changeset 80464 | 98d7d21c1bde |
parent 80324 | a6d5de03ffeb |
permissions | -rw-r--r-- |
59813 | 1 |
(* Title: HOL/Library/Multiset_Order.thy |
2 |
Author: Dmitriy Traytel, TU Muenchen |
|
3 |
Author: Jasmin Blanchette, Inria, LORIA, MPII |
|
77990 | 4 |
Author: Martin Desharnais, MPI-INF Saarbruecken |
59813 | 5 |
*) |
6 |
||
60500 | 7 |
section \<open>More Theorems about the Multiset Order\<close> |
59813 | 8 |
|
9 |
theory Multiset_Order |
|
10 |
imports Multiset |
|
11 |
begin |
|
12 |
||
65546 | 13 |
subsection \<open>Alternative Characterizations\<close> |
59813 | 14 |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
15 |
subsubsection \<open>The Dershowitz--Manna Ordering\<close> |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
16 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
17 |
definition multp\<^sub>D\<^sub>M where |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
18 |
"multp\<^sub>D\<^sub>M r M N \<longleftrightarrow> |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
19 |
(\<exists>X Y. X \<noteq> {#} \<and> X \<subseteq># N \<and> M = (N - X) + Y \<and> (\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> r k a)))" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
20 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
21 |
lemma multp\<^sub>D\<^sub>M_imp_multp: |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
22 |
"multp\<^sub>D\<^sub>M r M N \<Longrightarrow> multp r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
23 |
proof - |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
24 |
assume "multp\<^sub>D\<^sub>M r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
25 |
then obtain X Y where |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
26 |
"X \<noteq> {#}" and "X \<subseteq># N" and "M = N - X + Y" and "\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> r k a)" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
27 |
unfolding multp\<^sub>D\<^sub>M_def by blast |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
28 |
then have "multp r (N - X + Y) (N - X + X)" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
29 |
by (intro one_step_implies_multp) (auto simp: Bex_def trans_def) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
30 |
with \<open>M = N - X + Y\<close> \<open>X \<subseteq># N\<close> show "multp r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
31 |
by (metis subset_mset.diff_add) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
32 |
qed |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
33 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
34 |
subsubsection \<open>The Huet--Oppen Ordering\<close> |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
35 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
36 |
definition multp\<^sub>H\<^sub>O where |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
37 |
"multp\<^sub>H\<^sub>O r M N \<longleftrightarrow> M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x. r y x \<and> count M x < count N x))" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
38 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
39 |
lemma multp_imp_multp\<^sub>H\<^sub>O: |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
40 |
assumes "asymp r" and "transp r" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
41 |
shows "multp r M N \<Longrightarrow> multp\<^sub>H\<^sub>O r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
42 |
unfolding multp_def mult_def |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
43 |
proof (induction rule: trancl_induct) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
44 |
case (base P) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
45 |
then show ?case |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
46 |
using \<open>asymp r\<close> |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
47 |
by (auto elim!: mult1_lessE simp: count_eq_zero_iff multp\<^sub>H\<^sub>O_def split: if_splits |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
48 |
dest!: Suc_lessD) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
49 |
next |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
50 |
case (step N P) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
51 |
from step(3) have "M \<noteq> N" and |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
52 |
**: "\<And>y. count N y < count M y \<Longrightarrow> (\<exists>x. r y x \<and> count M x < count N x)" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
53 |
by (simp_all add: multp\<^sub>H\<^sub>O_def) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
54 |
from step(2) obtain M0 a K where |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
55 |
*: "P = add_mset a M0" "N = M0 + K" "a \<notin># K" "\<And>b. b \<in># K \<Longrightarrow> r b a" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
56 |
using \<open>asymp r\<close> by (auto elim: mult1_lessE) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
57 |
from \<open>M \<noteq> N\<close> ** *(1,2,3) have "M \<noteq> P" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
58 |
using *(4) \<open>asymp r\<close> |
76682
e260dabc88e6
added predicates asym_on and asymp_on and redefined asym and asymp to be abbreviations
desharna
parents:
74869
diff
changeset
|
59 |
by (metis asympD add_cancel_right_right add_diff_cancel_left' add_mset_add_single count_inI |
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
60 |
count_union diff_diff_add_mset diff_single_trivial in_diff_count multi_member_last) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
61 |
moreover |
80464 | 62 |
have count_a: "\<exists>z. r a z \<and> count M z < count P z" if "count P a \<le> count M a" |
63 |
proof - |
|
64 |
from \<open>a \<notin># K\<close> and that have "count N a < count M a" |
|
65 |
unfolding *(1,2) by (auto simp add: not_in_iff) |
|
66 |
with ** obtain z where z: "r a z" "count M z < count N z" |
|
67 |
by blast |
|
68 |
with * have "count N z \<le> count P z" |
|
69 |
using \<open>asymp r\<close> |
|
70 |
by (metis add_diff_cancel_left' add_mset_add_single asympD diff_diff_add_mset |
|
71 |
diff_single_trivial in_diff_count not_le_imp_less) |
|
72 |
with z show ?thesis by auto |
|
73 |
qed |
|
74 |
have "\<exists>x. r y x \<and> count M x < count P x" if count_y: "count P y < count M y" for y |
|
75 |
proof (cases "y = a") |
|
76 |
case True |
|
77 |
with count_y count_a show ?thesis by auto |
|
78 |
next |
|
79 |
case False |
|
80 |
show ?thesis |
|
81 |
proof (cases "y \<in># K") |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
82 |
case True |
80464 | 83 |
with *(4) have "r y a" by simp |
84 |
then show ?thesis |
|
85 |
by (cases "count P a \<le> count M a") (auto dest: count_a intro: \<open>transp r\<close>[THEN transpD]) |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
86 |
next |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
87 |
case False |
80464 | 88 |
with \<open>y \<noteq> a\<close> have "count P y = count N y" unfolding *(1,2) |
89 |
by (simp add: not_in_iff) |
|
90 |
with count_y ** obtain z where z: "r y z" "count M z < count N z" by auto |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
91 |
show ?thesis |
80464 | 92 |
proof (cases "z \<in># K") |
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
93 |
case True |
80464 | 94 |
with *(4) have "r z a" by simp |
95 |
with z(1) show ?thesis |
|
96 |
by (cases "count P a \<le> count M a") (auto dest!: count_a intro: \<open>transp r\<close>[THEN transpD]) |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
97 |
next |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
98 |
case False |
80464 | 99 |
with \<open>a \<notin># K\<close> have "count N z \<le> count P z" unfolding * |
100 |
by (auto simp add: not_in_iff) |
|
101 |
with z show ?thesis by auto |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
102 |
qed |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
103 |
qed |
80464 | 104 |
qed |
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
105 |
ultimately show ?case unfolding multp\<^sub>H\<^sub>O_def by blast |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
106 |
qed |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
107 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
108 |
lemma multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M: "multp\<^sub>H\<^sub>O r M N \<Longrightarrow> multp\<^sub>D\<^sub>M r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
109 |
unfolding multp\<^sub>D\<^sub>M_def |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
110 |
proof (intro iffI exI conjI) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
111 |
assume "multp\<^sub>H\<^sub>O r M N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
112 |
then obtain z where z: "count M z < count N z" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
113 |
unfolding multp\<^sub>H\<^sub>O_def by (auto simp: multiset_eq_iff nat_neq_iff) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
114 |
define X where "X = N - M" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
115 |
define Y where "Y = M - N" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
116 |
from z show "X \<noteq> {#}" unfolding X_def by (auto simp: multiset_eq_iff not_less_eq_eq Suc_le_eq) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
117 |
from z show "X \<subseteq># N" unfolding X_def by auto |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
118 |
show "M = (N - X) + Y" unfolding X_def Y_def multiset_eq_iff count_union count_diff by force |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
119 |
show "\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> r k a)" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
120 |
proof (intro allI impI) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
121 |
fix k |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
122 |
assume "k \<in># Y" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
123 |
then have "count N k < count M k" unfolding Y_def |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
124 |
by (auto simp add: in_diff_count) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
125 |
with \<open>multp\<^sub>H\<^sub>O r M N\<close> obtain a where "r k a" and "count M a < count N a" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
126 |
unfolding multp\<^sub>H\<^sub>O_def by blast |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
127 |
then show "\<exists>a. a \<in># X \<and> r k a" unfolding X_def |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
128 |
by (auto simp add: in_diff_count) |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
129 |
qed |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
130 |
qed |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
131 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
132 |
lemma multp_eq_multp\<^sub>D\<^sub>M: "asymp r \<Longrightarrow> transp r \<Longrightarrow> multp r = multp\<^sub>D\<^sub>M r" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
133 |
using multp\<^sub>D\<^sub>M_imp_multp multp_imp_multp\<^sub>H\<^sub>O[THEN multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
134 |
by blast |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
135 |
|
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
136 |
lemma multp_eq_multp\<^sub>H\<^sub>O: "asymp r \<Longrightarrow> transp r \<Longrightarrow> multp r = multp\<^sub>H\<^sub>O r" |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
137 |
using multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M[THEN multp\<^sub>D\<^sub>M_imp_multp] multp_imp_multp\<^sub>H\<^sub>O |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
138 |
by blast |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
139 |
|
77354 | 140 |
lemma multp\<^sub>D\<^sub>M_plus_plusI[simp]: |
141 |
assumes "multp\<^sub>D\<^sub>M R M1 M2" |
|
142 |
shows "multp\<^sub>D\<^sub>M R (M + M1) (M + M2)" |
|
143 |
proof - |
|
144 |
from assms obtain X Y where |
|
145 |
"X \<noteq> {#}" and "X \<subseteq># M2" and "M1 = M2 - X + Y" and "\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> R k a)" |
|
146 |
unfolding multp\<^sub>D\<^sub>M_def by auto |
|
147 |
||
148 |
show "multp\<^sub>D\<^sub>M R (M + M1) (M + M2)" |
|
149 |
unfolding multp\<^sub>D\<^sub>M_def |
|
150 |
proof (intro exI conjI) |
|
151 |
show "X \<noteq> {#}" |
|
152 |
using \<open>X \<noteq> {#}\<close> by simp |
|
153 |
next |
|
154 |
show "X \<subseteq># M + M2" |
|
155 |
using \<open>X \<subseteq># M2\<close> |
|
156 |
by (simp add: subset_mset.add_increasing) |
|
157 |
next |
|
158 |
show "M + M1 = M + M2 - X + Y" |
|
159 |
using \<open>X \<subseteq># M2\<close> \<open>M1 = M2 - X + Y\<close> |
|
160 |
by (metis multiset_diff_union_assoc union_assoc) |
|
161 |
next |
|
162 |
show "\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> R k a)" |
|
163 |
using \<open>\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> R k a)\<close> by simp |
|
164 |
qed |
|
165 |
qed |
|
166 |
||
77104 | 167 |
lemma multp\<^sub>H\<^sub>O_plus_plus[simp]: "multp\<^sub>H\<^sub>O R (M + M1) (M + M2) \<longleftrightarrow> multp\<^sub>H\<^sub>O R M1 M2" |
168 |
unfolding multp\<^sub>H\<^sub>O_def by simp |
|
169 |
||
77355
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
170 |
lemma strict_subset_implies_multp\<^sub>D\<^sub>M: "A \<subset># B \<Longrightarrow> multp\<^sub>D\<^sub>M r A B" |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
171 |
unfolding multp\<^sub>D\<^sub>M_def |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
172 |
by (metis add.right_neutral add_diff_cancel_right' empty_iff mset_subset_eq_add_right |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
173 |
set_mset_empty subset_mset.lessE) |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
174 |
|
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
175 |
lemma strict_subset_implies_multp\<^sub>H\<^sub>O: "A \<subset># B \<Longrightarrow> multp\<^sub>H\<^sub>O r A B" |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
176 |
unfolding multp\<^sub>H\<^sub>O_def |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
177 |
by (simp add: leD mset_subset_eq_count) |
b23367be6051
added lemmas strict_subset_implies_multpDM and strict_subset_implies_multpHO
desharna
parents:
77354
diff
changeset
|
178 |
|
77986 | 179 |
lemma multp\<^sub>H\<^sub>O_implies_one_step_strong: |
180 |
assumes "multp\<^sub>H\<^sub>O R A B" |
|
181 |
defines "J \<equiv> B - A" and "K \<equiv> A - B" |
|
182 |
shows "J \<noteq> {#}" and "\<forall>k \<in># K. \<exists>x \<in># J. R k x" |
|
183 |
proof - |
|
184 |
show "J \<noteq> {#}" |
|
185 |
using \<open>multp\<^sub>H\<^sub>O R A B\<close> |
|
186 |
by (metis Diff_eq_empty_iff_mset J_def add.right_neutral multp\<^sub>D\<^sub>M_def multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M |
|
187 |
multp\<^sub>H\<^sub>O_plus_plus subset_mset.add_diff_inverse subset_mset.le_zero_eq) |
|
188 |
||
189 |
show "\<forall>k\<in>#K. \<exists>x\<in>#J. R k x" |
|
190 |
using \<open>multp\<^sub>H\<^sub>O R A B\<close> |
|
191 |
by (metis J_def K_def in_diff_count multp\<^sub>H\<^sub>O_def) |
|
192 |
qed |
|
193 |
||
77988
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
194 |
lemma multp\<^sub>H\<^sub>O_minus_inter_minus_inter_iff: |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
195 |
fixes M1 M2 :: "_ multiset" |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
196 |
shows "multp\<^sub>H\<^sub>O R (M1 - M2) (M2 - M1) \<longleftrightarrow> multp\<^sub>H\<^sub>O R M1 M2" |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
197 |
by (metis diff_intersect_left_idem multiset_inter_commute multp\<^sub>H\<^sub>O_plus_plus |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
198 |
subset_mset.add_diff_inverse subset_mset.inf.cobounded1) |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
199 |
|
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
200 |
lemma multp\<^sub>H\<^sub>O_iff_set_mset_less\<^sub>H\<^sub>O_set_mset: |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
201 |
"multp\<^sub>H\<^sub>O R M1 M2 \<longleftrightarrow> (set_mset (M1 - M2) \<noteq> set_mset (M2 - M1) \<and> |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
202 |
(\<forall>y \<in># M1 - M2. (\<exists>x \<in># M2 - M1. R y x)))" |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
203 |
unfolding multp\<^sub>H\<^sub>O_minus_inter_minus_inter_iff[of R M1 M2, symmetric] |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
204 |
unfolding multp\<^sub>H\<^sub>O_def |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
205 |
unfolding count_minus_inter_lt_count_minus_inter_iff |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
206 |
unfolding minus_inter_eq_minus_inter_iff |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
207 |
by auto |
3e5f6e31c4fd
added lemmas multpHO_iff_set_mset_lessHO_set_mset and multpHO_minus_inter_minus_inter_iff
desharna
parents:
77986
diff
changeset
|
208 |
|
77063
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
209 |
|
77353
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
210 |
subsubsection \<open>Monotonicity\<close> |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
211 |
|
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
212 |
lemma multp\<^sub>D\<^sub>M_mono_strong: |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
213 |
"multp\<^sub>D\<^sub>M R M1 M2 \<Longrightarrow> (\<And>x y. x \<in># M1 \<Longrightarrow> y \<in># M2 \<Longrightarrow> R x y \<Longrightarrow> S x y) \<Longrightarrow> multp\<^sub>D\<^sub>M S M1 M2" |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
214 |
unfolding multp\<^sub>D\<^sub>M_def |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
215 |
by (metis add_diff_cancel_left' in_diffD subset_mset.diff_add) |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
216 |
|
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
217 |
lemma multp\<^sub>H\<^sub>O_mono_strong: |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
218 |
"multp\<^sub>H\<^sub>O R M1 M2 \<Longrightarrow> (\<And>x y. x \<in># M1 \<Longrightarrow> y \<in># M2 \<Longrightarrow> R x y \<Longrightarrow> S x y) \<Longrightarrow> multp\<^sub>H\<^sub>O S M1 M2" |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
219 |
unfolding multp\<^sub>H\<^sub>O_def |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
220 |
by (metis count_inI less_zeroE) |
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
221 |
|
42accfbf4d85
added lemmas multpDM_mono_strong and multpHO_mono_strong
desharna
parents:
77281
diff
changeset
|
222 |
|
78016 | 223 |
subsubsection \<open>Properties of Orders\<close> |
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
224 |
|
78016 | 225 |
paragraph \<open>Asymmetry\<close> |
77064 | 226 |
|
77281
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
227 |
text \<open>The following lemma is a negative result stating that asymmetry of an arbitrary binary |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
228 |
relation cannot be simply lifted to @{const multp\<^sub>H\<^sub>O}. It suffices to have four distinct values to |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
229 |
build a counterexample.\<close> |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
230 |
|
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
231 |
lemma asymp_not_liftable_to_multp\<^sub>H\<^sub>O: |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
232 |
fixes a b c d :: 'a |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
233 |
assumes "distinct [a, b, c, d]" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
234 |
shows "\<not> (\<forall>(R :: 'a \<Rightarrow> 'a \<Rightarrow> bool). asymp R \<longrightarrow> asymp (multp\<^sub>H\<^sub>O R))" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
235 |
proof - |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
236 |
define R :: "'a \<Rightarrow> 'a \<Rightarrow> bool" where |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
237 |
"R = (\<lambda>x y. x = a \<and> y = c \<or> x = b \<and> y = d \<or> x = c \<and> y = b \<or> x = d \<and> y = a)" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
238 |
|
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
239 |
from assms(1) have "{#a, b#} \<noteq> {#c, d#}" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
240 |
by (metis add_mset_add_single distinct.simps(2) list.set(1) list.simps(15) multi_member_this |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
241 |
set_mset_add_mset_insert set_mset_single) |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
242 |
|
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
243 |
from assms(1) have "asymp R" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
244 |
by (auto simp: R_def intro: asymp_onI) |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
245 |
moreover have "\<not> asymp (multp\<^sub>H\<^sub>O R)" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
246 |
unfolding asymp_on_def Set.ball_simps not_all not_imp not_not |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
247 |
proof (intro exI conjI) |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
248 |
show "multp\<^sub>H\<^sub>O R {#a, b#} {#c, d#}" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
249 |
unfolding multp\<^sub>H\<^sub>O_def |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
250 |
using \<open>{#a, b#} \<noteq> {#c, d#}\<close> R_def assms by auto |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
251 |
next |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
252 |
show "multp\<^sub>H\<^sub>O R {#c, d#} {#a, b#}" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
253 |
unfolding multp\<^sub>H\<^sub>O_def |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
254 |
using \<open>{#a, b#} \<noteq> {#c, d#}\<close> R_def assms by auto |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
255 |
qed |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
256 |
ultimately show ?thesis |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
257 |
unfolding not_all not_imp by auto |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
258 |
qed |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
259 |
|
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
260 |
text \<open>However, if the binary relation is both asymmetric and transitive, then @{const multp\<^sub>H\<^sub>O} is |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
261 |
also asymmetric.\<close> |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
262 |
|
77989 | 263 |
lemma asymp_on_multp\<^sub>H\<^sub>O: |
264 |
assumes "asymp_on A R" and "transp_on A R" and |
|
265 |
B_sub_A: "\<And>M. M \<in> B \<Longrightarrow> set_mset M \<subseteq> A" |
|
266 |
shows "asymp_on B (multp\<^sub>H\<^sub>O R)" |
|
267 |
proof (rule asymp_onI) |
|
268 |
fix M1 M2 :: "'a multiset" |
|
269 |
assume "M1 \<in> B" "M2 \<in> B" "multp\<^sub>H\<^sub>O R M1 M2" |
|
270 |
||
271 |
from \<open>transp_on A R\<close> B_sub_A have tran: "transp_on (set_mset (M1 - M2)) R" |
|
272 |
using \<open>M1 \<in> B\<close> |
|
273 |
by (meson in_diffD subset_eq transp_on_subset) |
|
274 |
||
275 |
from \<open>asymp_on A R\<close> B_sub_A have asym: "asymp_on (set_mset (M1 - M2)) R" |
|
276 |
using \<open>M1 \<in> B\<close> |
|
277 |
by (meson in_diffD subset_eq asymp_on_subset) |
|
278 |
||
279 |
show "\<not> multp\<^sub>H\<^sub>O R M2 M1" |
|
280 |
proof (cases "M1 - M2 = {#}") |
|
281 |
case True |
|
282 |
then show ?thesis |
|
283 |
using multp\<^sub>H\<^sub>O_implies_one_step_strong(1) by metis |
|
284 |
next |
|
285 |
case False |
|
286 |
hence "\<exists>m\<in>#M1 - M2. \<forall>x\<in>#M1 - M2. x \<noteq> m \<longrightarrow> \<not> R m x" |
|
78014
24f0cd70790b
added lemmas Finite_Set.bex_(min|max)_element_with_property and reordered assumptions of Finite_Set.bex_(min|max)_element
desharna
parents:
77990
diff
changeset
|
287 |
using Finite_Set.bex_max_element[of "set_mset (M1 - M2)" R, OF finite_set_mset asym tran] |
77989 | 288 |
by simp |
289 |
with \<open>transp_on A R\<close> B_sub_A have "\<exists>y\<in>#M2 - M1. \<forall>x\<in>#M1 - M2. \<not> R y x" |
|
290 |
using \<open>multp\<^sub>H\<^sub>O R M1 M2\<close>[THEN multp\<^sub>H\<^sub>O_implies_one_step_strong(2)] |
|
291 |
using asym[THEN irreflp_on_if_asymp_on, THEN irreflp_onD] |
|
292 |
by (metis \<open>M1 \<in> B\<close> \<open>M2 \<in> B\<close> in_diffD subsetD transp_onD) |
|
293 |
thus ?thesis |
|
294 |
unfolding multp\<^sub>H\<^sub>O_iff_set_mset_less\<^sub>H\<^sub>O_set_mset by simp |
|
295 |
qed |
|
296 |
qed |
|
297 |
||
77281
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
298 |
lemma asymp_multp\<^sub>H\<^sub>O: |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
299 |
assumes "asymp R" and "transp R" |
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
300 |
shows "asymp (multp\<^sub>H\<^sub>O R)" |
77989 | 301 |
using assms asymp_on_multp\<^sub>H\<^sub>O[of UNIV, simplified] by metis |
77281
3a2670c37e5c
added lemmas asymp_not_liftable_to_multpHO and asymp_multpHO
desharna
parents:
77104
diff
changeset
|
302 |
|
78016 | 303 |
|
304 |
paragraph \<open>Irreflexivity\<close> |
|
305 |
||
306 |
lemma irreflp_on_multp\<^sub>H\<^sub>O[simp]: "irreflp_on B (multp\<^sub>H\<^sub>O R)" |
|
307 |
by (simp add: irreflp_onI multp\<^sub>H\<^sub>O_def) |
|
308 |
||
309 |
||
310 |
paragraph \<open>Transitivity\<close> |
|
311 |
||
78017
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
312 |
lemma transp_on_multp\<^sub>H\<^sub>O: |
80464 | 313 |
assumes "asymp_on A R" and "transp_on A R" and B_sub_A: "\<And>M. M \<in> B \<Longrightarrow> set_mset M \<subseteq> A" |
78017
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
314 |
shows "transp_on B (multp\<^sub>H\<^sub>O R)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
315 |
proof (rule transp_onI) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
316 |
from assms have "asymp_on B (multp\<^sub>H\<^sub>O R)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
317 |
using asymp_on_multp\<^sub>H\<^sub>O by metis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
318 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
319 |
fix M1 M2 M3 |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
320 |
assume hyps: "M1 \<in> B" "M2 \<in> B" "M3 \<in> B" "multp\<^sub>H\<^sub>O R M1 M2" "multp\<^sub>H\<^sub>O R M2 M3" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
321 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
322 |
from assms have |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
323 |
[intro]: "asymp_on (set_mset M1 \<union> set_mset M2) R" "transp_on (set_mset M1 \<union> set_mset M2) R" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
324 |
using \<open>M1 \<in> B\<close> \<open>M2 \<in> B\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
325 |
by (simp_all add: asymp_on_subset transp_on_subset) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
326 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
327 |
from assms have "transp_on (set_mset M1) R" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
328 |
by (meson transp_on_subset hyps(1)) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
329 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
330 |
from \<open>multp\<^sub>H\<^sub>O R M1 M2\<close> have |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
331 |
"M1 \<noteq> M2" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
332 |
"\<forall>y. count M2 y < count M1 y \<longrightarrow> (\<exists>x. R y x \<and> count M1 x < count M2 x)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
333 |
unfolding multp\<^sub>H\<^sub>O_def by simp_all |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
334 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
335 |
from \<open>multp\<^sub>H\<^sub>O R M2 M3\<close> have |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
336 |
"M2 \<noteq> M3" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
337 |
"\<forall>y. count M3 y < count M2 y \<longrightarrow> (\<exists>x. R y x \<and> count M2 x < count M3 x)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
338 |
unfolding multp\<^sub>H\<^sub>O_def by simp_all |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
339 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
340 |
show "multp\<^sub>H\<^sub>O R M1 M3" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
341 |
proof (rule ccontr) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
342 |
let ?P = "\<lambda>x. count M3 x < count M1 x \<and> (\<forall>y. R x y \<longrightarrow> count M1 y \<ge> count M3 y)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
343 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
344 |
assume "\<not> multp\<^sub>H\<^sub>O R M1 M3" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
345 |
hence "M1 = M3 \<or> (\<exists>x. ?P x)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
346 |
unfolding multp\<^sub>H\<^sub>O_def by force |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
347 |
thus False |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
348 |
proof (elim disjE) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
349 |
assume "M1 = M3" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
350 |
thus False |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
351 |
using \<open>asymp_on B (multp\<^sub>H\<^sub>O R)\<close>[THEN asymp_onD] |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
352 |
using \<open>M2 \<in> B\<close> \<open>M3 \<in> B\<close> \<open>multp\<^sub>H\<^sub>O R M1 M2\<close> \<open>multp\<^sub>H\<^sub>O R M2 M3\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
353 |
by metis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
354 |
next |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
355 |
assume "\<exists>x. ?P x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
356 |
hence "\<exists>x \<in># M1 + M2. ?P x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
357 |
by (auto simp: count_inI) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
358 |
have "\<exists>y \<in># M1 + M2. ?P y \<and> (\<forall>z \<in># M1 + M2. R y z \<longrightarrow> \<not> ?P z)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
359 |
proof (rule Finite_Set.bex_max_element_with_property) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
360 |
show "\<exists>x \<in># M1 + M2. ?P x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
361 |
using \<open>\<exists>x. ?P x\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
362 |
by (auto simp: count_inI) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
363 |
qed auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
364 |
then obtain x where |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
365 |
"x \<in># M1 + M2" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
366 |
"count M3 x < count M1 x" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
367 |
"\<forall>y. R x y \<longrightarrow> count M1 y \<ge> count M3 y" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
368 |
"\<forall>y \<in># M1 + M2. R x y \<longrightarrow> count M3 y < count M1 y \<longrightarrow> (\<exists>z. R y z \<and> count M1 z < count M3 z)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
369 |
by force |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
370 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
371 |
let ?Q = "\<lambda>x'. R\<^sup>=\<^sup>= x x' \<and> count M3 x' < count M2 x'" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
372 |
show False |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
373 |
proof (cases "\<exists>x'. ?Q x'") |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
374 |
case True |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
375 |
have "\<exists>y \<in># M1 + M2. ?Q y \<and> (\<forall>z \<in># M1 + M2. R y z \<longrightarrow> \<not> ?Q z)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
376 |
proof (rule Finite_Set.bex_max_element_with_property) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
377 |
show "\<exists>x \<in># M1 + M2. ?Q x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
378 |
using \<open>\<exists>x. ?Q x\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
379 |
by (auto simp: count_inI) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
380 |
qed auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
381 |
then obtain x' where |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
382 |
"x' \<in># M1 + M2" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
383 |
"R\<^sup>=\<^sup>= x x'" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
384 |
"count M3 x' < count M2 x'" and |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
385 |
maximality_x': "\<forall>z \<in># M1 + M2. R x' z \<longrightarrow> \<not> (R\<^sup>=\<^sup>= x z) \<or> count M3 z \<ge> count M2 z" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
386 |
by (auto simp: linorder_not_less) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
387 |
with \<open>multp\<^sub>H\<^sub>O R M2 M3\<close> obtain y' where |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
388 |
"R x' y'" and "count M2 y' < count M3 y'" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
389 |
unfolding multp\<^sub>H\<^sub>O_def by auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
390 |
hence "count M2 y' < count M1 y'" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
391 |
by (smt (verit) \<open>R\<^sup>=\<^sup>= x x'\<close> \<open>\<forall>y. R x y \<longrightarrow> count M3 y \<le> count M1 y\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
392 |
\<open>count M3 x < count M1 x\<close> \<open>count M3 x' < count M2 x'\<close> assms(2) count_inI |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
393 |
dual_order.strict_trans1 hyps(1) hyps(2) hyps(3) less_nat_zero_code B_sub_A subsetD |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
394 |
sup2E transp_onD) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
395 |
with \<open>multp\<^sub>H\<^sub>O R M1 M2\<close> obtain y'' where |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
396 |
"R y' y''" and "count M1 y'' < count M2 y''" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
397 |
unfolding multp\<^sub>H\<^sub>O_def by auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
398 |
hence "count M3 y'' < count M2 y''" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
399 |
by (smt (verit, del_insts) \<open>R x' y'\<close> \<open>R\<^sup>=\<^sup>= x x'\<close> \<open>\<forall>y. R x y \<longrightarrow> count M3 y \<le> count M1 y\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
400 |
\<open>count M2 y' < count M3 y'\<close> \<open>count M3 x < count M1 x\<close> \<open>count M3 x' < count M2 x'\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
401 |
assms(2) count_greater_zero_iff dual_order.strict_trans1 hyps(1) hyps(2) hyps(3) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
402 |
less_nat_zero_code linorder_not_less B_sub_A subset_iff sup2E transp_onD) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
403 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
404 |
moreover have "count M2 y'' \<le> count M3 y''" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
405 |
proof - |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
406 |
have "y'' \<in># M1 + M2" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
407 |
by (metis \<open>count M1 y'' < count M2 y''\<close> count_inI not_less_iff_gr_or_eq union_iff) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
408 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
409 |
moreover have "R x' y''" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
410 |
by (metis \<open>R x' y'\<close> \<open>R y' y''\<close> \<open>count M2 y' < count M1 y'\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
411 |
\<open>transp_on (set_mset M1 \<union> set_mset M2) R\<close> \<open>x' \<in># M1 + M2\<close> calculation count_inI |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
412 |
nat_neq_iff set_mset_union transp_onD union_iff) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
413 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
414 |
moreover have "R\<^sup>=\<^sup>= x y''" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
415 |
using \<open>R\<^sup>=\<^sup>= x x'\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
416 |
by (metis (mono_tags, opaque_lifting) \<open>transp_on (set_mset M1 \<union> set_mset M2) R\<close> |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
417 |
\<open>x \<in># M1 + M2\<close> \<open>x' \<in># M1 + M2\<close> calculation(1) calculation(2) set_mset_union sup2I1 |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
418 |
transp_onD transp_on_reflclp) |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
419 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
420 |
ultimately show ?thesis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
421 |
using maximality_x'[rule_format, of y''] by metis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
422 |
qed |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
423 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
424 |
ultimately show ?thesis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
425 |
by linarith |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
426 |
next |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
427 |
case False |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
428 |
hence "\<And>x'. R\<^sup>=\<^sup>= x x' \<Longrightarrow> count M2 x' \<le> count M3 x'" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
429 |
by auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
430 |
hence "count M2 x \<le> count M3 x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
431 |
by simp |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
432 |
hence "count M2 x < count M1 x" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
433 |
using \<open>count M3 x < count M1 x\<close> by linarith |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
434 |
with \<open>multp\<^sub>H\<^sub>O R M1 M2\<close> obtain y where |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
435 |
"R x y" and "count M1 y < count M2 y" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
436 |
unfolding multp\<^sub>H\<^sub>O_def by auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
437 |
hence "count M3 y < count M2 y" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
438 |
using \<open>\<forall>y. R x y \<longrightarrow> count M3 y \<le> count M1 y\<close> dual_order.strict_trans2 by metis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
439 |
then show ?thesis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
440 |
using False \<open>R x y\<close> by auto |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
441 |
qed |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
442 |
qed |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
443 |
qed |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
444 |
qed |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
445 |
|
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
446 |
lemma transp_multp\<^sub>H\<^sub>O: |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
447 |
assumes "asymp R" and "transp R" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
448 |
shows "transp (multp\<^sub>H\<^sub>O R)" |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
449 |
using assms transp_on_multp\<^sub>H\<^sub>O[of UNIV, simplified] by metis |
db041670d6bb
added lemmas transp_on_multpHO and transp_multpHO
desharna
parents:
78016
diff
changeset
|
450 |
|
78016 | 451 |
|
452 |
paragraph \<open>Totality\<close> |
|
453 |
||
77063
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
454 |
lemma totalp_on_multp\<^sub>D\<^sub>M: |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
455 |
"totalp_on A R \<Longrightarrow> (\<And>M. M \<in> B \<Longrightarrow> set_mset M \<subseteq> A) \<Longrightarrow> totalp_on B (multp\<^sub>D\<^sub>M R)" |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
456 |
by (smt (verit, ccfv_SIG) count_inI in_mono multp\<^sub>H\<^sub>O_def multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M not_less_iff_gr_or_eq |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
457 |
totalp_onD totalp_onI) |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
458 |
|
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
459 |
lemma totalp_multp\<^sub>D\<^sub>M: "totalp R \<Longrightarrow> totalp (multp\<^sub>D\<^sub>M R)" |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
460 |
by (rule totalp_on_multp\<^sub>D\<^sub>M[of UNIV R UNIV, simplified]) |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
461 |
|
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
462 |
lemma totalp_on_multp\<^sub>H\<^sub>O: |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
463 |
"totalp_on A R \<Longrightarrow> (\<And>M. M \<in> B \<Longrightarrow> set_mset M \<subseteq> A) \<Longrightarrow> totalp_on B (multp\<^sub>H\<^sub>O R)" |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
464 |
by (smt (verit, ccfv_SIG) count_inI in_mono multp\<^sub>H\<^sub>O_def not_less_iff_gr_or_eq totalp_onD |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
465 |
totalp_onI) |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
466 |
|
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
467 |
lemma totalp_multp\<^sub>H\<^sub>O: "totalp R \<Longrightarrow> totalp (multp\<^sub>H\<^sub>O R)" |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
468 |
by (rule totalp_on_multp\<^sub>H\<^sub>O[of UNIV R UNIV, simplified]) |
4b37cc497d7e
added lemmas totalp_on_multpDM, totalp_multpDM, totalp_on_multpHO, and totalp_multpHO
desharna
parents:
76682
diff
changeset
|
469 |
|
78016 | 470 |
|
471 |
paragraph \<open>Type Classes\<close> |
|
472 |
||
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
473 |
context preorder |
59813 | 474 |
begin |
475 |
||
476 |
lemma order_mult: "class.order |
|
477 |
(\<lambda>M N. (M, N) \<in> mult {(x, y). x < y} \<or> M = N) |
|
478 |
(\<lambda>M N. (M, N) \<in> mult {(x, y). x < y})" |
|
479 |
(is "class.order ?le ?less") |
|
480 |
proof - |
|
481 |
have irrefl: "\<And>M :: 'a multiset. \<not> ?less M M" |
|
482 |
proof |
|
483 |
fix M :: "'a multiset" |
|
484 |
have "trans {(x'::'a, x). x' < x}" |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
485 |
by (rule transI) (blast intro: less_trans) |
59813 | 486 |
moreover |
487 |
assume "(M, M) \<in> mult {(x, y). x < y}" |
|
488 |
ultimately have "\<exists>I J K. M = I + J \<and> M = I + K |
|
60495 | 489 |
\<and> J \<noteq> {#} \<and> (\<forall>k\<in>set_mset K. \<exists>j\<in>set_mset J. (k, j) \<in> {(x, y). x < y})" |
59813 | 490 |
by (rule mult_implies_one_step) |
491 |
then obtain I J K where "M = I + J" and "M = I + K" |
|
60495 | 492 |
and "J \<noteq> {#}" and "(\<forall>k\<in>set_mset K. \<exists>j\<in>set_mset J. (k, j) \<in> {(x, y). x < y})" by blast |
493 |
then have aux1: "K \<noteq> {#}" and aux2: "\<forall>k\<in>set_mset K. \<exists>j\<in>set_mset K. k < j" by auto |
|
494 |
have "finite (set_mset K)" by simp |
|
59813 | 495 |
moreover note aux2 |
60495 | 496 |
ultimately have "set_mset K = {}" |
59813 | 497 |
by (induct rule: finite_induct) |
498 |
(simp, metis (mono_tags) insert_absorb insert_iff insert_not_empty less_irrefl less_trans) |
|
499 |
with aux1 show False by simp |
|
500 |
qed |
|
501 |
have trans: "\<And>K M N :: 'a multiset. ?less K M \<Longrightarrow> ?less M N \<Longrightarrow> ?less K N" |
|
502 |
unfolding mult_def by (blast intro: trancl_trans) |
|
503 |
show "class.order ?le ?less" |
|
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
504 |
by standard (auto simp add: less_eq_multiset_def irrefl dest: trans) |
59813 | 505 |
qed |
506 |
||
60500 | 507 |
text \<open>The Dershowitz--Manna ordering:\<close> |
59813 | 508 |
|
509 |
definition less_multiset\<^sub>D\<^sub>M where |
|
510 |
"less_multiset\<^sub>D\<^sub>M M N \<longleftrightarrow> |
|
64587 | 511 |
(\<exists>X Y. X \<noteq> {#} \<and> X \<subseteq># N \<and> M = (N - X) + Y \<and> (\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> k < a)))" |
59813 | 512 |
|
513 |
||
60500 | 514 |
text \<open>The Huet--Oppen ordering:\<close> |
59813 | 515 |
|
516 |
definition less_multiset\<^sub>H\<^sub>O where |
|
517 |
"less_multiset\<^sub>H\<^sub>O M N \<longleftrightarrow> M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x. y < x \<and> count M x < count N x))" |
|
518 |
||
62430
9527ff088c15
more succint formulation of membership for multisets, similar to lists;
haftmann
parents:
61424
diff
changeset
|
519 |
lemma mult_imp_less_multiset\<^sub>H\<^sub>O: |
9527ff088c15
more succint formulation of membership for multisets, similar to lists;
haftmann
parents:
61424
diff
changeset
|
520 |
"(M, N) \<in> mult {(x, y). x < y} \<Longrightarrow> less_multiset\<^sub>H\<^sub>O M N" |
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
521 |
unfolding multp_def[of "(<)", symmetric] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
522 |
using multp_imp_multp\<^sub>H\<^sub>O[of "(<)"] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
523 |
by (simp add: less_multiset\<^sub>H\<^sub>O_def multp\<^sub>H\<^sub>O_def) |
59813 | 524 |
|
525 |
lemma less_multiset\<^sub>D\<^sub>M_imp_mult: |
|
526 |
"less_multiset\<^sub>D\<^sub>M M N \<Longrightarrow> (M, N) \<in> mult {(x, y). x < y}" |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
527 |
unfolding multp_def[of "(<)", symmetric] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
528 |
by (rule multp\<^sub>D\<^sub>M_imp_multp[of "(<)" M N]) (simp add: less_multiset\<^sub>D\<^sub>M_def multp\<^sub>D\<^sub>M_def) |
59813 | 529 |
|
530 |
lemma less_multiset\<^sub>H\<^sub>O_imp_less_multiset\<^sub>D\<^sub>M: "less_multiset\<^sub>H\<^sub>O M N \<Longrightarrow> less_multiset\<^sub>D\<^sub>M M N" |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
531 |
unfolding less_multiset\<^sub>D\<^sub>M_def less_multiset\<^sub>H\<^sub>O_def |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
532 |
unfolding multp\<^sub>D\<^sub>M_def[symmetric] multp\<^sub>H\<^sub>O_def[symmetric] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
533 |
by (rule multp\<^sub>H\<^sub>O_imp_multp\<^sub>D\<^sub>M) |
59813 | 534 |
|
535 |
lemma mult_less_multiset\<^sub>D\<^sub>M: "(M, N) \<in> mult {(x, y). x < y} \<longleftrightarrow> less_multiset\<^sub>D\<^sub>M M N" |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
536 |
unfolding multp_def[of "(<)", symmetric] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
537 |
using multp_eq_multp\<^sub>D\<^sub>M[of "(<)", simplified] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
538 |
by (simp add: multp\<^sub>D\<^sub>M_def less_multiset\<^sub>D\<^sub>M_def) |
59813 | 539 |
|
540 |
lemma mult_less_multiset\<^sub>H\<^sub>O: "(M, N) \<in> mult {(x, y). x < y} \<longleftrightarrow> less_multiset\<^sub>H\<^sub>O M N" |
|
74869
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
541 |
unfolding multp_def[of "(<)", symmetric] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
542 |
using multp_eq_multp\<^sub>H\<^sub>O[of "(<)", simplified] |
7b0a241732c1
added definitions multp{DM,HO} and corresponding lemmas
desharna
parents:
74867
diff
changeset
|
543 |
by (simp add: multp\<^sub>H\<^sub>O_def less_multiset\<^sub>H\<^sub>O_def) |
59813 | 544 |
|
545 |
lemmas mult\<^sub>D\<^sub>M = mult_less_multiset\<^sub>D\<^sub>M[unfolded less_multiset\<^sub>D\<^sub>M_def] |
|
546 |
lemmas mult\<^sub>H\<^sub>O = mult_less_multiset\<^sub>H\<^sub>O[unfolded less_multiset\<^sub>H\<^sub>O_def] |
|
547 |
||
548 |
end |
|
549 |
||
67020 | 550 |
lemma less_multiset_less_multiset\<^sub>H\<^sub>O: "M < N \<longleftrightarrow> less_multiset\<^sub>H\<^sub>O M N" |
74864 | 551 |
unfolding less_multiset_def multp_def mult\<^sub>H\<^sub>O less_multiset\<^sub>H\<^sub>O_def .. |
59813 | 552 |
|
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
553 |
lemma less_multiset\<^sub>D\<^sub>M: |
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
554 |
"M < N \<longleftrightarrow> (\<exists>X Y. X \<noteq> {#} \<and> X \<subseteq># N \<and> M = N - X + Y \<and> (\<forall>k. k \<in># Y \<longrightarrow> (\<exists>a. a \<in># X \<and> k < a)))" |
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
555 |
by (rule mult\<^sub>D\<^sub>M[folded multp_def less_multiset_def]) |
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
556 |
|
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
557 |
lemma less_multiset\<^sub>H\<^sub>O: |
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
558 |
"M < N \<longleftrightarrow> M \<noteq> N \<and> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x>y. count M x < count N x))" |
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
559 |
by (rule mult\<^sub>H\<^sub>O[folded multp_def less_multiset_def]) |
59813 | 560 |
|
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
561 |
lemma subset_eq_imp_le_multiset: |
64587 | 562 |
shows "M \<subseteq># N \<Longrightarrow> M \<le> N" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
563 |
unfolding less_eq_multiset_def less_multiset\<^sub>H\<^sub>O |
60397
f8a513fedb31
Renaming multiset operators < ~> <#,...
Mathias Fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
59958
diff
changeset
|
564 |
by (simp add: less_le_not_le subseteq_mset_def) |
59813 | 565 |
|
67020 | 566 |
(* FIXME: "le" should be "less" in this and other names *) |
567 |
lemma le_multiset_right_total: "M < add_mset x M" |
|
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
568 |
unfolding less_eq_multiset_def less_multiset\<^sub>H\<^sub>O by simp |
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
569 |
|
80464 | 570 |
lemma less_eq_multiset_empty_left[simp]: "{#} \<le> M" |
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
571 |
by (simp add: subset_eq_imp_le_multiset) |
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
572 |
|
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
573 |
lemma ex_gt_imp_less_multiset: "(\<exists>y. y \<in># N \<and> (\<forall>x. x \<in># M \<longrightarrow> x < y)) \<Longrightarrow> M < N" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
574 |
unfolding less_multiset\<^sub>H\<^sub>O |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
575 |
by (metis count_eq_zero_iff count_greater_zero_iff less_le_not_le) |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
576 |
|
67020 | 577 |
lemma less_eq_multiset_empty_right[simp]: "M \<noteq> {#} \<Longrightarrow> \<not> M \<le> {#}" |
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
578 |
by (metis less_eq_multiset_empty_left antisym) |
59813 | 579 |
|
67020 | 580 |
(* FIXME: "le" should be "less" in this and other names *) |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
581 |
lemma le_multiset_empty_left[simp]: "M \<noteq> {#} \<Longrightarrow> {#} < M" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
582 |
by (simp add: less_multiset\<^sub>H\<^sub>O) |
59813 | 583 |
|
67020 | 584 |
(* FIXME: "le" should be "less" in this and other names *) |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
585 |
lemma le_multiset_empty_right[simp]: "\<not> M < {#}" |
74864 | 586 |
using subset_mset.le_zero_eq less_multiset_def multp_def less_multiset\<^sub>D\<^sub>M by blast |
59813 | 587 |
|
67020 | 588 |
(* FIXME: "le" should be "less" in this and other names *) |
64587 | 589 |
lemma union_le_diff_plus: "P \<subseteq># M \<Longrightarrow> N < P \<Longrightarrow> M - P + N < M" |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
590 |
by (drule subset_mset.diff_add[symmetric]) (metis union_le_mono2) |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
591 |
|
63525
f01d1e393f3f
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63410
diff
changeset
|
592 |
instantiation multiset :: (preorder) ordered_ab_semigroup_monoid_add_imp_le |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
593 |
begin |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
594 |
|
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
595 |
lemma less_eq_multiset\<^sub>H\<^sub>O: |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
596 |
"M \<le> N \<longleftrightarrow> (\<forall>y. count N y < count M y \<longrightarrow> (\<exists>x. y < x \<and> count M x < count N x))" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
597 |
by (auto simp: less_eq_multiset_def less_multiset\<^sub>H\<^sub>O) |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
598 |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
599 |
instance by standard (auto simp: less_eq_multiset\<^sub>H\<^sub>O) |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
600 |
|
59813 | 601 |
lemma |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
602 |
fixes M N :: "'a multiset" |
80464 | 603 |
shows less_eq_multiset_plus_left: "N \<le> (M + N)" |
604 |
and less_eq_multiset_plus_right: "M \<le> (M + N)" |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
605 |
by simp_all |
59813 | 606 |
|
607 |
lemma |
|
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
608 |
fixes M N :: "'a multiset" |
80464 | 609 |
shows le_multiset_plus_left_nonempty: "M \<noteq> {#} \<Longrightarrow> N < M + N" |
610 |
and le_multiset_plus_right_nonempty: "N \<noteq> {#} \<Longrightarrow> M < M + N" |
|
63525
f01d1e393f3f
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63410
diff
changeset
|
611 |
by simp_all |
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
612 |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
613 |
end |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
614 |
|
65546 | 615 |
lemma all_lt_Max_imp_lt_mset: "N \<noteq> {#} \<Longrightarrow> (\<forall>a \<in># M. a < Max (set_mset N)) \<Longrightarrow> M < N" |
616 |
by (meson Max_in[OF finite_set_mset] ex_gt_imp_less_multiset set_mset_eq_empty_iff) |
|
617 |
||
618 |
lemma lt_imp_ex_count_lt: "M < N \<Longrightarrow> \<exists>y. count M y < count N y" |
|
619 |
by (meson less_eq_multiset\<^sub>H\<^sub>O less_le_not_le) |
|
620 |
||
621 |
lemma subset_imp_less_mset: "A \<subset># B \<Longrightarrow> A < B" |
|
622 |
by (simp add: order.not_eq_order_implies_strict subset_eq_imp_le_multiset) |
|
623 |
||
624 |
lemma image_mset_strict_mono: |
|
80464 | 625 |
assumes mono_f: "\<forall>x \<in> set_mset M. \<forall>y \<in> set_mset N. x < y \<longrightarrow> f x < f y" |
626 |
and less: "M < N" |
|
65546 | 627 |
shows "image_mset f M < image_mset f N" |
628 |
proof - |
|
629 |
obtain Y X where |
|
630 |
y_nemp: "Y \<noteq> {#}" and y_sub_N: "Y \<subseteq># N" and M_eq: "M = N - Y + X" and |
|
631 |
ex_y: "\<forall>x. x \<in># X \<longrightarrow> (\<exists>y. y \<in># Y \<and> x < y)" |
|
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
632 |
using less[unfolded less_multiset\<^sub>D\<^sub>M] by blast |
65546 | 633 |
|
634 |
have x_sub_M: "X \<subseteq># M" |
|
635 |
using M_eq by simp |
|
636 |
||
637 |
let ?fY = "image_mset f Y" |
|
638 |
let ?fX = "image_mset f X" |
|
639 |
||
640 |
show ?thesis |
|
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
641 |
unfolding less_multiset\<^sub>D\<^sub>M |
65546 | 642 |
proof (intro exI conjI) |
643 |
show "image_mset f M = image_mset f N - ?fY + ?fX" |
|
644 |
using M_eq[THEN arg_cong, of "image_mset f"] y_sub_N |
|
645 |
by (metis image_mset_Diff image_mset_union) |
|
646 |
next |
|
647 |
obtain y where y: "\<forall>x. x \<in># X \<longrightarrow> y x \<in># Y \<and> x < y x" |
|
79669 | 648 |
using ex_y by metis |
65546 | 649 |
|
650 |
show "\<forall>fx. fx \<in># ?fX \<longrightarrow> (\<exists>fy. fy \<in># ?fY \<and> fx < fy)" |
|
651 |
proof (intro allI impI) |
|
652 |
fix fx |
|
653 |
assume "fx \<in># ?fX" |
|
654 |
then obtain x where fx: "fx = f x" and x_in: "x \<in># X" |
|
655 |
by auto |
|
656 |
hence y_in: "y x \<in># Y" and y_gt: "x < y x" |
|
657 |
using y[rule_format, OF x_in] by blast+ |
|
658 |
hence "f (y x) \<in># ?fY \<and> f x < f (y x)" |
|
659 |
using mono_f y_sub_N x_sub_M x_in |
|
660 |
by (metis image_eqI in_image_mset mset_subset_eqD) |
|
661 |
thus "\<exists>fy. fy \<in># ?fY \<and> fx < fy" |
|
662 |
unfolding fx by auto |
|
663 |
qed |
|
664 |
qed (auto simp: y_nemp y_sub_N image_mset_subseteq_mono) |
|
665 |
qed |
|
666 |
||
667 |
lemma image_mset_mono: |
|
80464 | 668 |
assumes mono_f: "\<forall>x \<in> set_mset M. \<forall>y \<in> set_mset N. x < y \<longrightarrow> f x < f y" |
669 |
and less: "M \<le> N" |
|
65546 | 670 |
shows "image_mset f M \<le> image_mset f N" |
671 |
by (metis eq_iff image_mset_strict_mono less less_imp_le mono_f order.not_eq_order_implies_strict) |
|
672 |
||
673 |
lemma mset_lt_single_right_iff[simp]: "M < {#y#} \<longleftrightarrow> (\<forall>x \<in># M. x < y)" for y :: "'a::linorder" |
|
674 |
proof (rule iffI) |
|
675 |
assume M_lt_y: "M < {#y#}" |
|
676 |
show "\<forall>x \<in># M. x < y" |
|
677 |
proof |
|
678 |
fix x |
|
679 |
assume x_in: "x \<in># M" |
|
680 |
hence M: "M - {#x#} + {#x#} = M" |
|
681 |
by (meson insert_DiffM2) |
|
682 |
hence "\<not> {#x#} < {#y#} \<Longrightarrow> x < y" |
|
683 |
using x_in M_lt_y |
|
684 |
by (metis diff_single_eq_union le_multiset_empty_left less_add_same_cancel2 mset_le_trans) |
|
685 |
also have "\<not> {#y#} < M" |
|
686 |
using M_lt_y mset_le_not_sym by blast |
|
687 |
ultimately show "x < y" |
|
688 |
by (metis (no_types) Max_ge all_lt_Max_imp_lt_mset empty_iff finite_set_mset insertE |
|
689 |
less_le_trans linorder_less_linear mset_le_not_sym set_mset_add_mset_insert |
|
690 |
set_mset_eq_empty_iff x_in) |
|
691 |
qed |
|
692 |
next |
|
693 |
assume y_max: "\<forall>x \<in># M. x < y" |
|
694 |
show "M < {#y#}" |
|
695 |
by (rule all_lt_Max_imp_lt_mset) (auto intro!: y_max) |
|
696 |
qed |
|
697 |
||
698 |
lemma mset_le_single_right_iff[simp]: |
|
699 |
"M \<le> {#y#} \<longleftrightarrow> M = {#y#} \<or> (\<forall>x \<in># M. x < y)" for y :: "'a::linorder" |
|
700 |
by (meson less_eq_multiset_def mset_lt_single_right_iff) |
|
701 |
||
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
702 |
|
77834
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
703 |
subsubsection \<open>Simplifications\<close> |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
704 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
705 |
lemma multp\<^sub>H\<^sub>O_repeat_mset_repeat_mset[simp]: |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
706 |
assumes "n \<noteq> 0" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
707 |
shows "multp\<^sub>H\<^sub>O R (repeat_mset n A) (repeat_mset n B) \<longleftrightarrow> multp\<^sub>H\<^sub>O R A B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
708 |
proof (rule iffI) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
709 |
assume hyp: "multp\<^sub>H\<^sub>O R (repeat_mset n A) (repeat_mset n B)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
710 |
hence |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
711 |
1: "repeat_mset n A \<noteq> repeat_mset n B" and |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
712 |
2: "\<forall>y. n * count B y < n * count A y \<longrightarrow> (\<exists>x. R y x \<and> n * count A x < n * count B x)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
713 |
by (simp_all add: multp\<^sub>H\<^sub>O_def) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
714 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
715 |
from 1 \<open>n \<noteq> 0\<close> have "A \<noteq> B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
716 |
by auto |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
717 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
718 |
moreover from 2 \<open>n \<noteq> 0\<close> have "\<forall>y. count B y < count A y \<longrightarrow> (\<exists>x. R y x \<and> count A x < count B x)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
719 |
by auto |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
720 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
721 |
ultimately show "multp\<^sub>H\<^sub>O R A B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
722 |
by (simp add: multp\<^sub>H\<^sub>O_def) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
723 |
next |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
724 |
assume "multp\<^sub>H\<^sub>O R A B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
725 |
hence 1: "A \<noteq> B" and 2: "\<forall>y. count B y < count A y \<longrightarrow> (\<exists>x. R y x \<and> count A x < count B x)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
726 |
by (simp_all add: multp\<^sub>H\<^sub>O_def) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
727 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
728 |
from 1 have "repeat_mset n A \<noteq> repeat_mset n B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
729 |
by (simp add: assms repeat_mset_cancel1) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
730 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
731 |
moreover from 2 have "\<forall>y. n * count B y < n * count A y \<longrightarrow> |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
732 |
(\<exists>x. R y x \<and> n * count A x < n * count B x)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
733 |
by auto |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
734 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
735 |
ultimately show "multp\<^sub>H\<^sub>O R (repeat_mset n A) (repeat_mset n B)" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
736 |
by (simp add: multp\<^sub>H\<^sub>O_def) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
737 |
qed |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
738 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
739 |
lemma multp\<^sub>H\<^sub>O_double_double[simp]: "multp\<^sub>H\<^sub>O R (A + A) (B + B) \<longleftrightarrow> multp\<^sub>H\<^sub>O R A B" |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
740 |
using multp\<^sub>H\<^sub>O_repeat_mset_repeat_mset[of 2] |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
741 |
by (simp add: numeral_Bit0) |
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
742 |
|
52e753197496
added lemmas multpHO_repeat_mset_repeat_mset[simp] and multpHO_double_double[simp]
desharna
parents:
77355
diff
changeset
|
743 |
|
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
744 |
subsection \<open>Simprocs\<close> |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
745 |
|
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
746 |
lemma mset_le_add_iff1: |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
747 |
"j \<le> (i::nat) \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (repeat_mset (i-j) u + m \<le> n)" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
748 |
proof - |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
749 |
assume "j \<le> i" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
750 |
then have "j + (i - j) = i" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
751 |
using le_add_diff_inverse by blast |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
752 |
then show ?thesis |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
753 |
by (metis (no_types) add_le_cancel_left left_add_mult_distrib_mset) |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
754 |
qed |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
755 |
|
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
756 |
lemma mset_le_add_iff2: |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
757 |
"i \<le> (j::nat) \<Longrightarrow> (repeat_mset i u + m \<le> repeat_mset j u + n) = (m \<le> repeat_mset (j-i) u + n)" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
758 |
proof - |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
759 |
assume "i \<le> j" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
760 |
then have "i + (j - i) = j" |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
761 |
using le_add_diff_inverse by blast |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
762 |
then show ?thesis |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
763 |
by (metis (no_types) add_le_cancel_left left_add_mult_distrib_mset) |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
764 |
qed |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
765 |
|
65027
2b8583507891
renaming multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
64978
diff
changeset
|
766 |
simproc_setup msetless_cancel |
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
767 |
("(l::'a::preorder multiset) + m < n" | "(l::'a multiset) < m + n" | |
65028
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
768 |
"add_mset a m < n" | "m < add_mset a n" | |
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
769 |
"replicate_mset p a < n" | "m < replicate_mset p a" | |
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
770 |
"repeat_mset p m < n" | "m < repeat_mset p n") = |
78099
4d9349989d94
more uniform simproc_setup: avoid vacuous abstraction over morphism, which sometimes captures context values in its functional closure;
wenzelm
parents:
78017
diff
changeset
|
771 |
\<open>K Cancel_Simprocs.less_cancel\<close> |
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
772 |
|
65027
2b8583507891
renaming multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
64978
diff
changeset
|
773 |
simproc_setup msetle_cancel |
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
774 |
("(l::'a::preorder multiset) + m \<le> n" | "(l::'a multiset) \<le> m + n" | |
65028
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
775 |
"add_mset a m \<le> n" | "m \<le> add_mset a n" | |
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
776 |
"replicate_mset p a \<le> n" | "m \<le> replicate_mset p a" | |
87e003397834
adding simplification patterns to multiset simprocs
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
65027
diff
changeset
|
777 |
"repeat_mset p m \<le> n" | "m \<le> repeat_mset p n") = |
78099
4d9349989d94
more uniform simproc_setup: avoid vacuous abstraction over morphism, which sometimes captures context values in its functional closure;
wenzelm
parents:
78017
diff
changeset
|
778 |
\<open>K Cancel_Simprocs.less_eq_cancel\<close> |
63793
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
779 |
|
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
780 |
|
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
781 |
subsection \<open>Additional facts and instantiations\<close> |
e68a0b651eb5
add_mset constructor in multisets
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63525
diff
changeset
|
782 |
|
63388
a095acd4cfbf
instantiate multiset with multiset ordering
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63310
diff
changeset
|
783 |
lemma ex_gt_count_imp_le_multiset: |
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
784 |
"(\<forall>y :: 'a :: order. y \<in># M + N \<longrightarrow> y \<le> x) \<Longrightarrow> count M x < count N x \<Longrightarrow> M < N" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
785 |
unfolding less_multiset\<^sub>H\<^sub>O |
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
786 |
by (metis count_greater_zero_iff le_imp_less_or_eq less_imp_not_less not_gr_zero union_iff) |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
787 |
|
64418 | 788 |
lemma mset_lt_single_iff[iff]: "{#x#} < {#y#} \<longleftrightarrow> x < y" |
74867
4220dcd6c22e
restored lemmas less_multiset{DM,HO} inadvertently changed by c256bba593f3
desharna
parents:
74864
diff
changeset
|
789 |
unfolding less_multiset\<^sub>H\<^sub>O by simp |
64418 | 790 |
|
791 |
lemma mset_le_single_iff[iff]: "{#x#} \<le> {#y#} \<longleftrightarrow> x \<le> y" for x y :: "'a::order" |
|
792 |
unfolding less_eq_multiset\<^sub>H\<^sub>O by force |
|
793 |
||
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
794 |
instance multiset :: (linorder) linordered_cancel_ab_semigroup_add |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
795 |
by standard (metis less_eq_multiset\<^sub>H\<^sub>O not_less_iff_gr_or_eq) |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
796 |
|
80464 | 797 |
lemma less_eq_multiset_total: "\<not> M \<le> N \<Longrightarrow> N \<le> M" for M N :: "'a :: linorder multiset" |
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
798 |
by simp |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
799 |
|
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
800 |
instantiation multiset :: (wellorder) wellorder |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
801 |
begin |
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
802 |
|
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
803 |
lemma wf_less_multiset: "wf {(M :: 'a multiset, N). M < N}" |
74864 | 804 |
unfolding less_multiset_def multp_def by (auto intro: wf_mult wf) |
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
805 |
|
80068 | 806 |
instance |
807 |
proof intro_classes |
|
808 |
fix P :: "'a multiset \<Rightarrow> bool" and a :: "'a multiset" |
|
809 |
have "wfp ((<) :: 'a \<Rightarrow> 'a \<Rightarrow> bool)" |
|
810 |
using wfp_on_less . |
|
811 |
hence "wfp ((<) :: 'a multiset \<Rightarrow> 'a multiset \<Rightarrow> bool)" |
|
80324 | 812 |
unfolding less_multiset_def by (rule wfp_multp) |
80068 | 813 |
thus "(\<And>x. (\<And>y. y < x \<Longrightarrow> P y) \<Longrightarrow> P x) \<Longrightarrow> P a" |
814 |
unfolding wfp_on_def[of UNIV, simplified] by metis |
|
815 |
qed |
|
59813 | 816 |
|
817 |
end |
|
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
818 |
|
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
819 |
instantiation multiset :: (preorder) order_bot |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
820 |
begin |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
821 |
|
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
822 |
definition bot_multiset :: "'a multiset" where "bot_multiset = {#}" |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
823 |
|
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
824 |
instance by standard (simp add: bot_multiset_def) |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
825 |
|
63409
3f3223b90239
moved lemmas and locales around (with minor incompatibilities)
blanchet
parents:
63407
diff
changeset
|
826 |
end |
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
827 |
|
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
828 |
instance multiset :: (preorder) no_top |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
829 |
proof standard |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
830 |
fix x :: "'a multiset" |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
831 |
obtain a :: 'a where True by simp |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
832 |
have "x < x + (x + {#a#})" |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
833 |
by simp |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
834 |
then show "\<exists>y. x < y" |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
835 |
by blast |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
836 |
qed |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
837 |
|
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
838 |
instance multiset :: (preorder) ordered_cancel_comm_monoid_add |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
839 |
by standard |
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
840 |
|
65546 | 841 |
instantiation multiset :: (linorder) distrib_lattice |
842 |
begin |
|
843 |
||
844 |
definition inf_multiset :: "'a multiset \<Rightarrow> 'a multiset \<Rightarrow> 'a multiset" where |
|
845 |
"inf_multiset A B = (if A < B then A else B)" |
|
846 |
||
847 |
definition sup_multiset :: "'a multiset \<Rightarrow> 'a multiset \<Rightarrow> 'a multiset" where |
|
848 |
"sup_multiset A B = (if B > A then B else A)" |
|
849 |
||
850 |
instance |
|
851 |
by intro_classes (auto simp: inf_multiset_def sup_multiset_def) |
|
852 |
||
63410
9789ccc2a477
more instantiations for multiset
fleury <Mathias.Fleury@mpi-inf.mpg.de>
parents:
63409
diff
changeset
|
853 |
end |
65546 | 854 |
|
79800 | 855 |
lemma add_mset_lt_left_lt: "a < b \<Longrightarrow> add_mset a A < add_mset b A" |
856 |
by fastforce |
|
857 |
||
858 |
lemma add_mset_le_left_le: "a \<le> b \<Longrightarrow> add_mset a A \<le> add_mset b A" for a :: "'a :: linorder" |
|
859 |
by fastforce |
|
860 |
||
861 |
lemma add_mset_lt_right_lt: "A < B \<Longrightarrow> add_mset a A < add_mset a B" |
|
862 |
by fastforce |
|
863 |
||
864 |
lemma add_mset_le_right_le: "A \<le> B \<Longrightarrow> add_mset a A \<le> add_mset a B" |
|
865 |
by fastforce |
|
866 |
||
867 |
lemma add_mset_lt_lt_lt: |
|
868 |
assumes a_lt_b: "a < b" and A_le_B: "A < B" |
|
869 |
shows "add_mset a A < add_mset b B" |
|
870 |
by (rule less_trans[OF add_mset_lt_left_lt[OF a_lt_b] add_mset_lt_right_lt[OF A_le_B]]) |
|
871 |
||
872 |
lemma add_mset_lt_lt_le: "a < b \<Longrightarrow> A \<le> B \<Longrightarrow> add_mset a A < add_mset b B" |
|
873 |
using add_mset_lt_lt_lt le_neq_trans by fastforce |
|
874 |
||
875 |
lemma add_mset_lt_le_lt: "a \<le> b \<Longrightarrow> A < B \<Longrightarrow> add_mset a A < add_mset b B" for a :: "'a :: linorder" |
|
876 |
using add_mset_lt_lt_lt by (metis add_mset_lt_right_lt le_less) |
|
877 |
||
878 |
lemma add_mset_le_le_le: |
|
879 |
fixes a :: "'a :: linorder" |
|
880 |
assumes a_le_b: "a \<le> b" and A_le_B: "A \<le> B" |
|
881 |
shows "add_mset a A \<le> add_mset b B" |
|
882 |
by (rule order.trans[OF add_mset_le_left_le[OF a_le_b] add_mset_le_right_le[OF A_le_B]]) |
|
883 |
||
884 |
lemma Max_lt_imp_lt_mset: |
|
885 |
assumes n_nemp: "N \<noteq> {#}" and max: "Max_mset M < Max_mset N" (is "?max_M < ?max_N") |
|
886 |
shows "M < N" |
|
887 |
proof (cases "M = {#}") |
|
888 |
case m_nemp: False |
|
889 |
||
890 |
have max_n_in_n: "?max_N \<in># N" |
|
891 |
using n_nemp by simp |
|
892 |
have max_n_nin_m: "?max_N \<notin># M" |
|
893 |
using max Max_ge leD by auto |
|
894 |
||
895 |
have "M \<noteq> N" |
|
896 |
using max by auto |
|
897 |
moreover |
|
80464 | 898 |
have "\<exists>x > y. count M x < count N x" if "count N y < count M y" for y |
899 |
proof - |
|
900 |
from that have "y \<in># M" |
|
79800 | 901 |
by (simp add: count_inI) |
80464 | 902 |
then have "?max_M \<ge> y" |
79800 | 903 |
by simp |
80464 | 904 |
then have "?max_N > y" |
79800 | 905 |
using max by auto |
80464 | 906 |
then show ?thesis |
79800 | 907 |
using max_n_nin_m max_n_in_n count_inI by force |
80464 | 908 |
qed |
79800 | 909 |
ultimately show ?thesis |
910 |
unfolding less_multiset\<^sub>H\<^sub>O by blast |
|
911 |
qed (auto simp: n_nemp) |
|
912 |
||
65546 | 913 |
end |