author | blanchet |
Fri, 14 Sep 2012 12:09:27 +0200 | |
changeset 49363 | 8fc53d925629 |
parent 49362 | 1271aca16aed |
child 49368 | df359ce891ac |
permissions | -rw-r--r-- |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
1 |
(* Title: HOL/Codatatype/Tools/bnf_fp_sugar_tactics.ML |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
2 |
Author: Jasmin Blanchette, TU Muenchen |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
3 |
Copyright 2012 |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
4 |
|
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
5 |
Tactics for the LFP/GFP sugar. |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
6 |
*) |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
7 |
|
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
8 |
signature BNF_FP_SUGAR_TACTICS = |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
9 |
sig |
49130
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
10 |
val mk_case_tac: Proof.context -> int -> int -> int -> thm -> thm -> thm -> tactic |
49226 | 11 |
val mk_coiter_like_tac: thm list -> thm list -> thm -> thm -> thm -> Proof.context -> tactic |
49161
a8e74375d971
fixed (n + 1)st bug in "mk_exhaust_tac" -- arose with uncurried constructors
blanchet
parents:
49160
diff
changeset
|
12 |
val mk_exhaust_tac: Proof.context -> int -> thm list -> thm -> thm -> tactic |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
13 |
val mk_fld_iff_unf_tac: Proof.context -> ctyp option list -> cterm -> cterm -> thm -> thm |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
14 |
-> tactic |
49127 | 15 |
val mk_half_distinct_tac: Proof.context -> thm -> thm list -> tactic |
49362
1271aca16aed
make tactic more robust in the case where "asm_simp_tac" already finishes the job
blanchet
parents:
49276
diff
changeset
|
16 |
val mk_induct_tac: Proof.context -> tactic |
49126 | 17 |
val mk_inject_tac: Proof.context -> thm -> thm -> tactic |
49226 | 18 |
val mk_iter_like_tac: thm list -> thm list -> thm list -> thm -> thm -> Proof.context -> tactic |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
19 |
end; |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
20 |
|
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
21 |
structure BNF_FP_Sugar_Tactics : BNF_FP_SUGAR_TACTICS = |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
22 |
struct |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
23 |
|
49125 | 24 |
open BNF_Tactics |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
25 |
open BNF_Util |
49264 | 26 |
open BNF_FP_Util |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
27 |
|
49130
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
28 |
fun mk_case_tac ctxt n k m case_def ctr_def unf_fld = |
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
29 |
Local_Defs.unfold_tac ctxt [case_def, ctr_def, unf_fld] THEN |
49264 | 30 |
(rtac (mk_sum_casesN_balanced n k RS ssubst) THEN' |
49130
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
31 |
REPEAT_DETERM_N (Int.max (0, m - 1)) o rtac (@{thm split} RS ssubst) THEN' |
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
32 |
rtac refl) 1; |
3c26e17b2849
implemented "mk_case_tac" -- and got rid of "cheat_tac"
blanchet
parents:
49127
diff
changeset
|
33 |
|
49161
a8e74375d971
fixed (n + 1)st bug in "mk_exhaust_tac" -- arose with uncurried constructors
blanchet
parents:
49160
diff
changeset
|
34 |
fun mk_exhaust_tac ctxt n ctr_defs fld_iff_unf sumEN' = |
49263 | 35 |
Local_Defs.unfold_tac ctxt (fld_iff_unf :: ctr_defs) THEN rtac sumEN' 1 THEN |
49125 | 36 |
Local_Defs.unfold_tac ctxt @{thms all_prod_eq} THEN |
49161
a8e74375d971
fixed (n + 1)st bug in "mk_exhaust_tac" -- arose with uncurried constructors
blanchet
parents:
49160
diff
changeset
|
37 |
EVERY' (maps (fn k => [select_prem_tac n (rotate_tac 1) k, REPEAT_DETERM o dtac @{thm meta_spec}, |
a8e74375d971
fixed (n + 1)st bug in "mk_exhaust_tac" -- arose with uncurried constructors
blanchet
parents:
49160
diff
changeset
|
38 |
etac @{thm meta_mp}, atac]) (1 upto n)) 1; |
49125 | 39 |
|
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
40 |
fun mk_fld_iff_unf_tac ctxt cTs cfld cunf fld_unf unf_fld = |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
41 |
(rtac iffI THEN' |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
42 |
EVERY' (map3 (fn cTs => fn cx => fn th => |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
43 |
dtac (Drule.instantiate' cTs [NONE, NONE, SOME cx] arg_cong) THEN' |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
44 |
SELECT_GOAL (Local_Defs.unfold_tac ctxt [th]) THEN' |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
45 |
atac) [rev cTs, cTs] [cunf, cfld] [unf_fld, fld_unf])) 1; |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
46 |
|
49127 | 47 |
fun mk_half_distinct_tac ctxt fld_inject ctr_defs = |
48 |
Local_Defs.unfold_tac ctxt (fld_inject :: @{thms sum.inject} @ ctr_defs) THEN |
|
49 |
rtac @{thm sum.distinct(1)} 1; |
|
50 |
||
49126 | 51 |
fun mk_inject_tac ctxt ctr_def fld_inject = |
49135 | 52 |
Local_Defs.unfold_tac ctxt [ctr_def] THEN rtac (fld_inject RS ssubst) 1 THEN |
53 |
Local_Defs.unfold_tac ctxt @{thms sum.inject Pair_eq conj_assoc} THEN rtac refl 1; |
|
49126 | 54 |
|
49362
1271aca16aed
make tactic more robust in the case where "asm_simp_tac" already finishes the job
blanchet
parents:
49276
diff
changeset
|
55 |
fun mk_induct_tac ctxt = |
49363 | 56 |
Skip_Proof.cheat_tac (Proof_Context.theory_of ctxt) (* FIXME: TODO *); |
49362
1271aca16aed
make tactic more robust in the case where "asm_simp_tac" already finishes the job
blanchet
parents:
49276
diff
changeset
|
57 |
|
49211 | 58 |
val iter_like_thms = |
49233 | 59 |
@{thms case_unit comp_def convol_def id_apply map_pair_def sum.simps(5,6) sum_map.simps |
60 |
split_conv}; |
|
49205 | 61 |
|
49229
d5717b5e2217
use map_id, not map_id', to allow better composition
blanchet
parents:
49226
diff
changeset
|
62 |
fun mk_iter_like_tac pre_map_defs map_ids iter_like_defs fld_iter_like ctr_def ctxt = |
d5717b5e2217
use map_id, not map_id', to allow better composition
blanchet
parents:
49226
diff
changeset
|
63 |
Local_Defs.unfold_tac ctxt (ctr_def :: fld_iter_like :: iter_like_defs @ pre_map_defs @ map_ids @ |
49232
9ea11f0c53e4
fixed and enabled generation of "coiters" theorems, including the recursive case
blanchet
parents:
49229
diff
changeset
|
64 |
iter_like_thms) THEN Local_Defs.unfold_tac ctxt @{thms id_def} THEN rtac refl 1; |
49205 | 65 |
|
49213 | 66 |
val coiter_like_ss = ss_only @{thms if_True if_False}; |
49276 | 67 |
val coiter_like_thms = @{thms id_apply map_pair_def sum_map.simps prod.cases}; |
49213 | 68 |
|
49229
d5717b5e2217
use map_id, not map_id', to allow better composition
blanchet
parents:
49226
diff
changeset
|
69 |
fun mk_coiter_like_tac coiter_like_defs map_ids fld_unf_coiter_like pre_map_def ctr_def ctxt = |
49213 | 70 |
Local_Defs.unfold_tac ctxt (ctr_def :: coiter_like_defs) THEN |
49226 | 71 |
subst_tac ctxt [fld_unf_coiter_like] 1 THEN asm_simp_tac coiter_like_ss 1 THEN |
49232
9ea11f0c53e4
fixed and enabled generation of "coiters" theorems, including the recursive case
blanchet
parents:
49229
diff
changeset
|
72 |
Local_Defs.unfold_tac ctxt (pre_map_def :: coiter_like_thms @ map_ids) THEN |
49235
f9fc2b64c599
fixed bug with one-value codatatype "codata 'a dead_foo = A"
blanchet
parents:
49233
diff
changeset
|
73 |
Local_Defs.unfold_tac ctxt @{thms id_def} THEN |
49362
1271aca16aed
make tactic more robust in the case where "asm_simp_tac" already finishes the job
blanchet
parents:
49276
diff
changeset
|
74 |
TRY ((rtac refl ORELSE' subst_tac ctxt @{thms unit_eq} THEN' rtac refl) 1); |
49213 | 75 |
|
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
76 |
end; |