src/HOL/Tools/Transfer/transfer.ML
changeset 64434 af5235830c16
parent 62958 b41c1cb5e251
child 67399 eab6ce8368fa
equal deleted inserted replaced
64433:d4829dc875fb 64434:af5235830c16
    17   val bottom_rewr_conv: thm list -> conv
    17   val bottom_rewr_conv: thm list -> conv
    18   val top_rewr_conv: thm list -> conv
    18   val top_rewr_conv: thm list -> conv
    19   val top_sweep_rewr_conv: thm list -> conv
    19   val top_sweep_rewr_conv: thm list -> conv
    20 
    20 
    21   val prep_conv: conv
    21   val prep_conv: conv
       
    22   val fold_relator_eqs_conv: Proof.context -> conv
       
    23   val unfold_relator_eqs_conv: Proof.context -> conv
    22   val get_transfer_raw: Proof.context -> thm list
    24   val get_transfer_raw: Proof.context -> thm list
    23   val get_relator_eq_item_net: Proof.context -> thm Item_Net.T
    25   val get_relator_eq_item_net: Proof.context -> thm Item_Net.T
    24   val get_relator_eq: Proof.context -> thm list
    26   val get_relator_eq: Proof.context -> thm list
    25   val get_sym_relator_eq: Proof.context -> thm list
    27   val get_sym_relator_eq: Proof.context -> thm list
    26   val get_relator_eq_raw: Proof.context -> thm list
    28   val get_relator_eq_raw: Proof.context -> thm list
   229       else_conv
   231       else_conv
   230       safe_Rel_conv
   232       safe_Rel_conv
   231       else_conv
   233       else_conv
   232       Conv.all_conv) ct
   234       Conv.all_conv) ct
   233 
   235 
       
   236 fun fold_relator_eqs_conv ctxt ct = (bottom_rewr_conv (get_relator_eq ctxt)) ct;
       
   237 fun unfold_relator_eqs_conv ctxt ct = (top_rewr_conv (get_sym_relator_eq ctxt)) ct;
       
   238 
       
   239 
   234 (** Replacing explicit equalities with is_equality premises **)
   240 (** Replacing explicit equalities with is_equality premises **)
   235 
   241 
   236 fun mk_is_equality t =
   242 fun mk_is_equality t =
   237   Const (@{const_name is_equality}, Term.fastype_of t --> HOLogic.boolT) $ t
   243   Const (@{const_name is_equality}, Term.fastype_of t --> HOLogic.boolT) $ t
   238 
   244 
   276       in
   282       in
   277         (rel, fn rel' =>
   283         (rel, fn rel' =>
   278           Logic.list_implies (prems, HOLogic.mk_Trueprop (rel' $ x $ y)))
   284           Logic.list_implies (prems, HOLogic.mk_Trueprop (rel' $ x $ y)))
   279       end
   285       end
   280     val contracted_eq_thm =
   286     val contracted_eq_thm =
   281       Conv.fconv_rule (transfer_rel_conv (bottom_rewr_conv (get_relator_eq ctxt))) thm
   287       Conv.fconv_rule (transfer_rel_conv (fold_relator_eqs_conv ctxt)) thm
   282       handle CTERM _ => thm
   288       handle CTERM _ => thm
   283   in
   289   in
   284     gen_abstract_equalities ctxt dest contracted_eq_thm
   290     gen_abstract_equalities ctxt dest contracted_eq_thm
   285   end
   291   end
   286 
   292 
   299         (dom, fn dom' => Logic.list_implies (prems, HOLogic.mk_Trueprop (eq $ dom' $ y)))
   305         (dom, fn dom' => Logic.list_implies (prems, HOLogic.mk_Trueprop (eq $ dom' $ y)))
   300       end
   306       end
   301     fun transfer_rel_conv conv =
   307     fun transfer_rel_conv conv =
   302       Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.arg1_conv (Conv.arg_conv conv)))
   308       Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.arg1_conv (Conv.arg_conv conv)))
   303     val contracted_eq_thm =
   309     val contracted_eq_thm =
   304       Conv.fconv_rule (transfer_rel_conv (bottom_rewr_conv (get_relator_eq ctxt))) thm
   310       Conv.fconv_rule (transfer_rel_conv (fold_relator_eqs_conv ctxt)) thm
   305   in
   311   in
   306     gen_abstract_equalities ctxt dest contracted_eq_thm
   312     gen_abstract_equalities ctxt dest contracted_eq_thm
   307   end
   313   end
   308 
   314 
   309 
   315 
   652 
   658 
   653 fun transfer_prover_start_tac ctxt = SUBGOAL (fn (t, i) =>
   659 fun transfer_prover_start_tac ctxt = SUBGOAL (fn (t, i) =>
   654   let
   660   let
   655     val rhs = (snd o Term.dest_comb o HOLogic.dest_Trueprop) t
   661     val rhs = (snd o Term.dest_comb o HOLogic.dest_Trueprop) t
   656     val rule1 = transfer_rule_of_term ctxt false rhs
   662     val rule1 = transfer_rule_of_term ctxt false rhs
   657     val expand_eq_in_rel = transfer_rel_conv (top_rewr_conv [@{thm rel_fun_eq[symmetric,THEN eq_reflection]}])
   663     val expand_eqs_in_rel_conv = transfer_rel_conv (unfold_relator_eqs_conv ctxt)
   658   in
   664   in
   659     EVERY
   665     EVERY
   660       [CONVERSION prep_conv i,
   666       [CONVERSION prep_conv i,
       
   667        CONVERSION expand_eqs_in_rel_conv i,
   661        resolve_tac ctxt @{thms transfer_prover_start} i,
   668        resolve_tac ctxt @{thms transfer_prover_start} i,
   662        (resolve_tac ctxt [rule1] ORELSE'
   669        resolve_tac ctxt [rule1] (i + 1)]
   663          (CONVERSION expand_eq_in_rel THEN' resolve_tac ctxt [rule1])) (i + 1)]
       
   664   end);
   670   end);
   665 
   671 
   666 fun transfer_end_tac ctxt i =
   672 fun transfer_end_tac ctxt i =
   667   let
   673   let
   668     val post_simps = @{thms transfer_forall_eq [symmetric]
   674     val post_simps = @{thms transfer_forall_eq [symmetric]