src/HOL/Codatatype/Tools/bnf_fp_sugar_tactics.ML
author blanchet
Tue Sep 04 16:17:22 2012 +0200 (2012-09-04)
changeset 49126 1bbd7a37fc29
parent 49125 5fc5211cf104
child 49127 f7326a0d7f19
permissions -rw-r--r--
implemented "mk_inject_tac"
blanchet@49123
     1
(*  Title:      HOL/Codatatype/Tools/bnf_fp_sugar_tactics.ML
blanchet@49123
     2
    Author:     Jasmin Blanchette, TU Muenchen
blanchet@49123
     3
    Copyright   2012
blanchet@49123
     4
blanchet@49123
     5
Tactics for the LFP/GFP sugar.
blanchet@49123
     6
*)
blanchet@49123
     7
blanchet@49123
     8
signature BNF_FP_SUGAR_TACTICS =
blanchet@49123
     9
sig
blanchet@49125
    10
  val mk_exhaust_tac: Proof.context -> int -> int list -> thm list -> thm -> thm -> tactic
blanchet@49123
    11
  val mk_fld_iff_unf_tac: Proof.context -> ctyp option list -> cterm -> cterm -> thm -> thm
blanchet@49123
    12
    -> tactic
blanchet@49126
    13
  val mk_inject_tac: Proof.context -> thm -> thm -> tactic
blanchet@49123
    14
end;
blanchet@49123
    15
blanchet@49123
    16
structure BNF_FP_Sugar_Tactics : BNF_FP_SUGAR_TACTICS =
blanchet@49123
    17
struct
blanchet@49123
    18
blanchet@49125
    19
open BNF_Tactics
blanchet@49123
    20
open BNF_Util
blanchet@49123
    21
blanchet@49125
    22
fun mk_exhaust_tac ctxt n ms ctr_defs fld_iff_unf sumEN' =
blanchet@49125
    23
  Local_Defs.unfold_tac ctxt (fld_iff_unf :: ctr_defs) THEN
blanchet@49125
    24
  rtac sumEN' 1 THEN
blanchet@49125
    25
  Local_Defs.unfold_tac ctxt @{thms all_prod_eq} THEN
blanchet@49125
    26
  EVERY' (map2 (fn k => fn m =>
blanchet@49125
    27
     select_prem_tac n (REPEAT_DETERM_N m o dtac @{thm meta_spec} THEN' etac @{thm meta_mp}) k THEN'
blanchet@49125
    28
     atac) (1 upto n) ms) 1;
blanchet@49125
    29
blanchet@49123
    30
fun mk_fld_iff_unf_tac ctxt cTs cfld cunf fld_unf unf_fld =
blanchet@49123
    31
  (rtac iffI THEN'
blanchet@49123
    32
   EVERY' (map3 (fn cTs => fn cx => fn th =>
blanchet@49123
    33
     dtac (Drule.instantiate' cTs [NONE, NONE, SOME cx] arg_cong) THEN'
blanchet@49123
    34
     SELECT_GOAL (Local_Defs.unfold_tac ctxt [th]) THEN'
blanchet@49123
    35
     atac) [rev cTs, cTs] [cunf, cfld] [unf_fld, fld_unf])) 1;
blanchet@49123
    36
blanchet@49126
    37
fun mk_inject_tac ctxt ctr_def fld_inject =
blanchet@49126
    38
  Local_Defs.unfold_tac ctxt [ctr_def] THEN
blanchet@49126
    39
  rtac (fld_inject RS ssubst) 1 THEN
blanchet@49126
    40
  Local_Defs.unfold_tac ctxt @{thms sum.inject Pair_eq conj_assoc} THEN
blanchet@49126
    41
  rtac refl 1;
blanchet@49126
    42
blanchet@49123
    43
end;