author | desharna |
Mon, 12 May 2014 17:42:54 +0200 | |
changeset 56956 | 7425fa3763ff |
parent 56765 | 644f0d4820a1 |
child 56990 | 299b026cc5af |
permissions | -rw-r--r-- |
55061 | 1 |
(* Title: HOL/Tools/BNF/bnf_fp_def_sugar_tactics.ML |
49123
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 |
|
49389 | 5 |
Tactics for datatype and codatatype sugar. |
49123
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 |
|
49636 | 8 |
signature BNF_FP_DEF_SUGAR_TACTICS = |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
9 |
sig |
55966 | 10 |
val sumprod_thms_map: thm list |
11 |
val sumprod_thms_set: thm list |
|
12 |
val sumprod_thms_rel: thm list |
|
49585
5c4a12550491
generate high-level "maps", "sets", and "rels" properties
blanchet
parents:
49542
diff
changeset
|
13 |
|
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
14 |
val mk_coinduct_tac: Proof.context -> thm list -> int -> int list -> thm -> thm list -> |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
15 |
thm list -> thm list -> thm list -> thm list -> thm list list -> thm list list list -> |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
16 |
thm list list list -> tactic |
55867 | 17 |
val mk_corec_tac: thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> tactic |
49501 | 18 |
val mk_ctor_iff_dtor_tac: Proof.context -> ctyp option list -> cterm -> cterm -> thm -> thm -> |
19 |
tactic |
|
55867 | 20 |
val mk_disc_corec_iff_tac: thm list -> thm list -> thm list -> Proof.context -> tactic |
49161
a8e74375d971
fixed (n + 1)st bug in "mk_exhaust_tac" -- arose with uncurried constructors
blanchet
parents:
49160
diff
changeset
|
21 |
val mk_exhaust_tac: Proof.context -> int -> thm list -> thm -> thm -> tactic |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
22 |
val mk_half_distinct_tac: Proof.context -> thm -> thm -> thm list -> tactic |
49590 | 23 |
val mk_induct_tac: Proof.context -> int -> int list -> int list list -> int list list list -> |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
24 |
thm list -> thm -> thm list -> thm list -> thm list -> thm list list -> tactic |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
25 |
val mk_inject_tac: Proof.context -> thm -> thm -> thm -> tactic |
55867 | 26 |
val mk_rec_tac: thm list -> thm list -> thm list -> thm -> thm -> thm -> thm -> Proof.context -> |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
27 |
tactic |
56956 | 28 |
val mk_set_empty_tac: Proof.context -> cterm -> thm -> thm list -> thm list -> tactic |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
29 |
end; |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
30 |
|
49636 | 31 |
structure BNF_FP_Def_Sugar_Tactics : BNF_FP_DEF_SUGAR_TACTICS = |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
32 |
struct |
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
33 |
|
49125 | 34 |
open BNF_Tactics |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
35 |
open BNF_Util |
51850
106afdf5806c
renamed a few FP-related files, to make it clear that these are not the sum of LFP + GFP but rather shared basic libraries
blanchet
parents:
51843
diff
changeset
|
36 |
open BNF_FP_Util |
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
37 |
|
49590 | 38 |
val basic_simp_thms = @{thms simp_thms(7,8,12,14,22,24)}; |
39 |
val more_simp_thms = basic_simp_thms @ @{thms simp_thms(11,15,16,21)}; |
|
40 |
||
55966 | 41 |
val sumprod_thms_map = @{thms id_apply map_prod_simp prod.case sum.case map_sum.simps}; |
42 |
val sumprod_thms_set = |
|
55930
25a90cebbbe5
more careful simplification of sets (cf. abf91ebd0820)---yields smaller terms
traytel
parents:
55906
diff
changeset
|
43 |
@{thms UN_empty UN_insert Un_empty_left Un_empty_right Un_iff UN_simps(10) UN_iff |
55932 | 44 |
Union_Un_distrib image_iff o_apply map_prod_simp |
55931 | 45 |
mem_Collect_eq prod_set_simps map_sum.simps sum_set_simps}; |
56765 | 46 |
val sumprod_thms_rel = @{thms rel_sum_simps rel_prod_apply prod.inject id_apply conj_assoc}; |
49368 | 47 |
|
49668 | 48 |
fun hhf_concl_conv cv ctxt ct = |
49 |
(case Thm.term_of ct of |
|
56245 | 50 |
Const (@{const_name Pure.all}, _) $ Abs _ => |
49668 | 51 |
Conv.arg_conv (Conv.abs_conv (hhf_concl_conv cv o snd) ctxt) ct |
52 |
| _ => Conv.concl_conv ~1 cv ct); |
|
53 |
||
54922 | 54 |
fun co_induct_inst_as_projs ctxt k thm = |
49368 | 55 |
let |
54922 | 56 |
val fs = Term.add_vars (prop_of thm) [] |
49368 | 57 |
|> filter (fn (_, Type (@{type_name fun}, [_, T'])) => T' <> HOLogic.boolT | _ => false); |
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
58 |
fun mk_cfp (f as (_, T)) = |
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
59 |
(certify ctxt (Var f), certify ctxt (mk_proj T (num_binder_types T) k)); |
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
60 |
val cfps = map mk_cfp fs; |
49368 | 61 |
in |
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
62 |
Drule.cterm_instantiate cfps thm |
49368 | 63 |
end; |
64 |
||
54922 | 65 |
val co_induct_inst_as_projs_tac = PRIMITIVE oo co_induct_inst_as_projs; |
49368 | 66 |
|
49501 | 67 |
fun mk_exhaust_tac ctxt n ctr_defs ctor_iff_dtor sumEN' = |
52324 | 68 |
unfold_thms_tac ctxt (ctor_iff_dtor :: ctr_defs) THEN HEADGOAL (rtac sumEN') THEN |
69 |
HEADGOAL (EVERY' (maps (fn k => [select_prem_tac n (rotate_tac 1) k, |
|
70 |
REPEAT_DETERM o dtac meta_spec, etac meta_mp, atac]) (1 upto n))); |
|
49125 | 71 |
|
49501 | 72 |
fun mk_ctor_iff_dtor_tac ctxt cTs cctor cdtor ctor_dtor dtor_ctor = |
52324 | 73 |
HEADGOAL (rtac iffI THEN' |
74 |
EVERY' (map3 (fn cTs => fn cx => fn th => |
|
75 |
dtac (Drule.instantiate' cTs [NONE, NONE, SOME cx] arg_cong) THEN' |
|
76 |
SELECT_GOAL (unfold_thms_tac ctxt [th]) THEN' |
|
77 |
atac) [rev cTs, cTs] [cdtor, cctor] [dtor_ctor, ctor_dtor])); |
|
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
78 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
79 |
fun mk_half_distinct_tac ctxt ctor_inject abs_inject ctr_defs = |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
80 |
unfold_thms_tac ctxt (ctor_inject :: abs_inject :: @{thms sum.inject} @ ctr_defs) THEN |
52324 | 81 |
HEADGOAL (rtac @{thm sum.distinct(1)}); |
49127 | 82 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
83 |
fun mk_inject_tac ctxt ctr_def ctor_inject abs_inject = |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
84 |
unfold_thms_tac ctxt [ctr_def] THEN |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
85 |
HEADGOAL (rtac (ctor_inject RS ssubst)) THEN |
56765 | 86 |
unfold_thms_tac ctxt (abs_inject :: @{thms sum.inject prod.inject conj_assoc}) THEN |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
87 |
HEADGOAL (rtac refl); |
49126 | 88 |
|
55867 | 89 |
val rec_unfold_thms = |
55414
eab03e9cee8a
renamed '{prod,sum,bool,unit}_case' to 'case_...'
blanchet
parents:
55083
diff
changeset
|
90 |
@{thms comp_def convol_def fst_conv id_def case_prod_Pair_iden snd_conv split_conv |
55966 | 91 |
case_unit_Unity} @ sumprod_thms_map; |
49205 | 92 |
|
55867 | 93 |
fun mk_rec_tac pre_map_defs map_idents rec_defs ctor_rec fp_abs_inverse abs_inverse ctr_def ctxt = |
94 |
unfold_thms_tac ctxt (ctr_def :: ctor_rec :: fp_abs_inverse :: abs_inverse :: rec_defs @ |
|
95 |
pre_map_defs @ map_idents @ rec_unfold_thms) THEN HEADGOAL (rtac refl); |
|
49205 | 96 |
|
55966 | 97 |
val corec_unfold_thms = @{thms id_def} @ sumprod_thms_map; |
49683 | 98 |
|
55867 | 99 |
fun mk_corec_tac corec_defs map_idents ctor_dtor_corec pre_map_def abs_inverse ctr_def ctxt = |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
100 |
let |
55867 | 101 |
val ss = ss_only (pre_map_def :: abs_inverse :: map_idents @ corec_unfold_thms @ |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
102 |
@{thms o_apply vimage2p_def if_True if_False}) ctxt; |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
103 |
in |
55867 | 104 |
unfold_thms_tac ctxt (ctr_def :: corec_defs) THEN |
105 |
HEADGOAL (rtac (ctor_dtor_corec RS trans) THEN' asm_simp_tac ss) THEN_MAYBE |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
106 |
HEADGOAL (rtac refl ORELSE' rtac (@{thm unit_eq} RS arg_cong)) |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
107 |
end; |
49213 | 108 |
|
55867 | 109 |
fun mk_disc_corec_iff_tac case_splits' corecs discs ctxt = |
110 |
EVERY (map3 (fn case_split_tac => fn corec_thm => fn disc => |
|
111 |
HEADGOAL case_split_tac THEN unfold_thms_tac ctxt [corec_thm] THEN |
|
52324 | 112 |
HEADGOAL (asm_simp_tac (ss_only basic_simp_thms ctxt)) THEN |
113 |
(if is_refl disc then all_tac else HEADGOAL (rtac disc))) |
|
55867 | 114 |
(map rtac case_splits' @ [K all_tac]) corecs discs); |
49482 | 115 |
|
51798 | 116 |
fun solve_prem_prem_tac ctxt = |
49429
64ac3471005a
cleaner way of dealing with the set functions of sums and products
blanchet
parents:
49428
diff
changeset
|
117 |
REPEAT o (eresolve_tac @{thms bexE rev_bexI} ORELSE' rtac @{thm rev_bexI[OF UNIV_I]} ORELSE' |
51798 | 118 |
hyp_subst_tac ctxt ORELSE' resolve_tac @{thms disjI1 disjI2}) THEN' |
49429
64ac3471005a
cleaner way of dealing with the set functions of sums and products
blanchet
parents:
49428
diff
changeset
|
119 |
(rtac refl ORELSE' atac ORELSE' rtac @{thm singletonI}); |
49426 | 120 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
121 |
fun mk_induct_leverage_prem_prems_tac ctxt nn kks fp_abs_inverses abs_inverses set_maps |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
122 |
pre_set_defs = |
52324 | 123 |
HEADGOAL (EVERY' (maps (fn kk => [select_prem_tac nn (dtac meta_spec) kk, etac meta_mp, |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
124 |
SELECT_GOAL (unfold_thms_tac ctxt (pre_set_defs @ fp_abs_inverses @ abs_inverses @ set_maps @ |
55966 | 125 |
sumprod_thms_set)), |
52324 | 126 |
solve_prem_prem_tac ctxt]) (rev kks))); |
49368 | 127 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
128 |
fun mk_induct_discharge_prem_tac ctxt nn n fp_abs_inverses abs_inverses set_maps pre_set_defs m k |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
129 |
kks = |
49429
64ac3471005a
cleaner way of dealing with the set functions of sums and products
blanchet
parents:
49428
diff
changeset
|
130 |
let val r = length kks in |
52324 | 131 |
HEADGOAL (EVERY' [select_prem_tac n (rotate_tac 1) k, rotate_tac ~1, hyp_subst_tac ctxt, |
132 |
REPEAT_DETERM_N m o (dtac meta_spec THEN' rotate_tac ~1)]) THEN |
|
49391 | 133 |
EVERY [REPEAT_DETERM_N r |
52324 | 134 |
(HEADGOAL (rotate_tac ~1 THEN' dtac meta_mp THEN' rotate_tac 1) THEN prefer_tac 2), |
54742
7a86358a3c0b
proper context for basic Simplifier operations: rewrite_rule, rewrite_goals_rule, rewrite_goals_tac etc.;
wenzelm
parents:
54241
diff
changeset
|
135 |
if r > 0 then ALLGOALS (Goal.norm_hhf_tac ctxt) else all_tac, HEADGOAL atac, |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
136 |
mk_induct_leverage_prem_prems_tac ctxt nn kks fp_abs_inverses abs_inverses set_maps |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
137 |
pre_set_defs] |
49391 | 138 |
end; |
49368 | 139 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
140 |
fun mk_induct_tac ctxt nn ns mss kkss ctr_defs ctor_induct' fp_abs_inverses abs_inverses set_maps |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
141 |
pre_set_defss = |
49590 | 142 |
let val n = Integer.sum ns in |
54922 | 143 |
unfold_thms_tac ctxt ctr_defs THEN HEADGOAL (rtac ctor_induct') THEN |
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
144 |
co_induct_inst_as_projs_tac ctxt 0 THEN |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
145 |
EVERY (map4 (EVERY oooo map3 o |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
146 |
mk_induct_discharge_prem_tac ctxt nn n fp_abs_inverses abs_inverses set_maps) |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
147 |
pre_set_defss mss (unflat mss (1 upto n)) kkss) |
49368 | 148 |
end; |
149 |
||
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
150 |
fun mk_coinduct_same_ctr_tac ctxt rel_eqs pre_rel_def fp_abs_inverse abs_inverse dtor_ctor ctr_def |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
151 |
discs sels = |
51798 | 152 |
hyp_subst_tac ctxt THEN' |
49665 | 153 |
CONVERSION (hhf_concl_conv |
154 |
(Conv.top_conv (K (Conv.try_conv (Conv.rewr_conv ctr_def))) ctxt) ctxt) THEN' |
|
49642
9f884142334c
fixed simplification of prod and sum relators to avoid issues with e.g. codata ('a, 'b) k = K "'a + 'b"
blanchet
parents:
49639
diff
changeset
|
155 |
SELECT_GOAL (unfold_thms_tac ctxt (pre_rel_def :: dtor_ctor :: sels)) THEN' |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
156 |
SELECT_GOAL (unfold_thms_tac ctxt (pre_rel_def :: fp_abs_inverse :: abs_inverse :: dtor_ctor :: |
55966 | 157 |
sels @ sumprod_thms_rel @ @{thms o_apply vimage2p_def})) THEN' |
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
158 |
(atac ORELSE' REPEAT o etac conjE THEN' |
56765 | 159 |
full_simp_tac (ss_only (no_refl discs @ rel_eqs @ more_simp_thms) ctxt) THEN' |
54241 | 160 |
REPEAT o etac conjE THEN_MAYBE' REPEAT o hyp_subst_tac ctxt THEN' |
161 |
REPEAT o (resolve_tac [refl, conjI] ORELSE' atac)); |
|
49590 | 162 |
|
52966 | 163 |
fun mk_coinduct_distinct_ctrs_tac ctxt discs discs' = |
54198
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
164 |
let |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
165 |
val discs'' = map (perhaps (try (fn th => th RS @{thm notnotD}))) (discs @ discs') |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
166 |
|> distinct Thm.eq_thm_prop; |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
167 |
in |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
168 |
hyp_subst_tac ctxt THEN' REPEAT o etac conjE THEN' |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
169 |
full_simp_tac (ss_only (refl :: no_refl discs'' @ basic_simp_thms) ctxt) |
4fadf746f2d5
got rid of annoying duplicate rewrite rule warnings
blanchet
parents:
53690
diff
changeset
|
170 |
end; |
49590 | 171 |
|
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
172 |
fun mk_coinduct_discharge_prem_tac ctxt rel_eqs' nn kk n pre_rel_def fp_abs_inverse abs_inverse |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
173 |
dtor_ctor exhaust ctr_defs discss selss = |
49590 | 174 |
let val ks = 1 upto n in |
54837 | 175 |
EVERY' ([rtac allI, rtac allI, rtac impI, select_prem_tac nn (dtac meta_spec) kk, |
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
176 |
dtac meta_spec, dtac meta_mp, atac, rtac exhaust, K (co_induct_inst_as_projs_tac ctxt 0), |
51798 | 177 |
hyp_subst_tac ctxt] @ |
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
178 |
map4 (fn k => fn ctr_def => fn discs => fn sels => |
54923
ffed2452f5f6
instantiate schematics as projections to avoid HOU trouble
blanchet
parents:
54922
diff
changeset
|
179 |
EVERY' ([rtac exhaust, K (co_induct_inst_as_projs_tac ctxt 1)] @ |
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
180 |
map2 (fn k' => fn discs' => |
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
181 |
if k' = k then |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
182 |
mk_coinduct_same_ctr_tac ctxt rel_eqs' pre_rel_def fp_abs_inverse abs_inverse |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
183 |
dtor_ctor ctr_def discs sels |
49591
91b228e26348
generate high-level "coinduct" and "strong_coinduct" properties
blanchet
parents:
49590
diff
changeset
|
184 |
else |
52966 | 185 |
mk_coinduct_distinct_ctrs_tac ctxt discs discs') ks discss)) ks ctr_defs discss selss) |
49590 | 186 |
end; |
187 |
||
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
188 |
fun mk_coinduct_tac ctxt rel_eqs' nn ns dtor_coinduct' pre_rel_defs fp_abs_inverses abs_inverses |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
189 |
dtor_ctors exhausts ctr_defss discsss selsss = |
52324 | 190 |
HEADGOAL (rtac dtor_coinduct' THEN' |
55803
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
191 |
EVERY' (map10 (mk_coinduct_discharge_prem_tac ctxt rel_eqs' nn) |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
192 |
(1 upto nn) ns pre_rel_defs fp_abs_inverses abs_inverses dtor_ctors exhausts ctr_defss discsss |
74d3fe9031d8
joint work with blanchet: intermediate typedef for the input to fp-operations
traytel
parents:
55642
diff
changeset
|
193 |
selsss)); |
49590 | 194 |
|
56956 | 195 |
fun mk_set_empty_tac ctxt ct exhaust sets discs = |
196 |
TRYALL Goal.conjunction_tac THEN |
|
197 |
ALLGOALS(rtac (Ctr_Sugar_Util.cterm_instantiate_pos [SOME ct] exhaust) THEN_ALL_NEW |
|
198 |
hyp_subst_tac ctxt) THEN |
|
199 |
Local_Defs.unfold_tac ctxt (sets @ map_filter (fn thm => |
|
200 |
SOME (thm RS @{thm iffD2[OF eq_False]}) handle THM _ => NONE) discs) THEN |
|
201 |
ALLGOALS(rtac refl ORELSE' etac FalseE); |
|
202 |
||
49123
263b0e330d8b
more work on sugar + simplify Trueprop + eq idiom everywhere
blanchet
parents:
diff
changeset
|
203 |
end; |