30 |
30 |
31 (* permutation on sets *) |
31 (* permutation on sets *) |
32 defs (unchecked overloaded) |
32 defs (unchecked overloaded) |
33 perm_set_def: "pi\<bullet>(X::'a set) \<equiv> {pi\<bullet>a | a. a\<in>X}" |
33 perm_set_def: "pi\<bullet>(X::'a set) \<equiv> {pi\<bullet>a | a. a\<in>X}" |
34 |
34 |
35 lemma perm_empty: |
35 lemma empty_eqvt: |
36 shows "pi\<bullet>{} = {}" |
36 shows "pi\<bullet>{} = {}" |
37 by (simp add: perm_set_def) |
37 by (simp add: perm_set_def) |
38 |
38 |
39 lemma perm_union: |
39 lemma union_eqvt: |
40 shows "pi \<bullet> (X \<union> Y) = (pi \<bullet> X) \<union> (pi \<bullet> Y)" |
40 shows "pi \<bullet> (X \<union> Y) = (pi \<bullet> X) \<union> (pi \<bullet> Y)" |
41 by (auto simp add: perm_set_def) |
41 by (auto simp add: perm_set_def) |
42 |
42 |
43 lemma perm_insert: |
43 lemma insert_eqvt: |
44 shows "pi\<bullet>(insert x X) = insert (pi\<bullet>x) (pi\<bullet>X)" |
44 shows "pi\<bullet>(insert x X) = insert (pi\<bullet>x) (pi\<bullet>X)" |
45 by (auto simp add: perm_set_def) |
45 by (auto simp add: perm_set_def) |
46 |
46 |
47 (* permutation on units and products *) |
47 (* permutation on units and products *) |
48 primrec (unchecked perm_unit) |
48 primrec (unchecked perm_unit) |
49 "pi\<bullet>() = ()" |
49 "pi\<bullet>() = ()" |
50 |
50 |
51 primrec (unchecked perm_prod) |
51 primrec (unchecked perm_prod) |
52 "pi\<bullet>(a,b) = (pi\<bullet>a,pi\<bullet>b)" |
52 "pi\<bullet>(a,b) = (pi\<bullet>a,pi\<bullet>b)" |
53 |
53 |
54 lemma perm_fst: |
54 lemma fst_eqvt: |
55 "pi\<bullet>(fst x) = fst (pi\<bullet>x)" |
55 "pi\<bullet>(fst x) = fst (pi\<bullet>x)" |
56 by (cases x) simp |
56 by (cases x) simp |
57 |
57 |
58 lemma perm_snd: |
58 lemma snd_eqvt: |
59 "pi\<bullet>(snd x) = snd (pi\<bullet>x)" |
59 "pi\<bullet>(snd x) = snd (pi\<bullet>x)" |
60 by (cases x) simp |
60 by (cases x) simp |
61 |
61 |
62 (* permutation on lists *) |
62 (* permutation on lists *) |
63 primrec (unchecked perm_list) |
63 primrec (unchecked perm_list) |
64 perm_nil_def: "pi\<bullet>[] = []" |
64 nil_eqvt: "pi\<bullet>[] = []" |
65 perm_cons_def: "pi\<bullet>(x#xs) = (pi\<bullet>x)#(pi\<bullet>xs)" |
65 cons_eqvt: "pi\<bullet>(x#xs) = (pi\<bullet>x)#(pi\<bullet>xs)" |
66 |
66 |
67 lemma perm_append: |
67 lemma append_eqvt: |
68 fixes pi :: "'x prm" |
68 fixes pi :: "'x prm" |
69 and l1 :: "'a list" |
69 and l1 :: "'a list" |
70 and l2 :: "'a list" |
70 and l2 :: "'a list" |
71 shows "pi\<bullet>(l1@l2) = (pi\<bullet>l1)@(pi\<bullet>l2)" |
71 shows "pi\<bullet>(l1@l2) = (pi\<bullet>l1)@(pi\<bullet>l2)" |
72 by (induct l1) auto |
72 by (induct l1) auto |
73 |
73 |
74 lemma perm_rev: |
74 lemma rev_eqvt: |
75 fixes pi :: "'x prm" |
75 fixes pi :: "'x prm" |
76 and l :: "'a list" |
76 and l :: "'a list" |
77 shows "pi\<bullet>(rev l) = rev (pi\<bullet>l)" |
77 shows "pi\<bullet>(rev l) = rev (pi\<bullet>l)" |
78 by (induct l) (simp_all add: perm_append) |
78 by (induct l) (simp_all add: append_eqvt) |
79 |
79 |
80 (* permutation on functions *) |
80 (* permutation on functions *) |
81 defs (unchecked overloaded) |
81 defs (unchecked overloaded) |
82 perm_fun_def: "pi\<bullet>(f::'a\<Rightarrow>'b) \<equiv> (\<lambda>x. pi\<bullet>f((rev pi)\<bullet>x))" |
82 perm_fun_def: "pi\<bullet>(f::'a\<Rightarrow>'b) \<equiv> (\<lambda>x. pi\<bullet>f((rev pi)\<bullet>x))" |
83 |
83 |
|
84 lemma swap_fun: |
|
85 shows "[(a,b)]\<bullet>(f::'a\<Rightarrow>'b) \<equiv> (\<lambda>x. [(a,b)]\<bullet>f([(a,b)]\<bullet>x))" |
|
86 by (unfold perm_fun_def,auto) |
|
87 |
84 (* permutation on bools *) |
88 (* permutation on bools *) |
85 primrec (unchecked perm_bool) |
89 primrec (unchecked perm_bool) |
86 perm_true_def: "pi\<bullet>True = True" |
90 true_eqvt: "pi\<bullet>True = True" |
87 perm_false_def: "pi\<bullet>False = False" |
91 false_eqvt: "pi\<bullet>False = False" |
88 |
92 |
89 lemma perm_bool: |
93 lemma perm_bool: |
90 shows "pi\<bullet>(b::bool) = b" |
94 shows "pi\<bullet>(b::bool) = b" |
91 by (cases b) auto |
95 by (cases b) auto |
92 |
96 |
98 lemma perm_boolE: |
102 lemma perm_boolE: |
99 assumes a: "pi\<bullet>P" |
103 assumes a: "pi\<bullet>P" |
100 shows "P" |
104 shows "P" |
101 using a by (simp add: perm_bool) |
105 using a by (simp add: perm_bool) |
102 |
106 |
103 lemma perm_if: |
107 lemma if_eqvt: |
104 fixes pi::"'a prm" |
108 fixes pi::"'a prm" |
105 shows "pi\<bullet>(if b then c1 else c2) = (if (pi\<bullet>b) then (pi\<bullet>c1) else (pi\<bullet>c2))" |
109 shows "pi\<bullet>(if b then c1 else c2) = (if (pi\<bullet>b) then (pi\<bullet>c1) else (pi\<bullet>c2))" |
106 apply(simp add: perm_fun_def) |
110 apply(simp add: perm_fun_def) |
107 done |
111 done |
108 |
112 |
109 |
|
110 (* permutation on options *) |
113 (* permutation on options *) |
111 |
114 |
112 primrec (unchecked perm_option) |
115 primrec (unchecked perm_option) |
113 perm_some_def: "pi\<bullet>Some(x) = Some(pi\<bullet>x)" |
116 some_eqvt: "pi\<bullet>Some(x) = Some(pi\<bullet>x)" |
114 perm_none_def: "pi\<bullet>None = None" |
117 none_eqvt: "pi\<bullet>None = None" |
115 |
118 |
116 (* a "private" copy of the option type used in the abstraction function *) |
119 (* a "private" copy of the option type used in the abstraction function *) |
117 datatype 'a noption = nSome 'a | nNone |
120 datatype 'a noption = nSome 'a | nNone |
118 |
121 |
119 primrec (unchecked perm_noption) |
122 primrec (unchecked perm_noption) |
120 perm_nSome_def: "pi\<bullet>nSome(x) = nSome(pi\<bullet>x)" |
123 nSome_eqvt: "pi\<bullet>nSome(x) = nSome(pi\<bullet>x)" |
121 perm_nNone_def: "pi\<bullet>nNone = nNone" |
124 nNone_eqvt: "pi\<bullet>nNone = nNone" |
122 |
125 |
123 (* a "private" copy of the product type used in the nominal induct method *) |
126 (* a "private" copy of the product type used in the nominal induct method *) |
124 datatype ('a,'b) nprod = nPair 'a 'b |
127 datatype ('a,'b) nprod = nPair 'a 'b |
125 |
128 |
126 primrec (unchecked perm_nprod) |
129 primrec (unchecked perm_nprod) |
3001 apply(rule pt_perm_compose[OF pt, OF at]) |
3045 apply(rule pt_perm_compose[OF pt, OF at]) |
3002 apply(simp add: pt_rev_pi[OF pt_prm, OF at]) |
3046 apply(simp add: pt_rev_pi[OF pt_prm, OF at]) |
3003 done |
3047 done |
3004 qed |
3048 qed |
3005 |
3049 |
|
3050 (************************) |
|
3051 (* Various eqvt-lemmas *) |
|
3052 |
|
3053 lemma Zero_nat_eqvt: |
|
3054 shows "pi\<bullet> (0::nat) = 0" |
|
3055 by (auto simp add: perm_nat_def) |
|
3056 |
|
3057 lemma One_nat_eqvt: |
|
3058 shows "pi\<bullet> (1::nat) = 1" |
|
3059 by (simp add: perm_nat_def) |
|
3060 |
|
3061 lemma Suc_eqvt: |
|
3062 shows "pi\<bullet> Suc x = Suc (pi\<bullet>x)" |
|
3063 by (auto simp add: perm_nat_def) |
|
3064 |
|
3065 lemma numeral_nat_eqvt: |
|
3066 shows "pi\<bullet> ((number_of n)::nat) = number_of ( n)" |
|
3067 by (simp add: perm_nat_def perm_int_def) |
|
3068 |
|
3069 lemma max_nat_eqvt: |
|
3070 shows "pi\<bullet>(max (x::nat) y) = max (pi\<bullet>x) (pi\<bullet>y)" |
|
3071 by (simp add:perm_nat_def) |
|
3072 |
|
3073 lemma min_nat_eqvt: |
|
3074 shows "pi\<bullet> max (x::nat) y = max (pi\<bullet>x) (pi\<bullet>y)" |
|
3075 by (simp add:perm_nat_def) |
|
3076 |
|
3077 lemma plus_nat_eqvt: |
|
3078 shows "pi\<bullet>((x::nat) + y) = (pi\<bullet>x) + (pi\<bullet>y)" |
|
3079 by (simp add:perm_nat_def) |
|
3080 |
|
3081 lemma minus_nat_eqvt: |
|
3082 shows "pi\<bullet>((x::nat) - y) = (pi\<bullet>x) - (pi\<bullet>y)" |
|
3083 by (simp add:perm_nat_def) |
|
3084 |
|
3085 lemma mult_nat_eqvt: |
|
3086 shows "pi\<bullet>((x::nat) * y) = (pi\<bullet>x) * (pi\<bullet>y)" |
|
3087 by (simp add:perm_nat_def) |
|
3088 |
|
3089 lemma div_nat_eqvt: |
|
3090 shows "pi\<bullet>((x::nat) div y) = (pi\<bullet>x) div (pi\<bullet>y)" |
|
3091 by (simp add:perm_nat_def) |
|
3092 |
3006 (*******************************************************) |
3093 (*******************************************************) |
3007 (* Setup of the theorem attributes eqvt, fresh and bij *) |
3094 (* Setup of the theorem attributes eqvt, fresh and bij *) |
3008 use "nominal_thmdecls.ML" |
3095 use "nominal_thmdecls.ML" |
3009 setup "NominalThmDecls.setup" |
3096 setup "NominalThmDecls.setup" |
3010 |
3097 |
3011 lemmas [eqvt] = perm_list.simps perm_prod.simps |
3098 lemmas [eqvt] = |
3012 |
3099 if_eqvt |
3013 |
3100 perm_unit.simps |
|
3101 perm_list.simps |
|
3102 perm_prod.simps |
|
3103 imp_eqvt disj_eqvt conj_eqvt neg_eqvt |
|
3104 Suc_eqvt Zero_nat_eqvt One_nat_eqvt |
|
3105 min_nat_eqvt max_nat_eqvt |
|
3106 plus_nat_eqvt minus_nat_eqvt mult_nat_eqvt div_nat_eqvt |
|
3107 union_eqvt empty_eqvt insert_eqvt |
|
3108 fst_eqvt snd_eqvt |
|
3109 |
|
3110 (* this lemma does not conform with the form of an eqvt-lemma but is *) |
|
3111 (* still useful to have when analysing permutations on numbers *) |
|
3112 lemmas [eqvt_force] = numeral_nat_eqvt |
3014 |
3113 |
3015 (***************************************) |
3114 (***************************************) |
3016 (* setup for the individial atom-kinds *) |
3115 (* setup for the individial atom-kinds *) |
3017 (* and nominal datatypes *) |
3116 (* and nominal datatypes *) |
3018 use "nominal_atoms.ML" |
3117 use "nominal_atoms.ML" |
3019 (* permutation equality tactic *) |
3118 setup "NominalAtoms.setup" |
|
3119 |
|
3120 (************************************************************) |
|
3121 (* various tactics for analysing permutations, supports etc *) |
3020 use "nominal_permeq.ML"; |
3122 use "nominal_permeq.ML"; |
|
3123 |
|
3124 method_setup perm_simp = |
|
3125 {* NominalPermeq.perm_simp_meth *} |
|
3126 {* simp rules and simprocs for analysing permutations *} |
|
3127 |
|
3128 method_setup perm_simp_debug = |
|
3129 {* NominalPermeq.perm_simp_meth_debug *} |
|
3130 {* simp rules and simprocs for analysing permutations including debugging facilities *} |
|
3131 |
|
3132 method_setup perm_full_simp = |
|
3133 {* NominalPermeq.perm_full_simp_meth *} |
|
3134 {* tactic for deciding equalities involving permutations *} |
|
3135 |
|
3136 method_setup perm_full_simp_debug = |
|
3137 {* NominalPermeq.perm_full_simp_meth_debug *} |
|
3138 {* tactic for deciding equalities involving permutations including debugging facilities *} |
|
3139 |
|
3140 method_setup supports_simp = |
|
3141 {* NominalPermeq.supports_meth *} |
|
3142 {* tactic for deciding whether something supports something else *} |
|
3143 |
|
3144 method_setup supports_simp_debug = |
|
3145 {* NominalPermeq.supports_meth_debug *} |
|
3146 {* tactic for deciding whether something supports something else including debugging facilities *} |
|
3147 |
|
3148 method_setup finite_guess = |
|
3149 {* NominalPermeq.finite_guess_meth *} |
|
3150 {* tactic for deciding whether something has finite support *} |
|
3151 |
|
3152 method_setup finite_guess_debug = |
|
3153 {* NominalPermeq.finite_guess_meth_debug *} |
|
3154 {* tactic for deciding whether something has finite support including debugging facilities *} |
|
3155 |
|
3156 method_setup fresh_guess = |
|
3157 {* NominalPermeq.fresh_guess_meth *} |
|
3158 {* tactic for deciding whether an atom is fresh for something*} |
|
3159 |
|
3160 method_setup fresh_guess_debug = |
|
3161 {* NominalPermeq.fresh_guess_meth_debug *} |
|
3162 {* tactic for deciding whether an atom is fresh for something including debugging facilities *} |
|
3163 |
|
3164 (************************************************) |
|
3165 (* main file for constructing nominal datatypes *) |
3021 use "nominal_package.ML" |
3166 use "nominal_package.ML" |
3022 setup "NominalAtoms.setup" |
|
3023 setup "NominalPackage.setup" |
3167 setup "NominalPackage.setup" |
3024 |
3168 |
3025 (** primitive recursive functions on nominal datatypes **) |
3169 (******************************************************) |
|
3170 (* primitive recursive functions on nominal datatypes *) |
3026 use "nominal_primrec.ML" |
3171 use "nominal_primrec.ML" |
3027 |
3172 |
3028 (** inductive predicates involving nominal datatypes **) |
3173 (****************************************************) |
|
3174 (* inductive definition involving nominal datatypes *) |
3029 use "nominal_inductive.ML" |
3175 use "nominal_inductive.ML" |
3030 |
3176 |
3031 (*****************************************) |
3177 (*****************************************) |
3032 (* setup for induction principles method *) |
3178 (* setup for induction principles method *) |
3033 |
|
3034 use "nominal_induct.ML"; |
3179 use "nominal_induct.ML"; |
3035 method_setup nominal_induct = |
3180 method_setup nominal_induct = |
3036 {* NominalInduct.nominal_induct_method *} |
3181 {* NominalInduct.nominal_induct_method *} |
3037 {* nominal induction *} |
3182 {* nominal induction *} |
3038 |
3183 |
3039 method_setup perm_simp = |
|
3040 {* NominalPermeq.perm_eq_meth *} |
|
3041 {* simp rules and simprocs for analysing permutations *} |
|
3042 |
|
3043 method_setup perm_simp_debug = |
|
3044 {* NominalPermeq.perm_eq_meth_debug *} |
|
3045 {* simp rules and simprocs for analysing permutations including debugging facilities *} |
|
3046 |
|
3047 method_setup perm_full_simp = |
|
3048 {* NominalPermeq.perm_full_eq_meth *} |
|
3049 {* tactic for deciding equalities involving permutations *} |
|
3050 |
|
3051 method_setup perm_full_simp_debug = |
|
3052 {* NominalPermeq.perm_full_eq_meth_debug *} |
|
3053 {* tactic for deciding equalities involving permutations including debugging facilities *} |
|
3054 |
|
3055 method_setup supports_simp = |
|
3056 {* NominalPermeq.supports_meth *} |
|
3057 {* tactic for deciding whether something supports something else *} |
|
3058 |
|
3059 method_setup supports_simp_debug = |
|
3060 {* NominalPermeq.supports_meth_debug *} |
|
3061 {* tactic for deciding whether something supports something else including debugging facilities *} |
|
3062 |
|
3063 method_setup finite_guess = |
|
3064 {* NominalPermeq.finite_gs_meth *} |
|
3065 {* tactic for deciding whether something has finite support *} |
|
3066 |
|
3067 method_setup finite_guess_debug = |
|
3068 {* NominalPermeq.finite_gs_meth_debug *} |
|
3069 {* tactic for deciding whether something has finite support including debugging facilities *} |
|
3070 |
|
3071 method_setup fresh_guess = |
|
3072 {* NominalPermeq.fresh_gs_meth *} |
|
3073 {* tactic for deciding whether an atom is fresh for something*} |
|
3074 |
|
3075 method_setup fresh_guess_debug = |
|
3076 {* NominalPermeq.fresh_gs_meth_debug *} |
|
3077 {* tactic for deciding whether an atom is fresh for something including debugging facilities *} |
|
3078 |
3184 |
3079 end |
3185 end |