author | Manuel Eberl <eberlm@in.tum.de> |
Tue, 03 Jun 2025 12:22:58 +0200 | |
changeset 82683 | 71304514891e |
parent 80777 | 623d46973cbe |
permissions | -rw-r--r-- |
73477 | 1 |
(* Author: Amine Chaieb, University of Cambridge |
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
2 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
3 |
With various additions by Manuel Eberl |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
4 |
*) |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
5 |
|
60500 | 6 |
section \<open>Permutations, both general and specifically on finite sets.\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
7 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
8 |
theory Permutations |
73477 | 9 |
imports |
10 |
"HOL-Library.Multiset" |
|
11 |
"HOL-Library.Disjoint_Sets" |
|
73623 | 12 |
Transposition |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
13 |
begin |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
14 |
|
73466 | 15 |
subsection \<open>Auxiliary\<close> |
16 |
||
17 |
abbreviation (input) fixpoints :: \<open>('a \<Rightarrow> 'a) \<Rightarrow> 'a set\<close> |
|
18 |
where \<open>fixpoints f \<equiv> {x. f x = x}\<close> |
|
19 |
||
20 |
lemma inj_on_fixpoints: |
|
21 |
\<open>inj_on f (fixpoints f)\<close> |
|
22 |
by (rule inj_onI) simp |
|
23 |
||
24 |
lemma bij_betw_fixpoints: |
|
25 |
\<open>bij_betw f (fixpoints f) (fixpoints f)\<close> |
|
26 |
using inj_on_fixpoints by (auto simp add: bij_betw_def) |
|
27 |
||
28 |
||
73328 | 29 |
subsection \<open>Basic definition and consequences\<close> |
54681 | 30 |
|
73466 | 31 |
definition permutes :: \<open>('a \<Rightarrow> 'a) \<Rightarrow> 'a set \<Rightarrow> bool\<close> (infixr \<open>permutes\<close> 41) |
32 |
where \<open>p permutes S \<longleftrightarrow> (\<forall>x. x \<notin> S \<longrightarrow> p x = x) \<and> (\<forall>y. \<exists>!x. p x = y)\<close> |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
33 |
|
73466 | 34 |
lemma bij_imp_permutes: |
35 |
\<open>p permutes S\<close> if \<open>bij_betw p S S\<close> and stable: \<open>\<And>x. x \<notin> S \<Longrightarrow> p x = x\<close> |
|
36 |
proof - |
|
37 |
note \<open>bij_betw p S S\<close> |
|
38 |
moreover have \<open>bij_betw p (- S) (- S)\<close> |
|
39 |
by (auto simp add: stable intro!: bij_betw_imageI inj_onI) |
|
40 |
ultimately have \<open>bij_betw p (S \<union> - S) (S \<union> - S)\<close> |
|
41 |
by (rule bij_betw_combine) simp |
|
42 |
then have \<open>\<exists>!x. p x = y\<close> for y |
|
43 |
by (simp add: bij_iff) |
|
44 |
with stable show ?thesis |
|
45 |
by (simp add: permutes_def) |
|
46 |
qed |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
47 |
|
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
48 |
lemma inj_imp_permutes: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
49 |
assumes i: "inj_on f S" and fin: "finite S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
50 |
and fS: "\<And>x. x \<in> S \<Longrightarrow> f x \<in> S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
51 |
and f: "\<And>i. i \<notin> S \<Longrightarrow> f i = i" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
52 |
shows "f permutes S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
53 |
unfolding permutes_def |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
54 |
proof (intro conjI allI impI, rule f) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
55 |
fix y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
56 |
from endo_inj_surj[OF fin _ i] fS have fs: "f ` S = S" by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
57 |
show "\<exists>!x. f x = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
58 |
proof (cases "y \<in> S") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
59 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
60 |
thus ?thesis by (intro ex1I[of _ y], insert fS f) force+ |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
61 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
62 |
case True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
63 |
with fs obtain x where x: "x \<in> S" and fx: "f x = y" by force |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
64 |
show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
65 |
proof (rule ex1I, rule fx) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
66 |
fix x' |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
67 |
assume fx': "f x' = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
68 |
with True f[of x'] have "x' \<in> S" by metis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
69 |
from inj_onD[OF i fx[folded fx'] x this] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
70 |
show "x' = x" by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
71 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
72 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
73 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
74 |
|
73466 | 75 |
context |
76 |
fixes p :: \<open>'a \<Rightarrow> 'a\<close> and S :: \<open>'a set\<close> |
|
77 |
assumes perm: \<open>p permutes S\<close> |
|
78 |
begin |
|
79 |
||
80 |
lemma permutes_inj: |
|
81 |
\<open>inj p\<close> |
|
82 |
using perm by (auto simp: permutes_def inj_on_def) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
83 |
|
73466 | 84 |
lemma permutes_image: |
85 |
\<open>p ` S = S\<close> |
|
86 |
proof (rule set_eqI) |
|
87 |
fix x |
|
88 |
show \<open>x \<in> p ` S \<longleftrightarrow> x \<in> S\<close> |
|
89 |
proof |
|
90 |
assume \<open>x \<in> p ` S\<close> |
|
91 |
then obtain y where \<open>y \<in> S\<close> \<open>p y = x\<close> |
|
92 |
by blast |
|
93 |
with perm show \<open>x \<in> S\<close> |
|
94 |
by (cases \<open>y = x\<close>) (auto simp add: permutes_def) |
|
95 |
next |
|
96 |
assume \<open>x \<in> S\<close> |
|
97 |
with perm obtain y where \<open>y \<in> S\<close> \<open>p y = x\<close> |
|
98 |
by (metis permutes_def) |
|
99 |
then show \<open>x \<in> p ` S\<close> |
|
100 |
by blast |
|
101 |
qed |
|
102 |
qed |
|
103 |
||
104 |
lemma permutes_not_in: |
|
105 |
\<open>x \<notin> S \<Longrightarrow> p x = x\<close> |
|
106 |
using perm by (auto simp: permutes_def) |
|
107 |
||
108 |
lemma permutes_image_complement: |
|
109 |
\<open>p ` (- S) = - S\<close> |
|
110 |
by (auto simp add: permutes_not_in) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
111 |
|
73466 | 112 |
lemma permutes_in_image: |
113 |
\<open>p x \<in> S \<longleftrightarrow> x \<in> S\<close> |
|
114 |
using permutes_image permutes_inj by (auto dest: inj_image_mem_iff) |
|
115 |
||
116 |
lemma permutes_surj: |
|
117 |
\<open>surj p\<close> |
|
118 |
proof - |
|
119 |
have \<open>p ` (S \<union> - S) = p ` S \<union> p ` (- S)\<close> |
|
120 |
by (rule image_Un) |
|
121 |
then show ?thesis |
|
122 |
by (simp add: permutes_image permutes_image_complement) |
|
123 |
qed |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
124 |
|
73466 | 125 |
lemma permutes_inv_o: |
126 |
shows "p \<circ> inv p = id" |
|
127 |
and "inv p \<circ> p = id" |
|
128 |
using permutes_inj permutes_surj |
|
129 |
unfolding inj_iff [symmetric] surj_iff [symmetric] by auto |
|
130 |
||
131 |
lemma permutes_inverses: |
|
132 |
shows "p (inv p x) = x" |
|
133 |
and "inv p (p x) = x" |
|
134 |
using permutes_inv_o [unfolded fun_eq_iff o_def] by auto |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
135 |
|
73466 | 136 |
lemma permutes_inv_eq: |
137 |
\<open>inv p y = x \<longleftrightarrow> p x = y\<close> |
|
138 |
by (auto simp add: permutes_inverses) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
139 |
|
73466 | 140 |
lemma permutes_inj_on: |
141 |
\<open>inj_on p A\<close> |
|
142 |
by (rule inj_on_subset [of _ UNIV]) (auto intro: permutes_inj) |
|
143 |
||
144 |
lemma permutes_bij: |
|
145 |
\<open>bij p\<close> |
|
65342 | 146 |
unfolding bij_def by (metis permutes_inj permutes_surj) |
60601 | 147 |
|
73466 | 148 |
lemma permutes_imp_bij: |
149 |
\<open>bij_betw p S S\<close> |
|
150 |
by (simp add: bij_betw_def permutes_image permutes_inj_on) |
|
59474 | 151 |
|
73466 | 152 |
lemma permutes_subset: |
153 |
\<open>p permutes T\<close> if \<open>S \<subseteq> T\<close> |
|
154 |
proof (rule bij_imp_permutes) |
|
155 |
define R where \<open>R = T - S\<close> |
|
156 |
with that have \<open>T = R \<union> S\<close> \<open>R \<inter> S = {}\<close> |
|
157 |
by auto |
|
158 |
then have \<open>p x = x\<close> if \<open>x \<in> R\<close> for x |
|
159 |
using that by (auto intro: permutes_not_in) |
|
160 |
then have \<open>p ` R = R\<close> |
|
161 |
by simp |
|
162 |
with \<open>T = R \<union> S\<close> show \<open>bij_betw p T T\<close> |
|
163 |
by (simp add: bij_betw_def permutes_inj_on image_Un permutes_image) |
|
164 |
fix x |
|
165 |
assume \<open>x \<notin> T\<close> |
|
166 |
with \<open>T = R \<union> S\<close> show \<open>p x = x\<close> |
|
167 |
by (simp add: permutes_not_in) |
|
168 |
qed |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
169 |
|
73410 | 170 |
lemma permutes_imp_permutes_insert: |
73466 | 171 |
\<open>p permutes insert x S\<close> |
172 |
by (rule permutes_subset) auto |
|
173 |
||
174 |
end |
|
175 |
||
176 |
lemma permutes_id [simp]: |
|
177 |
\<open>id permutes S\<close> |
|
178 |
by (auto intro: bij_imp_permutes) |
|
73410 | 179 |
|
73466 | 180 |
lemma permutes_empty [simp]: |
181 |
\<open>p permutes {} \<longleftrightarrow> p = id\<close> |
|
182 |
proof |
|
183 |
assume \<open>p permutes {}\<close> |
|
184 |
then show \<open>p = id\<close> |
|
185 |
by (auto simp add: fun_eq_iff permutes_not_in) |
|
186 |
next |
|
187 |
assume \<open>p = id\<close> |
|
188 |
then show \<open>p permutes {}\<close> |
|
189 |
by simp |
|
190 |
qed |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
191 |
|
73466 | 192 |
lemma permutes_sing [simp]: |
193 |
\<open>p permutes {a} \<longleftrightarrow> p = id\<close> |
|
194 |
proof |
|
195 |
assume perm: \<open>p permutes {a}\<close> |
|
196 |
show \<open>p = id\<close> |
|
197 |
proof |
|
198 |
fix x |
|
199 |
from perm have \<open>p ` {a} = {a}\<close> |
|
200 |
by (rule permutes_image) |
|
201 |
with perm show \<open>p x = id x\<close> |
|
202 |
by (cases \<open>x = a\<close>) (auto simp add: permutes_not_in) |
|
203 |
qed |
|
204 |
next |
|
205 |
assume \<open>p = id\<close> |
|
206 |
then show \<open>p permutes {a}\<close> |
|
207 |
by simp |
|
208 |
qed |
|
30488 | 209 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
210 |
lemma permutes_univ: "p permutes UNIV \<longleftrightarrow> (\<forall>y. \<exists>!x. p x = y)" |
65342 | 211 |
by (simp add: permutes_def) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
212 |
|
73648 | 213 |
lemma permutes_swap_id: "a \<in> S \<Longrightarrow> b \<in> S \<Longrightarrow> transpose a b permutes S" |
214 |
by (rule bij_imp_permutes) (auto intro: transpose_apply_other) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
215 |
|
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
216 |
lemma permutes_altdef: "p permutes A \<longleftrightarrow> bij_betw p A A \<and> {x. p x \<noteq> x} \<subseteq> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
217 |
using permutes_not_in[of p A] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
218 |
by (auto simp: permutes_imp_bij intro!: bij_imp_permutes) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
219 |
|
73466 | 220 |
lemma permutes_superset: |
221 |
\<open>p permutes T\<close> if \<open>p permutes S\<close> \<open>\<And>x. x \<in> S - T \<Longrightarrow> p x = x\<close> |
|
222 |
proof - |
|
223 |
define R U where \<open>R = T \<inter> S\<close> and \<open>U = S - T\<close> |
|
224 |
then have \<open>T = R \<union> (T - S)\<close> \<open>S = R \<union> U\<close> \<open>R \<inter> U = {}\<close> |
|
225 |
by auto |
|
226 |
from that \<open>U = S - T\<close> have \<open>p ` U = U\<close> |
|
227 |
by simp |
|
228 |
from \<open>p permutes S\<close> have \<open>bij_betw p (R \<union> U) (R \<union> U)\<close> |
|
229 |
by (simp add: permutes_imp_bij \<open>S = R \<union> U\<close>) |
|
230 |
moreover have \<open>bij_betw p U U\<close> |
|
231 |
using that \<open>U = S - T\<close> by (simp add: bij_betw_def permutes_inj_on) |
|
232 |
ultimately have \<open>bij_betw p R R\<close> |
|
233 |
using \<open>R \<inter> U = {}\<close> \<open>R \<inter> U = {}\<close> by (rule bij_betw_partition) |
|
234 |
then have \<open>p permutes R\<close> |
|
235 |
proof (rule bij_imp_permutes) |
|
236 |
fix x |
|
237 |
assume \<open>x \<notin> R\<close> |
|
238 |
with \<open>R = T \<inter> S\<close> \<open>p permutes S\<close> show \<open>p x = x\<close> |
|
239 |
by (cases \<open>x \<in> S\<close>) (auto simp add: permutes_not_in that(2)) |
|
240 |
qed |
|
241 |
then have \<open>p permutes R \<union> (T - S)\<close> |
|
242 |
by (rule permutes_subset) simp |
|
243 |
with \<open>T = R \<union> (T - S)\<close> show ?thesis |
|
244 |
by simp |
|
245 |
qed |
|
54681 | 246 |
|
69895
6b03a8cf092d
more formal contributors (with the help of the history);
wenzelm
parents:
67673
diff
changeset
|
247 |
lemma permutes_bij_inv_into: \<^marker>\<open>contributor \<open>Lukas Bulwahn\<close>\<close> |
65342 | 248 |
fixes A :: "'a set" |
249 |
and B :: "'b set" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
250 |
assumes "p permutes A" |
65342 | 251 |
and "bij_betw f A B" |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
252 |
shows "(\<lambda>x. if x \<in> B then f (p (inv_into A f x)) else x) permutes B" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
253 |
proof (rule bij_imp_permutes) |
65342 | 254 |
from assms have "bij_betw p A A" "bij_betw f A B" "bij_betw (inv_into A f) B A" |
255 |
by (auto simp add: permutes_imp_bij bij_betw_inv_into) |
|
256 |
then have "bij_betw (f \<circ> p \<circ> inv_into A f) B B" |
|
257 |
by (simp add: bij_betw_trans) |
|
258 |
then show "bij_betw (\<lambda>x. if x \<in> B then f (p (inv_into A f x)) else x) B B" |
|
259 |
by (subst bij_betw_cong[where g="f \<circ> p \<circ> inv_into A f"]) auto |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
260 |
next |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
261 |
fix x |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
262 |
assume "x \<notin> B" |
65342 | 263 |
then show "(if x \<in> B then f (p (inv_into A f x)) else x) = x" by auto |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
264 |
qed |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
265 |
|
69895
6b03a8cf092d
more formal contributors (with the help of the history);
wenzelm
parents:
67673
diff
changeset
|
266 |
lemma permutes_image_mset: \<^marker>\<open>contributor \<open>Lukas Bulwahn\<close>\<close> |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
267 |
assumes "p permutes A" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
268 |
shows "image_mset p (mset_set A) = mset_set A" |
65342 | 269 |
using assms by (metis image_mset_mset_set bij_betw_imp_inj_on permutes_imp_bij permutes_image) |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
270 |
|
69895
6b03a8cf092d
more formal contributors (with the help of the history);
wenzelm
parents:
67673
diff
changeset
|
271 |
lemma permutes_implies_image_mset_eq: \<^marker>\<open>contributor \<open>Lukas Bulwahn\<close>\<close> |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
272 |
assumes "p permutes A" "\<And>x. x \<in> A \<Longrightarrow> f x = f' (p x)" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
273 |
shows "image_mset f' (mset_set A) = image_mset f (mset_set A)" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
274 |
proof - |
65342 | 275 |
have "f x = f' (p x)" if "x \<in># mset_set A" for x |
276 |
using assms(2)[of x] that by (cases "finite A") auto |
|
277 |
with assms have "image_mset f (mset_set A) = image_mset (f' \<circ> p) (mset_set A)" |
|
278 |
by (auto intro!: image_mset_cong) |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
279 |
also have "\<dots> = image_mset f' (image_mset p (mset_set A))" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
280 |
by (simp add: image_mset.compositionality) |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
281 |
also have "\<dots> = image_mset f' (mset_set A)" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
282 |
proof - |
65342 | 283 |
from assms permutes_image_mset have "image_mset p (mset_set A) = mset_set A" |
284 |
by blast |
|
285 |
then show ?thesis by simp |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
286 |
qed |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
287 |
finally show ?thesis .. |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
288 |
qed |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
289 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
290 |
|
60500 | 291 |
subsection \<open>Group properties\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
292 |
|
54681 | 293 |
lemma permutes_compose: "p permutes S \<Longrightarrow> q permutes S \<Longrightarrow> q \<circ> p permutes S" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
294 |
unfolding permutes_def o_def by metis |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
295 |
|
54681 | 296 |
lemma permutes_inv: |
65342 | 297 |
assumes "p permutes S" |
54681 | 298 |
shows "inv p permutes S" |
65342 | 299 |
using assms unfolding permutes_def permutes_inv_eq[OF assms] by metis |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
300 |
|
54681 | 301 |
lemma permutes_inv_inv: |
65342 | 302 |
assumes "p permutes S" |
54681 | 303 |
shows "inv (inv p) = p" |
65342 | 304 |
unfolding fun_eq_iff permutes_inv_eq[OF assms] permutes_inv_eq[OF permutes_inv[OF assms]] |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
305 |
by blast |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
306 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
307 |
lemma permutes_invI: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
308 |
assumes perm: "p permutes S" |
65342 | 309 |
and inv: "\<And>x. x \<in> S \<Longrightarrow> p' (p x) = x" |
310 |
and outside: "\<And>x. x \<notin> S \<Longrightarrow> p' x = x" |
|
311 |
shows "inv p = p'" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
312 |
proof |
65342 | 313 |
show "inv p x = p' x" for x |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
314 |
proof (cases "x \<in> S") |
65342 | 315 |
case True |
316 |
from assms have "p' x = p' (p (inv p x))" |
|
317 |
by (simp add: permutes_inverses) |
|
318 |
also from permutes_inv[OF perm] True have "\<dots> = inv p x" |
|
319 |
by (subst inv) (simp_all add: permutes_in_image) |
|
320 |
finally show ?thesis .. |
|
321 |
next |
|
322 |
case False |
|
323 |
with permutes_inv[OF perm] show ?thesis |
|
324 |
by (simp_all add: outside permutes_not_in) |
|
325 |
qed |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
326 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
327 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
328 |
lemma permutes_vimage: "f permutes A \<Longrightarrow> f -` A = A" |
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
329 |
by (simp add: bij_vimage_eq_inv_image permutes_bij permutes_image[OF permutes_inv]) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
330 |
|
54681 | 331 |
|
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
332 |
subsection \<open>Restricting a permutation to a subset\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
333 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
334 |
definition restrict_id :: "('a \<Rightarrow> 'a) \<Rightarrow> 'a set \<Rightarrow> 'a \<Rightarrow> 'a" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
335 |
where "restrict_id f A = (\<lambda>x. if x \<in> A then f x else x)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
336 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
337 |
lemma restrict_id_cong [cong]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
338 |
assumes "\<And>x. x \<in> A \<Longrightarrow> f x = g x" "A = B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
339 |
shows "restrict_id f A = restrict_id g B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
340 |
using assms unfolding restrict_id_def by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
341 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
342 |
lemma restrict_id_cong': |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
343 |
assumes "x \<in> A \<Longrightarrow> f x = g x" "A = B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
344 |
shows "restrict_id f A x = restrict_id g B x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
345 |
using assms unfolding restrict_id_def by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
346 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
347 |
lemma restrict_id_simps [simp]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
348 |
"x \<in> A \<Longrightarrow> restrict_id f A x = f x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
349 |
"x \<notin> A \<Longrightarrow> restrict_id f A x = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
350 |
by (auto simp: restrict_id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
351 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
352 |
lemma bij_betw_restrict_id: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
353 |
assumes "bij_betw f A A" "A \<subseteq> B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
354 |
shows "bij_betw (restrict_id f A) B B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
355 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
356 |
have "bij_betw (restrict_id f A) (A \<union> (B - A)) (A \<union> (B - A))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
357 |
unfolding restrict_id_def |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
358 |
by (rule bij_betw_disjoint_Un) (use assms in \<open>auto intro: bij_betwI\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
359 |
also have "A \<union> (B - A) = B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
360 |
using assms(2) by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
361 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
362 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
363 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
364 |
lemma permutes_restrict_id: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
365 |
assumes "bij_betw f A A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
366 |
shows "restrict_id f A permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
367 |
by (intro bij_imp_permutes bij_betw_restrict_id assms) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
368 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
369 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
370 |
subsection \<open>Mapping a permutation\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
371 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
372 |
definition map_permutation :: "'a set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> 'b \<Rightarrow> 'b" where |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
373 |
"map_permutation A f p = restrict_id (f \<circ> p \<circ> inv_into A f) (f ` A)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
374 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
375 |
lemma map_permutation_cong_strong: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
376 |
assumes "A = B" "\<And>x. x \<in> A \<Longrightarrow> f x = g x" "\<And>x. x \<in> A \<Longrightarrow> p x = q x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
377 |
assumes "p ` A \<subseteq> A" "inj_on f A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
378 |
shows "map_permutation A f p = map_permutation B g q" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
379 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
380 |
have fg: "f x = g y" if "x \<in> A" "x = y" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
381 |
using assms(2) that by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
382 |
have pq: "p x = q y" if "x \<in> A" "x = y" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
383 |
using assms(3) that by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
384 |
have p: "p x \<in> A" if "x \<in> A" for x |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
385 |
using assms(4) that by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
386 |
have inv: "inv_into A f x = inv_into B g y" if "x \<in> f ` A" "x = y" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
387 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
388 |
from that obtain u where u: "u \<in> A" "x = f u" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
389 |
by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
390 |
have "inv_into A f (f u) = inv_into A g (f u)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
391 |
using \<open>inj_on f A\<close> u(1) by (metis assms(2) inj_on_cong inv_into_f_f) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
392 |
thus ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
393 |
using u \<open>x = y\<close> \<open>A = B\<close> by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
394 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
395 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
396 |
show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
397 |
unfolding map_permutation_def o_def |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
398 |
by (intro restrict_id_cong image_cong fg pq inv_into_into p inv) (auto simp: \<open>A = B\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
399 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
400 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
401 |
lemma map_permutation_cong: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
402 |
assumes "inj_on f A" "p permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
403 |
assumes "A = B" "\<And>x. x \<in> A \<Longrightarrow> f x = g x" "\<And>x. x \<in> A \<Longrightarrow> p x = q x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
404 |
shows "map_permutation A f p = map_permutation B g q" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
405 |
proof (intro map_permutation_cong_strong assms) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
406 |
show "p ` A \<subseteq> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
407 |
using \<open>p permutes A\<close> by (simp add: permutes_image) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
408 |
qed auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
409 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
410 |
lemma inv_into_id [simp]: "x \<in> A \<Longrightarrow> inv_into A id x = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
411 |
by (metis f_inv_into_f id_apply image_eqI) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
412 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
413 |
lemma inv_into_ident [simp]: "x \<in> A \<Longrightarrow> inv_into A (\<lambda>x. x) x = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
414 |
by (metis f_inv_into_f image_eqI) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
415 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
416 |
lemma map_permutation_id [simp]: "p permutes A \<Longrightarrow> map_permutation A id p = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
417 |
by (auto simp: fun_eq_iff map_permutation_def restrict_id_def permutes_not_in) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
418 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
419 |
lemma map_permutation_ident [simp]: "p permutes A \<Longrightarrow> map_permutation A (\<lambda>x. x) p = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
420 |
by (auto simp: fun_eq_iff map_permutation_def restrict_id_def permutes_not_in) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
421 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
422 |
lemma map_permutation_id': "inj_on f A \<Longrightarrow> map_permutation A f id = id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
423 |
unfolding map_permutation_def by (auto simp: restrict_id_def fun_eq_iff) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
424 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
425 |
lemma map_permutation_ident': "inj_on f A \<Longrightarrow> map_permutation A f (\<lambda>x. x) = (\<lambda>x. x)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
426 |
unfolding map_permutation_def by (auto simp: restrict_id_def fun_eq_iff) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
427 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
428 |
lemma map_permutation_permutes: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
429 |
assumes "bij_betw f A B" "p permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
430 |
shows "map_permutation A f p permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
431 |
proof (rule bij_imp_permutes) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
432 |
have f_A: "f ` A = B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
433 |
using assms(1) by (auto simp: bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
434 |
from assms(2) have "bij_betw p A A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
435 |
by (simp add: permutes_imp_bij) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
436 |
show "bij_betw (map_permutation A f p) B B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
437 |
unfolding map_permutation_def f_A |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
438 |
by (rule bij_betw_restrict_id bij_betw_trans bij_betw_inv_into assms(1) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
439 |
permutes_imp_bij[OF assms(2)] order.refl)+ |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
440 |
show "map_permutation A f p x = x" if "x \<notin> B" for x |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
441 |
using that unfolding map_permutation_def f_A by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
442 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
443 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
444 |
lemma map_permutation_compose: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
445 |
fixes f :: "'a \<Rightarrow> 'b" and g :: "'b \<Rightarrow> 'c" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
446 |
assumes "bij_betw f A B" "inj_on g B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
447 |
shows "map_permutation B g (map_permutation A f p) = map_permutation A (g \<circ> f) p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
448 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
449 |
fix c :: 'c |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
450 |
have bij_g: "bij_betw g B (g ` B)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
451 |
using \<open>inj_on g B\<close> unfolding bij_betw_def by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
452 |
have [simp]: "f x = f y \<longleftrightarrow> x = y" if "x \<in> A" "y \<in> A" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
453 |
using assms(1) that by (auto simp: bij_betw_def inj_on_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
454 |
have [simp]: "g x = g y \<longleftrightarrow> x = y" if "x \<in> B" "y \<in> B" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
455 |
using assms(2) that by (auto simp: bij_betw_def inj_on_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
456 |
show "map_permutation B g (map_permutation A f p) c = map_permutation A (g \<circ> f) p c" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
457 |
proof (cases "c \<in> g ` B") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
458 |
case c: True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
459 |
then obtain a where a: "a \<in> A" "c = g (f a)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
460 |
using assms(1,2) unfolding bij_betw_def by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
461 |
have "map_permutation B g (map_permutation A f p) c = g (f (p a))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
462 |
using a assms by (auto simp: map_permutation_def restrict_id_def bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
463 |
also have "\<dots> = map_permutation A (g \<circ> f) p c" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
464 |
using a bij_betw_inv_into_left[OF bij_betw_trans[OF assms(1) bij_g]] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
465 |
by (auto simp: map_permutation_def restrict_id_def bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
466 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
467 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
468 |
case c: False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
469 |
thus ?thesis using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
470 |
by (auto simp: map_permutation_def bij_betw_def restrict_id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
471 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
472 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
473 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
474 |
lemma map_permutation_compose_inv: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
475 |
assumes "bij_betw f A B" "p permutes A" "\<And>x. x \<in> A \<Longrightarrow> g (f x) = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
476 |
shows "map_permutation B g (map_permutation A f p) = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
477 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
478 |
have "inj_on g B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
479 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
480 |
fix x y assume "x \<in> B" "y \<in> B" "g x = g y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
481 |
then obtain x' y' where *: "x' \<in> A" "y' : A" "x = f x'" "y = f y'" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
482 |
using assms(1) unfolding bij_betw_def by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
483 |
thus "x = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
484 |
using assms(3)[of x'] assms(3)[of y'] \<open>g x = g y\<close> by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
485 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
486 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
487 |
have "map_permutation B g (map_permutation A f p) = map_permutation A (g \<circ> f) p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
488 |
by (rule map_permutation_compose) (use assms \<open>inj_on g B\<close> in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
489 |
also have "\<dots> = map_permutation A id p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
490 |
by (intro map_permutation_cong assms comp_inj_on) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
491 |
(use \<open>inj_on g B\<close> assms(1,3) in \<open>auto simp: bij_betw_def\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
492 |
also have "\<dots> = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
493 |
by (rule map_permutation_id) fact |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
494 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
495 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
496 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
497 |
lemma map_permutation_apply: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
498 |
assumes "inj_on f A" "x \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
499 |
shows "map_permutation A f h (f x) = f (h x)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
500 |
using assms by (auto simp: map_permutation_def inj_on_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
501 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
502 |
lemma map_permutation_compose': |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
503 |
fixes f :: "'a \<Rightarrow> 'b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
504 |
assumes "inj_on f A" "q permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
505 |
shows "map_permutation A f (p \<circ> q) = map_permutation A f p \<circ> map_permutation A f q" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
506 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
507 |
fix y :: 'b |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
508 |
show "map_permutation A f (p \<circ> q) y = (map_permutation A f p \<circ> map_permutation A f q) y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
509 |
proof (cases "y \<in> f ` A") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
510 |
case True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
511 |
then obtain x where x: "x \<in> A" "y = f x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
512 |
by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
513 |
have "map_permutation A f (p \<circ> q) y = f (p (q x))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
514 |
unfolding x(2) by (subst map_permutation_apply) (use assms x in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
515 |
also have "\<dots> = (map_permutation A f p \<circ> map_permutation A f q) y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
516 |
unfolding x o_apply using x(1) assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
517 |
by (simp add: map_permutation_apply permutes_in_image) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
518 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
519 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
520 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
521 |
thus ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
522 |
using False by (simp add: map_permutation_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
523 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
524 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
525 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
526 |
lemma map_permutation_transpose: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
527 |
assumes "inj_on f A" "a \<in> A" "b \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
528 |
shows "map_permutation A f (Transposition.transpose a b) = Transposition.transpose (f a) (f b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
529 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
530 |
fix y :: 'b |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
531 |
show "map_permutation A f (Transposition.transpose a b) y = Transposition.transpose (f a) (f b) y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
532 |
proof (cases "y \<in> f ` A") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
533 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
534 |
hence "map_permutation A f (Transposition.transpose a b) y = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
535 |
unfolding map_permutation_def by (intro restrict_id_simps) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
536 |
moreover have "Transposition.transpose (f a) (f b) y = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
537 |
using False assms by (intro transpose_apply_other) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
538 |
ultimately show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
539 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
540 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
541 |
case True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
542 |
then obtain x where x: "x \<in> A" "y = f x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
543 |
by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
544 |
have "map_permutation A f (Transposition.transpose a b) y = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
545 |
f (Transposition.transpose a b x)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
546 |
unfolding x by (subst map_permutation_apply) (use x assms in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
547 |
also have "\<dots> = Transposition.transpose (f a) (f b) y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
548 |
using assms(2,3) x |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
549 |
by (auto simp: Transposition.transpose_def inj_on_eq_iff[OF assms(1)]) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
550 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
551 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
552 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
553 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
554 |
lemma map_permutation_permutes_iff: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
555 |
assumes "bij_betw f A B" "p ` A \<subseteq> A" "\<And>x. x \<notin> A \<Longrightarrow> p x = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
556 |
shows "map_permutation A f p permutes B \<longleftrightarrow> p permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
557 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
558 |
assume "p permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
559 |
thus "map_permutation A f p permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
560 |
by (intro map_permutation_permutes assms) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
561 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
562 |
assume *: "map_permutation A f p permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
563 |
hence "map_permutation B (inv_into A f) (map_permutation A f p) permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
564 |
by (rule map_permutation_permutes[OF bij_betw_inv_into[OF assms(1)]]) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
565 |
also have "map_permutation B (inv_into A f) (map_permutation A f p) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
566 |
map_permutation A (inv_into A f \<circ> f) p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
567 |
by (rule map_permutation_compose[OF _ inj_on_inv_into]) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
568 |
(use assms in \<open>auto simp: bij_betw_def\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
569 |
also have "\<dots> = map_permutation A id p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
570 |
unfolding o_def id_def |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
571 |
by (rule sym, intro map_permutation_cong_strong inv_into_f_f[symmetric] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
572 |
assms(2) bij_betw_imp_inj_on[OF assms(1)]) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
573 |
also have "\<dots> = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
574 |
unfolding map_permutation_def using assms(3) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
575 |
by (auto simp: restrict_id_def fun_eq_iff split: if_splits) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
576 |
finally show "p permutes A" . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
577 |
qed |
66486
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
578 |
|
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
579 |
lemma bij_betw_permutations: |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
580 |
assumes "bij_betw f A B" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
581 |
shows "bij_betw (\<lambda>\<pi> x. if x \<in> B then f (\<pi> (inv_into A f x)) else x) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
582 |
{\<pi>. \<pi> permutes A} {\<pi>. \<pi> permutes B}" (is "bij_betw ?f _ _") |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
583 |
proof - |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
584 |
let ?g = "(\<lambda>\<pi> x. if x \<in> A then inv_into A f (\<pi> (f x)) else x)" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
585 |
show ?thesis |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
586 |
proof (rule bij_betw_byWitness [of _ ?g], goal_cases) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
587 |
case 3 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
588 |
show ?case using permutes_bij_inv_into[OF _ assms] by auto |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
589 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
590 |
case 4 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
591 |
have bij_inv: "bij_betw (inv_into A f) B A" by (intro bij_betw_inv_into assms) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
592 |
{ |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
593 |
fix \<pi> assume "\<pi> permutes B" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
594 |
from permutes_bij_inv_into[OF this bij_inv] and assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
595 |
have "(\<lambda>x. if x \<in> A then inv_into A f (\<pi> (f x)) else x) permutes A" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
596 |
by (simp add: inv_into_inv_into_eq cong: if_cong) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
597 |
} |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
598 |
from this show ?case by (auto simp: permutes_inv) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
599 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
600 |
case 1 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
601 |
thus ?case using assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
602 |
by (auto simp: fun_eq_iff permutes_not_in permutes_in_image bij_betw_inv_into_left |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
603 |
dest: bij_betwE) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
604 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
605 |
case 2 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
606 |
moreover have "bij_betw (inv_into A f) B A" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
607 |
by (intro bij_betw_inv_into assms) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
608 |
ultimately show ?case using assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
609 |
by (auto simp: fun_eq_iff permutes_not_in permutes_in_image bij_betw_inv_into_right |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
610 |
dest: bij_betwE) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
611 |
qed |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
612 |
qed |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
613 |
|
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
614 |
lemma bij_betw_derangements: |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
615 |
assumes "bij_betw f A B" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
616 |
shows "bij_betw (\<lambda>\<pi> x. if x \<in> B then f (\<pi> (inv_into A f x)) else x) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
617 |
{\<pi>. \<pi> permutes A \<and> (\<forall>x\<in>A. \<pi> x \<noteq> x)} {\<pi>. \<pi> permutes B \<and> (\<forall>x\<in>B. \<pi> x \<noteq> x)}" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
618 |
(is "bij_betw ?f _ _") |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
619 |
proof - |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
620 |
let ?g = "(\<lambda>\<pi> x. if x \<in> A then inv_into A f (\<pi> (f x)) else x)" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
621 |
show ?thesis |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
622 |
proof (rule bij_betw_byWitness [of _ ?g], goal_cases) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
623 |
case 3 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
624 |
have "?f \<pi> x \<noteq> x" if "\<pi> permutes A" "\<And>x. x \<in> A \<Longrightarrow> \<pi> x \<noteq> x" "x \<in> B" for \<pi> x |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
625 |
using that and assms by (metis bij_betwE bij_betw_imp_inj_on bij_betw_imp_surj_on |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
626 |
inv_into_f_f inv_into_into permutes_imp_bij) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
627 |
with permutes_bij_inv_into[OF _ assms] show ?case by auto |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
628 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
629 |
case 4 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
630 |
have bij_inv: "bij_betw (inv_into A f) B A" by (intro bij_betw_inv_into assms) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
631 |
have "?g \<pi> permutes A" if "\<pi> permutes B" for \<pi> |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
632 |
using permutes_bij_inv_into[OF that bij_inv] and assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
633 |
by (simp add: inv_into_inv_into_eq cong: if_cong) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
634 |
moreover have "?g \<pi> x \<noteq> x" if "\<pi> permutes B" "\<And>x. x \<in> B \<Longrightarrow> \<pi> x \<noteq> x" "x \<in> A" for \<pi> x |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
635 |
using that and assms by (metis bij_betwE bij_betw_imp_surj_on f_inv_into_f permutes_imp_bij) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
636 |
ultimately show ?case by auto |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
637 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
638 |
case 1 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
639 |
thus ?case using assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
640 |
by (force simp: fun_eq_iff permutes_not_in permutes_in_image bij_betw_inv_into_left |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
641 |
dest: bij_betwE) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
642 |
next |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
643 |
case 2 |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
644 |
moreover have "bij_betw (inv_into A f) B A" |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
645 |
by (intro bij_betw_inv_into assms) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
646 |
ultimately show ?case using assms |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
647 |
by (force simp: fun_eq_iff permutes_not_in permutes_in_image bij_betw_inv_into_right |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
648 |
dest: bij_betwE) |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
649 |
qed |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
650 |
qed |
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
651 |
|
ffaaa83543b2
Lemmas about analysis and permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
65552
diff
changeset
|
652 |
|
60500 | 653 |
subsection \<open>The number of permutations on a finite set\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
654 |
|
30488 | 655 |
lemma permutes_insert_lemma: |
65342 | 656 |
assumes "p permutes (insert a S)" |
73648 | 657 |
shows "transpose a (p a) \<circ> p permutes S" |
80777 | 658 |
proof (rule permutes_superset[where S = "insert a S"]) |
659 |
show "Transposition.transpose a (p a) \<circ> p permutes insert a S" |
|
660 |
by (meson assms insertI1 permutes_compose permutes_in_image permutes_swap_id) |
|
661 |
qed auto |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
662 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
663 |
lemma permutes_insert: "{p. p permutes (insert a S)} = |
73648 | 664 |
(\<lambda>(b, p). transpose a b \<circ> p) ` {(b, p). b \<in> insert a S \<and> p \<in> {p. p permutes S}}" |
54681 | 665 |
proof - |
65342 | 666 |
have "p permutes insert a S \<longleftrightarrow> |
73648 | 667 |
(\<exists>b q. p = transpose a b \<circ> q \<and> b \<in> insert a S \<and> q permutes S)" for p |
65342 | 668 |
proof - |
73648 | 669 |
have "\<exists>b q. p = transpose a b \<circ> q \<and> b \<in> insert a S \<and> q permutes S" |
65342 | 670 |
if p: "p permutes insert a S" |
671 |
proof - |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
672 |
let ?b = "p a" |
73648 | 673 |
let ?q = "transpose a (p a) \<circ> p" |
674 |
have *: "p = transpose a ?b \<circ> ?q" |
|
65342 | 675 |
by (simp add: fun_eq_iff o_assoc) |
676 |
have **: "?b \<in> insert a S" |
|
677 |
unfolding permutes_in_image[OF p] by simp |
|
678 |
from permutes_insert_lemma[OF p] * ** show ?thesis |
|
73648 | 679 |
by blast |
65342 | 680 |
qed |
681 |
moreover have "p permutes insert a S" |
|
73648 | 682 |
if bq: "p = transpose a b \<circ> q" "b \<in> insert a S" "q permutes S" for b q |
65342 | 683 |
proof - |
684 |
from permutes_subset[OF bq(3), of "insert a S"] have q: "q permutes insert a S" |
|
54681 | 685 |
by auto |
65342 | 686 |
have a: "a \<in> insert a S" |
54681 | 687 |
by simp |
65342 | 688 |
from bq(1) permutes_compose[OF q permutes_swap_id[OF a bq(2)]] show ?thesis |
54681 | 689 |
by simp |
65342 | 690 |
qed |
691 |
ultimately show ?thesis by blast |
|
692 |
qed |
|
693 |
then show ?thesis by auto |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
694 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
695 |
|
54681 | 696 |
lemma card_permutations: |
65342 | 697 |
assumes "card S = n" |
698 |
and "finite S" |
|
33715 | 699 |
shows "card {p. p permutes S} = fact n" |
65342 | 700 |
using assms(2,1) |
54681 | 701 |
proof (induct arbitrary: n) |
702 |
case empty |
|
703 |
then show ?case by simp |
|
33715 | 704 |
next |
705 |
case (insert x F) |
|
54681 | 706 |
{ |
707 |
fix n |
|
72304 | 708 |
assume card_insert: "card (insert x F) = n" |
33715 | 709 |
let ?xF = "{p. p permutes insert x F}" |
710 |
let ?pF = "{p. p permutes F}" |
|
711 |
let ?pF' = "{(b, p). b \<in> insert x F \<and> p \<in> ?pF}" |
|
73648 | 712 |
let ?g = "(\<lambda>(b, p). transpose x b \<circ> p)" |
65342 | 713 |
have xfgpF': "?xF = ?g ` ?pF'" |
714 |
by (rule permutes_insert[of x F]) |
|
72304 | 715 |
from \<open>x \<notin> F\<close> \<open>finite F\<close> card_insert have Fs: "card F = n - 1" |
65342 | 716 |
by auto |
717 |
from \<open>finite F\<close> insert.hyps Fs have pFs: "card ?pF = fact (n - 1)" |
|
718 |
by auto |
|
54681 | 719 |
then have "finite ?pF" |
59730
b7c394c7a619
The factorial function, "fact", now has type "nat => 'a"
paulson <lp15@cam.ac.uk>
parents:
59669
diff
changeset
|
720 |
by (auto intro: card_ge_0_finite) |
72302
d7d90ed4c74e
fixed some remarkably ugly proofs
paulson <lp15@cam.ac.uk>
parents:
69895
diff
changeset
|
721 |
with \<open>finite F\<close> card.insert_remove have pF'f: "finite ?pF'" |
80777 | 722 |
by simp |
33715 | 723 |
have ginj: "inj_on ?g ?pF'" |
54681 | 724 |
proof - |
33715 | 725 |
{ |
54681 | 726 |
fix b p c q |
65342 | 727 |
assume bp: "(b, p) \<in> ?pF'" |
728 |
assume cq: "(c, q) \<in> ?pF'" |
|
729 |
assume eq: "?g (b, p) = ?g (c, q)" |
|
730 |
from bp cq have pF: "p permutes F" and qF: "q permutes F" |
|
54681 | 731 |
by auto |
65342 | 732 |
from pF \<open>x \<notin> F\<close> eq have "b = ?g (b, p) x" |
73663 | 733 |
by (auto simp: permutes_def fun_upd_def fun_eq_iff) |
65342 | 734 |
also from qF \<open>x \<notin> F\<close> eq have "\<dots> = ?g (c, q) x" |
73466 | 735 |
by (auto simp: fun_upd_def fun_eq_iff) |
65342 | 736 |
also from qF \<open>x \<notin> F\<close> have "\<dots> = c" |
73663 | 737 |
by (auto simp: permutes_def fun_upd_def fun_eq_iff) |
65342 | 738 |
finally have "b = c" . |
73663 | 739 |
then have "transpose x b = transpose x c" |
54681 | 740 |
by simp |
73663 | 741 |
with eq have "transpose x b \<circ> p = transpose x b \<circ> q" |
54681 | 742 |
by simp |
73663 | 743 |
then have "transpose x b \<circ> (transpose x b \<circ> p) = transpose x b \<circ> (transpose x b \<circ> q)" |
54681 | 744 |
by simp |
745 |
then have "p = q" |
|
746 |
by (simp add: o_assoc) |
|
65342 | 747 |
with \<open>b = c\<close> have "(b, p) = (c, q)" |
54681 | 748 |
by simp |
33715 | 749 |
} |
54681 | 750 |
then show ?thesis |
751 |
unfolding inj_on_def by blast |
|
33715 | 752 |
qed |
72304 | 753 |
from \<open>x \<notin> F\<close> \<open>finite F\<close> card_insert have "n \<noteq> 0" |
65342 | 754 |
by auto |
54681 | 755 |
then have "\<exists>m. n = Suc m" |
756 |
by presburger |
|
65342 | 757 |
then obtain m where n: "n = Suc m" |
54681 | 758 |
by blast |
72304 | 759 |
from pFs card_insert have *: "card ?xF = fact n" |
54681 | 760 |
unfolding xfgpF' card_image[OF ginj] |
60500 | 761 |
using \<open>finite F\<close> \<open>finite ?pF\<close> |
65342 | 762 |
by (simp only: Collect_case_prod Collect_mem_eq card_cartesian_product) (simp add: n) |
54681 | 763 |
from finite_imageI[OF pF'f, of ?g] have xFf: "finite ?xF" |
65342 | 764 |
by (simp add: xfgpF' n) |
765 |
from * have "card ?xF = fact n" |
|
766 |
unfolding xFf by blast |
|
33715 | 767 |
} |
65342 | 768 |
with insert show ?case by simp |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
769 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
770 |
|
54681 | 771 |
lemma finite_permutations: |
65342 | 772 |
assumes "finite S" |
54681 | 773 |
shows "finite {p. p permutes S}" |
65342 | 774 |
using card_permutations[OF refl assms] by (auto intro: card_ge_0_finite) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
775 |
|
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
776 |
lemma permutes_doubleton_iff: "f permutes {a, b} \<longleftrightarrow> f = id \<or> f = Transposition.transpose a b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
777 |
proof (cases "a = b") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
778 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
779 |
have "{id, Transposition.transpose a b} \<subseteq> {f. f permutes {a, b}}" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
780 |
by (auto simp: permutes_id permutes_swap_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
781 |
moreover have "id \<noteq> Transposition.transpose a b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
782 |
using False by (auto simp: fun_eq_iff Transposition.transpose_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
783 |
hence "card {id, Transposition.transpose a b} = card {f. f permutes {a, b}}" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
784 |
using False by (simp add: card_permutations) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
785 |
ultimately have "{id, Transposition.transpose a b} = {f. f permutes {a, b}}" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
786 |
by (intro card_subset_eq finite_permutations) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
787 |
thus ?thesis by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
788 |
qed auto |
73466 | 789 |
|
790 |
||
60500 | 791 |
subsection \<open>Permutations of index set for iterated operations\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
792 |
|
51489 | 793 |
lemma (in comm_monoid_set) permute: |
794 |
assumes "p permutes S" |
|
54681 | 795 |
shows "F g S = F (g \<circ> p) S" |
51489 | 796 |
proof - |
60500 | 797 |
from \<open>p permutes S\<close> have "inj p" |
54681 | 798 |
by (rule permutes_inj) |
799 |
then have "inj_on p S" |
|
800 |
by (auto intro: subset_inj_on) |
|
801 |
then have "F g (p ` S) = F (g \<circ> p) S" |
|
802 |
by (rule reindex) |
|
60500 | 803 |
moreover from \<open>p permutes S\<close> have "p ` S = S" |
54681 | 804 |
by (rule permutes_image) |
805 |
ultimately show ?thesis |
|
806 |
by simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
807 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
808 |
|
54681 | 809 |
|
60500 | 810 |
subsection \<open>Permutations as transposition sequences\<close> |
54681 | 811 |
|
812 |
inductive swapidseq :: "nat \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool" |
|
65342 | 813 |
where |
814 |
id[simp]: "swapidseq 0 id" |
|
73648 | 815 |
| comp_Suc: "swapidseq n p \<Longrightarrow> a \<noteq> b \<Longrightarrow> swapidseq (Suc n) (transpose a b \<circ> p)" |
54681 | 816 |
|
817 |
declare id[unfolded id_def, simp] |
|
818 |
||
819 |
definition "permutation p \<longleftrightarrow> (\<exists>n. swapidseq n p)" |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
820 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
821 |
|
60500 | 822 |
subsection \<open>Some closure properties of the set of permutations, with lengths\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
823 |
|
54681 | 824 |
lemma permutation_id[simp]: "permutation id" |
825 |
unfolding permutation_def by (rule exI[where x=0]) simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
826 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
827 |
declare permutation_id[unfolded id_def, simp] |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
828 |
|
73648 | 829 |
lemma swapidseq_swap: "swapidseq (if a = b then 0 else 1) (transpose a b)" |
80777 | 830 |
using swapidseq.simps by fastforce |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
831 |
|
73648 | 832 |
lemma permutation_swap_id: "permutation (transpose a b)" |
80777 | 833 |
by (meson permutation_def swapidseq_swap) |
65342 | 834 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
835 |
|
54681 | 836 |
lemma swapidseq_comp_add: "swapidseq n p \<Longrightarrow> swapidseq m q \<Longrightarrow> swapidseq (n + m) (p \<circ> q)" |
837 |
proof (induct n p arbitrary: m q rule: swapidseq.induct) |
|
838 |
case (id m q) |
|
839 |
then show ?case by simp |
|
840 |
next |
|
841 |
case (comp_Suc n p a b m q) |
|
80777 | 842 |
then show ?case |
843 |
by (metis add_Suc comp_assoc swapidseq.comp_Suc) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
844 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
845 |
|
54681 | 846 |
lemma permutation_compose: "permutation p \<Longrightarrow> permutation q \<Longrightarrow> permutation (p \<circ> q)" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
847 |
unfolding permutation_def using swapidseq_comp_add[of _ p _ q] by metis |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
848 |
|
73648 | 849 |
lemma swapidseq_endswap: "swapidseq n p \<Longrightarrow> a \<noteq> b \<Longrightarrow> swapidseq (Suc n) (p \<circ> transpose a b)" |
65342 | 850 |
by (induct n p rule: swapidseq.induct) |
851 |
(use swapidseq_swap[of a b] in \<open>auto simp add: comp_assoc intro: swapidseq.comp_Suc\<close>) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
852 |
|
54681 | 853 |
lemma swapidseq_inverse_exists: "swapidseq n p \<Longrightarrow> \<exists>q. swapidseq n q \<and> p \<circ> q = id \<and> q \<circ> p = id" |
854 |
proof (induct n p rule: swapidseq.induct) |
|
855 |
case id |
|
856 |
then show ?case |
|
857 |
by (rule exI[where x=id]) simp |
|
30488 | 858 |
next |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
859 |
case (comp_Suc n p a b) |
54681 | 860 |
from comp_Suc.hyps obtain q where q: "swapidseq n q" "p \<circ> q = id" "q \<circ> p = id" |
861 |
by blast |
|
73648 | 862 |
let ?q = "q \<circ> transpose a b" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
863 |
note H = comp_Suc.hyps |
73648 | 864 |
from swapidseq_swap[of a b] H(3) have *: "swapidseq 1 (transpose a b)" |
54681 | 865 |
by simp |
65342 | 866 |
from swapidseq_comp_add[OF q(1) *] have **: "swapidseq (Suc n) ?q" |
54681 | 867 |
by simp |
73648 | 868 |
have "transpose a b \<circ> p \<circ> ?q = transpose a b \<circ> (p \<circ> q) \<circ> transpose a b" |
54681 | 869 |
by (simp add: o_assoc) |
870 |
also have "\<dots> = id" |
|
871 |
by (simp add: q(2)) |
|
73648 | 872 |
finally have ***: "transpose a b \<circ> p \<circ> ?q = id" . |
873 |
have "?q \<circ> (transpose a b \<circ> p) = q \<circ> (transpose a b \<circ> transpose a b) \<circ> p" |
|
54681 | 874 |
by (simp only: o_assoc) |
73648 | 875 |
then have "?q \<circ> (transpose a b \<circ> p) = id" |
54681 | 876 |
by (simp add: q(3)) |
65342 | 877 |
with ** *** show ?case |
54681 | 878 |
by blast |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
879 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
880 |
|
54681 | 881 |
lemma swapidseq_inverse: |
65342 | 882 |
assumes "swapidseq n p" |
54681 | 883 |
shows "swapidseq n (inv p)" |
65342 | 884 |
using swapidseq_inverse_exists[OF assms] inv_unique_comp[of p] by auto |
54681 | 885 |
|
886 |
lemma permutation_inverse: "permutation p \<Longrightarrow> permutation (inv p)" |
|
887 |
using permutation_def swapidseq_inverse by blast |
|
888 |
||
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
889 |
|
73328 | 890 |
|
891 |
subsection \<open>Various combinations of transpositions with 2, 1 and 0 common elements\<close> |
|
892 |
||
893 |
lemma swap_id_common:" a \<noteq> c \<Longrightarrow> b \<noteq> c \<Longrightarrow> |
|
73663 | 894 |
transpose a b \<circ> transpose a c = transpose b c \<circ> transpose a b" |
895 |
by (simp add: fun_eq_iff transpose_def) |
|
73328 | 896 |
|
897 |
lemma swap_id_common': "a \<noteq> b \<Longrightarrow> a \<noteq> c \<Longrightarrow> |
|
73663 | 898 |
transpose a c \<circ> transpose b c = transpose b c \<circ> transpose a b" |
899 |
by (simp add: fun_eq_iff transpose_def) |
|
73328 | 900 |
|
901 |
lemma swap_id_independent: "a \<noteq> c \<Longrightarrow> a \<noteq> d \<Longrightarrow> b \<noteq> c \<Longrightarrow> b \<noteq> d \<Longrightarrow> |
|
73648 | 902 |
transpose a b \<circ> transpose c d = transpose c d \<circ> transpose a b" |
73663 | 903 |
by (simp add: fun_eq_iff transpose_def) |
73328 | 904 |
|
905 |
||
60500 | 906 |
subsection \<open>The identity map only has even transposition sequences\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
907 |
|
54681 | 908 |
lemma symmetry_lemma: |
909 |
assumes "\<And>a b c d. P a b c d \<Longrightarrow> P a b d c" |
|
910 |
and "\<And>a b c d. a \<noteq> b \<Longrightarrow> c \<noteq> d \<Longrightarrow> |
|
911 |
a = c \<and> b = d \<or> a = c \<and> b \<noteq> d \<or> a \<noteq> c \<and> b = d \<or> a \<noteq> c \<and> a \<noteq> d \<and> b \<noteq> c \<and> b \<noteq> d \<Longrightarrow> |
|
912 |
P a b c d" |
|
913 |
shows "\<And>a b c d. a \<noteq> b \<longrightarrow> c \<noteq> d \<longrightarrow> P a b c d" |
|
914 |
using assms by metis |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
915 |
|
80777 | 916 |
lemma swap_general: |
917 |
assumes "a \<noteq> b" "c \<noteq> d" |
|
918 |
shows "transpose a b \<circ> transpose c d = id \<or> |
|
54681 | 919 |
(\<exists>x y z. x \<noteq> a \<and> y \<noteq> a \<and> z \<noteq> a \<and> x \<noteq> y \<and> |
73648 | 920 |
transpose a b \<circ> transpose c d = transpose x y \<circ> transpose a z)" |
80777 | 921 |
by (metis assms swap_id_common' swap_id_independent transpose_commute transpose_comp_involutory) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
922 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
923 |
lemma swapidseq_id_iff[simp]: "swapidseq 0 p \<longleftrightarrow> p = id" |
65342 | 924 |
using swapidseq.cases[of 0 p "p = id"] by auto |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
925 |
|
54681 | 926 |
lemma swapidseq_cases: "swapidseq n p \<longleftrightarrow> |
73648 | 927 |
n = 0 \<and> p = id \<or> (\<exists>a b q m. n = Suc m \<and> p = transpose a b \<circ> q \<and> swapidseq m q \<and> a \<noteq> b)" |
80777 | 928 |
by (meson comp_Suc id swapidseq.cases) |
54681 | 929 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
930 |
lemma fixing_swapidseq_decrease: |
65342 | 931 |
assumes "swapidseq n p" |
932 |
and "a \<noteq> b" |
|
73648 | 933 |
and "(transpose a b \<circ> p) a = a" |
934 |
shows "n \<noteq> 0 \<and> swapidseq (n - 1) (transpose a b \<circ> p)" |
|
65342 | 935 |
using assms |
54681 | 936 |
proof (induct n arbitrary: p a b) |
937 |
case 0 |
|
938 |
then show ?case |
|
73663 | 939 |
by (auto simp add: fun_upd_def) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
940 |
next |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
941 |
case (Suc n p a b) |
54681 | 942 |
from Suc.prems(1) swapidseq_cases[of "Suc n" p] |
943 |
obtain c d q m where |
|
73648 | 944 |
cdqm: "Suc n = Suc m" "p = transpose c d \<circ> q" "swapidseq m q" "c \<noteq> d" "n = m" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
945 |
by auto |
73648 | 946 |
consider "transpose a b \<circ> transpose c d = id" |
65342 | 947 |
| x y z where "x \<noteq> a" "y \<noteq> a" "z \<noteq> a" "x \<noteq> y" |
73648 | 948 |
"transpose a b \<circ> transpose c d = transpose x y \<circ> transpose a z" |
65342 | 949 |
using swap_general[OF Suc.prems(2) cdqm(4)] by metis |
950 |
then show ?case |
|
951 |
proof cases |
|
952 |
case 1 |
|
953 |
then show ?thesis |
|
954 |
by (simp only: cdqm o_assoc) (simp add: cdqm) |
|
955 |
next |
|
80777 | 956 |
case 2 |
65342 | 957 |
then have az: "a \<noteq> z" |
54681 | 958 |
by simp |
80777 | 959 |
from 2 have *: "(transpose x y \<circ> h) a = a \<longleftrightarrow> h a = a" for h |
73648 | 960 |
by (simp add: transpose_def) |
961 |
from cdqm(2) have "transpose a b \<circ> p = transpose a b \<circ> (transpose c d \<circ> q)" |
|
54681 | 962 |
by simp |
80777 | 963 |
then have \<section>: "transpose a b \<circ> p = transpose x y \<circ> (transpose a z \<circ> q)" |
964 |
by (simp add: o_assoc 2) |
|
965 |
obtain **: "swapidseq (n - 1) (transpose a z \<circ> q)" and "n\<noteq>0" |
|
966 |
by (metis "*" "\<section>" Suc.hyps Suc.prems(3) az cdqm(3,5)) |
|
967 |
then have "Suc n - 1 = Suc (n - 1)" |
|
65342 | 968 |
by auto |
80777 | 969 |
with 2 show ?thesis |
970 |
using "**" \<section> swapidseq.simps by blast |
|
65342 | 971 |
qed |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
972 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
973 |
|
30488 | 974 |
lemma swapidseq_identity_even: |
54681 | 975 |
assumes "swapidseq n (id :: 'a \<Rightarrow> 'a)" |
976 |
shows "even n" |
|
60500 | 977 |
using \<open>swapidseq n id\<close> |
54681 | 978 |
proof (induct n rule: nat_less_induct) |
65342 | 979 |
case H: (1 n) |
980 |
consider "n = 0" |
|
73648 | 981 |
| a b :: 'a and q m where "n = Suc m" "id = transpose a b \<circ> q" "swapidseq m q" "a \<noteq> b" |
65342 | 982 |
using H(2)[unfolded swapidseq_cases[of n id]] by auto |
983 |
then show ?case |
|
984 |
proof cases |
|
985 |
case 1 |
|
986 |
then show ?thesis by presburger |
|
987 |
next |
|
988 |
case h: 2 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
989 |
from fixing_swapidseq_decrease[OF h(3,4), unfolded h(2)[symmetric]] |
54681 | 990 |
have m: "m \<noteq> 0" "swapidseq (m - 1) (id :: 'a \<Rightarrow> 'a)" |
991 |
by auto |
|
992 |
from h m have mn: "m - 1 < n" |
|
993 |
by arith |
|
65342 | 994 |
from H(1)[rule_format, OF mn m(2)] h(1) m(1) show ?thesis |
54681 | 995 |
by presburger |
65342 | 996 |
qed |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
997 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
998 |
|
54681 | 999 |
|
60500 | 1000 |
subsection \<open>Therefore we have a welldefined notion of parity\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1001 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1002 |
definition "evenperm p = even (SOME n. swapidseq n p)" |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1003 |
|
54681 | 1004 |
lemma swapidseq_even_even: |
1005 |
assumes m: "swapidseq m p" |
|
1006 |
and n: "swapidseq n p" |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1007 |
shows "even m \<longleftrightarrow> even n" |
54681 | 1008 |
proof - |
65342 | 1009 |
from swapidseq_inverse_exists[OF n] obtain q where q: "swapidseq n q" "p \<circ> q = id" "q \<circ> p = id" |
54681 | 1010 |
by blast |
65342 | 1011 |
from swapidseq_identity_even[OF swapidseq_comp_add[OF m q(1), unfolded q]] show ?thesis |
54681 | 1012 |
by arith |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1013 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1014 |
|
54681 | 1015 |
lemma evenperm_unique: |
80777 | 1016 |
assumes "swapidseq n p" and"even n = b" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1017 |
shows "evenperm p = b" |
80777 | 1018 |
by (metis evenperm_def assms someI swapidseq_even_even) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1019 |
|
54681 | 1020 |
|
60500 | 1021 |
subsection \<open>And it has the expected composition properties\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1022 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1023 |
lemma evenperm_id[simp]: "evenperm id = True" |
54681 | 1024 |
by (rule evenperm_unique[where n = 0]) simp_all |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1025 |
|
73621 | 1026 |
lemma evenperm_identity [simp]: |
1027 |
\<open>evenperm (\<lambda>x. x)\<close> |
|
1028 |
using evenperm_id by (simp add: id_def [abs_def]) |
|
1029 |
||
73648 | 1030 |
lemma evenperm_swap: "evenperm (transpose a b) = (a = b)" |
54681 | 1031 |
by (rule evenperm_unique[where n="if a = b then 0 else 1"]) (simp_all add: swapidseq_swap) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1032 |
|
30488 | 1033 |
lemma evenperm_comp: |
65342 | 1034 |
assumes "permutation p" "permutation q" |
1035 |
shows "evenperm (p \<circ> q) \<longleftrightarrow> evenperm p = evenperm q" |
|
54681 | 1036 |
proof - |
65342 | 1037 |
from assms obtain n m where n: "swapidseq n p" and m: "swapidseq m q" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1038 |
unfolding permutation_def by blast |
65342 | 1039 |
have "even (n + m) \<longleftrightarrow> (even n \<longleftrightarrow> even m)" |
54681 | 1040 |
by arith |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1041 |
from evenperm_unique[OF n refl] evenperm_unique[OF m refl] |
65342 | 1042 |
and evenperm_unique[OF swapidseq_comp_add[OF n m] this] show ?thesis |
54681 | 1043 |
by blast |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1044 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1045 |
|
54681 | 1046 |
lemma evenperm_inv: |
65342 | 1047 |
assumes "permutation p" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1048 |
shows "evenperm (inv p) = evenperm p" |
54681 | 1049 |
proof - |
65342 | 1050 |
from assms obtain n where n: "swapidseq n p" |
54681 | 1051 |
unfolding permutation_def by blast |
65342 | 1052 |
show ?thesis |
1053 |
by (rule evenperm_unique[OF swapidseq_inverse[OF n] evenperm_unique[OF n refl, symmetric]]) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1054 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1055 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1056 |
|
60500 | 1057 |
subsection \<open>A more abstract characterization of permutations\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1058 |
|
30488 | 1059 |
lemma permutation_bijective: |
65342 | 1060 |
assumes "permutation p" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1061 |
shows "bij p" |
80777 | 1062 |
by (meson assms o_bij permutation_def swapidseq_inverse_exists) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1063 |
|
54681 | 1064 |
lemma permutation_finite_support: |
65342 | 1065 |
assumes "permutation p" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1066 |
shows "finite {x. p x \<noteq> x}" |
54681 | 1067 |
proof - |
65342 | 1068 |
from assms obtain n where "swapidseq n p" |
54681 | 1069 |
unfolding permutation_def by blast |
65342 | 1070 |
then show ?thesis |
54681 | 1071 |
proof (induct n p rule: swapidseq.induct) |
1072 |
case id |
|
1073 |
then show ?case by simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1074 |
next |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1075 |
case (comp_Suc n p a b) |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1076 |
let ?S = "insert a (insert b {x. p x \<noteq> x})" |
65342 | 1077 |
from comp_Suc.hyps(2) have *: "finite ?S" |
54681 | 1078 |
by simp |
73648 | 1079 |
from \<open>a \<noteq> b\<close> have **: "{x. (transpose a b \<circ> p) x \<noteq> x} \<subseteq> ?S" |
73663 | 1080 |
by auto |
65342 | 1081 |
show ?case |
1082 |
by (rule finite_subset[OF ** *]) |
|
54681 | 1083 |
qed |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1084 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1085 |
|
30488 | 1086 |
lemma permutation_lemma: |
65342 | 1087 |
assumes "finite S" |
1088 |
and "bij p" |
|
73328 | 1089 |
and "\<forall>x. x \<notin> S \<longrightarrow> p x = x" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1090 |
shows "permutation p" |
65342 | 1091 |
using assms |
54681 | 1092 |
proof (induct S arbitrary: p rule: finite_induct) |
65342 | 1093 |
case empty |
1094 |
then show ?case |
|
1095 |
by simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1096 |
next |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1097 |
case (insert a F p) |
73663 | 1098 |
let ?r = "transpose a (p a) \<circ> p" |
1099 |
let ?q = "transpose a (p a) \<circ> ?r" |
|
65342 | 1100 |
have *: "?r a = a" |
73663 | 1101 |
by simp |
65342 | 1102 |
from insert * have **: "\<forall>x. x \<notin> F \<longrightarrow> ?r x = x" |
64966
d53d7ca3303e
added inj_def (redundant, analogous to surj_def, bij_def);
wenzelm
parents:
64543
diff
changeset
|
1103 |
by (metis bij_pointE comp_apply id_apply insert_iff swap_apply(3)) |
65342 | 1104 |
have "bij ?r" |
73663 | 1105 |
using insert by (simp add: bij_comp) |
65342 | 1106 |
have "permutation ?r" |
1107 |
by (rule insert(3)[OF \<open>bij ?r\<close> **]) |
|
1108 |
then have "permutation ?q" |
|
1109 |
by (simp add: permutation_compose permutation_swap_id) |
|
54681 | 1110 |
then show ?case |
1111 |
by (simp add: o_assoc) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1112 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1113 |
|
30488 | 1114 |
lemma permutation: "permutation p \<longleftrightarrow> bij p \<and> finite {x. p x \<noteq> x}" |
80777 | 1115 |
using permutation_bijective permutation_finite_support permutation_lemma by auto |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1116 |
|
54681 | 1117 |
lemma permutation_inverse_works: |
65342 | 1118 |
assumes "permutation p" |
54681 | 1119 |
shows "inv p \<circ> p = id" |
1120 |
and "p \<circ> inv p = id" |
|
65342 | 1121 |
using permutation_bijective [OF assms] by (auto simp: bij_def inj_iff surj_iff) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1122 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1123 |
lemma permutation_inverse_compose: |
54681 | 1124 |
assumes p: "permutation p" |
1125 |
and q: "permutation q" |
|
1126 |
shows "inv (p \<circ> q) = inv q \<circ> inv p" |
|
80777 | 1127 |
by (simp add: o_inv_distrib p permutation_bijective q) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1128 |
|
54681 | 1129 |
|
65342 | 1130 |
subsection \<open>Relation to \<open>permutes\<close>\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1131 |
|
73466 | 1132 |
lemma permutes_imp_permutation: |
1133 |
\<open>permutation p\<close> if \<open>finite S\<close> \<open>p permutes S\<close> |
|
1134 |
proof - |
|
1135 |
from \<open>p permutes S\<close> have \<open>{x. p x \<noteq> x} \<subseteq> S\<close> |
|
1136 |
by (auto dest: permutes_not_in) |
|
1137 |
then have \<open>finite {x. p x \<noteq> x}\<close> |
|
1138 |
using \<open>finite S\<close> by (rule finite_subset) |
|
1139 |
moreover from \<open>p permutes S\<close> have \<open>bij p\<close> |
|
1140 |
by (auto dest: permutes_bij) |
|
1141 |
ultimately show ?thesis |
|
1142 |
by (simp add: permutation) |
|
1143 |
qed |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1144 |
|
73466 | 1145 |
lemma permutation_permutesE: |
1146 |
assumes \<open>permutation p\<close> |
|
1147 |
obtains S where \<open>finite S\<close> \<open>p permutes S\<close> |
|
1148 |
proof - |
|
1149 |
from assms have fin: \<open>finite {x. p x \<noteq> x}\<close> |
|
1150 |
by (simp add: permutation) |
|
1151 |
from assms have \<open>bij p\<close> |
|
1152 |
by (simp add: permutation) |
|
1153 |
also have \<open>UNIV = {x. p x \<noteq> x} \<union> {x. p x = x}\<close> |
|
1154 |
by auto |
|
1155 |
finally have \<open>bij_betw p {x. p x \<noteq> x} {x. p x \<noteq> x}\<close> |
|
1156 |
by (rule bij_betw_partition) (auto simp add: bij_betw_fixpoints) |
|
1157 |
then have \<open>p permutes {x. p x \<noteq> x}\<close> |
|
1158 |
by (auto intro: bij_imp_permutes) |
|
1159 |
with fin show thesis .. |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1160 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1161 |
|
73466 | 1162 |
lemma permutation_permutes: "permutation p \<longleftrightarrow> (\<exists>S. finite S \<and> p permutes S)" |
1163 |
by (auto elim: permutation_permutesE intro: permutes_imp_permutation) |
|
1164 |
||
54681 | 1165 |
|
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1166 |
subsection \<open>Sign of a permutation\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1167 |
|
73328 | 1168 |
definition sign :: \<open>('a \<Rightarrow> 'a) \<Rightarrow> int\<close> \<comment> \<open>TODO: prefer less generic name\<close> |
73621 | 1169 |
where \<open>sign p = (if evenperm p then 1 else - 1)\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1170 |
|
73621 | 1171 |
lemma sign_cases [case_names even odd]: |
1172 |
obtains \<open>sign p = 1\<close> | \<open>sign p = - 1\<close> |
|
1173 |
by (cases \<open>evenperm p\<close>) (simp_all add: sign_def) |
|
1174 |
||
1175 |
lemma sign_nz [simp]: "sign p \<noteq> 0" |
|
1176 |
by (cases p rule: sign_cases) simp_all |
|
1177 |
||
1178 |
lemma sign_id [simp]: "sign id = 1" |
|
54681 | 1179 |
by (simp add: sign_def) |
1180 |
||
73621 | 1181 |
lemma sign_identity [simp]: |
1182 |
\<open>sign (\<lambda>x. x) = 1\<close> |
|
54681 | 1183 |
by (simp add: sign_def) |
1184 |
||
1185 |
lemma sign_inverse: "permutation p \<Longrightarrow> sign (inv p) = sign p" |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1186 |
by (simp add: sign_def evenperm_inv) |
54681 | 1187 |
|
1188 |
lemma sign_compose: "permutation p \<Longrightarrow> permutation q \<Longrightarrow> sign (p \<circ> q) = sign p * sign q" |
|
1189 |
by (simp add: sign_def evenperm_comp) |
|
1190 |
||
73648 | 1191 |
lemma sign_swap_id: "sign (transpose a b) = (if a = b then 1 else - 1)" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1192 |
by (simp add: sign_def evenperm_swap) |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1193 |
|
73621 | 1194 |
lemma sign_idempotent [simp]: "sign p * sign p = 1" |
54681 | 1195 |
by (simp add: sign_def) |
1196 |
||
73621 | 1197 |
lemma sign_left_idempotent [simp]: |
1198 |
\<open>sign p * (sign p * sign q) = sign q\<close> |
|
1199 |
by (simp add: sign_def) |
|
1200 |
||
82683
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1201 |
lemma abs_sign [simp]: "\<bar>sign p\<bar> = 1" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1202 |
by (simp add: sign_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1203 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1204 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1205 |
subsection \<open>An induction principle in terms of transpositions\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1206 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1207 |
definition apply_transps :: "('a \<times> 'a) list \<Rightarrow> 'a \<Rightarrow> 'a" where |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1208 |
"apply_transps xs = foldr (\<circ>) (map (\<lambda>(a,b). Transposition.transpose a b) xs) id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1209 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1210 |
lemma apply_transps_Nil [simp]: "apply_transps [] = id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1211 |
by (simp add: apply_transps_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1212 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1213 |
lemma apply_transps_Cons [simp]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1214 |
"apply_transps (x # xs) = Transposition.transpose (fst x) (snd x) \<circ> apply_transps xs" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1215 |
by (simp add: apply_transps_def case_prod_unfold) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1216 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1217 |
lemma apply_transps_append [simp]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1218 |
"apply_transps (xs @ ys) = apply_transps xs \<circ> apply_transps ys" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1219 |
by (induction xs) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1220 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1221 |
lemma permutation_apply_transps [simp, intro]: "permutation (apply_transps xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1222 |
proof (induction xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1223 |
case (Cons x xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1224 |
thus ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1225 |
unfolding apply_transps_Cons by (intro permutation_compose permutation_swap_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1226 |
qed auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1227 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1228 |
lemma permutes_apply_transps: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1229 |
assumes "\<forall>(a,b)\<in>set xs. a \<in> A \<and> b \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1230 |
shows "apply_transps xs permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1231 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1232 |
proof (induction xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1233 |
case (Cons x xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1234 |
from Cons.prems show ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1235 |
unfolding apply_transps_Cons |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1236 |
by (intro permutes_compose permutes_swap_id Cons) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1237 |
qed (auto simp: permutes_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1238 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1239 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1240 |
lemma permutes_induct [consumes 2, case_names id swap]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1241 |
assumes "p permutes S" "finite S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1242 |
assumes "P id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1243 |
assumes "\<And>a b p. a \<in> S \<Longrightarrow> b \<in> S \<Longrightarrow> a \<noteq> b \<Longrightarrow> P p \<Longrightarrow> p permutes S |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1244 |
\<Longrightarrow> P (Transposition.transpose a b \<circ> p)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1245 |
shows "P p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1246 |
using assms(2,1,4) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1247 |
proof (induct S arbitrary: p rule: finite_induct) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1248 |
case empty |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1249 |
then show ?case using assms by (auto simp: id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1250 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1251 |
case (insert x F p) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1252 |
let ?r = "Transposition.transpose x (p x) \<circ> p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1253 |
let ?q = "Transposition.transpose x (p x) \<circ> ?r" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1254 |
have qp: "?q = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1255 |
by (simp add: o_assoc) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1256 |
have "?r permutes F" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1257 |
using permutes_insert_lemma[OF insert.prems(1)] . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1258 |
have "P ?r" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1259 |
by (rule insert(3)[OF \<open>?r permutes F\<close>], rule insert(5)) (auto intro: permutes_subset) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1260 |
show ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1261 |
proof (cases "x = p x") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1262 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1263 |
have "p x \<in> F" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1264 |
using permutes_in_image[OF \<open>p permutes _\<close>, of x] False by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1265 |
have "P ?q" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1266 |
by (rule insert(5)) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1267 |
(use \<open>P ?r\<close> \<open>p x \<in> F\<close> \<open>?r permutes F\<close> False in \<open>auto simp: o_def intro: permutes_subset\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1268 |
thus "P p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1269 |
by (simp add: qp) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1270 |
qed (use \<open>P ?r\<close> in simp) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1271 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1272 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1273 |
lemma permutes_rev_induct[consumes 2, case_names id swap]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1274 |
assumes "finite S" "p permutes S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1275 |
assumes "P id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1276 |
assumes "\<And>a b p. a \<in> S \<Longrightarrow> b \<in> S \<Longrightarrow> a \<noteq> b \<Longrightarrow> P p \<Longrightarrow> p permutes S |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1277 |
\<Longrightarrow> P (p \<circ> Transposition.transpose a b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1278 |
shows "P p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1279 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1280 |
have "inv_into UNIV p permutes S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1281 |
using assms by (intro permutes_inv) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1282 |
from this and assms(1,2) show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1283 |
proof (induction "inv_into UNIV p" arbitrary: p rule: permutes_induct) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1284 |
case id |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1285 |
hence "p = id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1286 |
by (metis inv_id permutes_inv_inv) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1287 |
thus ?case using \<open>P id\<close> by (auto simp: id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1288 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1289 |
case (swap a b p p') |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1290 |
have "p = Transposition.transpose a b \<circ> (Transposition.transpose a b \<circ> p)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1291 |
by (simp add: o_assoc) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1292 |
also have "\<dots> = Transposition.transpose a b \<circ> inv_into UNIV p'" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1293 |
by (subst swap.hyps) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1294 |
also have "Transposition.transpose a b = inv_into UNIV (Transposition.transpose a b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1295 |
by (simp add: inv_swap_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1296 |
also have "\<dots> \<circ> inv_into UNIV p' = inv_into UNIV (p' \<circ> Transposition.transpose a b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1297 |
using swap \<open>finite S\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1298 |
by (intro permutation_inverse_compose [symmetric] permutation_swap_id permutation_inverse) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1299 |
(auto simp: permutation_permutes) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1300 |
finally have "p = inv (p' \<circ> Transposition.transpose a b)" . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1301 |
moreover have "p' \<circ> Transposition.transpose a b permutes S" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1302 |
by (intro permutes_compose permutes_swap_id swap) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1303 |
ultimately have *: "P (p' \<circ> Transposition.transpose a b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1304 |
by (rule swap(4)) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1305 |
have "P (p' \<circ> Transposition.transpose a b \<circ> Transposition.transpose a b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1306 |
by (rule assms; intro * swap permutes_compose permutes_swap_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1307 |
also have "p' \<circ> Transposition.transpose a b \<circ> Transposition.transpose a b = p'" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1308 |
by (simp flip: o_assoc) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1309 |
finally show ?case . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1310 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1311 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1312 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1313 |
lemma map_permutation_apply_transps: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1314 |
assumes f: "inj_on f A" and "set ts \<subseteq> A \<times> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1315 |
shows "map_permutation A f (apply_transps ts) = apply_transps (map (map_prod f f) ts)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1316 |
using assms(2) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1317 |
proof (induction ts) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1318 |
case (Cons t ts) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1319 |
obtain a b where [simp]: "t = (a, b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1320 |
by (cases t) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1321 |
have "map_permutation A f (apply_transps (t # ts)) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1322 |
map_permutation A f (Transposition.transpose a b \<circ> apply_transps ts)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1323 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1324 |
also have "\<dots> = map_permutation A f (Transposition.transpose a b) \<circ> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1325 |
map_permutation A f (apply_transps ts)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1326 |
by (subst map_permutation_compose') |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1327 |
(use f Cons.prems in \<open>auto intro!: permutes_apply_transps\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1328 |
also have "map_permutation A f (Transposition.transpose a b) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1329 |
Transposition.transpose (f a) (f b)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1330 |
by (intro map_permutation_transpose f) (use Cons.prems in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1331 |
also have "map_permutation A f (apply_transps ts) = apply_transps (map (map_prod f f) ts)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1332 |
by (intro Cons.IH) (use Cons.prems in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1333 |
also have "Transposition.transpose (f a) (f b) \<circ> apply_transps (map (map_prod f f) ts) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1334 |
apply_transps (map (map_prod f f) (t # ts))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1335 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1336 |
finally show ?case . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1337 |
qed (use f in \<open>auto simp: map_permutation_id'\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1338 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1339 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1340 |
lemma permutes_from_transpositions: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1341 |
assumes "p permutes A" "finite A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1342 |
shows "\<exists>xs. (\<forall>(a,b)\<in>set xs. a \<noteq> b \<and> a \<in> A \<and> b \<in> A) \<and> apply_transps xs = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1343 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1344 |
proof (induction rule: permutes_induct) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1345 |
case id |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1346 |
thus ?case by (intro exI[of _ "[]"]) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1347 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1348 |
case (swap a b p) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1349 |
from swap.IH obtain xs where |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1350 |
xs: "(\<forall>(a,b)\<in>set xs. a \<noteq> b \<and> a \<in> A \<and> b \<in> A)" "apply_transps xs = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1351 |
by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1352 |
thus ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1353 |
using swap.hyps by (intro exI[of _ "(a,b) # xs"]) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1354 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1355 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1356 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1357 |
subsection \<open>More on the sign of permutations\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1358 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1359 |
lemma evenperm_apply_transps_iff: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1360 |
assumes "\<forall>(a,b)\<in>set xs. a \<noteq> b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1361 |
shows "evenperm (apply_transps xs) \<longleftrightarrow> even (length xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1362 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1363 |
by (induction xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1364 |
(simp_all add: case_prod_unfold evenperm_comp permutation_swap_id evenperm_swap) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1365 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1366 |
lemma evenperm_map_permutation: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1367 |
assumes f: "inj_on f A" and "p permutes A" "finite A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1368 |
shows "evenperm (map_permutation A f p) \<longleftrightarrow> evenperm p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1369 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1370 |
note [simp] = inj_on_eq_iff[OF f] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1371 |
obtain ts where ts: "\<forall>(a, b)\<in>set ts. a \<noteq> b \<and> a \<in> A \<and> b \<in> A" "apply_transps ts = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1372 |
using permutes_from_transpositions[OF assms(2,3)] by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1373 |
have "evenperm p \<longleftrightarrow> even (length ts)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1374 |
by (subst ts(2) [symmetric], subst evenperm_apply_transps_iff) (use ts(1) in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1375 |
also have "\<dots> \<longleftrightarrow> even (length (map (map_prod f f) ts))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1376 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1377 |
also have "\<dots> \<longleftrightarrow> evenperm (apply_transps (map (map_prod f f) ts))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1378 |
by (subst evenperm_apply_transps_iff) (use ts(1) in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1379 |
also have "apply_transps (map (map_prod f f) ts) = map_permutation A f p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1380 |
unfolding ts(2)[symmetric] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1381 |
by (rule map_permutation_apply_transps [symmetric]) (use f ts(1) in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1382 |
finally show ?thesis .. |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1383 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1384 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1385 |
lemma sign_map_permutation: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1386 |
assumes "inj_on f A" "p permutes A" "finite A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1387 |
shows "sign (map_permutation A f p) = sign p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1388 |
unfolding sign_def by (subst evenperm_map_permutation) (use assms in auto) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1389 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1390 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1391 |
text \<open> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1392 |
Sometimes it can be useful to consider the sign of a function that is not a permutation in the |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1393 |
Isabelle/HOL sense, but its restriction to some finite subset is. |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1394 |
\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1395 |
definition sign_on :: "'a set \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> int" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1396 |
where "sign_on A f = sign (restrict_id f A)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1397 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1398 |
lemma sign_on_cong [cong]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1399 |
assumes "A = B" "\<And>x. x \<in> A \<Longrightarrow> f x = g x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1400 |
shows "sign_on A f = sign_on B g" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1401 |
unfolding sign_on_def using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1402 |
by (intro arg_cong[of _ _ sign] restrict_id_cong) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1403 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1404 |
lemma sign_on_permutes: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1405 |
assumes "f permutes A" "A \<subseteq> B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1406 |
shows "sign_on B f = sign f" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1407 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1408 |
have f: "f permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1409 |
using assms permutes_subset by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1410 |
have "sign_on B f = sign (restrict_id f B)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1411 |
by (simp add: sign_on_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1412 |
also have "restrict_id f B = f" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1413 |
using f by (auto simp: fun_eq_iff permutes_not_in restrict_id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1414 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1415 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1416 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1417 |
lemma sign_on_id [simp]: "sign_on A id = 1" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1418 |
by (subst sign_on_permutes[of _ A]) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1419 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1420 |
lemma sign_on_ident [simp]: "sign_on A (\<lambda>x. x) = 1" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1421 |
using sign_on_id[of A] unfolding id_def by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1422 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1423 |
lemma sign_on_transpose: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1424 |
assumes "a \<in> A" "b \<in> A" "a \<noteq> b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1425 |
shows "sign_on A (Transposition.transpose a b) = -1" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1426 |
by (subst sign_on_permutes[of _ A]) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1427 |
(use assms in \<open>auto simp: permutes_swap_id sign_swap_id\<close>) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1428 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1429 |
lemma sign_on_compose: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1430 |
assumes "bij_betw f A A" "bij_betw g A A" "finite A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1431 |
shows "sign_on A (f \<circ> g) = sign_on A f * sign_on A g" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1432 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1433 |
define restr where "restr = (\<lambda>f. restrict_id f A)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1434 |
have "sign_on A (f \<circ> g) = sign (restr (f \<circ> g))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1435 |
by (simp add: sign_on_def restr_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1436 |
also have "restr (f \<circ> g) = restr f \<circ> restr g" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1437 |
using assms(2) by (auto simp: restr_def fun_eq_iff bij_betw_def restrict_id_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1438 |
also have "sign \<dots> = sign (restr f) * sign (restr g)" unfolding restr_def |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1439 |
by (rule sign_compose) (auto intro!: permutes_imp_permutation[of A] permutes_restrict_id assms) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1440 |
also have "\<dots> = sign_on A f * sign_on A g" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1441 |
by (simp add: sign_on_def restr_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1442 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1443 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1444 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1445 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1446 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1447 |
subsection \<open>Transpositions of adjacent elements\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1448 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1449 |
text \<open> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1450 |
We have shown above that every permutation can be written as a product of transpositions. |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1451 |
We will now furthermore show that any transposition of successive natural numbers |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1452 |
$\{m, \ldots, n\}$ can be written as a product of transpositions of \<^emph>\<open>adjacent\<close> elements, |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1453 |
i.e.\ transpositions of the form $i \leftrightarrow i+1$. |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1454 |
\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1455 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1456 |
function adj_transp_seq :: "nat \<Rightarrow> nat \<Rightarrow> nat list" where |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1457 |
"adj_transp_seq a b = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1458 |
(if a \<ge> b then [] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1459 |
else if b = a + 1 then [a] |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1460 |
else a # adj_transp_seq (a+1) b @ [a])" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1461 |
by auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1462 |
termination by (relation "measure (\<lambda>(a,b). b - a)") auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1463 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1464 |
lemmas [simp del] = adj_transp_seq.simps |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1465 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1466 |
lemma length_adj_transp_seq: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1467 |
"a < b \<Longrightarrow> length (adj_transp_seq a b) = 2 * (b - a) - 1" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1468 |
by (induction a b rule: adj_transp_seq.induct; subst adj_transp_seq.simps) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1469 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1470 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1471 |
definition apply_adj_transps :: "nat list \<Rightarrow> nat \<Rightarrow> nat" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1472 |
where "apply_adj_transps xs = foldl (\<circ>) id (map (\<lambda>x. Transposition.transpose x (x+1)) xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1473 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1474 |
lemma apply_adj_transps_aux: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1475 |
"f \<circ> foldl (\<circ>) g (map (\<lambda>x. Transposition.transpose x (Suc x)) xs) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1476 |
foldl (\<circ>) (f \<circ> g) (map (\<lambda>x. Transposition.transpose x (Suc x)) xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1477 |
by (induction xs arbitrary: f g) (auto simp: o_assoc) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1478 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1479 |
lemma apply_adj_transps_Nil [simp]: "apply_adj_transps [] = id" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1480 |
and apply_adj_transps_Cons [simp]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1481 |
"apply_adj_transps (x # xs) = Transposition.transpose x (x+1) \<circ> apply_adj_transps xs" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1482 |
and apply_adj_transps_snoc [simp]: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1483 |
"apply_adj_transps (xs @ [x]) = apply_adj_transps xs \<circ> Transposition.transpose x (x+1)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1484 |
by (simp_all add: apply_adj_transps_def apply_adj_transps_aux) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1485 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1486 |
lemma adj_transp_seq_correct: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1487 |
assumes "a < b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1488 |
shows "apply_adj_transps (adj_transp_seq a b) = Transposition.transpose a b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1489 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1490 |
proof (induction a b rule: adj_transp_seq.induct) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1491 |
case (1 a b) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1492 |
show ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1493 |
proof (cases "b = a + 1") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1494 |
case True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1495 |
thus ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1496 |
by (subst adj_transp_seq.simps) (auto simp: o_def Transposition.transpose_def apply_adj_transps_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1497 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1498 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1499 |
hence "apply_adj_transps (adj_transp_seq a b) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1500 |
Transposition.transpose a (Suc a) \<circ> Transposition.transpose (Suc a) b \<circ> Transposition.transpose a (Suc a)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1501 |
using 1 by (subst adj_transp_seq.simps) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1502 |
(simp add: o_assoc swap_id_common swap_id_common' id_def o_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1503 |
also have "\<dots> = Transposition.transpose a b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1504 |
using False 1 by (simp add: Transposition.transpose_def fun_eq_iff) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1505 |
finally show ?thesis . |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1506 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1507 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1508 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1509 |
lemma permutation_apply_adj_transps: "permutation (apply_adj_transps xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1510 |
proof (induction xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1511 |
case (Cons x xs) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1512 |
have "permutation (Transposition.transpose x (Suc x) \<circ> apply_adj_transps xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1513 |
by (intro permutation_compose permutation_swap_id Cons) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1514 |
thus ?case by (simp add: o_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1515 |
qed auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1516 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1517 |
lemma permutes_apply_adj_transps: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1518 |
assumes "\<forall>x\<in>set xs. x \<in> A \<and> Suc x \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1519 |
shows "apply_adj_transps xs permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1520 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1521 |
by (induction xs) (auto intro!: permutes_compose permutes_swap_id permutes_id) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1522 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1523 |
lemma set_adj_transp_seq: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1524 |
"a < b \<Longrightarrow> set (adj_transp_seq a b) = {a..<b}" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1525 |
by (induction a b rule: adj_transp_seq.induct, subst adj_transp_seq.simps) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1526 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1527 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1528 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1529 |
subsection \<open>Transferring properties of permutations along bijections\<close> |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1530 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1531 |
locale permutes_bij = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1532 |
fixes p :: "'a \<Rightarrow> 'a" and A :: "'a set" and B :: "'b set" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1533 |
fixes f :: "'a \<Rightarrow> 'b" and f' :: "'b \<Rightarrow> 'a" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1534 |
fixes p' :: "'b \<Rightarrow> 'b" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1535 |
defines "p' \<equiv> (\<lambda>x. if x \<in> B then f (p (f' x)) else x)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1536 |
assumes permutes_p: "p permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1537 |
assumes bij_f: "bij_betw f A B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1538 |
assumes f'_f: "x \<in> A \<Longrightarrow> f' (f x) = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1539 |
begin |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1540 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1541 |
lemma bij_f': "bij_betw f' B A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1542 |
using bij_f f'_f by (auto simp: bij_betw_def) (auto simp: inj_on_def image_image) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1543 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1544 |
lemma f_f': "x \<in> B \<Longrightarrow> f (f' x) = x" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1545 |
using f'_f bij_f by (auto simp: bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1546 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1547 |
lemma f_in_B: "x \<in> A \<Longrightarrow> f x \<in> B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1548 |
using bij_f by (auto simp: bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1549 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1550 |
lemma f'_in_A: "x \<in> B \<Longrightarrow> f' x \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1551 |
using bij_f' by (auto simp: bij_betw_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1552 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1553 |
lemma permutes_p': "p' permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1554 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1555 |
have p': "p' x = x" if "x \<notin> B" for x |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1556 |
using that by (simp add: p'_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1557 |
have bij_p: "bij_betw p A A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1558 |
using permutes_p by (simp add: permutes_imp_bij) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1559 |
have "bij_betw (f \<circ> p \<circ> f') B B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1560 |
by (rule bij_betw_trans bij_f bij_f' bij_p)+ |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1561 |
also have "?this \<longleftrightarrow> bij_betw p' B B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1562 |
by (intro bij_betw_cong) (auto simp: p'_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1563 |
finally show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1564 |
using p' by (rule bij_imp_permutes) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1565 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1566 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1567 |
lemma f_eq_iff [simp]: "f x = f y \<longleftrightarrow> x = y" if "x \<in> A" "y \<in> A" for x y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1568 |
using that bij_f by (auto simp: bij_betw_def inj_on_def) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1569 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1570 |
lemma apply_transps_map_f_aux: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1571 |
assumes "\<forall>(a,b)\<in>set xs. a \<in> A \<and> b \<in> A" "y \<in> B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1572 |
shows "apply_transps (map (map_prod f f) xs) y = f (apply_transps xs (f' y))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1573 |
using assms |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1574 |
proof (induction xs arbitrary: y) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1575 |
case Nil |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1576 |
thus ?case by (auto simp: f_f') |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1577 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1578 |
case (Cons x xs y) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1579 |
from Cons.prems have "apply_transps xs permutes A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1580 |
by (intro permutes_apply_transps) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1581 |
hence [simp]: "apply_transps xs z \<in> A \<longleftrightarrow> z \<in> A" for z |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1582 |
by (simp add: permutes_in_image) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1583 |
from Cons show ?case |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1584 |
by (auto simp: Transposition.transpose_def f_f' f'_f case_prod_unfold f'_in_A) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1585 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1586 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1587 |
lemma apply_transps_map_f: |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1588 |
assumes "\<forall>(a,b)\<in>set xs. a \<in> A \<and> b \<in> A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1589 |
shows "apply_transps (map (map_prod f f) xs) = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1590 |
(\<lambda>y. if y \<in> B then f (apply_transps xs (f' y)) else y)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1591 |
proof |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1592 |
fix y |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1593 |
show "apply_transps (map (map_prod f f) xs) y = |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1594 |
(if y \<in> B then f (apply_transps xs (f' y)) else y)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1595 |
proof (cases "y \<in> B") |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1596 |
case True |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1597 |
thus ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1598 |
using apply_transps_map_f_aux[OF assms] by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1599 |
next |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1600 |
case False |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1601 |
have "apply_transps (map (map_prod f f) xs) permutes B" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1602 |
using assms by (intro permutes_apply_transps) (auto simp: case_prod_unfold f_in_B) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1603 |
with False have "apply_transps (map (map_prod f f) xs) y = y" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1604 |
by (intro permutes_not_in) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1605 |
with False show ?thesis |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1606 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1607 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1608 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1609 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1610 |
end |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1611 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1612 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1613 |
locale permutes_bij_finite = permutes_bij + |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1614 |
assumes finite_A: "finite A" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1615 |
begin |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1616 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1617 |
lemma evenperm_p'_iff: "evenperm p' \<longleftrightarrow> evenperm p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1618 |
proof - |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1619 |
obtain xs where xs: "\<forall>(a,b)\<in>set xs. a \<in> A \<and> b \<in> A \<and> a \<noteq> b" "apply_transps xs = p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1620 |
using permutes_from_transpositions[OF permutes_p finite_A] by blast |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1621 |
have "evenperm p \<longleftrightarrow> evenperm (apply_transps xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1622 |
using xs by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1623 |
also have "\<dots> \<longleftrightarrow> even (length xs)" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1624 |
using xs by (intro evenperm_apply_transps_iff) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1625 |
also have "\<dots> \<longleftrightarrow> even (length (map (map_prod f f) xs))" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1626 |
by simp |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1627 |
also have "\<dots> \<longleftrightarrow> evenperm (apply_transps (map (map_prod f f) xs))" using xs |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1628 |
by (intro evenperm_apply_transps_iff [symmetric]) (auto simp: case_prod_unfold) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1629 |
also have "apply_transps (map (map_prod f f) xs) = p'" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1630 |
using xs unfolding p'_def by (subst apply_transps_map_f) auto |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1631 |
finally show ?thesis .. |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1632 |
qed |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1633 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1634 |
lemma sign_p': "sign p' = sign p" |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1635 |
by (auto simp: sign_def evenperm_p'_iff) |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1636 |
|
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1637 |
end |
71304514891e
HOL-Combinatorics: more lemmas about permutations
Manuel Eberl <eberlm@in.tum.de>
parents:
80777
diff
changeset
|
1638 |
|
73621 | 1639 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1640 |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1641 |
subsection \<open>Permuting a list\<close> |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1642 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1643 |
text \<open>This function permutes a list by applying a permutation to the indices.\<close> |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1644 |
|
65342 | 1645 |
definition permute_list :: "(nat \<Rightarrow> nat) \<Rightarrow> 'a list \<Rightarrow> 'a list" |
1646 |
where "permute_list f xs = map (\<lambda>i. xs ! (f i)) [0..<length xs]" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1647 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1648 |
lemma permute_list_map: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1649 |
assumes "f permutes {..<length xs}" |
65342 | 1650 |
shows "permute_list f (map g xs) = map g (permute_list f xs)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1651 |
using permutes_in_image[OF assms] by (auto simp: permute_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1652 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1653 |
lemma permute_list_nth: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1654 |
assumes "f permutes {..<length xs}" "i < length xs" |
65342 | 1655 |
shows "permute_list f xs ! i = xs ! f i" |
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1656 |
using permutes_in_image[OF assms(1)] assms(2) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1657 |
by (simp add: permute_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1658 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1659 |
lemma permute_list_Nil [simp]: "permute_list f [] = []" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1660 |
by (simp add: permute_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1661 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1662 |
lemma length_permute_list [simp]: "length (permute_list f xs) = length xs" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1663 |
by (simp add: permute_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1664 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1665 |
lemma permute_list_compose: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1666 |
assumes "g permutes {..<length xs}" |
65342 | 1667 |
shows "permute_list (f \<circ> g) xs = permute_list g (permute_list f xs)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1668 |
using assms[THEN permutes_in_image] by (auto simp add: permute_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1669 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1670 |
lemma permute_list_ident [simp]: "permute_list (\<lambda>x. x) xs = xs" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1671 |
by (simp add: permute_list_def map_nth) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1672 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1673 |
lemma permute_list_id [simp]: "permute_list id xs = xs" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1674 |
by (simp add: id_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1675 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1676 |
lemma mset_permute_list [simp]: |
65342 | 1677 |
fixes xs :: "'a list" |
1678 |
assumes "f permutes {..<length xs}" |
|
1679 |
shows "mset (permute_list f xs) = mset xs" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1680 |
proof (rule multiset_eqI) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1681 |
fix y :: 'a |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1682 |
from assms have [simp]: "f x < length xs \<longleftrightarrow> x < length xs" for x |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1683 |
using permutes_in_image[OF assms] by auto |
65342 | 1684 |
have "count (mset (permute_list f xs)) y = card ((\<lambda>i. xs ! f i) -` {y} \<inter> {..<length xs})" |
64543
6b13586ef1a2
remove typo in bij_swap_compose_bij theorem name; tune proof
bulwahn
parents:
64284
diff
changeset
|
1685 |
by (simp add: permute_list_def count_image_mset atLeast0LessThan) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1686 |
also have "(\<lambda>i. xs ! f i) -` {y} \<inter> {..<length xs} = f -` {i. i < length xs \<and> y = xs ! i}" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1687 |
by auto |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1688 |
also from assms have "card \<dots> = card {i. i < length xs \<and> y = xs ! i}" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1689 |
by (intro card_vimage_inj) (auto simp: permutes_inj permutes_surj) |
65342 | 1690 |
also have "\<dots> = count (mset xs) y" |
1691 |
by (simp add: count_mset length_filter_conv_card) |
|
1692 |
finally show "count (mset (permute_list f xs)) y = count (mset xs) y" |
|
1693 |
by simp |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1694 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1695 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1696 |
lemma set_permute_list [simp]: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1697 |
assumes "f permutes {..<length xs}" |
65342 | 1698 |
shows "set (permute_list f xs) = set xs" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1699 |
by (rule mset_eq_setD[OF mset_permute_list]) fact |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1700 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1701 |
lemma distinct_permute_list [simp]: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1702 |
assumes "f permutes {..<length xs}" |
65342 | 1703 |
shows "distinct (permute_list f xs) = distinct xs" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1704 |
by (simp add: distinct_count_atmost_1 assms) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1705 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1706 |
lemma permute_list_zip: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1707 |
assumes "f permutes A" "A = {..<length xs}" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1708 |
assumes [simp]: "length xs = length ys" |
65342 | 1709 |
shows "permute_list f (zip xs ys) = zip (permute_list f xs) (permute_list f ys)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1710 |
proof - |
65342 | 1711 |
from permutes_in_image[OF assms(1)] assms(2) have *: "f i < length ys \<longleftrightarrow> i < length ys" for i |
1712 |
by simp |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1713 |
have "permute_list f (zip xs ys) = map (\<lambda>i. zip xs ys ! f i) [0..<length ys]" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1714 |
by (simp_all add: permute_list_def zip_map_map) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1715 |
also have "\<dots> = map (\<lambda>(x, y). (xs ! f x, ys ! f y)) (zip [0..<length ys] [0..<length ys])" |
65342 | 1716 |
by (intro nth_equalityI) (simp_all add: *) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1717 |
also have "\<dots> = zip (permute_list f xs) (permute_list f ys)" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1718 |
by (simp_all add: permute_list_def zip_map_map) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1719 |
finally show ?thesis . |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1720 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1721 |
|
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1722 |
lemma map_of_permute: |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1723 |
assumes "\<sigma> permutes fst ` set xs" |
65342 | 1724 |
shows "map_of xs \<circ> \<sigma> = map_of (map (\<lambda>(x,y). (inv \<sigma> x, y)) xs)" |
1725 |
(is "_ = map_of (map ?f _)") |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1726 |
proof |
65342 | 1727 |
from assms have "inj \<sigma>" "surj \<sigma>" |
1728 |
by (simp_all add: permutes_inj permutes_surj) |
|
1729 |
then show "(map_of xs \<circ> \<sigma>) x = map_of (map ?f xs) x" for x |
|
1730 |
by (induct xs) (auto simp: inv_f_f surj_f_inv_f) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1731 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1732 |
|
73706 | 1733 |
lemma list_all2_permute_list_iff: |
1734 |
\<open>list_all2 P (permute_list p xs) (permute_list p ys) \<longleftrightarrow> list_all2 P xs ys\<close> |
|
1735 |
if \<open>p permutes {..<length xs}\<close> |
|
1736 |
using that by (auto simp add: list_all2_iff simp flip: permute_list_zip) |
|
1737 |
||
54681 | 1738 |
|
60500 | 1739 |
subsection \<open>More lemmas about permutations\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1740 |
|
73555 | 1741 |
lemma permutes_in_funpow_image: \<^marker>\<open>contributor \<open>Lars Noschinski\<close>\<close> |
1742 |
assumes "f permutes S" "x \<in> S" |
|
1743 |
shows "(f ^^ n) x \<in> S" |
|
1744 |
using assms by (induction n) (auto simp: permutes_in_image) |
|
1745 |
||
1746 |
lemma permutation_self: \<^marker>\<open>contributor \<open>Lars Noschinski\<close>\<close> |
|
1747 |
assumes \<open>permutation p\<close> |
|
1748 |
obtains n where \<open>n > 0\<close> \<open>(p ^^ n) x = x\<close> |
|
1749 |
proof (cases \<open>p x = x\<close>) |
|
1750 |
case True |
|
1751 |
with that [of 1] show thesis by simp |
|
1752 |
next |
|
1753 |
case False |
|
1754 |
from \<open>permutation p\<close> have \<open>inj p\<close> |
|
1755 |
by (intro permutation_bijective bij_is_inj) |
|
1756 |
moreover from \<open>p x \<noteq> x\<close> have \<open>(p ^^ Suc n) x \<noteq> (p ^^ n) x\<close> for n |
|
1757 |
proof (induction n arbitrary: x) |
|
1758 |
case 0 then show ?case by simp |
|
1759 |
next |
|
1760 |
case (Suc n) |
|
1761 |
have "p (p x) \<noteq> p x" |
|
1762 |
proof (rule notI) |
|
1763 |
assume "p (p x) = p x" |
|
1764 |
then show False using \<open>p x \<noteq> x\<close> \<open>inj p\<close> by (simp add: inj_eq) |
|
1765 |
qed |
|
1766 |
have "(p ^^ Suc (Suc n)) x = (p ^^ Suc n) (p x)" |
|
1767 |
by (simp add: funpow_swap1) |
|
1768 |
also have "\<dots> \<noteq> (p ^^ n) (p x)" |
|
1769 |
by (rule Suc) fact |
|
1770 |
also have "(p ^^ n) (p x) = (p ^^ Suc n) x" |
|
1771 |
by (simp add: funpow_swap1) |
|
1772 |
finally show ?case by simp |
|
1773 |
qed |
|
1774 |
then have "{y. \<exists>n. y = (p ^^ n) x} \<subseteq> {x. p x \<noteq> x}" |
|
1775 |
by auto |
|
1776 |
then have "finite {y. \<exists>n. y = (p ^^ n) x}" |
|
1777 |
using permutation_finite_support[OF assms] by (rule finite_subset) |
|
1778 |
ultimately obtain n where \<open>n > 0\<close> \<open>(p ^^ n) x = x\<close> |
|
1779 |
by (rule funpow_inj_finite) |
|
1780 |
with that [of n] show thesis by blast |
|
1781 |
qed |
|
1782 |
||
65342 | 1783 |
text \<open>The following few lemmas were contributed by Lukas Bulwahn.\<close> |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1784 |
|
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1785 |
lemma count_image_mset_eq_card_vimage: |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1786 |
assumes "finite A" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1787 |
shows "count (image_mset f (mset_set A)) b = card {a \<in> A. f a = b}" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1788 |
using assms |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1789 |
proof (induct A) |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1790 |
case empty |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1791 |
show ?case by simp |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1792 |
next |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1793 |
case (insert x F) |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1794 |
show ?case |
65342 | 1795 |
proof (cases "f x = b") |
1796 |
case True |
|
1797 |
with insert.hyps |
|
1798 |
have "count (image_mset f (mset_set (insert x F))) b = Suc (card {a \<in> F. f a = f x})" |
|
1799 |
by auto |
|
1800 |
also from insert.hyps(1,2) have "\<dots> = card (insert x {a \<in> F. f a = f x})" |
|
1801 |
by simp |
|
1802 |
also from \<open>f x = b\<close> have "card (insert x {a \<in> F. f a = f x}) = card {a \<in> insert x F. f a = b}" |
|
1803 |
by (auto intro: arg_cong[where f="card"]) |
|
1804 |
finally show ?thesis |
|
1805 |
using insert by auto |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1806 |
next |
65342 | 1807 |
case False |
1808 |
then have "{a \<in> F. f a = b} = {a \<in> insert x F. f a = b}" |
|
1809 |
by auto |
|
1810 |
with insert False show ?thesis |
|
1811 |
by simp |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1812 |
qed |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1813 |
qed |
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
1814 |
|
67408 | 1815 |
\<comment> \<open>Prove \<open>image_mset_eq_implies_permutes\<close> ...\<close> |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1816 |
lemma image_mset_eq_implies_permutes: |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1817 |
fixes f :: "'a \<Rightarrow> 'b" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1818 |
assumes "finite A" |
65342 | 1819 |
and mset_eq: "image_mset f (mset_set A) = image_mset f' (mset_set A)" |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1820 |
obtains p where "p permutes A" and "\<forall>x\<in>A. f x = f' (p x)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1821 |
proof - |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1822 |
from \<open>finite A\<close> have [simp]: "finite {a \<in> A. f a = (b::'b)}" for f b by auto |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1823 |
have "f ` A = f' ` A" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1824 |
proof - |
65342 | 1825 |
from \<open>finite A\<close> have "f ` A = f ` (set_mset (mset_set A))" |
1826 |
by simp |
|
1827 |
also have "\<dots> = f' ` set_mset (mset_set A)" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1828 |
by (metis mset_eq multiset.set_map) |
65342 | 1829 |
also from \<open>finite A\<close> have "\<dots> = f' ` A" |
1830 |
by simp |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1831 |
finally show ?thesis . |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1832 |
qed |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1833 |
have "\<forall>b\<in>(f ` A). \<exists>p. bij_betw p {a \<in> A. f a = b} {a \<in> A. f' a = b}" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1834 |
proof |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1835 |
fix b |
65342 | 1836 |
from mset_eq have "count (image_mset f (mset_set A)) b = count (image_mset f' (mset_set A)) b" |
1837 |
by simp |
|
1838 |
with \<open>finite A\<close> have "card {a \<in> A. f a = b} = card {a \<in> A. f' a = b}" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1839 |
by (simp add: count_image_mset_eq_card_vimage) |
65342 | 1840 |
then show "\<exists>p. bij_betw p {a\<in>A. f a = b} {a \<in> A. f' a = b}" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1841 |
by (intro finite_same_card_bij) simp_all |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1842 |
qed |
65342 | 1843 |
then have "\<exists>p. \<forall>b\<in>f ` A. bij_betw (p b) {a \<in> A. f a = b} {a \<in> A. f' a = b}" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1844 |
by (rule bchoice) |
65342 | 1845 |
then obtain p where p: "\<forall>b\<in>f ` A. bij_betw (p b) {a \<in> A. f a = b} {a \<in> A. f' a = b}" .. |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1846 |
define p' where "p' = (\<lambda>a. if a \<in> A then p (f a) a else a)" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1847 |
have "p' permutes A" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1848 |
proof (rule bij_imp_permutes) |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1849 |
have "disjoint_family_on (\<lambda>i. {a \<in> A. f' a = i}) (f ` A)" |
65342 | 1850 |
by (auto simp: disjoint_family_on_def) |
1851 |
moreover |
|
1852 |
have "bij_betw (\<lambda>a. p (f a) a) {a \<in> A. f a = b} {a \<in> A. f' a = b}" if "b \<in> f ` A" for b |
|
1853 |
using p that by (subst bij_betw_cong[where g="p b"]) auto |
|
1854 |
ultimately |
|
1855 |
have "bij_betw (\<lambda>a. p (f a) a) (\<Union>b\<in>f ` A. {a \<in> A. f a = b}) (\<Union>b\<in>f ` A. {a \<in> A. f' a = b})" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1856 |
by (rule bij_betw_UNION_disjoint) |
65342 | 1857 |
moreover have "(\<Union>b\<in>f ` A. {a \<in> A. f a = b}) = A" |
1858 |
by auto |
|
1859 |
moreover from \<open>f ` A = f' ` A\<close> have "(\<Union>b\<in>f ` A. {a \<in> A. f' a = b}) = A" |
|
1860 |
by auto |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1861 |
ultimately show "bij_betw p' A A" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1862 |
unfolding p'_def by (subst bij_betw_cong[where g="(\<lambda>a. p (f a) a)"]) auto |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1863 |
next |
65342 | 1864 |
show "\<And>x. x \<notin> A \<Longrightarrow> p' x = x" |
1865 |
by (simp add: p'_def) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1866 |
qed |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1867 |
moreover from p have "\<forall>x\<in>A. f x = f' (p' x)" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1868 |
unfolding p'_def using bij_betwE by fastforce |
65342 | 1869 |
ultimately show ?thesis .. |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1870 |
qed |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1871 |
|
67408 | 1872 |
\<comment> \<open>... and derive the existing property:\<close> |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1873 |
lemma mset_eq_permutation: |
65342 | 1874 |
fixes xs ys :: "'a list" |
1875 |
assumes mset_eq: "mset xs = mset ys" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1876 |
obtains p where "p permutes {..<length ys}" "permute_list p ys = xs" |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1877 |
proof - |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1878 |
from mset_eq have length_eq: "length xs = length ys" |
65342 | 1879 |
by (rule mset_eq_length) |
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1880 |
have "mset_set {..<length ys} = mset [0..<length ys]" |
65342 | 1881 |
by (rule mset_set_upto_eq_mset_upto) |
1882 |
with mset_eq length_eq have "image_mset (\<lambda>i. xs ! i) (mset_set {..<length ys}) = |
|
1883 |
image_mset (\<lambda>i. ys ! i) (mset_set {..<length ys})" |
|
63921
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1884 |
by (metis map_nth mset_map) |
0a5184877cb7
Additions to permutations (contributed by Lukas Bulwahn)
eberlm <eberlm@in.tum.de>
parents:
63539
diff
changeset
|
1885 |
from image_mset_eq_implies_permutes[OF _ this] |
65342 | 1886 |
obtain p where p: "p permutes {..<length ys}" and "\<forall>i\<in>{..<length ys}. xs ! i = ys ! (p i)" |
1887 |
by auto |
|
1888 |
with length_eq have "permute_list p ys = xs" |
|
1889 |
by (auto intro!: nth_equalityI simp: permute_list_nth) |
|
1890 |
with p show thesis .. |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1891 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
1892 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1893 |
lemma permutes_natset_le: |
54681 | 1894 |
fixes S :: "'a::wellorder set" |
65342 | 1895 |
assumes "p permutes S" |
1896 |
and "\<forall>i \<in> S. p i \<le> i" |
|
54681 | 1897 |
shows "p = id" |
1898 |
proof - |
|
65342 | 1899 |
have "p n = n" for n |
1900 |
using assms |
|
1901 |
proof (induct n arbitrary: S rule: less_induct) |
|
1902 |
case (less n) |
|
1903 |
show ?case |
|
1904 |
proof (cases "n \<in> S") |
|
1905 |
case False |
|
1906 |
with less(2) show ?thesis |
|
1907 |
unfolding permutes_def by metis |
|
1908 |
next |
|
1909 |
case True |
|
1910 |
with less(3) have "p n < n \<or> p n = n" |
|
1911 |
by auto |
|
1912 |
then show ?thesis |
|
1913 |
proof |
|
1914 |
assume "p n < n" |
|
1915 |
with less have "p (p n) = p n" |
|
1916 |
by metis |
|
1917 |
with permutes_inj[OF less(2)] have "p n = n" |
|
1918 |
unfolding inj_def by blast |
|
1919 |
with \<open>p n < n\<close> have False |
|
1920 |
by simp |
|
1921 |
then show ?thesis .. |
|
1922 |
qed |
|
54681 | 1923 |
qed |
65342 | 1924 |
qed |
1925 |
then show ?thesis by (auto simp: fun_eq_iff) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1926 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1927 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1928 |
lemma permutes_natset_ge: |
54681 | 1929 |
fixes S :: "'a::wellorder set" |
1930 |
assumes p: "p permutes S" |
|
1931 |
and le: "\<forall>i \<in> S. p i \<ge> i" |
|
1932 |
shows "p = id" |
|
1933 |
proof - |
|
65342 | 1934 |
have "i \<ge> inv p i" if "i \<in> S" for i |
1935 |
proof - |
|
1936 |
from that permutes_in_image[OF permutes_inv[OF p]] have "inv p i \<in> S" |
|
54681 | 1937 |
by simp |
1938 |
with le have "p (inv p i) \<ge> inv p i" |
|
1939 |
by blast |
|
65342 | 1940 |
with permutes_inverses[OF p] show ?thesis |
54681 | 1941 |
by simp |
65342 | 1942 |
qed |
1943 |
then have "\<forall>i\<in>S. inv p i \<le> i" |
|
54681 | 1944 |
by blast |
65342 | 1945 |
from permutes_natset_le[OF permutes_inv[OF p] this] have "inv p = inv id" |
54681 | 1946 |
by simp |
30488 | 1947 |
then show ?thesis |
80777 | 1948 |
using p permutes_inv_inv by fastforce |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1949 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1950 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1951 |
lemma image_inverse_permutations: "{inv p |p. p permutes S} = {p. p permutes S}" |
80777 | 1952 |
using permutes_inv permutes_inv_inv by force |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1953 |
|
30488 | 1954 |
lemma image_compose_permutations_left: |
65342 | 1955 |
assumes "q permutes S" |
1956 |
shows "{q \<circ> p |p. p permutes S} = {p. p permutes S}" |
|
80777 | 1957 |
proof - |
1958 |
have "\<And>p. p permutes S \<Longrightarrow> q \<circ> p permutes S" |
|
1959 |
by (simp add: assms permutes_compose) |
|
1960 |
moreover have "\<And>x. x permutes S \<Longrightarrow> \<exists>p. x = q \<circ> p \<and> p permutes S" |
|
1961 |
by (metis assms id_comp o_assoc permutes_compose permutes_inv permutes_inv_o(1)) |
|
1962 |
ultimately show ?thesis |
|
1963 |
by auto |
|
1964 |
qed |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1965 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1966 |
lemma image_compose_permutations_right: |
65342 | 1967 |
assumes "q permutes S" |
54681 | 1968 |
shows "{p \<circ> q | p. p permutes S} = {p . p permutes S}" |
80777 | 1969 |
by (metis (no_types, opaque_lifting) assms comp_id fun.map_comp permutes_compose permutes_inv permutes_inv_o(2)) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1970 |
|
54681 | 1971 |
lemma permutes_in_seg: "p permutes {1 ..n} \<Longrightarrow> i \<in> {1..n} \<Longrightarrow> 1 \<le> p i \<and> p i \<le> n" |
1972 |
by (simp add: permutes_def) metis |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1973 |
|
65342 | 1974 |
lemma sum_permutations_inverse: "sum f {p. p permutes S} = sum (\<lambda>p. f(inv p)) {p. p permutes S}" |
54681 | 1975 |
(is "?lhs = ?rhs") |
1976 |
proof - |
|
30036 | 1977 |
let ?S = "{p . p permutes S}" |
65342 | 1978 |
have *: "inj_on inv ?S" |
54681 | 1979 |
proof (auto simp add: inj_on_def) |
1980 |
fix q r |
|
1981 |
assume q: "q permutes S" |
|
1982 |
and r: "r permutes S" |
|
1983 |
and qr: "inv q = inv r" |
|
1984 |
then have "inv (inv q) = inv (inv r)" |
|
1985 |
by simp |
|
1986 |
with permutes_inv_inv[OF q] permutes_inv_inv[OF r] show "q = r" |
|
1987 |
by metis |
|
1988 |
qed |
|
65342 | 1989 |
have **: "inv ` ?S = ?S" |
54681 | 1990 |
using image_inverse_permutations by blast |
65342 | 1991 |
have ***: "?rhs = sum (f \<circ> inv) ?S" |
54681 | 1992 |
by (simp add: o_def) |
65342 | 1993 |
from sum.reindex[OF *, of f] show ?thesis |
1994 |
by (simp only: ** ***) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1995 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1996 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
1997 |
lemma setum_permutations_compose_left: |
30036 | 1998 |
assumes q: "q permutes S" |
64267 | 1999 |
shows "sum f {p. p permutes S} = sum (\<lambda>p. f(q \<circ> p)) {p. p permutes S}" |
54681 | 2000 |
(is "?lhs = ?rhs") |
2001 |
proof - |
|
30036 | 2002 |
let ?S = "{p. p permutes S}" |
67399 | 2003 |
have *: "?rhs = sum (f \<circ> ((\<circ>) q)) ?S" |
54681 | 2004 |
by (simp add: o_def) |
67399 | 2005 |
have **: "inj_on ((\<circ>) q) ?S" |
54681 | 2006 |
proof (auto simp add: inj_on_def) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2007 |
fix p r |
54681 | 2008 |
assume "p permutes S" |
2009 |
and r: "r permutes S" |
|
2010 |
and rp: "q \<circ> p = q \<circ> r" |
|
2011 |
then have "inv q \<circ> q \<circ> p = inv q \<circ> q \<circ> r" |
|
2012 |
by (simp add: comp_assoc) |
|
2013 |
with permutes_inj[OF q, unfolded inj_iff] show "p = r" |
|
2014 |
by simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2015 |
qed |
67399 | 2016 |
have "((\<circ>) q) ` ?S = ?S" |
54681 | 2017 |
using image_compose_permutations_left[OF q] by auto |
65342 | 2018 |
with * sum.reindex[OF **, of f] show ?thesis |
2019 |
by (simp only:) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2020 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2021 |
|
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2022 |
lemma sum_permutations_compose_right: |
30036 | 2023 |
assumes q: "q permutes S" |
64267 | 2024 |
shows "sum f {p. p permutes S} = sum (\<lambda>p. f(p \<circ> q)) {p. p permutes S}" |
54681 | 2025 |
(is "?lhs = ?rhs") |
2026 |
proof - |
|
30036 | 2027 |
let ?S = "{p. p permutes S}" |
65342 | 2028 |
have *: "?rhs = sum (f \<circ> (\<lambda>p. p \<circ> q)) ?S" |
54681 | 2029 |
by (simp add: o_def) |
65342 | 2030 |
have **: "inj_on (\<lambda>p. p \<circ> q) ?S" |
54681 | 2031 |
proof (auto simp add: inj_on_def) |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2032 |
fix p r |
54681 | 2033 |
assume "p permutes S" |
2034 |
and r: "r permutes S" |
|
2035 |
and rp: "p \<circ> q = r \<circ> q" |
|
2036 |
then have "p \<circ> (q \<circ> inv q) = r \<circ> (q \<circ> inv q)" |
|
2037 |
by (simp add: o_assoc) |
|
2038 |
with permutes_surj[OF q, unfolded surj_iff] show "p = r" |
|
2039 |
by simp |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2040 |
qed |
65342 | 2041 |
from image_compose_permutations_right[OF q] have "(\<lambda>p. p \<circ> q) ` ?S = ?S" |
2042 |
by auto |
|
2043 |
with * sum.reindex[OF **, of f] show ?thesis |
|
2044 |
by (simp only:) |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2045 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2046 |
|
73621 | 2047 |
lemma inv_inj_on_permutes: |
2048 |
\<open>inj_on inv {p. p permutes S}\<close> |
|
2049 |
proof (intro inj_onI, unfold mem_Collect_eq) |
|
2050 |
fix p q |
|
2051 |
assume p: "p permutes S" and q: "q permutes S" and eq: "inv p = inv q" |
|
2052 |
have "inv (inv p) = inv (inv q)" using eq by simp |
|
2053 |
thus "p = q" |
|
2054 |
using inv_inv_eq[OF permutes_bij] p q by metis |
|
2055 |
qed |
|
2056 |
||
2057 |
lemma permutes_pair_eq: |
|
2058 |
\<open>{(p s, s) |s. s \<in> S} = {(s, inv p s) |s. s \<in> S}\<close> (is \<open>?L = ?R\<close>) if \<open>p permutes S\<close> |
|
2059 |
proof |
|
2060 |
show "?L \<subseteq> ?R" |
|
2061 |
proof |
|
2062 |
fix x assume "x \<in> ?L" |
|
2063 |
then obtain s where x: "x = (p s, s)" and s: "s \<in> S" by auto |
|
2064 |
note x |
|
2065 |
also have "(p s, s) = (p s, Hilbert_Choice.inv p (p s))" |
|
2066 |
using permutes_inj [OF that] inv_f_f by auto |
|
2067 |
also have "... \<in> ?R" using s permutes_in_image[OF that] by auto |
|
2068 |
finally show "x \<in> ?R". |
|
2069 |
qed |
|
2070 |
show "?R \<subseteq> ?L" |
|
2071 |
proof |
|
2072 |
fix x assume "x \<in> ?R" |
|
2073 |
then obtain s |
|
2074 |
where x: "x = (s, Hilbert_Choice.inv p s)" (is "_ = (s, ?ips)") |
|
2075 |
and s: "s \<in> S" by auto |
|
2076 |
note x |
|
2077 |
also have "(s, ?ips) = (p ?ips, ?ips)" |
|
2078 |
using inv_f_f[OF permutes_inj[OF permutes_inv[OF that]]] |
|
2079 |
using inv_inv_eq[OF permutes_bij[OF that]] by auto |
|
2080 |
also have "... \<in> ?L" |
|
2081 |
using s permutes_in_image[OF permutes_inv[OF that]] by auto |
|
2082 |
finally show "x \<in> ?L". |
|
2083 |
qed |
|
2084 |
qed |
|
2085 |
||
2086 |
context |
|
2087 |
fixes p and n i :: nat |
|
2088 |
assumes p: \<open>p permutes {0..<n}\<close> and i: \<open>i < n\<close> |
|
2089 |
begin |
|
2090 |
||
2091 |
lemma permutes_nat_less: |
|
2092 |
\<open>p i < n\<close> |
|
2093 |
proof - |
|
2094 |
have \<open>?thesis \<longleftrightarrow> p i \<in> {0..<n}\<close> |
|
2095 |
by simp |
|
2096 |
also from p have \<open>p i \<in> {0..<n} \<longleftrightarrow> i \<in> {0..<n}\<close> |
|
2097 |
by (rule permutes_in_image) |
|
2098 |
finally show ?thesis |
|
2099 |
using i by simp |
|
2100 |
qed |
|
2101 |
||
2102 |
lemma permutes_nat_inv_less: |
|
2103 |
\<open>inv p i < n\<close> |
|
2104 |
proof - |
|
2105 |
from p have \<open>inv p permutes {0..<n}\<close> |
|
2106 |
by (rule permutes_inv) |
|
2107 |
then show ?thesis |
|
2108 |
using i by (rule Permutations.permutes_nat_less) |
|
2109 |
qed |
|
2110 |
||
2111 |
end |
|
2112 |
||
2113 |
context comm_monoid_set |
|
2114 |
begin |
|
2115 |
||
2116 |
lemma permutes_inv: |
|
2117 |
\<open>F (\<lambda>s. g (p s) s) S = F (\<lambda>s. g s (inv p s)) S\<close> (is \<open>?l = ?r\<close>) |
|
2118 |
if \<open>p permutes S\<close> |
|
2119 |
proof - |
|
2120 |
let ?g = "\<lambda>(x, y). g x y" |
|
2121 |
let ?ps = "\<lambda>s. (p s, s)" |
|
2122 |
let ?ips = "\<lambda>s. (s, inv p s)" |
|
2123 |
have inj1: "inj_on ?ps S" by (rule inj_onI) auto |
|
2124 |
have inj2: "inj_on ?ips S" by (rule inj_onI) auto |
|
2125 |
have "?l = F ?g (?ps ` S)" |
|
2126 |
using reindex [OF inj1, of ?g] by simp |
|
2127 |
also have "?ps ` S = {(p s, s) |s. s \<in> S}" by auto |
|
2128 |
also have "... = {(s, inv p s) |s. s \<in> S}" |
|
2129 |
unfolding permutes_pair_eq [OF that] by simp |
|
2130 |
also have "... = ?ips ` S" by auto |
|
2131 |
also have "F ?g ... = ?r" |
|
2132 |
using reindex [OF inj2, of ?g] by simp |
|
2133 |
finally show ?thesis. |
|
2134 |
qed |
|
2135 |
||
2136 |
end |
|
2137 |
||
54681 | 2138 |
|
60500 | 2139 |
subsection \<open>Sum over a set of permutations (could generalize to iteration)\<close> |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2140 |
|
64267 | 2141 |
lemma sum_over_permutations_insert: |
54681 | 2142 |
assumes fS: "finite S" |
2143 |
and aS: "a \<notin> S" |
|
64267 | 2144 |
shows "sum f {p. p permutes (insert a S)} = |
73648 | 2145 |
sum (\<lambda>b. sum (\<lambda>q. f (transpose a b \<circ> q)) {p. p permutes S}) (insert a S)" |
54681 | 2146 |
proof - |
73648 | 2147 |
have *: "\<And>f a b. (\<lambda>(b, p). f (transpose a b \<circ> p)) = f \<circ> (\<lambda>(b,p). transpose a b \<circ> p)" |
39302
d7728f65b353
renamed lemmas: ext_iff -> fun_eq_iff, set_ext_iff -> set_eq_iff, set_ext -> set_eqI
nipkow
parents:
39198
diff
changeset
|
2148 |
by (simp add: fun_eq_iff) |
65342 | 2149 |
have **: "\<And>P Q. {(a, b). a \<in> P \<and> b \<in> Q} = P \<times> Q" |
54681 | 2150 |
by blast |
30488 | 2151 |
show ?thesis |
65342 | 2152 |
unfolding * ** sum.cartesian_product permutes_insert |
64267 | 2153 |
proof (rule sum.reindex) |
73648 | 2154 |
let ?f = "(\<lambda>(b, y). transpose a b \<circ> y)" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2155 |
let ?P = "{p. p permutes S}" |
54681 | 2156 |
{ |
2157 |
fix b c p q |
|
2158 |
assume b: "b \<in> insert a S" |
|
2159 |
assume c: "c \<in> insert a S" |
|
2160 |
assume p: "p permutes S" |
|
2161 |
assume q: "q permutes S" |
|
73648 | 2162 |
assume eq: "transpose a b \<circ> p = transpose a c \<circ> q" |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2163 |
from p q aS have pa: "p a = a" and qa: "q a = a" |
32960
69916a850301
eliminated hard tabulators, guessing at each author's individual tab-width;
wenzelm
parents:
32456
diff
changeset
|
2164 |
unfolding permutes_def by metis+ |
73648 | 2165 |
from eq have "(transpose a b \<circ> p) a = (transpose a c \<circ> q) a" |
54681 | 2166 |
by simp |
2167 |
then have bc: "b = c" |
|
73663 | 2168 |
by (simp add: permutes_def pa qa o_def fun_upd_def id_def |
62390 | 2169 |
cong del: if_weak_cong split: if_split_asm) |
73648 | 2170 |
from eq[unfolded bc] have "(\<lambda>p. transpose a c \<circ> p) (transpose a c \<circ> p) = |
2171 |
(\<lambda>p. transpose a c \<circ> p) (transpose a c \<circ> q)" by simp |
|
54681 | 2172 |
then have "p = q" |
65342 | 2173 |
unfolding o_assoc swap_id_idempotent by simp |
54681 | 2174 |
with bc have "b = c \<and> p = q" |
2175 |
by blast |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2176 |
} |
30488 | 2177 |
then show "inj_on ?f (insert a S \<times> ?P)" |
54681 | 2178 |
unfolding inj_on_def by clarify metis |
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2179 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2180 |
qed |
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2181 |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2182 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2183 |
subsection \<open>Constructing permutations from association lists\<close> |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2184 |
|
65342 | 2185 |
definition list_permutes :: "('a \<times> 'a) list \<Rightarrow> 'a set \<Rightarrow> bool" |
2186 |
where "list_permutes xs A \<longleftrightarrow> |
|
2187 |
set (map fst xs) \<subseteq> A \<and> |
|
2188 |
set (map snd xs) = set (map fst xs) \<and> |
|
2189 |
distinct (map fst xs) \<and> |
|
2190 |
distinct (map snd xs)" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2191 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2192 |
lemma list_permutesI [simp]: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2193 |
assumes "set (map fst xs) \<subseteq> A" "set (map snd xs) = set (map fst xs)" "distinct (map fst xs)" |
65342 | 2194 |
shows "list_permutes xs A" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2195 |
proof - |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2196 |
from assms(2,3) have "distinct (map snd xs)" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2197 |
by (intro card_distinct) (simp_all add: distinct_card del: set_map) |
65342 | 2198 |
with assms show ?thesis |
2199 |
by (simp add: list_permutes_def) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2200 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2201 |
|
65342 | 2202 |
definition permutation_of_list :: "('a \<times> 'a) list \<Rightarrow> 'a \<Rightarrow> 'a" |
2203 |
where "permutation_of_list xs x = (case map_of xs x of None \<Rightarrow> x | Some y \<Rightarrow> y)" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2204 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2205 |
lemma permutation_of_list_Cons: |
65342 | 2206 |
"permutation_of_list ((x, y) # xs) x' = (if x = x' then y else permutation_of_list xs x')" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2207 |
by (simp add: permutation_of_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2208 |
|
65342 | 2209 |
fun inverse_permutation_of_list :: "('a \<times> 'a) list \<Rightarrow> 'a \<Rightarrow> 'a" |
2210 |
where |
|
2211 |
"inverse_permutation_of_list [] x = x" |
|
2212 |
| "inverse_permutation_of_list ((y, x') # xs) x = |
|
2213 |
(if x = x' then y else inverse_permutation_of_list xs x)" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2214 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2215 |
declare inverse_permutation_of_list.simps [simp del] |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2216 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2217 |
lemma inj_on_map_of: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2218 |
assumes "distinct (map snd xs)" |
65342 | 2219 |
shows "inj_on (map_of xs) (set (map fst xs))" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2220 |
proof (rule inj_onI) |
65342 | 2221 |
fix x y |
2222 |
assume xy: "x \<in> set (map fst xs)" "y \<in> set (map fst xs)" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2223 |
assume eq: "map_of xs x = map_of xs y" |
65342 | 2224 |
from xy obtain x' y' where x'y': "map_of xs x = Some x'" "map_of xs y = Some y'" |
2225 |
by (cases "map_of xs x"; cases "map_of xs y") (simp_all add: map_of_eq_None_iff) |
|
2226 |
moreover from x'y' have *: "(x, x') \<in> set xs" "(y, y') \<in> set xs" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2227 |
by (force dest: map_of_SomeD)+ |
65342 | 2228 |
moreover from * eq x'y' have "x' = y'" |
2229 |
by simp |
|
2230 |
ultimately show "x = y" |
|
2231 |
using assms by (force simp: distinct_map dest: inj_onD[of _ _ "(x,x')" "(y,y')"]) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2232 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2233 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2234 |
lemma inj_on_the: "None \<notin> A \<Longrightarrow> inj_on the A" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2235 |
by (auto simp: inj_on_def option.the_def split: option.splits) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2236 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2237 |
lemma inj_on_map_of': |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2238 |
assumes "distinct (map snd xs)" |
65342 | 2239 |
shows "inj_on (the \<circ> map_of xs) (set (map fst xs))" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2240 |
by (intro comp_inj_on inj_on_map_of assms inj_on_the) |
65342 | 2241 |
(force simp: eq_commute[of None] map_of_eq_None_iff) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2242 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2243 |
lemma image_map_of: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2244 |
assumes "distinct (map fst xs)" |
65342 | 2245 |
shows "map_of xs ` set (map fst xs) = Some ` set (map snd xs)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2246 |
using assms by (auto simp: rev_image_eqI) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2247 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2248 |
lemma the_Some_image [simp]: "the ` Some ` A = A" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2249 |
by (subst image_image) simp |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2250 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2251 |
lemma image_map_of': |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2252 |
assumes "distinct (map fst xs)" |
65342 | 2253 |
shows "(the \<circ> map_of xs) ` set (map fst xs) = set (map snd xs)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2254 |
by (simp only: image_comp [symmetric] image_map_of assms the_Some_image) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2255 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2256 |
lemma permutation_of_list_permutes [simp]: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2257 |
assumes "list_permutes xs A" |
65342 | 2258 |
shows "permutation_of_list xs permutes A" |
2259 |
(is "?f permutes _") |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2260 |
proof (rule permutes_subset[OF bij_imp_permutes]) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2261 |
from assms show "set (map fst xs) \<subseteq> A" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2262 |
by (simp add: list_permutes_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2263 |
from assms have "inj_on (the \<circ> map_of xs) (set (map fst xs))" (is ?P) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2264 |
by (intro inj_on_map_of') (simp_all add: list_permutes_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2265 |
also have "?P \<longleftrightarrow> inj_on ?f (set (map fst xs))" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2266 |
by (intro inj_on_cong) |
65342 | 2267 |
(auto simp: permutation_of_list_def map_of_eq_None_iff split: option.splits) |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2268 |
finally have "bij_betw ?f (set (map fst xs)) (?f ` set (map fst xs))" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2269 |
by (rule inj_on_imp_bij_betw) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2270 |
also from assms have "?f ` set (map fst xs) = (the \<circ> map_of xs) ` set (map fst xs)" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2271 |
by (intro image_cong refl) |
65342 | 2272 |
(auto simp: permutation_of_list_def map_of_eq_None_iff split: option.splits) |
64284
f3b905b2eee2
HOL-Analysis: more theorems from Sébastien Gouëzel's Ergodic_Theory
hoelzl
parents:
64267
diff
changeset
|
2273 |
also from assms have "\<dots> = set (map fst xs)" |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2274 |
by (subst image_map_of') (simp_all add: list_permutes_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2275 |
finally show "bij_betw ?f (set (map fst xs)) (set (map fst xs))" . |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2276 |
qed (force simp: permutation_of_list_def dest!: map_of_SomeD split: option.splits)+ |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2277 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2278 |
lemma eval_permutation_of_list [simp]: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2279 |
"permutation_of_list [] x = x" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2280 |
"x = x' \<Longrightarrow> permutation_of_list ((x',y)#xs) x = y" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2281 |
"x \<noteq> x' \<Longrightarrow> permutation_of_list ((x',y')#xs) x = permutation_of_list xs x" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2282 |
by (simp_all add: permutation_of_list_def) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2283 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2284 |
lemma eval_inverse_permutation_of_list [simp]: |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2285 |
"inverse_permutation_of_list [] x = x" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2286 |
"x = x' \<Longrightarrow> inverse_permutation_of_list ((y,x')#xs) x = y" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2287 |
"x \<noteq> x' \<Longrightarrow> inverse_permutation_of_list ((y',x')#xs) x = inverse_permutation_of_list xs x" |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2288 |
by (simp_all add: inverse_permutation_of_list.simps) |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2289 |
|
65342 | 2290 |
lemma permutation_of_list_id: "x \<notin> set (map fst xs) \<Longrightarrow> permutation_of_list xs x = x" |
2291 |
by (induct xs) (auto simp: permutation_of_list_Cons) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2292 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2293 |
lemma permutation_of_list_unique': |
65342 | 2294 |
"distinct (map fst xs) \<Longrightarrow> (x, y) \<in> set xs \<Longrightarrow> permutation_of_list xs x = y" |
2295 |
by (induct xs) (force simp: permutation_of_list_Cons)+ |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2296 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2297 |
lemma permutation_of_list_unique: |
65342 | 2298 |
"list_permutes xs A \<Longrightarrow> (x, y) \<in> set xs \<Longrightarrow> permutation_of_list xs x = y" |
2299 |
by (intro permutation_of_list_unique') (simp_all add: list_permutes_def) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2300 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2301 |
lemma inverse_permutation_of_list_id: |
65342 | 2302 |
"x \<notin> set (map snd xs) \<Longrightarrow> inverse_permutation_of_list xs x = x" |
2303 |
by (induct xs) auto |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2304 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2305 |
lemma inverse_permutation_of_list_unique': |
65342 | 2306 |
"distinct (map snd xs) \<Longrightarrow> (x, y) \<in> set xs \<Longrightarrow> inverse_permutation_of_list xs y = x" |
73328 | 2307 |
by (induct xs) (force simp: inverse_permutation_of_list.simps(2))+ |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2308 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2309 |
lemma inverse_permutation_of_list_unique: |
65342 | 2310 |
"list_permutes xs A \<Longrightarrow> (x,y) \<in> set xs \<Longrightarrow> inverse_permutation_of_list xs y = x" |
2311 |
by (intro inverse_permutation_of_list_unique') (simp_all add: list_permutes_def) |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2312 |
|
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2313 |
lemma inverse_permutation_of_list_correct: |
65342 | 2314 |
fixes A :: "'a set" |
2315 |
assumes "list_permutes xs A" |
|
2316 |
shows "inverse_permutation_of_list xs = inv (permutation_of_list xs)" |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2317 |
proof (rule ext, rule sym, subst permutes_inv_eq) |
65342 | 2318 |
from assms show "permutation_of_list xs permutes A" |
2319 |
by simp |
|
2320 |
show "permutation_of_list xs (inverse_permutation_of_list xs x) = x" for x |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2321 |
proof (cases "x \<in> set (map snd xs)") |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2322 |
case True |
65342 | 2323 |
then obtain y where "(y, x) \<in> set xs" by auto |
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2324 |
with assms show ?thesis |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2325 |
by (simp add: inverse_permutation_of_list_unique permutation_of_list_unique) |
65342 | 2326 |
next |
2327 |
case False |
|
2328 |
with assms show ?thesis |
|
2329 |
by (auto simp: list_permutes_def inverse_permutation_of_list_id permutation_of_list_id) |
|
2330 |
qed |
|
63099
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2331 |
qed |
af0e964aad7b
Moved material from AFP/Randomised_Social_Choice to distribution
eberlm
parents:
62390
diff
changeset
|
2332 |
|
29840
cfab6a76aa13
Permutations, both general and specifically on finite sets.
chaieb
parents:
diff
changeset
|
2333 |
end |