author | wenzelm |
Sun, 08 Mar 2009 17:26:14 +0100 | |
changeset 30364 | 577edc39b501 |
parent 30307 | 6c74ef5a349f |
child 30450 | 7655e6533209 |
permissions | -rw-r--r-- |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
1 |
(* Title: HOL/Nominal/nominal_inductive2.ML |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
2 |
Author: Stefan Berghofer, TU Muenchen |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
3 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
4 |
Infrastructure for proving equivariance and strong induction theorems |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
5 |
for inductive predicates involving nominal datatypes. |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
6 |
Experimental version that allows to avoid lists of atoms. |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
7 |
*) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
8 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
9 |
signature NOMINAL_INDUCTIVE2 = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
10 |
sig |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
11 |
val prove_strong_ind: string -> (string * string list) list -> local_theory -> Proof.state |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
12 |
end |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
13 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
14 |
structure NominalInductive2 : NOMINAL_INDUCTIVE2 = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
15 |
struct |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
16 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
17 |
val inductive_forall_name = "HOL.induct_forall"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
18 |
val inductive_forall_def = thm "induct_forall_def"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
19 |
val inductive_atomize = thms "induct_atomize"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
20 |
val inductive_rulify = thms "induct_rulify"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
21 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
22 |
fun rulify_term thy = MetaSimplifier.rewrite_term thy inductive_rulify []; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
23 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
24 |
val atomize_conv = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
25 |
MetaSimplifier.rewrite_cterm (true, false, false) (K (K NONE)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
26 |
(HOL_basic_ss addsimps inductive_atomize); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
27 |
val atomize_intr = Conv.fconv_rule (Conv.prems_conv ~1 atomize_conv); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
28 |
fun atomize_induct ctxt = Conv.fconv_rule (Conv.prems_conv ~1 |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
29 |
(Conv.params_conv ~1 (K (Conv.prems_conv ~1 atomize_conv)) ctxt)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
30 |
|
30108 | 31 |
val fresh_postprocess = |
32 |
Simplifier.full_simplify (HOL_basic_ss addsimps |
|
33 |
[@{thm fresh_star_set_eq}, @{thm fresh_star_Un_elim}, |
|
34 |
@{thm fresh_star_insert_elim}, @{thm fresh_star_empty_elim}]); |
|
35 |
||
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
36 |
fun preds_of ps t = gen_inter (op = o apfst dest_Free) (ps, Term.add_frees t []); |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
37 |
|
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
38 |
val perm_bool = mk_meta_eq (thm "perm_bool"); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
39 |
val perm_boolI = thm "perm_boolI"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
40 |
val (_, [perm_boolI_pi, _]) = Drule.strip_comb (snd (Thm.dest_comb |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
41 |
(Drule.strip_imp_concl (cprop_of perm_boolI)))); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
42 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
43 |
fun mk_perm_bool pi th = th RS Drule.cterm_instantiate |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
44 |
[(perm_boolI_pi, pi)] perm_boolI; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
45 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
46 |
fun mk_perm_bool_simproc names = Simplifier.simproc_i |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
47 |
(theory_of_thm perm_bool) "perm_bool" [@{term "perm pi x"}] (fn thy => fn ss => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
48 |
fn Const ("Nominal.perm", _) $ _ $ t => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
49 |
if the_default "" (try (head_of #> dest_Const #> fst) t) mem names |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
50 |
then SOME perm_bool else NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
51 |
| _ => NONE); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
52 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
53 |
fun transp ([] :: _) = [] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
54 |
| transp xs = map hd xs :: transp (map tl xs); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
55 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
56 |
fun add_binders thy i (t as (_ $ _)) bs = (case strip_comb t of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
57 |
(Const (s, T), ts) => (case strip_type T of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
58 |
(Ts, Type (tname, _)) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
59 |
(case NominalPackage.get_nominal_datatype thy tname of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
60 |
NONE => fold (add_binders thy i) ts bs |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
61 |
| SOME {descr, index, ...} => (case AList.lookup op = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
62 |
(#3 (the (AList.lookup op = descr index))) s of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
63 |
NONE => fold (add_binders thy i) ts bs |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
64 |
| SOME cargs => fst (fold (fn (xs, x) => fn (bs', cargs') => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
65 |
let val (cargs1, (u, _) :: cargs2) = chop (length xs) cargs' |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
66 |
in (add_binders thy i u |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
67 |
(fold (fn (u, T) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
68 |
if exists (fn j => j < i) (loose_bnos u) then I |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
69 |
else AList.map_default op = (T, []) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
70 |
(insert op aconv (incr_boundvars (~i) u))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
71 |
cargs1 bs'), cargs2) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
72 |
end) cargs (bs, ts ~~ Ts)))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
73 |
| _ => fold (add_binders thy i) ts bs) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
74 |
| (u, ts) => add_binders thy i u (fold (add_binders thy i) ts bs)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
75 |
| add_binders thy i (Abs (_, _, t)) bs = add_binders thy (i + 1) t bs |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
76 |
| add_binders thy i _ bs = bs; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
77 |
|
30304
d8e4cd2ac2a1
set operations Int, Un, INTER, UNION, Inter, Union, empty, UNIV are now proper qualified constants with authentic syntax
haftmann
parents:
30087
diff
changeset
|
78 |
fun mk_set T [] = Const (@{const_name Set.empty}, HOLogic.mk_setT T) |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
79 |
| mk_set T (x :: xs) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
80 |
Const ("insert", T --> HOLogic.mk_setT T --> HOLogic.mk_setT T) $ x $ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
81 |
mk_set T xs; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
82 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
83 |
fun split_conj f names (Const ("op &", _) $ p $ q) _ = (case head_of p of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
84 |
Const (name, _) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
85 |
if name mem names then SOME (f p q) else NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
86 |
| _ => NONE) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
87 |
| split_conj _ _ _ _ = NONE; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
88 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
89 |
fun strip_all [] t = t |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
90 |
| strip_all (_ :: xs) (Const ("All", _) $ Abs (s, T, t)) = strip_all xs t; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
91 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
92 |
(*********************************************************************) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
93 |
(* maps R ... & (ALL pi_1 ... pi_n z. P z (pi_1 o ... o pi_n o t)) *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
94 |
(* or ALL pi_1 ... pi_n z. P z (pi_1 o ... o pi_n o t) *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
95 |
(* to R ... & id (ALL z. P z (pi_1 o ... o pi_n o t)) *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
96 |
(* or id (ALL z. P z (pi_1 o ... o pi_n o t)) *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
97 |
(* *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
98 |
(* where "id" protects the subformula from simplification *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
99 |
(*********************************************************************) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
100 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
101 |
fun inst_conj_all names ps pis (Const ("op &", _) $ p $ q) _ = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
102 |
(case head_of p of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
103 |
Const (name, _) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
104 |
if name mem names then SOME (HOLogic.mk_conj (p, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
105 |
Const ("Fun.id", HOLogic.boolT --> HOLogic.boolT) $ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
106 |
(subst_bounds (pis, strip_all pis q)))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
107 |
else NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
108 |
| _ => NONE) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
109 |
| inst_conj_all names ps pis t u = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
110 |
if member (op aconv) ps (head_of u) then |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
111 |
SOME (Const ("Fun.id", HOLogic.boolT --> HOLogic.boolT) $ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
112 |
(subst_bounds (pis, strip_all pis t))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
113 |
else NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
114 |
| inst_conj_all _ _ _ _ _ = NONE; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
115 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
116 |
fun inst_conj_all_tac k = EVERY |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
117 |
[TRY (EVERY [etac conjE 1, rtac conjI 1, atac 1]), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
118 |
REPEAT_DETERM_N k (etac allE 1), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
119 |
simp_tac (HOL_basic_ss addsimps [@{thm id_apply}]) 1]; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
120 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
121 |
fun map_term f t u = (case f t u of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
122 |
NONE => map_term' f t u | x => x) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
123 |
and map_term' f (t $ u) (t' $ u') = (case (map_term f t t', map_term f u u') of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
124 |
(NONE, NONE) => NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
125 |
| (SOME t'', NONE) => SOME (t'' $ u) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
126 |
| (NONE, SOME u'') => SOME (t $ u'') |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
127 |
| (SOME t'', SOME u'') => SOME (t'' $ u'')) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
128 |
| map_term' f (Abs (s, T, t)) (Abs (s', T', t')) = (case map_term f t t' of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
129 |
NONE => NONE |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
130 |
| SOME t'' => SOME (Abs (s, T, t''))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
131 |
| map_term' _ _ _ = NONE; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
132 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
133 |
(*********************************************************************) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
134 |
(* Prove F[f t] from F[t], where F is monotone *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
135 |
(*********************************************************************) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
136 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
137 |
fun map_thm ctxt f tac monos opt th = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
138 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
139 |
val prop = prop_of th; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
140 |
fun prove t = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
141 |
Goal.prove ctxt [] [] t (fn _ => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
142 |
EVERY [cut_facts_tac [th] 1, etac rev_mp 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
143 |
REPEAT_DETERM (FIRSTGOAL (resolve_tac monos)), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
144 |
REPEAT_DETERM (rtac impI 1 THEN (atac 1 ORELSE tac))]) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
145 |
in Option.map prove (map_term f prop (the_default prop opt)) end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
146 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
147 |
fun abs_params params t = |
29276 | 148 |
let val vs = map (Var o apfst (rpair 0)) (Term.rename_wrt_term t params) |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
149 |
in (list_all (params, t), (rev vs, subst_bounds (vs, t))) end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
150 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
151 |
fun inst_params thy (vs, p) th cts = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
152 |
let val env = Pattern.first_order_match thy (p, prop_of th) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
153 |
(Vartab.empty, Vartab.empty) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
154 |
in Thm.instantiate ([], |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
155 |
map (Envir.subst_vars env #> cterm_of thy) vs ~~ cts) th |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
156 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
157 |
|
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
158 |
fun prove_strong_ind s avoids ctxt = |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
159 |
let |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
160 |
val thy = ProofContext.theory_of ctxt; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
161 |
val ({names, ...}, {raw_induct, intrs, elims, ...}) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
162 |
InductivePackage.the_inductive ctxt (Sign.intern_const thy s); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
163 |
val ind_params = InductivePackage.params_of raw_induct; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
164 |
val raw_induct = atomize_induct ctxt raw_induct; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
165 |
val elims = map (atomize_induct ctxt) elims; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
166 |
val monos = InductivePackage.get_monos ctxt; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
167 |
val eqvt_thms = NominalThmDecls.get_eqvt_thms ctxt; |
29287 | 168 |
val _ = (case names \\ fold (Term.add_const_names o Thm.prop_of) eqvt_thms [] of |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
169 |
[] => () |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
170 |
| xs => error ("Missing equivariance theorem for predicate(s): " ^ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
171 |
commas_quote xs)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
172 |
val induct_cases = map fst (fst (RuleCases.get (the |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
173 |
(Induct.lookup_inductP ctxt (hd names))))); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
174 |
val induct_cases' = if null induct_cases then replicate (length intrs) "" |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
175 |
else induct_cases; |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
176 |
val ([raw_induct'], ctxt') = Variable.import_terms false [prop_of raw_induct] ctxt; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
177 |
val concls = raw_induct' |> Logic.strip_imp_concl |> HOLogic.dest_Trueprop |> |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
178 |
HOLogic.dest_conj |> map (HOLogic.dest_imp ##> strip_comb); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
179 |
val ps = map (fst o snd) concls; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
180 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
181 |
val _ = (case duplicates (op = o pairself fst) avoids of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
182 |
[] => () |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
183 |
| xs => error ("Duplicate case names: " ^ commas_quote (map fst xs))); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
184 |
val _ = (case map fst avoids \\ induct_cases of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
185 |
[] => () |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
186 |
| xs => error ("No such case(s) in inductive definition: " ^ commas_quote xs)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
187 |
fun mk_avoids params name sets = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
188 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
189 |
val (_, ctxt') = ProofContext.add_fixes_i |
28965 | 190 |
(map (fn (s, T) => (Binding.name s, SOME T, NoSyn)) params) ctxt; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
191 |
fun mk s = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
192 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
193 |
val t = Syntax.read_term ctxt' s; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
194 |
val t' = list_abs_free (params, t) |> |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
195 |
funpow (length params) (fn Abs (_, _, t) => t) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
196 |
in (t', HOLogic.dest_setT (fastype_of t)) end |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
197 |
handle TERM _ => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
198 |
error ("Expression " ^ quote s ^ " to be avoided in case " ^ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
199 |
quote name ^ " is not a set type"); |
30108 | 200 |
fun add_set p [] = [p] |
201 |
| add_set (t, T) ((u, U) :: ps) = |
|
202 |
if T = U then |
|
203 |
let val S = HOLogic.mk_setT T |
|
30306
8f4d5eaa9878
set operations Int, Un, INTER, UNION, Inter, Union, empty, UNIV are now proper qualified constants with authentic syntax
haftmann
parents:
30305
diff
changeset
|
204 |
in (Const (@{const_name "Un"}, S --> S --> S) $ u $ t, T) :: ps |
30108 | 205 |
end |
206 |
else (u, U) :: add_set (t, T) ps |
|
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
207 |
in |
30108 | 208 |
fold (mk #> add_set) sets [] |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
209 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
210 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
211 |
val prems = map (fn (prem, name) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
212 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
213 |
val prems = map (incr_boundvars 1) (Logic.strip_assums_hyp prem); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
214 |
val concl = incr_boundvars 1 (Logic.strip_assums_concl prem); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
215 |
val params = Logic.strip_params prem |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
216 |
in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
217 |
(params, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
218 |
if null avoids then |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
219 |
map (fn (T, ts) => (mk_set T ts, T)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
220 |
(fold (add_binders thy 0) (prems @ [concl]) []) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
221 |
else case AList.lookup op = avoids name of |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
222 |
NONE => [] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
223 |
| SOME sets => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
224 |
map (apfst (incr_boundvars 1)) (mk_avoids params name sets), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
225 |
prems, strip_comb (HOLogic.dest_Trueprop concl)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
226 |
end) (Logic.strip_imp_prems raw_induct' ~~ induct_cases'); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
227 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
228 |
val atomTs = distinct op = (maps (map snd o #2) prems); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
229 |
val atoms = map (fst o dest_Type) atomTs; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
230 |
val ind_sort = if null atomTs then HOLogic.typeS |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
231 |
else Sign.certify_sort thy (map (fn a => Sign.intern_class thy |
30364
577edc39b501
moved basic algebra of long names from structure NameSpace to Long_Name;
wenzelm
parents:
30307
diff
changeset
|
232 |
("fs_" ^ Long_Name.base_name a)) atoms); |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
233 |
val ([fs_ctxt_tyname], _) = Name.variants ["'n"] (Variable.names_of ctxt'); |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
234 |
val ([fs_ctxt_name], ctxt'') = Variable.variant_fixes ["z"] ctxt'; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
235 |
val fsT = TFree (fs_ctxt_tyname, ind_sort); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
236 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
237 |
val inductive_forall_def' = Drule.instantiate' |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
238 |
[SOME (ctyp_of thy fsT)] [] inductive_forall_def; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
239 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
240 |
fun lift_pred' t (Free (s, T)) ts = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
241 |
list_comb (Free (s, fsT --> T), t :: ts); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
242 |
val lift_pred = lift_pred' (Bound 0); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
243 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
244 |
fun lift_prem (t as (f $ u)) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
245 |
let val (p, ts) = strip_comb t |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
246 |
in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
247 |
if p mem ps then |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
248 |
Const (inductive_forall_name, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
249 |
(fsT --> HOLogic.boolT) --> HOLogic.boolT) $ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
250 |
Abs ("z", fsT, lift_pred p (map (incr_boundvars 1) ts)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
251 |
else lift_prem f $ lift_prem u |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
252 |
end |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
253 |
| lift_prem (Abs (s, T, t)) = Abs (s, T, lift_prem t) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
254 |
| lift_prem t = t; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
255 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
256 |
fun mk_fresh (x, T) = HOLogic.mk_Trueprop |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
257 |
(NominalPackage.fresh_star_const T fsT $ x $ Bound 0); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
258 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
259 |
val (prems', prems'') = split_list (map (fn (params, sets, prems, (p, ts)) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
260 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
261 |
val params' = params @ [("y", fsT)]; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
262 |
val prem = Logic.list_implies |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
263 |
(map mk_fresh sets @ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
264 |
map (fn prem => |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
265 |
if null (preds_of ps prem) then prem |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
266 |
else lift_prem prem) prems, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
267 |
HOLogic.mk_Trueprop (lift_pred p ts)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
268 |
in abs_params params' prem end) prems); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
269 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
270 |
val ind_vars = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
271 |
(DatatypeProp.indexify_names (replicate (length atomTs) "pi") ~~ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
272 |
map NominalAtoms.mk_permT atomTs) @ [("z", fsT)]; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
273 |
val ind_Ts = rev (map snd ind_vars); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
274 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
275 |
val concl = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
276 |
(map (fn (prem, (p, ts)) => HOLogic.mk_imp (prem, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
277 |
HOLogic.list_all (ind_vars, lift_pred p |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
278 |
(map (fold_rev (NominalPackage.mk_perm ind_Ts) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
279 |
(map Bound (length atomTs downto 1))) ts)))) concls)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
280 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
281 |
val concl' = HOLogic.mk_Trueprop (foldr1 HOLogic.mk_conj |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
282 |
(map (fn (prem, (p, ts)) => HOLogic.mk_imp (prem, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
283 |
lift_pred' (Free (fs_ctxt_name, fsT)) p ts)) concls)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
284 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
285 |
val (vc_compat, vc_compat') = map (fn (params, sets, prems, (p, ts)) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
286 |
map (fn q => abs_params params (incr_boundvars ~1 (Logic.list_implies |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
287 |
(List.mapPartial (fn prem => |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
288 |
if null (preds_of ps prem) then SOME prem |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
289 |
else map_term (split_conj (K o I) names) prem prem) prems, q)))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
290 |
(maps (fn (t, T) => map (fn (u, U) => HOLogic.mk_Trueprop |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
291 |
(NominalPackage.fresh_star_const U T $ u $ t)) sets) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
292 |
(ts ~~ binder_types (fastype_of p)) @ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
293 |
map (fn (u, U) => HOLogic.mk_Trueprop (Const (@{const_name finite}, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
294 |
HOLogic.mk_setT U --> HOLogic.boolT) $ u)) sets) |> |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
295 |
split_list) prems |> split_list; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
296 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
297 |
val perm_pi_simp = PureThy.get_thms thy "perm_pi_simp"; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
298 |
val pt2_atoms = map (fn a => PureThy.get_thm thy |
30364
577edc39b501
moved basic algebra of long names from structure NameSpace to Long_Name;
wenzelm
parents:
30307
diff
changeset
|
299 |
("pt_" ^ Long_Name.base_name a ^ "2")) atoms; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
300 |
val eqvt_ss = Simplifier.theory_context thy HOL_basic_ss |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
301 |
addsimps (eqvt_thms @ perm_pi_simp @ pt2_atoms) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
302 |
addsimprocs [mk_perm_bool_simproc ["Fun.id"], |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
303 |
NominalPermeq.perm_simproc_app, NominalPermeq.perm_simproc_fun]; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
304 |
val fresh_star_bij = PureThy.get_thms thy "fresh_star_bij"; |
28730
71c946ce7eb9
Streamlined functions for accessing information about atoms.
berghofe
parents:
28653
diff
changeset
|
305 |
val pt_insts = map (NominalAtoms.pt_inst_of thy) atoms; |
71c946ce7eb9
Streamlined functions for accessing information about atoms.
berghofe
parents:
28653
diff
changeset
|
306 |
val at_insts = map (NominalAtoms.at_inst_of thy) atoms; |
71c946ce7eb9
Streamlined functions for accessing information about atoms.
berghofe
parents:
28653
diff
changeset
|
307 |
val dj_thms = maps (fn a => |
71c946ce7eb9
Streamlined functions for accessing information about atoms.
berghofe
parents:
28653
diff
changeset
|
308 |
map (NominalAtoms.dj_thm_of thy a) (atoms \ a)) atoms; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
309 |
val finite_ineq = map2 (fn th => fn th' => th' RS (th RS |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
310 |
@{thm pt_set_finite_ineq})) pt_insts at_insts; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
311 |
val perm_set_forget = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
312 |
map (fn th => th RS @{thm dj_perm_set_forget}) dj_thms; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
313 |
val perm_freshs_freshs = atomTs ~~ map2 (fn th => fn th' => th' RS (th RS |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
314 |
@{thm pt_freshs_freshs})) pt_insts at_insts; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
315 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
316 |
fun obtain_fresh_name ts sets (T, fin) (freshs, ths1, ths2, ths3, ctxt) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
317 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
318 |
val thy = ProofContext.theory_of ctxt; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
319 |
(** protect terms to avoid that fresh_star_prod_set interferes with **) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
320 |
(** pairs used in introduction rules of inductive predicate **) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
321 |
fun protect t = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
322 |
let val T = fastype_of t in Const ("Fun.id", T --> T) $ t end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
323 |
val p = foldr1 HOLogic.mk_prod (map protect ts); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
324 |
val atom = fst (dest_Type T); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
325 |
val {at_inst, ...} = NominalAtoms.the_atom_info thy atom; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
326 |
val fs_atom = PureThy.get_thm thy |
30364
577edc39b501
moved basic algebra of long names from structure NameSpace to Long_Name;
wenzelm
parents:
30307
diff
changeset
|
327 |
("fs_" ^ Long_Name.base_name atom ^ "1"); |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
328 |
val avoid_th = Drule.instantiate' |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
329 |
[SOME (ctyp_of thy (fastype_of p))] [SOME (cterm_of thy p)] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
330 |
([at_inst, fin, fs_atom] MRS @{thm at_set_avoiding}); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
331 |
val (([cx], th1 :: th2 :: ths), ctxt') = Obtain.result |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
332 |
(fn _ => EVERY |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
333 |
[rtac avoid_th 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
334 |
full_simp_tac (HOL_ss addsimps [@{thm fresh_star_prod_set}]) 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
335 |
full_simp_tac (HOL_basic_ss addsimps [@{thm id_apply}]) 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
336 |
rotate_tac 1 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
337 |
REPEAT (etac conjE 1)]) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
338 |
[] ctxt; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
339 |
val (Ts1, _ :: Ts2) = take_prefix (not o equal T) (map snd sets); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
340 |
val pTs = map NominalAtoms.mk_permT (Ts1 @ Ts2); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
341 |
val (pis1, pis2) = chop (length Ts1) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
342 |
(map Bound (length pTs - 1 downto 0)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
343 |
val _ $ (f $ (_ $ pi $ l) $ r) = prop_of th2 |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
344 |
val th2' = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
345 |
Goal.prove ctxt [] [] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
346 |
(list_all (map (pair "pi") pTs, HOLogic.mk_Trueprop |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
347 |
(f $ fold_rev (NominalPackage.mk_perm (rev pTs)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
348 |
(pis1 @ pi :: pis2) l $ r))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
349 |
(fn _ => cut_facts_tac [th2] 1 THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
350 |
full_simp_tac (HOL_basic_ss addsimps perm_set_forget) 1) |> |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
351 |
Simplifier.simplify eqvt_ss |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
352 |
in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
353 |
(freshs @ [term_of cx], |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
354 |
ths1 @ ths, ths2 @ [th1], ths3 @ [th2'], ctxt') |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
355 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
356 |
|
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
357 |
fun mk_ind_proof ctxt' thss = |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
358 |
Goal.prove ctxt' [] prems' concl' (fn {prems = ihyps, context = ctxt} => |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
359 |
let val th = Goal.prove ctxt [] [] concl (fn {context, ...} => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
360 |
rtac raw_induct 1 THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
361 |
EVERY (maps (fn (((((_, sets, oprems, _), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
362 |
vc_compat_ths), vc_compat_vs), ihyp), vs_ihypt) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
363 |
[REPEAT (rtac allI 1), simp_tac eqvt_ss 1, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
364 |
SUBPROOF (fn {prems = gprems, params, concl, context = ctxt', ...} => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
365 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
366 |
val (cparams', (pis, z)) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
367 |
chop (length params - length atomTs - 1) params ||> |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
368 |
(map term_of #> split_last); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
369 |
val params' = map term_of cparams' |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
370 |
val sets' = map (apfst (curry subst_bounds (rev params'))) sets; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
371 |
val pi_sets = map (fn (t, _) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
372 |
fold_rev (NominalPackage.mk_perm []) pis t) sets'; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
373 |
val (P, ts) = strip_comb (HOLogic.dest_Trueprop (term_of concl)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
374 |
val gprems1 = List.mapPartial (fn (th, t) => |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
375 |
if null (preds_of ps t) then SOME th |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
376 |
else |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
377 |
map_thm ctxt' (split_conj (K o I) names) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
378 |
(etac conjunct1 1) monos NONE th) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
379 |
(gprems ~~ oprems); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
380 |
val vc_compat_ths' = map2 (fn th => fn p => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
381 |
let |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
382 |
val th' = gprems1 MRS inst_params thy p th cparams'; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
383 |
val (h, ts) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
384 |
strip_comb (HOLogic.dest_Trueprop (concl_of th')) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
385 |
in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
386 |
Goal.prove ctxt' [] [] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
387 |
(HOLogic.mk_Trueprop (list_comb (h, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
388 |
map (fold_rev (NominalPackage.mk_perm []) pis) ts))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
389 |
(fn _ => simp_tac (HOL_basic_ss addsimps |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
390 |
(fresh_star_bij @ finite_ineq)) 1 THEN rtac th' 1) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
391 |
end) vc_compat_ths vc_compat_vs; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
392 |
val (vc_compat_ths1, vc_compat_ths2) = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
393 |
chop (length vc_compat_ths - length sets) vc_compat_ths'; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
394 |
val vc_compat_ths1' = map |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
395 |
(Conv.fconv_rule (Conv.arg_conv (Conv.arg_conv |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
396 |
(Simplifier.rewrite eqvt_ss)))) vc_compat_ths1; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
397 |
val (pis', fresh_ths1, fresh_ths2, fresh_ths3, ctxt'') = fold |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
398 |
(obtain_fresh_name ts sets) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
399 |
(map snd sets' ~~ vc_compat_ths2) ([], [], [], [], ctxt'); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
400 |
fun concat_perm pi1 pi2 = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
401 |
let val T = fastype_of pi1 |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
402 |
in if T = fastype_of pi2 then |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
403 |
Const ("List.append", T --> T --> T) $ pi1 $ pi2 |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
404 |
else pi2 |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
405 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
406 |
val pis'' = fold_rev (concat_perm #> map) pis' pis; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
407 |
val ihyp' = inst_params thy vs_ihypt ihyp |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
408 |
(map (fold_rev (NominalPackage.mk_perm []) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
409 |
(pis' @ pis) #> cterm_of thy) params' @ [cterm_of thy z]); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
410 |
fun mk_pi th = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
411 |
Simplifier.simplify (HOL_basic_ss addsimps [@{thm id_apply}] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
412 |
addsimprocs [NominalPackage.perm_simproc]) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
413 |
(Simplifier.simplify eqvt_ss |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
414 |
(fold_rev (mk_perm_bool o cterm_of thy) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
415 |
(pis' @ pis) th)); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
416 |
val gprems2 = map (fn (th, t) => |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
417 |
if null (preds_of ps t) then mk_pi th |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
418 |
else |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
419 |
mk_pi (the (map_thm ctxt (inst_conj_all names ps (rev pis'')) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
420 |
(inst_conj_all_tac (length pis'')) monos (SOME t) th))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
421 |
(gprems ~~ oprems); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
422 |
val perm_freshs_freshs' = map (fn (th, (_, T)) => |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
423 |
th RS the (AList.lookup op = perm_freshs_freshs T)) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
424 |
(fresh_ths2 ~~ sets); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
425 |
val th = Goal.prove ctxt'' [] [] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
426 |
(HOLogic.mk_Trueprop (list_comb (P $ hd ts, |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
427 |
map (fold_rev (NominalPackage.mk_perm []) pis') (tl ts)))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
428 |
(fn _ => EVERY ([simp_tac eqvt_ss 1, rtac ihyp' 1] @ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
429 |
map (fn th => rtac th 1) fresh_ths3 @ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
430 |
[REPEAT_DETERM_N (length gprems) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
431 |
(simp_tac (HOL_basic_ss |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
432 |
addsimps [inductive_forall_def'] |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
433 |
addsimprocs [NominalPackage.perm_simproc]) 1 THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
434 |
resolve_tac gprems2 1)])); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
435 |
val final = Goal.prove ctxt'' [] [] (term_of concl) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
436 |
(fn _ => cut_facts_tac [th] 1 THEN full_simp_tac (HOL_ss |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
437 |
addsimps vc_compat_ths1' @ fresh_ths1 @ |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
438 |
perm_freshs_freshs') 1); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
439 |
val final' = ProofContext.export ctxt'' ctxt' [final]; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
440 |
in resolve_tac final' 1 end) context 1]) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
441 |
(prems ~~ thss ~~ vc_compat' ~~ ihyps ~~ prems''))) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
442 |
in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
443 |
cut_facts_tac [th] 1 THEN REPEAT (etac conjE 1) THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
444 |
REPEAT (REPEAT (resolve_tac [conjI, impI] 1) THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
445 |
etac impE 1 THEN atac 1 THEN REPEAT (etac @{thm allE_Nil} 1) THEN |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
446 |
asm_full_simp_tac (simpset_of thy) 1) |
30108 | 447 |
end) |> |
448 |
fresh_postprocess |> |
|
449 |
singleton (ProofContext.export ctxt' ctxt); |
|
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
450 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
451 |
in |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
452 |
ctxt'' |> |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
453 |
Proof.theorem_i NONE (fn thss => fn ctxt => |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
454 |
let |
30364
577edc39b501
moved basic algebra of long names from structure NameSpace to Long_Name;
wenzelm
parents:
30307
diff
changeset
|
455 |
val rec_name = space_implode "_" (map Long_Name.base_name names); |
30223
24d975352879
renamed Binding.name_pos to Binding.make, renamed Binding.base_name to Binding.name_of, renamed Binding.map_base to Binding.map_name, added mandatory flag to Binding.qualify;
wenzelm
parents:
30108
diff
changeset
|
456 |
val rec_qualified = Binding.qualify false rec_name; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
457 |
val ind_case_names = RuleCases.case_names induct_cases; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
458 |
val induct_cases' = InductivePackage.partition_rules' raw_induct |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
459 |
(intrs ~~ induct_cases); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
460 |
val thss' = map (map atomize_intr) thss; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
461 |
val thsss = InductivePackage.partition_rules' raw_induct (intrs ~~ thss'); |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
462 |
val strong_raw_induct = |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
463 |
mk_ind_proof ctxt thss' |> InductivePackage.rulify; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
464 |
val strong_induct = |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
465 |
if length names > 1 then |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
466 |
(strong_raw_induct, [ind_case_names, RuleCases.consumes 0]) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
467 |
else (strong_raw_induct RSN (2, rev_mp), |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
468 |
[ind_case_names, RuleCases.consumes 1]); |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
469 |
val ((_, [strong_induct']), ctxt') = LocalTheory.note Thm.theoremK |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
470 |
((rec_qualified (Binding.name "strong_induct"), |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
471 |
map (Attrib.internal o K) (#2 strong_induct)), [#1 strong_induct]) |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
472 |
ctxt; |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
473 |
val strong_inducts = |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
474 |
ProjectRule.projects ctxt' (1 upto length names) strong_induct' |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
475 |
in |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
476 |
ctxt' |> |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
477 |
LocalTheory.note Thm.theoremK |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
478 |
((rec_qualified (Binding.name "strong_inducts"), |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
479 |
[Attrib.internal (K ind_case_names), |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
480 |
Attrib.internal (K (RuleCases.consumes 1))]), |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
481 |
strong_inducts) |> snd |
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
482 |
end) |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
483 |
(map (map (rulify_term thy #> rpair [])) vc_compat) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
484 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
485 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
486 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
487 |
(* outer syntax *) |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
488 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
489 |
local structure P = OuterParse and K = OuterKeyword in |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
490 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
491 |
val _ = |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
492 |
OuterSyntax.local_theory_to_proof "nominal_inductive2" |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
493 |
"prove strong induction theorem for inductive predicate involving nominal datatypes" K.thy_goal |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
494 |
(P.xname -- Scan.optional (P.$$$ "avoids" |-- P.enum1 "|" (P.name -- |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
495 |
(P.$$$ ":" |-- P.and_list1 P.term))) [] >> (fn (name, avoids) => |
30087
a780642a9c9c
nominal_inductive and equivariance now work on local_theory.
berghofe
parents:
29585
diff
changeset
|
496 |
prove_strong_ind name avoids)); |
28653
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
497 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
498 |
end; |
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
499 |
|
4593c70e228e
More general, still experimental version of nominal_inductive for
berghofe
parents:
diff
changeset
|
500 |
end |