210 "sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0" |
210 "sort_of a \<noteq> sort_of b \<Longrightarrow> (a \<rightleftharpoons> b) = 0" |
211 by (rule Rep_perm_ext) (simp add: Rep_perm_simps) |
211 by (rule Rep_perm_ext) (simp add: Rep_perm_simps) |
212 |
212 |
213 lemma swap_cancel: |
213 lemma swap_cancel: |
214 "(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0" |
214 "(a \<rightleftharpoons> b) + (a \<rightleftharpoons> b) = 0" |
215 by (rule Rep_perm_ext) |
215 by (rule Rep_perm_ext) |
216 (simp add: Rep_perm_simps expand_fun_eq) |
216 (simp add: Rep_perm_simps expand_fun_eq) |
217 |
217 |
218 lemma swap_self [simp]: |
218 lemma swap_self [simp]: |
219 "(a \<rightleftharpoons> a) = 0" |
219 "(a \<rightleftharpoons> a) = 0" |
220 by (rule Rep_perm_ext, simp add: Rep_perm_simps expand_fun_eq) |
220 by (rule Rep_perm_ext, simp add: Rep_perm_simps expand_fun_eq) |
221 |
221 |
349 apply (simp add: permute_perm_def diff_minus minus_add add_assoc) |
349 apply (simp add: permute_perm_def diff_minus minus_add add_assoc) |
350 done |
350 done |
351 |
351 |
352 end |
352 end |
353 |
353 |
354 lemma permute_self: "p \<bullet> p = p" |
354 lemma permute_self: |
355 unfolding permute_perm_def by (simp add: diff_minus add_assoc) |
355 shows "p \<bullet> p = p" |
|
356 unfolding permute_perm_def |
|
357 by (simp add: diff_minus add_assoc) |
356 |
358 |
357 lemma permute_eqvt: |
359 lemma permute_eqvt: |
358 shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)" |
360 shows "p \<bullet> (q \<bullet> x) = (p \<bullet> q) \<bullet> (p \<bullet> x)" |
359 unfolding permute_perm_def by simp |
361 unfolding permute_perm_def by simp |
360 |
362 |
427 |
429 |
428 lemma permute_set_eq: |
430 lemma permute_set_eq: |
429 fixes x::"'a::pt" |
431 fixes x::"'a::pt" |
430 and p::"perm" |
432 and p::"perm" |
431 shows "(p \<bullet> X) = {p \<bullet> x | x. x \<in> X}" |
433 shows "(p \<bullet> X) = {p \<bullet> x | x. x \<in> X}" |
432 apply(auto simp add: permute_fun_def permute_bool_def mem_def) |
434 unfolding permute_fun_def |
|
435 unfolding permute_bool_def |
|
436 apply(auto simp add: mem_def) |
433 apply(rule_tac x="- p \<bullet> x" in exI) |
437 apply(rule_tac x="- p \<bullet> x" in exI) |
434 apply(simp) |
438 apply(simp) |
435 done |
439 done |
436 |
440 |
437 lemma permute_set_eq_image: |
441 lemma permute_set_eq_image: |
438 shows "p \<bullet> X = permute p ` X" |
442 shows "p \<bullet> X = permute p ` X" |
439 unfolding permute_set_eq by auto |
443 unfolding permute_set_eq by auto |
440 |
444 |
441 lemma permute_set_eq_vimage: |
445 lemma permute_set_eq_vimage: |
442 shows "p \<bullet> X = permute (- p) -` X" |
446 shows "p \<bullet> X = permute (- p) -` X" |
443 unfolding permute_fun_def permute_bool_def |
447 unfolding permute_fun_def permute_bool_def |
444 unfolding vimage_def Collect_def mem_def .. |
448 unfolding vimage_def Collect_def mem_def .. |
445 |
449 |
446 lemma swap_set_not_in: |
450 lemma swap_set_not_in: |
447 assumes a: "a \<notin> S" "b \<notin> S" |
451 assumes a: "a \<notin> S" "b \<notin> S" |
448 shows "(a \<rightleftharpoons> b) \<bullet> S = S" |
452 shows "(a \<rightleftharpoons> b) \<bullet> S = S" |
449 using a by (auto simp add: permute_set_eq swap_atom) |
453 unfolding permute_set_eq |
|
454 using a by (auto simp add: swap_atom) |
450 |
455 |
451 lemma swap_set_in: |
456 lemma swap_set_in: |
452 assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b" |
457 assumes a: "a \<in> S" "b \<notin> S" "sort_of a = sort_of b" |
453 shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S" |
458 shows "(a \<rightleftharpoons> b) \<bullet> S \<noteq> S" |
454 using a by (auto simp add: permute_set_eq swap_atom) |
459 unfolding permute_set_eq |
|
460 using a by (auto simp add: swap_atom) |
455 |
461 |
456 |
462 |
457 subsection {* Permutations for units *} |
463 subsection {* Permutations for units *} |
458 |
464 |
459 instantiation unit :: pt |
465 instantiation unit :: pt |
460 begin |
466 begin |
461 |
467 |
462 definition "p \<bullet> (u::unit) = u" |
468 definition "p \<bullet> (u::unit) = u" |
463 |
469 |
464 instance proof |
470 instance |
465 qed (simp_all add: permute_unit_def) |
471 by (default) (simp_all add: permute_unit_def) |
466 |
472 |
467 end |
473 end |
468 |
474 |
469 |
475 |
470 subsection {* Permutations for products *} |
476 subsection {* Permutations for products *} |
523 permute_option |
529 permute_option |
524 where |
530 where |
525 "p \<bullet> None = None" |
531 "p \<bullet> None = None" |
526 | "p \<bullet> (Some x) = Some (p \<bullet> x)" |
532 | "p \<bullet> (Some x) = Some (p \<bullet> x)" |
527 |
533 |
528 instance proof |
534 instance |
529 qed (induct_tac [!] x, simp_all) |
535 by (default) (induct_tac [!] x, simp_all) |
530 |
536 |
531 end |
537 end |
532 |
538 |
533 subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *} |
539 subsection {* Permutations for @{typ char}, @{typ nat}, and @{typ int} *} |
534 |
540 |
535 instantiation char :: pt |
541 instantiation char :: pt |
536 begin |
542 begin |
537 |
543 |
538 definition "p \<bullet> (c::char) = c" |
544 definition "p \<bullet> (c::char) = c" |
539 |
545 |
540 instance proof |
546 instance |
541 qed (simp_all add: permute_char_def) |
547 by (default) (simp_all add: permute_char_def) |
542 |
548 |
543 end |
549 end |
544 |
550 |
545 instantiation nat :: pt |
551 instantiation nat :: pt |
546 begin |
552 begin |
547 |
553 |
548 definition "p \<bullet> (n::nat) = n" |
554 definition "p \<bullet> (n::nat) = n" |
549 |
555 |
550 instance proof |
556 instance |
551 qed (simp_all add: permute_nat_def) |
557 by (default) (simp_all add: permute_nat_def) |
552 |
558 |
553 end |
559 end |
554 |
560 |
555 instantiation int :: pt |
561 instantiation int :: pt |
556 begin |
562 begin |
557 |
563 |
558 definition "p \<bullet> (i::int) = i" |
564 definition "p \<bullet> (i::int) = i" |
559 |
565 |
560 instance proof |
566 instance |
561 qed (simp_all add: permute_int_def) |
567 by (default) (simp_all add: permute_int_def) |
562 |
568 |
563 end |
569 end |
564 |
570 |
565 |
571 |
566 section {* Pure types *} |
572 section {* Pure types *} |
677 shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" |
683 shows "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" |
678 proof - |
684 proof - |
679 have "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
685 have "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
680 unfolding fresh_def supp_def by simp |
686 unfolding fresh_def supp_def by simp |
681 also have "\<dots> \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> p \<bullet> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
687 also have "\<dots> \<longleftrightarrow> finite {b. (p \<bullet> a \<rightleftharpoons> p \<bullet> b) \<bullet> p \<bullet> x \<noteq> p \<bullet> x}" |
682 using bij_permute by (rule finite_Collect_bij [symmetric]) |
688 using bij_permute by (rule finite_Collect_bij[symmetric]) |
683 also have "\<dots> \<longleftrightarrow> finite {b. p \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> p \<bullet> x}" |
689 also have "\<dots> \<longleftrightarrow> finite {b. p \<bullet> (a \<rightleftharpoons> b) \<bullet> x \<noteq> p \<bullet> x}" |
684 by (simp only: permute_eqvt [of p] swap_eqvt) |
690 by (simp only: permute_eqvt [of p] swap_eqvt) |
685 also have "\<dots> \<longleftrightarrow> finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}" |
691 also have "\<dots> \<longleftrightarrow> finite {b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x}" |
686 by (simp only: permute_eq_iff) |
692 by (simp only: permute_eq_iff) |
687 also have "\<dots> \<longleftrightarrow> a \<sharp> x" |
693 also have "\<dots> \<longleftrightarrow> a \<sharp> x" |
688 unfolding fresh_def supp_def by simp |
694 unfolding fresh_def supp_def by simp |
689 finally show ?thesis . |
695 finally show "(p \<bullet> a) \<sharp> (p \<bullet> x) \<longleftrightarrow> a \<sharp> x" . |
690 qed |
696 qed |
691 |
697 |
692 lemma fresh_eqvt: |
698 lemma fresh_eqvt: |
693 shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)" |
699 shows "p \<bullet> (a \<sharp> x) = (p \<bullet> a) \<sharp> (p \<bullet> x)" |
694 by (simp add: permute_bool_def fresh_permute_iff) |
700 unfolding permute_bool_def |
|
701 by (simp add: fresh_permute_iff) |
695 |
702 |
696 lemma supp_eqvt: |
703 lemma supp_eqvt: |
697 fixes p :: "perm" |
704 fixes p :: "perm" |
698 and x :: "'a::pt" |
705 and x :: "'a::pt" |
699 shows "p \<bullet> (supp x) = supp (p \<bullet> x)" |
706 shows "p \<bullet> (supp x) = supp (p \<bullet> x)" |
700 unfolding supp_conv_fresh |
707 unfolding supp_conv_fresh |
701 unfolding permute_fun_def Collect_def |
708 unfolding Collect_def |
|
709 unfolding permute_fun_def |
702 by (simp add: Not_eqvt fresh_eqvt) |
710 by (simp add: Not_eqvt fresh_eqvt) |
703 |
711 |
704 subsection {* supports *} |
712 subsection {* supports *} |
705 |
713 |
706 definition |
714 definition |
713 and x :: "'a::pt" |
721 and x :: "'a::pt" |
714 assumes a1: "S supports x" |
722 assumes a1: "S supports x" |
715 and a2: "finite S" |
723 and a2: "finite S" |
716 shows "(supp x) \<subseteq> S" |
724 shows "(supp x) \<subseteq> S" |
717 proof (rule ccontr) |
725 proof (rule ccontr) |
718 assume "\<not>(supp x \<subseteq> S)" |
726 assume "\<not> (supp x \<subseteq> S)" |
719 then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto |
727 then obtain a where b1: "a \<in> supp x" and b2: "a \<notin> S" by auto |
720 from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" by (unfold supports_def) (auto) |
728 from a1 b2 have "\<forall>b. b \<notin> S \<longrightarrow> (a \<rightleftharpoons> b) \<bullet> x = x" unfolding supports_def by auto |
721 hence "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto |
729 then have "{b. (a \<rightleftharpoons> b) \<bullet> x \<noteq> x} \<subseteq> S" by auto |
722 with a2 have "finite {b. (a \<rightleftharpoons> b)\<bullet>x \<noteq> x}" by (simp add: finite_subset) |
730 with a2 have "finite {b. (a \<rightleftharpoons> b)\<bullet>x \<noteq> x}" by (simp add: finite_subset) |
723 then have "a \<notin> (supp x)" unfolding supp_def by simp |
731 then have "a \<notin> (supp x)" unfolding supp_def by simp |
724 with b1 show False by simp |
732 with b1 show False by simp |
725 qed |
733 qed |
726 |
734 |
736 qed |
744 qed |
737 |
745 |
738 lemma supp_supports: |
746 lemma supp_supports: |
739 fixes x :: "'a::pt" |
747 fixes x :: "'a::pt" |
740 shows "(supp x) supports x" |
748 shows "(supp x) supports x" |
741 proof (unfold supports_def, intro strip) |
749 unfolding supports_def |
|
750 proof (intro strip) |
742 fix a b |
751 fix a b |
743 assume "a \<notin> (supp x) \<and> b \<notin> (supp x)" |
752 assume "a \<notin> (supp x) \<and> b \<notin> (supp x)" |
744 then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def) |
753 then have "a \<sharp> x" and "b \<sharp> x" by (simp_all add: fresh_def) |
745 then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (rule swap_fresh_fresh) |
754 then show "(a \<rightleftharpoons> b) \<bullet> x = x" by (simp add: swap_fresh_fresh) |
746 qed |
755 qed |
747 |
756 |
748 lemma supp_is_least_supports: |
757 lemma supp_is_least_supports: |
749 fixes S :: "atom set" |
758 fixes S :: "atom set" |
750 and x :: "'a::pt" |
759 and x :: "'a::pt" |
835 by (metis add_diff_cancel minus_perm_def) |
844 by (metis add_diff_cancel minus_perm_def) |
836 |
845 |
837 lemma supports_perm: |
846 lemma supports_perm: |
838 shows "{a. p \<bullet> a \<noteq> a} supports p" |
847 shows "{a. p \<bullet> a \<noteq> a} supports p" |
839 unfolding supports_def |
848 unfolding supports_def |
840 by (simp add: perm_swap_eq swap_eqvt) |
849 unfolding perm_swap_eq |
|
850 by (simp add: swap_eqvt) |
841 |
851 |
842 lemma finite_perm_lemma: |
852 lemma finite_perm_lemma: |
843 shows "finite {a::atom. p \<bullet> a \<noteq> a}" |
853 shows "finite {a::atom. p \<bullet> a \<noteq> a}" |
844 using finite_Rep_perm [of p] |
854 using finite_Rep_perm [of p] |
845 unfolding permute_atom_def . |
855 unfolding permute_atom_def . |
853 apply (auto simp add: expand_perm_eq swap_atom) |
863 apply (auto simp add: expand_perm_eq swap_atom) |
854 done |
864 done |
855 |
865 |
856 lemma fresh_perm: |
866 lemma fresh_perm: |
857 shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a" |
867 shows "a \<sharp> p \<longleftrightarrow> p \<bullet> a = a" |
858 unfolding fresh_def by (simp add: supp_perm) |
868 unfolding fresh_def |
|
869 by (simp add: supp_perm) |
859 |
870 |
860 lemma supp_swap: |
871 lemma supp_swap: |
861 shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})" |
872 shows "supp (a \<rightleftharpoons> b) = (if a = b \<or> sort_of a \<noteq> sort_of b then {} else {a, b})" |
862 by (auto simp add: supp_perm swap_atom) |
873 by (auto simp add: supp_perm swap_atom) |
863 |
874 |
884 |
895 |
885 lemma fresh_minus_perm: |
896 lemma fresh_minus_perm: |
886 fixes p::perm |
897 fixes p::perm |
887 shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p" |
898 shows "a \<sharp> (- p) \<longleftrightarrow> a \<sharp> p" |
888 unfolding fresh_def |
899 unfolding fresh_def |
889 apply(auto simp add: supp_perm) |
900 unfolding supp_perm |
890 apply(metis permute_minus_cancel)+ |
901 apply(simp) |
|
902 apply(metis permute_minus_cancel) |
891 done |
903 done |
892 |
904 |
893 lemma supp_minus_perm: |
905 lemma supp_minus_perm: |
894 fixes p::perm |
906 fixes p::perm |
895 shows "supp (- p) = supp p" |
907 shows "supp (- p) = supp p" |
1021 apply (simp_all add: supp_Nil supp_Cons finite_supp) |
1033 apply (simp_all add: supp_Nil supp_Cons finite_supp) |
1022 done |
1034 done |
1023 |
1035 |
1024 section {* Support and freshness for applications *} |
1036 section {* Support and freshness for applications *} |
1025 |
1037 |
|
1038 lemma fresh_conv_MOST: |
|
1039 shows "a \<sharp> x \<longleftrightarrow> (MOST b. (a \<rightleftharpoons> b) \<bullet> x = x)" |
|
1040 unfolding fresh_def supp_def |
|
1041 unfolding MOST_iff_cofinite by simp |
|
1042 |
|
1043 lemma fresh_fun_app: |
|
1044 assumes "a \<sharp> f" and "a \<sharp> x" |
|
1045 shows "a \<sharp> f x" |
|
1046 using assms |
|
1047 unfolding fresh_conv_MOST |
|
1048 unfolding permute_fun_app_eq |
|
1049 by (elim MOST_rev_mp, simp) |
|
1050 |
1026 lemma supp_fun_app: |
1051 lemma supp_fun_app: |
|
1052 shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)" |
|
1053 using fresh_fun_app |
|
1054 unfolding fresh_def |
|
1055 by auto |
|
1056 |
|
1057 (* alternative proof *) |
|
1058 lemma |
1027 shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)" |
1059 shows "supp (f x) \<subseteq> (supp f) \<union> (supp x)" |
1028 proof (rule subsetCI) |
1060 proof (rule subsetCI) |
1029 fix a::"atom" |
1061 fix a::"atom" |
1030 assume a: "a \<in> supp (f x)" |
1062 assume a: "a \<in> supp (f x)" |
1031 assume b: "a \<notin> supp f \<union> supp x" |
1063 assume b: "a \<notin> supp f \<union> supp x" |
1040 then have "a \<notin> supp (f x)" unfolding supp_def |
1072 then have "a \<notin> supp (f x)" unfolding supp_def |
1041 by (simp add: permute_fun_app_eq) |
1073 by (simp add: permute_fun_app_eq) |
1042 with a show "False" by simp |
1074 with a show "False" by simp |
1043 qed |
1075 qed |
1044 |
1076 |
1045 lemma fresh_fun_app: |
|
1046 shows "a \<sharp> (f, x) \<Longrightarrow> a \<sharp> f x" |
|
1047 unfolding fresh_def |
|
1048 using supp_fun_app |
|
1049 by (auto simp add: supp_Pair) |
|
1050 |
|
1051 lemma fresh_fun_eqvt_app: |
1077 lemma fresh_fun_eqvt_app: |
1052 assumes a: "\<forall>p. p \<bullet> f = f" |
1078 assumes a: "\<forall>p. p \<bullet> f = f" |
1053 shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1079 shows "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1054 proof - |
1080 proof - |
1055 from a have b: "supp f = {}" |
1081 from a have "supp f = {}" |
1056 unfolding supp_def by simp |
1082 unfolding supp_def by simp |
1057 show "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1083 then show "a \<sharp> x \<Longrightarrow> a \<sharp> f x" |
1058 unfolding fresh_def |
1084 unfolding fresh_def |
1059 using supp_fun_app b |
1085 using supp_fun_app |
1060 by auto |
1086 by auto |
1061 qed |
1087 qed |
1062 |
1088 |
1063 (* nominal infrastructure *) |
1089 section {* library functions for the nominal infrastructure *} |
1064 use "nominal_library.ML" |
1090 use "nominal_library.ML" |
1065 |
1091 |
1066 end |
1092 end |