197 in |
197 in |
198 forall_elim (thm COMP (equal_thm COMP @{thm equal_elim_rule2})) |
198 forall_elim (thm COMP (equal_thm COMP @{thm equal_elim_rule2})) |
199 end |
199 end |
200 handle TERM _ => thm |
200 handle TERM _ => thm |
201 |
201 |
202 fun abstract_equalities_transfer thm = |
202 fun abstract_equalities_transfer ctxt thm = |
203 let |
203 let |
204 fun dest prop = |
204 fun dest prop = |
205 let |
205 let |
206 val prems = Logic.strip_imp_prems prop |
206 val prems = Logic.strip_imp_prems prop |
207 val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop) |
207 val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop) |
208 val ((rel, x), y) = apfst Term.dest_comb (Term.dest_comb concl) |
208 val ((rel, x), y) = apfst Term.dest_comb (Term.dest_comb concl) |
209 in |
209 in |
210 (rel, fn rel' => |
210 (rel, fn rel' => |
211 Logic.list_implies (prems, HOLogic.mk_Trueprop (rel' $ x $ y))) |
211 Logic.list_implies (prems, HOLogic.mk_Trueprop (rel' $ x $ y))) |
212 end |
212 end |
213 in |
213 val contracted_eq_thm = |
214 gen_abstract_equalities dest thm |
214 Conv.fconv_rule (transfer_rel_conv (bottom_rewr_conv (get_relator_eq ctxt))) thm |
|
215 handle CTERM _ => thm |
|
216 in |
|
217 gen_abstract_equalities dest contracted_eq_thm |
215 end |
218 end |
216 |
219 |
217 fun abstract_equalities_relator_eq rel_eq_thm = |
220 fun abstract_equalities_relator_eq rel_eq_thm = |
218 gen_abstract_equalities (fn x => (x, I)) |
221 gen_abstract_equalities (fn x => (x, I)) |
219 (rel_eq_thm RS @{thm is_equality_def [THEN iffD2]}) |
222 (rel_eq_thm RS @{thm is_equality_def [THEN iffD2]}) |
220 |
223 |
221 fun abstract_equalities_domain thm = |
224 fun abstract_equalities_domain ctxt thm = |
222 let |
225 let |
223 fun dest prop = |
226 fun dest prop = |
224 let |
227 let |
225 val prems = Logic.strip_imp_prems prop |
228 val prems = Logic.strip_imp_prems prop |
226 val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop) |
229 val concl = HOLogic.dest_Trueprop (Logic.strip_imp_concl prop) |
227 val ((dom, x), y) = apfst Term.dest_comb (Term.dest_comb concl) |
230 val ((eq, dom), y) = apfst Term.dest_comb (Term.dest_comb concl) |
228 in |
231 in |
229 (x, fn x' => Logic.list_implies (prems, HOLogic.mk_Trueprop (dom $ x' $ y))) |
232 (dom, fn dom' => Logic.list_implies (prems, HOLogic.mk_Trueprop (eq $ dom' $ y))) |
230 end |
233 end |
231 in |
234 fun transfer_rel_conv conv = |
232 gen_abstract_equalities dest thm |
235 Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.arg1_conv (Conv.arg_conv conv))) |
|
236 val contracted_eq_thm = |
|
237 Conv.fconv_rule (transfer_rel_conv (bottom_rewr_conv (get_relator_eq ctxt))) thm |
|
238 in |
|
239 gen_abstract_equalities dest contracted_eq_thm |
233 end |
240 end |
234 |
241 |
235 |
242 |
236 (** Replacing explicit Domainp predicates with Domainp assumptions **) |
243 (** Replacing explicit Domainp predicates with Domainp assumptions **) |
237 |
244 |
312 Conv.fconv_rule (Conv.prems_conv ~1 safe_transfer_rule_conv) thm |
319 Conv.fconv_rule (Conv.prems_conv ~1 safe_transfer_rule_conv) thm |
313 end |
320 end |
314 |
321 |
315 (** Adding transfer domain rules **) |
322 (** Adding transfer domain rules **) |
316 |
323 |
317 fun add_transfer_domain_thm thm = |
324 fun add_transfer_domain_thm thm ctxt = |
318 (add_transfer_thm o abstract_equalities_domain o detect_transfer_rules) thm |
325 (add_transfer_thm o abstract_equalities_domain (Context.proof_of ctxt) o detect_transfer_rules) thm ctxt |
319 |
326 |
320 fun del_transfer_domain_thm thm = |
327 fun del_transfer_domain_thm thm ctxt = |
321 (del_transfer_thm o abstract_equalities_domain o detect_transfer_rules) thm |
328 (del_transfer_thm o abstract_equalities_domain (Context.proof_of ctxt) o detect_transfer_rules) thm ctxt |
322 |
329 |
323 (** Transfer proof method **) |
330 (** Transfer proof method **) |
324 |
331 |
325 val post_simps = |
332 val post_simps = |
326 @{thms transfer_forall_eq [symmetric] |
333 @{thms transfer_forall_eq [symmetric] |
666 val transfer_prover_method : (Proof.context -> Method.method) context_parser = |
673 val transfer_prover_method : (Proof.context -> Method.method) context_parser = |
667 Scan.succeed (fn ctxt => SIMPLE_METHOD' (transfer_prover_tac ctxt)) |
674 Scan.succeed (fn ctxt => SIMPLE_METHOD' (transfer_prover_tac ctxt)) |
668 |
675 |
669 (* Attribute for transfer rules *) |
676 (* Attribute for transfer rules *) |
670 |
677 |
671 val prep_rule = abstract_domains_transfer o abstract_equalities_transfer o Conv.fconv_rule prep_conv |
678 fun prep_rule ctxt thm = |
|
679 (abstract_domains_transfer o abstract_equalities_transfer ctxt o Conv.fconv_rule prep_conv) thm |
672 |
680 |
673 val transfer_add = |
681 val transfer_add = |
674 Thm.declaration_attribute (add_transfer_thm o prep_rule) |
682 Thm.declaration_attribute (fn thm => fn ctxt => |
|
683 (add_transfer_thm o prep_rule (Context.proof_of ctxt)) thm ctxt) |
675 |
684 |
676 val transfer_del = |
685 val transfer_del = |
677 Thm.declaration_attribute (del_transfer_thm o prep_rule) |
686 Thm.declaration_attribute (fn thm => fn ctxt => |
|
687 (del_transfer_thm o prep_rule (Context.proof_of ctxt)) thm ctxt) |
678 |
688 |
679 val transfer_attribute = |
689 val transfer_attribute = |
680 Attrib.add_del transfer_add transfer_del |
690 Attrib.add_del transfer_add transfer_del |
681 |
691 |
682 (* Attributes for transfer domain rules *) |
692 (* Attributes for transfer domain rules *) |