src/HOL/Tools/transfer.ML
changeset 52883 0a7c97c76f46
parent 52358 f4c4bcb0d564
child 52884 34c47bc771f2
equal deleted inserted replaced
52882:45678f8e7a0f 52883:0a7c97c76f46
     5 Generic theorem transfer method.
     5 Generic theorem transfer method.
     6 *)
     6 *)
     7 
     7 
     8 signature TRANSFER =
     8 signature TRANSFER =
     9 sig
     9 sig
       
    10   val bottom_rewr_conv: thm list -> conv
       
    11   val top_rewr_conv: thm list -> conv
       
    12 
    10   val prep_conv: conv
    13   val prep_conv: conv
    11   val get_transfer_raw: Proof.context -> thm list
    14   val get_transfer_raw: Proof.context -> thm list
    12   val get_relator_eq: Proof.context -> thm list
    15   val get_relator_eq: Proof.context -> thm list
    13   val get_sym_relator_eq: Proof.context -> thm list
    16   val get_sym_relator_eq: Proof.context -> thm list
    14   val get_relator_eq_raw: Proof.context -> thm list
    17   val get_relator_eq_raw: Proof.context -> thm list
   129    map_known_frees (Term.add_frees (Thm.concl_of thm)))
   132    map_known_frees (Term.add_frees (Thm.concl_of thm)))
   130 
   133 
   131 fun del_transfer_thm thm = Data.map (map_transfer_raw (Item_Net.remove thm))
   134 fun del_transfer_thm thm = Data.map (map_transfer_raw (Item_Net.remove thm))
   132 
   135 
   133 (** Conversions **)
   136 (** Conversions **)
       
   137 
       
   138 fun bottom_rewr_conv rewrs = Conv.bottom_conv (K (Conv.try_conv (Conv.rewrs_conv rewrs))) @{context}
       
   139 fun top_rewr_conv rewrs = Conv.top_conv (K (Conv.try_conv (Conv.rewrs_conv rewrs))) @{context}
       
   140 
       
   141 fun transfer_rel_conv conv = 
       
   142   Conv.concl_conv ~1 (HOLogic.Trueprop_conv (Conv.fun2_conv (Conv.arg_conv conv)))
   134 
   143 
   135 val Rel_rule = Thm.symmetric @{thm Rel_def}
   144 val Rel_rule = Thm.symmetric @{thm Rel_def}
   136 
   145 
   137 fun dest_funcT cT =
   146 fun dest_funcT cT =
   138   (case Thm.dest_ctyp cT of [T, U] => (T, U)
   147   (case Thm.dest_ctyp cT of [T, U] => (T, U)
   557   let
   566   let
   558     val rhs = (snd o Term.dest_comb o HOLogic.dest_Trueprop) t
   567     val rhs = (snd o Term.dest_comb o HOLogic.dest_Trueprop) t
   559     val rule1 = transfer_rule_of_term ctxt false rhs
   568     val rule1 = transfer_rule_of_term ctxt false rhs
   560     val rules = get_transfer_raw ctxt
   569     val rules = get_transfer_raw ctxt
   561     val eq_rules = get_relator_eq_raw ctxt
   570     val eq_rules = get_relator_eq_raw ctxt
       
   571     val expand_eq_in_rel = transfer_rel_conv (top_rewr_conv [@{thm fun_rel_eq[symmetric,THEN eq_reflection]}])
   562   in
   572   in
   563     EVERY
   573     EVERY
   564       [CONVERSION prep_conv i,
   574       [CONVERSION prep_conv i,
   565        rtac @{thm transfer_prover_start} i,
   575        rtac @{thm transfer_prover_start} i,
   566        (rtac rule1 THEN_ALL_NEW
   576        ((rtac rule1 ORELSE' (CONVERSION expand_eq_in_rel THEN' rtac rule1))
       
   577         THEN_ALL_NEW
   567          (REPEAT_ALL_NEW (resolve_tac rules) THEN_ALL_NEW (DETERM o eq_tac eq_rules))) (i+1),
   578          (REPEAT_ALL_NEW (resolve_tac rules) THEN_ALL_NEW (DETERM o eq_tac eq_rules))) (i+1),
   568        rtac @{thm refl} i]
   579        rtac @{thm refl} i]
   569   end)
   580   end)
   570 
   581 
   571 (** Transfer attribute **)
   582 (** Transfer attribute **)