10 respectively the lemma from the data-slot. |
10 respectively the lemma from the data-slot. |
11 *) |
11 *) |
12 |
12 |
13 signature NOMINAL_THMDECLS = |
13 signature NOMINAL_THMDECLS = |
14 sig |
14 sig |
15 val print_eqvtset: Proof.context -> unit |
15 val print_data: Proof.context -> unit |
16 val eqvt_add: attribute |
16 val eqvt_add: attribute |
17 val eqvt_del: attribute |
17 val eqvt_del: attribute |
18 val setup: theory -> theory |
18 val setup: theory -> theory |
19 |
19 |
20 val NOMINAL_EQVT_DEBUG : bool ref |
20 val NOMINAL_EQVT_DEBUG : bool ref |
25 |
25 |
26 structure Data = GenericDataFun |
26 structure Data = GenericDataFun |
27 ( |
27 ( |
28 val name = "HOL/Nominal/eqvt"; |
28 val name = "HOL/Nominal/eqvt"; |
29 type T = {eqvt:thm list, fresh:thm list, bij:thm list}; |
29 type T = {eqvt:thm list, fresh:thm list, bij:thm list}; |
30 val empty = {eqvt=[], fresh=[], bij=[]}; |
30 val empty = ({eqvt=[], fresh=[], bij=[]}:T); |
31 val extend = I; |
31 val extend = I; |
32 fun merge _ (r1,r2) = {eqvt = Drule.merge_rules (#eqvt r1, #eqvt r2), |
32 fun merge _ (r1:T,r2:T) = {eqvt = Drule.merge_rules (#eqvt r1, #eqvt r2), |
33 fresh = Drule.merge_rules (#fresh r1, #fresh r2), |
33 fresh = Drule.merge_rules (#fresh r1, #fresh r2), |
34 bij = Drule.merge_rules (#bij r1, #bij r2)} |
34 bij = Drule.merge_rules (#bij r1, #bij r2)} |
35 fun print context rules = |
35 fun print context (data:T) = |
36 Pretty.writeln (Pretty.big_list "Equivariance lemmas:" |
36 let |
37 (map (ProofContext.pretty_thm (Context.proof_of context)) (#eqvt rules))); |
37 fun print_aux msg thms = |
|
38 Pretty.writeln (Pretty.big_list msg |
|
39 (map (ProofContext.pretty_thm (Context.proof_of context)) thms)) |
|
40 in |
|
41 (print_aux "Equivariance lemmas: " (#eqvt data); |
|
42 print_aux "Freshness lemmas: " (#fresh data); |
|
43 print_aux "Bijection lemmas: " (#bij data)) |
|
44 end; |
|
45 |
38 ); |
46 ); |
39 |
47 |
40 (* Exception for when a theorem does not conform with form of an equivariance lemma. *) |
48 (* Exception for when a theorem does not conform with form of an equivariance lemma. *) |
41 (* There are two forms: one is an implication (for relations) and the other is an *) |
49 (* There are two forms: one is an implication (for relations) and the other is an *) |
42 (* equality (for functions). In the implication-case, say P ==> Q, Q must be equal *) |
50 (* equality (for functions). In the implication-case, say P ==> Q, Q must be equal *) |
46 (* the implicational case it is also checked that the variables and permutation fit *) |
54 (* the implicational case it is also checked that the variables and permutation fit *) |
47 (* together, i.e. are of the right "pt_class", so that a stronger version of the *) |
55 (* together, i.e. are of the right "pt_class", so that a stronger version of the *) |
48 (* eqality-lemma can be derived. *) |
56 (* eqality-lemma can be derived. *) |
49 exception EQVT_FORM; |
57 exception EQVT_FORM; |
50 |
58 |
51 val print_eqvtset = Data.print o Context.Proof; |
59 val print_data = Data.print o Context.Proof; |
52 |
60 |
53 (* FIXME: should be a function in a library *) |
61 (* FIXME: should be a function in a library *) |
54 fun mk_permT T = HOLogic.listT (HOLogic.mk_prodT (T, T)); |
62 fun mk_permT T = HOLogic.listT (HOLogic.mk_prodT (T, T)); |
55 |
63 |
56 val perm_bool = thm "perm_bool"; |
64 val perm_bool = thm "perm_bool"; |
174 val context' = Data.map (flag th) context |
182 val context' = Data.map (flag th) context |
175 in |
183 in |
176 Context.mapping (snd o PureThy.add_thmss [((name,(record_access (Data.get context'))),[])]) I context' |
184 Context.mapping (snd o PureThy.add_thmss [((name,(record_access (Data.get context'))),[])]) I context' |
177 end |
185 end |
178 |
186 |
179 (* |
187 fun bij_add_del_aux f = simple_add_del_aux #bij "bij" f |
180 fun simple_add_del_aux record_access name flag th context = |
188 fun fresh_add_del_aux f = simple_add_del_aux #fresh "fresh" f |
181 let |
189 |
182 val context' = Data.map th context |
190 fun eqvt_map f th (r:Data.T) = {eqvt = (f th (#eqvt r)), fresh = #fresh r, bij = #bij r}; |
183 in |
191 fun fresh_map f th (r:Data.T) = {eqvt = #eqvt r, fresh = (f th (#fresh r)), bij = #bij r}; |
184 Context.mapping (snd o PureThy.add_thmss [((name,(record_access (Data.get context'))),[])]) I context' |
192 fun bij_map f th (r:Data.T) = {eqvt = #eqvt r, fresh = #fresh r, bij = (f th (#bij r))}; |
185 end |
|
186 *) |
|
187 |
|
188 val bij_add_del_aux = simple_add_del_aux #bij "bij" |
|
189 val fresh_add_del_aux = simple_add_del_aux #fresh "fresh" |
|
190 |
|
191 fun eqvt_map f th r = {eqvt = (f th (#eqvt r)), fresh = #fresh r, bij = #bij r}; |
|
192 fun fresh_map f th r = {eqvt = #eqvt r, fresh = (f th (#fresh r)), bij = #bij r}; |
|
193 fun bij_map f th r = {eqvt = #eqvt r, fresh = #fresh r, bij = (f th (#bij r))}; |
|
194 |
193 |
195 val eqvt_add = Thm.declaration_attribute (eqvt_add_del_aux (eqvt_map Drule.add_rule)); |
194 val eqvt_add = Thm.declaration_attribute (eqvt_add_del_aux (eqvt_map Drule.add_rule)); |
196 val eqvt_del = Thm.declaration_attribute (eqvt_add_del_aux (eqvt_map Drule.del_rule)); |
195 val eqvt_del = Thm.declaration_attribute (eqvt_add_del_aux (eqvt_map Drule.del_rule)); |
197 val bij_add = Thm.declaration_attribute (bij_add_del_aux (bij_map Drule.add_rule)); |
196 val bij_add = Thm.declaration_attribute (bij_add_del_aux (bij_map Drule.add_rule)); |
198 val bij_del = Thm.declaration_attribute (bij_add_del_aux (bij_map Drule.del_rule)); |
197 val bij_del = Thm.declaration_attribute (bij_add_del_aux (bij_map Drule.del_rule)); |