156 inductive swapidseq_ext :: "'a set \<Rightarrow> nat \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool" |
156 inductive swapidseq_ext :: "'a set \<Rightarrow> nat \<Rightarrow> ('a \<Rightarrow> 'a) \<Rightarrow> bool" |
157 where |
157 where |
158 empty: "swapidseq_ext {} 0 id" |
158 empty: "swapidseq_ext {} 0 id" |
159 | single: "\<lbrakk> swapidseq_ext S n p; a \<notin> S \<rbrakk> \<Longrightarrow> swapidseq_ext (insert a S) n p" |
159 | single: "\<lbrakk> swapidseq_ext S n p; a \<notin> S \<rbrakk> \<Longrightarrow> swapidseq_ext (insert a S) n p" |
160 | comp: "\<lbrakk> swapidseq_ext S n p; a \<noteq> b \<rbrakk> \<Longrightarrow> |
160 | comp: "\<lbrakk> swapidseq_ext S n p; a \<noteq> b \<rbrakk> \<Longrightarrow> |
161 swapidseq_ext (insert a (insert b S)) (Suc n) ((Fun.swap a b id) \<circ> p)" |
161 swapidseq_ext (insert a (insert b S)) (Suc n) ((transpose a b) \<circ> p)" |
162 |
162 |
163 |
163 |
164 lemma swapidseq_ext_finite: |
164 lemma swapidseq_ext_finite: |
165 assumes "swapidseq_ext S n p" shows "finite S" |
165 assumes "swapidseq_ext S n p" shows "finite S" |
166 using assms by (induction) (auto) |
166 using assms by (induction) (auto) |
178 next |
178 next |
179 case (single S n p a) |
179 case (single S n p a) |
180 then show ?case by simp |
180 then show ?case by simp |
181 next |
181 next |
182 case (comp S n p a b) |
182 case (comp S n p a b) |
183 then have \<open>swapidseq (Suc n) (Fun.swap a b id \<circ> p)\<close> |
183 then have \<open>swapidseq (Suc n) (transpose a b \<circ> p)\<close> |
184 by (simp add: comp_Suc) |
184 by (simp add: comp_Suc) |
185 then show ?case by (simp add: comp_def) |
185 then show ?case by (simp add: comp_def) |
186 qed |
186 qed |
187 |
187 |
188 lemma swapidseq_ext_zero_imp_id: |
188 lemma swapidseq_ext_zero_imp_id: |
203 qed |
203 qed |
204 |
204 |
205 lemma swapidseq_ext_backwards: |
205 lemma swapidseq_ext_backwards: |
206 assumes "swapidseq_ext A (Suc n) p" |
206 assumes "swapidseq_ext A (Suc n) p" |
207 shows "\<exists>a b A' p'. a \<noteq> b \<and> A = (insert a (insert b A')) \<and> |
207 shows "\<exists>a b A' p'. a \<noteq> b \<and> A = (insert a (insert b A')) \<and> |
208 swapidseq_ext A' n p' \<and> p = (Fun.swap a b id) \<circ> p'" |
208 swapidseq_ext A' n p' \<and> p = (transpose a b) \<circ> p'" |
209 proof - |
209 proof - |
210 { fix A n k and p :: "'a \<Rightarrow> 'a" |
210 { fix A n k and p :: "'a \<Rightarrow> 'a" |
211 assume "swapidseq_ext A n p" "n = Suc k" |
211 assume "swapidseq_ext A n p" "n = Suc k" |
212 hence "\<exists>a b A' p'. a \<noteq> b \<and> A = (insert a (insert b A')) \<and> |
212 hence "\<exists>a b A' p'. a \<noteq> b \<and> A = (insert a (insert b A')) \<and> |
213 swapidseq_ext A' k p' \<and> p = (Fun.swap a b id) \<circ> p'" |
213 swapidseq_ext A' k p' \<and> p = (transpose a b) \<circ> p'" |
214 proof (induction, simp) |
214 proof (induction, simp) |
215 case single thus ?case |
215 case single thus ?case |
216 by (metis Un_insert_right insert_iff insert_is_Un swapidseq_ext.single) |
216 by (metis Un_insert_right insert_iff insert_is_Un swapidseq_ext.single) |
217 next |
217 next |
218 case comp thus ?case |
218 case comp thus ?case |
222 using assms by simp |
222 using assms by simp |
223 qed |
223 qed |
224 |
224 |
225 lemma swapidseq_ext_backwards': |
225 lemma swapidseq_ext_backwards': |
226 assumes "swapidseq_ext A (Suc n) p" |
226 assumes "swapidseq_ext A (Suc n) p" |
227 shows "\<exists>a b A' p'. a \<in> A \<and> b \<in> A \<and> a \<noteq> b \<and> swapidseq_ext A n p' \<and> p = (Fun.swap a b id) \<circ> p'" |
227 shows "\<exists>a b A' p'. a \<in> A \<and> b \<in> A \<and> a \<noteq> b \<and> swapidseq_ext A n p' \<and> p = (transpose a b) \<circ> p'" |
228 using swapidseq_ext_backwards[OF assms] swapidseq_ext_finite_expansion |
228 using swapidseq_ext_backwards[OF assms] swapidseq_ext_finite_expansion |
229 by (metis Un_insert_left assms insertI1 sup.idem sup_commute swapidseq_ext_finite) |
229 by (metis Un_insert_left assms insertI1 sup.idem sup_commute swapidseq_ext_finite) |
230 |
230 |
231 lemma swapidseq_ext_endswap: |
231 lemma swapidseq_ext_endswap: |
232 assumes "swapidseq_ext S n p" "a \<noteq> b" |
232 assumes "swapidseq_ext S n p" "a \<noteq> b" |
233 shows "swapidseq_ext (insert a (insert b S)) (Suc n) (p \<circ> (Fun.swap a b id))" |
233 shows "swapidseq_ext (insert a (insert b S)) (Suc n) (p \<circ> (transpose a b))" |
234 using assms |
234 using assms |
235 proof (induction n arbitrary: S p a b) |
235 proof (induction n arbitrary: S p a b) |
236 case 0 hence "p = id" |
236 case 0 hence "p = id" |
237 using swapidseq_ext_zero_imp_id by blast |
237 using swapidseq_ext_zero_imp_id by blast |
238 thus ?case |
238 thus ?case |
239 using 0 by (metis comp_id id_comp swapidseq_ext.comp) |
239 using 0 by (metis comp_id id_comp swapidseq_ext.comp) |
240 next |
240 next |
241 case (Suc n) |
241 case (Suc n) |
242 then obtain c d S' and p' :: "'a \<Rightarrow> 'a" |
242 then obtain c d S' and p' :: "'a \<Rightarrow> 'a" |
243 where cd: "c \<noteq> d" and S: "S = (insert c (insert d S'))" "swapidseq_ext S' n p'" |
243 where cd: "c \<noteq> d" and S: "S = (insert c (insert d S'))" "swapidseq_ext S' n p'" |
244 and p: "p = (Fun.swap c d id) \<circ> p'" |
244 and p: "p = transpose c d \<circ> p'" |
245 using swapidseq_ext_backwards[OF Suc(2)] by blast |
245 using swapidseq_ext_backwards[OF Suc(2)] by blast |
246 hence "swapidseq_ext (insert a (insert b S')) (Suc n) (p' \<circ> (Fun.swap a b id))" |
246 hence "swapidseq_ext (insert a (insert b S')) (Suc n) (p' \<circ> (transpose a b))" |
247 by (simp add: Suc.IH Suc.prems(2)) |
247 by (simp add: Suc.IH Suc.prems(2)) |
248 hence "swapidseq_ext (insert c (insert d (insert a (insert b S')))) (Suc (Suc n)) |
248 hence "swapidseq_ext (insert c (insert d (insert a (insert b S')))) (Suc (Suc n)) |
249 ((Fun.swap c d id) \<circ> p' \<circ> (Fun.swap a b id))" |
249 (transpose c d \<circ> p' \<circ> (transpose a b))" |
250 by (metis cd fun.map_comp swapidseq_ext.comp) |
250 by (metis cd fun.map_comp swapidseq_ext.comp) |
251 thus ?case |
251 thus ?case |
252 by (metis S(1) p insert_commute) |
252 by (metis S(1) p insert_commute) |
253 qed |
253 qed |
254 |
254 |
313 then obtain q r U V |
313 then obtain q r U V |
314 where q: "swapidseq_ext U (n - Suc m) q" and r: "swapidseq_ext V (Suc m) r" |
314 where q: "swapidseq_ext U (n - Suc m) q" and r: "swapidseq_ext V (Suc m) r" |
315 and p: "p = q \<circ> r" and S: "U \<union> V = S" |
315 and p: "p = q \<circ> r" and S: "U \<union> V = S" |
316 by blast |
316 by blast |
317 obtain a b r' V' |
317 obtain a b r' V' |
318 where "a \<noteq> b" and r': "V = (insert a (insert b V'))" "swapidseq_ext V' m r'" "r = (Fun.swap a b id) \<circ> r'" |
318 where "a \<noteq> b" and r': "V = (insert a (insert b V'))" "swapidseq_ext V' m r'" "r = (transpose a b) \<circ> r'" |
319 using swapidseq_ext_backwards[OF r] by blast |
319 using swapidseq_ext_backwards[OF r] by blast |
320 have "swapidseq_ext (insert a (insert b U)) (n - m) (q \<circ> (Fun.swap a b id))" |
320 have "swapidseq_ext (insert a (insert b U)) (n - m) (q \<circ> (transpose a b))" |
321 using swapidseq_ext_endswap[OF q \<open>a \<noteq> b\<close>] step(2) by (metis Suc_diff_Suc) |
321 using swapidseq_ext_endswap[OF q \<open>a \<noteq> b\<close>] step(2) by (metis Suc_diff_Suc) |
322 hence "?split m (q \<circ> (Fun.swap a b id)) r' (insert a (insert b U)) V'" |
322 hence "?split m (q \<circ> (transpose a b)) r' (insert a (insert b U)) V'" |
323 using r' S unfolding p by fastforce |
323 using r' S unfolding p by fastforce |
324 thus ?case by blast |
324 thus ?case by blast |
325 qed |
325 qed |
326 thus ?thesis |
326 thus ?thesis |
327 using that by blast |
327 using that by blast |
348 fix p assume "p \<in> three_cycles n" |
348 fix p assume "p \<in> three_cycles n" |
349 then obtain cs where cs: "p = cycle_of_list cs" "cycle cs" "length cs = 3" "set cs \<subseteq> {1..n}" |
349 then obtain cs where cs: "p = cycle_of_list cs" "cycle cs" "length cs = 3" "set cs \<subseteq> {1..n}" |
350 by auto |
350 by auto |
351 obtain a b c where cs_def: "cs = [ a, b, c ]" |
351 obtain a b c where cs_def: "cs = [ a, b, c ]" |
352 using stupid_lemma[OF cs(3)] by auto |
352 using stupid_lemma[OF cs(3)] by auto |
353 have "swapidseq (Suc (Suc 0)) ((Fun.swap a b id) \<circ> (Fun.swap b c id))" |
353 have "swapidseq (Suc (Suc 0)) ((transpose a b) \<circ> (Fun.swap b c id))" |
354 using comp_Suc[OF comp_Suc[OF id], of b c a b] cs(2) unfolding cs_def by simp |
354 using comp_Suc[OF comp_Suc[OF id], of b c a b] cs(2) unfolding cs_def by simp |
355 hence "evenperm p" |
355 hence "evenperm p" |
356 using cs(1) unfolding cs_def by (simp add: evenperm_unique) |
356 using cs(1) unfolding cs_def by (simp add: evenperm_unique) |
357 thus "p \<in> carrier (alt_group n)" |
357 thus "p \<in> carrier (alt_group n)" |
358 using permutes_subset[OF cycle_permutes cs(4)] |
358 using permutes_subset[OF cycle_permutes cs(4)] |
393 { fix S :: "nat set" and q :: "nat \<Rightarrow> nat" |
393 { fix S :: "nat set" and q :: "nat \<Rightarrow> nat" |
394 assume seq: "swapidseq_ext S (Suc (Suc 0)) q" and S: "S \<subseteq> {1..n}" |
394 assume seq: "swapidseq_ext S (Suc (Suc 0)) q" and S: "S \<subseteq> {1..n}" |
395 have "q \<in> generate (alt_group n) (three_cycles n)" |
395 have "q \<in> generate (alt_group n) (three_cycles n)" |
396 proof - |
396 proof - |
397 obtain a b q' where ab: "a \<noteq> b" "a \<in> S" "b \<in> S" |
397 obtain a b q' where ab: "a \<noteq> b" "a \<in> S" "b \<in> S" |
398 and q': "swapidseq_ext S (Suc 0) q'" "q = (Fun.swap a b id) \<circ> q'" |
398 and q': "swapidseq_ext S (Suc 0) q'" "q = (transpose a b) \<circ> q'" |
399 using swapidseq_ext_backwards'[OF seq] by auto |
399 using swapidseq_ext_backwards'[OF seq] by auto |
400 obtain c d where cd: "c \<noteq> d" "c \<in> S" "d \<in> S" |
400 obtain c d where cd: "c \<noteq> d" "c \<in> S" "d \<in> S" |
401 and q: "q = (Fun.swap a b id) \<circ> (Fun.swap c d id)" |
401 and q: "q = (transpose a b) \<circ> (Fun.swap c d id)" |
402 using swapidseq_ext_backwards'[OF q'(1)] |
402 using swapidseq_ext_backwards'[OF q'(1)] |
403 swapidseq_ext_zero_imp_id |
403 swapidseq_ext_zero_imp_id |
404 unfolding q'(2) |
404 unfolding q'(2) |
405 by fastforce |
405 by fastforce |
406 |
406 |
414 ultimately show ?thesis |
414 ultimately show ?thesis |
415 using aux_lemma1[OF ab(1)] cd(1) eq by simp |
415 using aux_lemma1[OF ab(1)] cd(1) eq by simp |
416 next |
416 next |
417 case ineq |
417 case ineq |
418 hence "q = cycle_of_list [ a, b, c ] \<circ> cycle_of_list [ b, c, d ]" |
418 hence "q = cycle_of_list [ a, b, c ] \<circ> cycle_of_list [ b, c, d ]" |
419 unfolding q by (simp add: comp_swap) |
419 unfolding q by (simp add: swap_nilpotent o_assoc) |
420 moreover have "{ a, b, c } \<subseteq> {1..n}" and "{ b, c, d } \<subseteq> {1..n}" |
420 moreover have "{ a, b, c } \<subseteq> {1..n}" and "{ b, c, d } \<subseteq> {1..n}" |
421 using ab cd S by blast+ |
421 using ab cd S by blast+ |
422 ultimately show ?thesis |
422 ultimately show ?thesis |
423 using eng[OF aux_lemma1[OF ab(1) ineq] aux_lemma1[OF ineq cd(1)]] |
423 using eng[OF aux_lemma1[OF ab(1) ineq] aux_lemma1[OF ineq cd(1)]] |
424 unfolding alt_group_mult by simp |
424 unfolding alt_group_mult by simp |
497 ultimately have "q \<circ> p \<circ> (inv' q) = cycle_of_list [ a, c, b ]" |
497 ultimately have "q \<circ> p \<circ> (inv' q) = cycle_of_list [ a, c, b ]" |
498 using conjugation_of_cycle[OF cs(2), of q] |
498 using conjugation_of_cycle[OF cs(2), of q] |
499 unfolding sym[OF cs(1)] unfolding cs_def by simp |
499 unfolding sym[OF cs(1)] unfolding cs_def by simp |
500 also have " ... = p \<circ> p" |
500 also have " ... = p \<circ> p" |
501 using cs(2) unfolding cs(1) cs_def |
501 using cs(2) unfolding cs(1) cs_def |
502 by (auto, metis comp_id comp_swap swap_commute swap_triple) |
502 by (simp add: comp_swap swap_commute transpose_comp_triple) |
503 finally have "q \<circ> p \<circ> (inv' q) = p \<circ> p" . |
503 finally have "q \<circ> p \<circ> (inv' q) = p \<circ> p" . |
504 moreover have "bij p" |
504 moreover have "bij p" |
505 unfolding cs(1) cs_def by (simp add: bij_comp) |
505 unfolding cs(1) cs_def by (simp add: bij_comp) |
506 ultimately have p: "q \<circ> p \<circ> (inv' q) \<circ> (inv' p) = p" |
506 ultimately have p: "q \<circ> p \<circ> (inv' q) \<circ> (inv' p) = p" |
507 by (simp add: bijection.intro bijection.inv_comp_right comp_assoc) |
507 by (simp add: bijection.intro bijection.inv_comp_right comp_assoc) |