author | Christian Urban <christian dot urban at kcl dot ac dot uk> |
Tue, 08 Jul 2014 11:18:31 +0100 | |
changeset 3238 | b2e1a7b83e05 |
parent 3231 | 188826f1ccdb |
child 3239 | 67370521c09c |
permissions | -rw-r--r-- |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(* Title: nominal_inductive.ML |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Christian Urban |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
3 |
Author: Tjark Weber |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
4 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
Infrastructure for proving strong induction theorems |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
for inductive predicates involving nominal datatypes. |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
Code based on an earlier version by Stefan Berghofer. |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
9 |
*) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
10 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
11 |
signature NOMINAL_INDUCTIVE = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
12 |
sig |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
13 |
val prove_strong_inductive: string list -> string list -> term list list -> thm -> thm list -> |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
14 |
Proof.context -> Proof.state |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
15 |
val prove_strong_inductive_cmd: xstring * (string * string list) list -> Proof.context -> Proof.state |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
16 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
17 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
structure Nominal_Inductive : NOMINAL_INDUCTIVE = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
19 |
struct |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
20 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
21 |
fun mk_cplus p q = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
22 |
Thm.apply (Thm.apply @{cterm "plus :: perm => perm => perm"} p) q |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
23 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
24 |
fun mk_cminus p = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
25 |
Thm.apply @{cterm "uminus :: perm => perm"} p |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
26 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
27 |
fun minus_permute_intro_tac p = |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
28 |
rtac (Drule.instantiate' [] [SOME (mk_cminus p)] @{thm permute_boolE}) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
29 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
30 |
fun minus_permute_elim p thm = |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
31 |
thm RS (Drule.instantiate' [] [NONE, SOME (mk_cminus p)] @{thm permute_boolI}) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
32 |
|
2680
cd5614027c53
removed diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2645
diff
changeset
|
33 |
(* fixme: move to nominal_library *) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
34 |
fun real_head_of (@{term Trueprop} $ t) = real_head_of t |
3231
188826f1ccdb
updated to massive changes in Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3218
diff
changeset
|
35 |
| real_head_of (Const (@{const_name Pure.imp}, _) $ _ $ t) = real_head_of t |
188826f1ccdb
updated to massive changes in Isabelle
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3218
diff
changeset
|
36 |
| real_head_of (Const (@{const_name Pure.all}, _) $ Abs (_, _, t)) = real_head_of t |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
37 |
| real_head_of (Const (@{const_name All}, _) $ Abs (_, _, t)) = real_head_of t |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
38 |
| real_head_of (Const ("HOL.induct_forall", _) $ Abs (_, _, t)) = real_head_of t |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
39 |
| real_head_of t = head_of t |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
40 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
41 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
42 |
fun mk_vc_compat (avoid, avoid_trm) prems concl_args params = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
43 |
if null avoid then |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
44 |
[] |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
45 |
else |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
46 |
let |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
47 |
val vc_goal = concl_args |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
48 |
|> HOLogic.mk_tuple |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
49 |
|> mk_fresh_star avoid_trm |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
50 |
|> HOLogic.mk_Trueprop |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
51 |
|> (curry Logic.list_implies) prems |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
52 |
|> fold_rev (Logic.all o Free) params |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
53 |
val finite_goal = avoid_trm |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
54 |
|> mk_finite |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
55 |
|> HOLogic.mk_Trueprop |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
56 |
|> (curry Logic.list_implies) prems |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
57 |
|> fold_rev (Logic.all o Free) params |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
58 |
in |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
59 |
[vc_goal, finite_goal] |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
60 |
end |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
|
2680
cd5614027c53
removed diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2645
diff
changeset
|
62 |
(* fixme: move to nominal_library *) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
63 |
fun map_term prop f trm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
64 |
if prop trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
65 |
then f trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
66 |
else case trm of |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
67 |
(t1 $ t2) => map_term prop f t1 $ map_term prop f t2 |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
68 |
| Abs (x, T, t) => Abs (x, T, map_term prop f t) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
69 |
| _ => trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
70 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
71 |
fun add_p_c p (c, c_ty) trm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
72 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
73 |
val (P, args) = strip_comb trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
74 |
val (P_name, P_ty) = dest_Free P |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
75 |
val (ty_args, bool) = strip_type P_ty |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
76 |
val args' = map (mk_perm p) args |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
78 |
list_comb (Free (P_name, (c_ty :: ty_args) ---> bool), c :: args') |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
79 |
|> (fn t => HOLogic.all_const c_ty $ lambda c t ) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|> (fn t => HOLogic.all_const @{typ perm} $ lambda p t) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
81 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
82 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
83 |
fun induct_forall_const T = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
84 |
Const ("HOL.induct_forall", (T --> @{typ bool}) --> @{typ bool}) |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
85 |
|
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
86 |
fun mk_induct_forall (a, T) t = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
87 |
induct_forall_const T $ Abs (a, T, t) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
88 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
89 |
fun add_c_prop qnt Ps (c, c_name, c_ty) trm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
90 |
let |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
91 |
fun add t = |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
92 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
93 |
val (P, args) = strip_comb t |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
94 |
val (P_name, P_ty) = dest_Free P |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
95 |
val (ty_args, bool) = strip_type P_ty |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
val args' = args |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
97 |
|> qnt ? map (incr_boundvars 1) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
98 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
99 |
list_comb (Free (P_name, (c_ty :: ty_args) ---> bool), c :: args') |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
100 |
|> qnt ? mk_induct_forall (c_name, c_ty) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
101 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
102 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
103 |
map_term (member (op =) Ps o head_of) add trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
104 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
105 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
106 |
fun prep_prem Ps c_name c_ty (avoid, avoid_trm) (params, prems, concl) = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
107 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
108 |
val prems' = prems |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
109 |
|> map (incr_boundvars 1) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
110 |
|> map (add_c_prop true Ps (Bound 0, c_name, c_ty)) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
111 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
112 |
val avoid_trm' = avoid_trm |
2994
4ee772b12032
Update to new Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2987
diff
changeset
|
113 |
|> fold_rev absfree (params @ [(c_name, c_ty)]) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
114 |
|> strip_abs_body |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
115 |
|> (fn t => mk_fresh_star_ty c_ty t (Bound 0)) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
116 |
|> HOLogic.mk_Trueprop |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
117 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
118 |
val prems'' = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
119 |
if null avoid |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
120 |
then prems' |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
121 |
else avoid_trm' :: prems' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
122 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
123 |
val concl' = concl |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
124 |
|> incr_boundvars 1 |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
125 |
|> add_c_prop false Ps (Bound 0, c_name, c_ty) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
126 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
127 |
mk_full_horn (params @ [(c_name, c_ty)]) prems'' concl' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
128 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
129 |
|
2680
cd5614027c53
removed diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2645
diff
changeset
|
130 |
(* fixme: move to nominal_library *) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
131 |
fun same_name (Free (a1, _), Free (a2, _)) = (a1 = a2) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
132 |
| same_name (Var (a1, _), Var (a2, _)) = (a1 = a2) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
133 |
| same_name (Const (a1, _), Const (a2, _)) = (a1 = a2) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
134 |
| same_name _ = false |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
135 |
|
2680
cd5614027c53
removed diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2645
diff
changeset
|
136 |
(* fixme: move to nominal_library *) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
137 |
fun map7 _ [] [] [] [] [] [] [] = [] |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
138 |
| map7 f (x :: xs) (y :: ys) (z :: zs) (u :: us) (v :: vs) (r :: rs) (s :: ss) = |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
139 |
f x y z u v r s :: map7 f xs ys zs us vs rs ss |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
140 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
141 |
(* local abbreviations *) |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
142 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
143 |
local |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
144 |
open Nominal_Permeq |
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
145 |
in |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
146 |
|
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
147 |
(* by default eqvt_strict_config contains unwanted @{thm permute_pure} *) |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
148 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
149 |
val eqvt_sconfig = eqvt_strict_config addpres @{thms permute_minus_cancel} |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
150 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
151 |
fun eqvt_stac ctxt = eqvt_tac ctxt eqvt_sconfig |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
152 |
fun eqvt_srule ctxt = eqvt_rule ctxt eqvt_sconfig |
2765
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
153 |
|
7ac5e5c86c7d
introduced framework for finetuning eqvt-rules; this solves problem with permute_pure called in nominal_inductive
Christian Urban <urbanc@in.tum.de>
parents:
2680
diff
changeset
|
154 |
end |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
155 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
156 |
val all_elims = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
157 |
let |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
158 |
fun spec' ct = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
159 |
Drule.instantiate' [SOME (ctyp_of_term ct)] [NONE, SOME ct] @{thm spec} |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
160 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
161 |
fold (fn ct => fn th => th RS spec' ct) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
162 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
163 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
164 |
fun helper_tac flag prm p ctxt = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
165 |
Subgoal.SUBPROOF (fn {context, prems, ...} => |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
166 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
167 |
val prems' = prems |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
168 |
|> map (minus_permute_elim p) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
169 |
|> map (eqvt_srule context) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
170 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
171 |
val prm' = (prems' MRS prm) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
172 |
|> flag ? (all_elims [p]) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
173 |
|> flag ? (eqvt_srule context) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
174 |
in |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
175 |
asm_full_simp_tac (put_simpset HOL_ss ctxt addsimps (prm' :: @{thms induct_forall_def})) 1 |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
176 |
end) ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
177 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
178 |
fun non_binder_tac prem intr_cvars Ps ctxt = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
179 |
Subgoal.SUBPROOF (fn {context, params, prems, ...} => |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
180 |
let |
3045
d0ad264f8c4f
updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
2994
diff
changeset
|
181 |
val thy = Proof_Context.theory_of context |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
182 |
val (prms, p, _) = split_last2 (map snd params) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
183 |
val prm_tys = map (fastype_of o term_of) prms |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
184 |
val cperms = map (cterm_of thy o perm_const) prm_tys |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
185 |
val p_prms = map2 (fn ct1 => fn ct2 => Thm.mk_binop ct1 p ct2) cperms prms |
2768
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
186 |
val prem' = prem |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
187 |
|> cterm_instantiate (intr_cvars ~~ p_prms) |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
188 |
|> eqvt_srule ctxt |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
189 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
190 |
(* for inductive-premises*) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
191 |
fun tac1 prm = helper_tac true prm p context |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
192 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
193 |
(* for non-inductive premises *) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
194 |
fun tac2 prm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
195 |
EVERY' [ minus_permute_intro_tac p, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
196 |
eqvt_stac context, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
197 |
helper_tac false prm p context ] |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
198 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
199 |
fun select prm (t, i) = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
200 |
(if member same_name Ps (real_head_of t) then tac1 prm else tac2 prm) i |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
201 |
in |
2768
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
202 |
EVERY1 [ eqvt_stac context, |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
203 |
rtac prem', |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
204 |
RANGE (map (SUBGOAL o select) prems) ] |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
205 |
end) ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
206 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
207 |
fun fresh_thm ctxt user_thm p c concl_args avoid_trm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
208 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
209 |
val conj1 = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
210 |
mk_fresh_star (mk_perm (Bound 0) (mk_perm p avoid_trm)) c |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
211 |
val conj2 = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
212 |
mk_fresh_star_ty @{typ perm} (mk_supp (HOLogic.mk_tuple (map (mk_perm p) concl_args))) (Bound 0) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
213 |
val fresh_goal = mk_exists ("q", @{typ perm}) (HOLogic.mk_conj (conj1, conj2)) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
214 |
|> HOLogic.mk_Trueprop |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
215 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
216 |
val ss = @{thms finite_supp supp_Pair finite_Un permute_finite} @ |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
217 |
@{thms fresh_star_Pair fresh_star_permute_iff} |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
218 |
val simp = asm_full_simp_tac (put_simpset HOL_ss ctxt addsimps ss) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
219 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
220 |
Goal.prove ctxt [] [] fresh_goal |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
221 |
(K (HEADGOAL (rtac @{thm at_set_avoiding2} |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
222 |
THEN_ALL_NEW EVERY' [cut_facts_tac user_thm, REPEAT o etac @{thm conjE}, simp]))) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
223 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
224 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
225 |
val supp_perm_eq' = @{lemma "fresh_star (supp (permute p x)) q ==> permute p x == permute (q + p) x" |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
226 |
by (simp add: supp_perm_eq)} |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
227 |
|
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
228 |
val fresh_star_plus = @{lemma "fresh_star (permute q (permute p x)) c ==> fresh_star (permute (q + p) x) c" |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
229 |
by (simp add: permute_plus)} |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
230 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
231 |
|
2645 | 232 |
fun binder_tac prem intr_cvars param_trms Ps user_thm avoid_trm concl_args ctxt = |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
233 |
Subgoal.FOCUS (fn {context = ctxt, params, prems, concl, ...} => |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
234 |
let |
3045
d0ad264f8c4f
updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
2994
diff
changeset
|
235 |
val thy = Proof_Context.theory_of ctxt |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
236 |
val (prms, p, c) = split_last2 (map snd params) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
237 |
val prm_trms = map term_of prms |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
238 |
val prm_tys = map fastype_of prm_trms |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
239 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
240 |
val avoid_trm' = subst_free (param_trms ~~ prm_trms) avoid_trm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
241 |
val concl_args' = map (subst_free (param_trms ~~ prm_trms)) concl_args |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
242 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
243 |
val user_thm' = map (cterm_instantiate (intr_cvars ~~ prms)) user_thm |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
244 |
|> map (full_simplify (put_simpset HOL_ss ctxt addsimps (@{thm fresh_star_Pair}::prems))) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
245 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
246 |
val fthm = fresh_thm ctxt user_thm' (term_of p) (term_of c) concl_args' avoid_trm' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
247 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
248 |
val (([(_, q)], fprop :: fresh_eqs), ctxt') = Obtain.result |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
249 |
(K (EVERY1 [etac @{thm exE}, |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
250 |
full_simp_tac (put_simpset HOL_basic_ss ctxt |
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
251 |
addsimps @{thms supp_Pair fresh_star_Un}), |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
252 |
REPEAT o etac @{thm conjE}, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
253 |
dtac fresh_star_plus, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
254 |
REPEAT o dtac supp_perm_eq'])) [fthm] ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
255 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
256 |
val expand_conv = Conv.try_conv (Conv.rewrs_conv fresh_eqs) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
fun expand_conv_bot ctxt = Conv.bottom_conv (K expand_conv) ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
val cperms = map (cterm_of thy o perm_const) prm_tys |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
260 |
val qp_prms = map2 (fn ct1 => fn ct2 => Thm.mk_binop ct1 (mk_cplus q p) ct2) cperms prms |
2768
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
261 |
val prem' = prem |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
262 |
|> cterm_instantiate (intr_cvars ~~ qp_prms) |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
263 |
|> eqvt_srule ctxt |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
264 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
265 |
val fprop' = eqvt_srule ctxt' fprop |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
266 |
val tac_fresh = simp_tac (put_simpset HOL_basic_ss ctxt' addsimps [fprop']) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
267 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
268 |
(* for inductive-premises*) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
269 |
fun tac1 prm = helper_tac true prm (mk_cplus q p) ctxt' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
270 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
271 |
(* for non-inductive premises *) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
272 |
fun tac2 prm = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
273 |
EVERY' [ minus_permute_intro_tac (mk_cplus q p), |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
274 |
eqvt_stac ctxt, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
275 |
helper_tac false prm (mk_cplus q p) ctxt' ] |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
276 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
277 |
fun select prm (t, i) = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
278 |
(if member same_name Ps (real_head_of t) then tac1 prm else tac2 prm) i |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
279 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
280 |
val side_thm = Goal.prove ctxt' [] [] (term_of concl) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
281 |
(fn {context, ...} => |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
282 |
EVERY1 [ CONVERSION (expand_conv_bot context), |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
283 |
eqvt_stac context, |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
284 |
rtac prem', |
2680
cd5614027c53
removed diagnostic code
Christian Urban <urbanc@in.tum.de>
parents:
2645
diff
changeset
|
285 |
RANGE (tac_fresh :: map (SUBGOAL o select) prems) ]) |
3045
d0ad264f8c4f
updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
2994
diff
changeset
|
286 |
|> singleton (Proof_Context.export ctxt' ctxt) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
287 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
288 |
rtac side_thm 1 |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
289 |
end) ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
290 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
291 |
fun case_tac ctxt Ps avoid avoid_trm intr_cvars param_trms prem user_thm concl_args = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
292 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
293 |
val tac1 = non_binder_tac prem intr_cvars Ps ctxt |
2645 | 294 |
val tac2 = binder_tac prem intr_cvars param_trms Ps user_thm avoid_trm concl_args ctxt |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
295 |
in |
2768
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
296 |
EVERY' [ rtac @{thm allI}, rtac @{thm allI}, |
639979b7fa6e
added permute_pure back into the nominal_inductive procedure; updated to Isabelle 17 April
Christian Urban <urbanc@in.tum.de>
parents:
2765
diff
changeset
|
297 |
if null avoid then tac1 else tac2 ] |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
298 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
299 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
300 |
fun prove_sinduct_tac raw_induct user_thms Ps avoids avoid_trms intr_cvars param_trms concl_args |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
301 |
{prems, context} = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
302 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
303 |
val cases_tac = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
304 |
map7 (case_tac context Ps) avoids avoid_trms intr_cvars param_trms prems user_thms concl_args |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
305 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
306 |
EVERY1 [ DETERM o rtac raw_induct, RANGE cases_tac ] |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
307 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
308 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
309 |
val normalise = @{lemma "(Q --> (!p c. P p c)) ==> (!!c. Q ==> P (0::perm) c)" by simp} |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
310 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
311 |
fun prove_strong_inductive pred_names rule_names avoids raw_induct intrs ctxt = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
312 |
let |
3045
d0ad264f8c4f
updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
2994
diff
changeset
|
313 |
val thy = Proof_Context.theory_of ctxt |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
314 |
val ((_, [raw_induct']), ctxt') = Variable.import true [raw_induct] ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
315 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
316 |
val (ind_prems, ind_concl) = raw_induct' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
317 |
|> prop_of |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
318 |
|> Logic.strip_horn |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
319 |
|>> map strip_full_horn |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
320 |
val params = map (fn (x, _, _) => x) ind_prems |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
321 |
val param_trms = (map o map) Free params |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
322 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
323 |
val intr_vars_tys = map (fn t => rev (Term.add_vars (prop_of t) [])) intrs |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
324 |
val intr_vars = (map o map) fst intr_vars_tys |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
325 |
val intr_vars_substs = map2 (curry (op ~~)) intr_vars param_trms |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
326 |
val intr_cvars = (map o map) (cterm_of thy o Var) intr_vars_tys |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
327 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
328 |
val (intr_prems, intr_concls) = intrs |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
329 |
|> map prop_of |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
330 |
|> map2 subst_Vars intr_vars_substs |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
331 |
|> map Logic.strip_horn |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
332 |
|> split_list |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
333 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
334 |
val intr_concls_args = |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
335 |
map (snd o fixed_nonfixed_args ctxt' o HOLogic.dest_Trueprop) intr_concls |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
336 |
|
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
337 |
val avoid_trms = avoids |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
338 |
|> (map o map) (setify ctxt') |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
339 |
|> map fold_union |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
340 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
341 |
val vc_compat_goals = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
342 |
map4 mk_vc_compat (avoids ~~ avoid_trms) intr_prems intr_concls_args params |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
343 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
344 |
val ([c_name, a, p], ctxt'') = Variable.variant_fixes ["c", "'a", "p"] ctxt' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
345 |
val c_ty = TFree (a, @{sort fs}) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
346 |
val c = Free (c_name, c_ty) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
347 |
val p = Free (p, @{typ perm}) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
348 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
349 |
val (preconds, ind_concls) = ind_concl |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
350 |
|> HOLogic.dest_Trueprop |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
351 |
|> HOLogic.dest_conj |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
352 |
|> map HOLogic.dest_imp |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
353 |
|> split_list |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
354 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
355 |
val Ps = map (fst o strip_comb) ind_concls |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
356 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
357 |
val ind_concl' = ind_concls |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
358 |
|> map (add_p_c p (c, c_ty)) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
359 |
|> (curry (op ~~)) preconds |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
360 |
|> map HOLogic.mk_imp |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
361 |
|> fold_conj |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
362 |
|> HOLogic.mk_Trueprop |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
363 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
364 |
val ind_prems' = ind_prems |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
365 |
|> map2 (prep_prem Ps c_name c_ty) (avoids ~~ avoid_trms) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
366 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
367 |
fun after_qed ctxt_outside user_thms ctxt = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
368 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
369 |
val strong_ind_thms = Goal.prove ctxt [] ind_prems' ind_concl' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
370 |
(prove_sinduct_tac raw_induct user_thms Ps avoids avoid_trms intr_cvars param_trms intr_concls_args) |
3045
d0ad264f8c4f
updated to Isabelle 3 Nov; it includes a hack to work around a bug in the localised version of the quotient package
Christian Urban <urbanc@in.tum.de>
parents:
2994
diff
changeset
|
371 |
|> singleton (Proof_Context.export ctxt ctxt_outside) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
372 |
|> Datatype_Aux.split_conj_thm |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
373 |
|> map (fn thm => thm RS normalise) |
3218
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
374 |
|> map (asm_full_simplify (put_simpset HOL_basic_ss ctxt |
89158f401b07
updated to simplifier changes
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
3214
diff
changeset
|
375 |
addsimps @{thms permute_zero induct_rulify})) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
376 |
|> map (Drule.rotate_prems (length ind_prems')) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
377 |
|> map zero_var_indexes |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
378 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
379 |
val qualified_thm_name = pred_names |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
380 |
|> map Long_Name.base_name |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
381 |
|> space_implode "_" |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
382 |
|> (fn s => Binding.qualify false s (Binding.name "strong_induct")) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
383 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
384 |
val attrs = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
385 |
[ Attrib.internal (K (Rule_Cases.consumes 1)), |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
386 |
Attrib.internal (K (Rule_Cases.case_names rule_names)) ] |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
387 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
388 |
ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
389 |
|> Local_Theory.note ((qualified_thm_name, attrs), strong_ind_thms) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
390 |
|> snd |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
391 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
392 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
393 |
Proof.theorem NONE (after_qed ctxt) ((map o map) (rpair []) vc_compat_goals) ctxt'' |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
394 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
395 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
396 |
fun prove_strong_inductive_cmd (pred_name, avoids) ctxt = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
397 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
398 |
val ({names, ...}, {raw_induct, intrs, ...}) = |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
399 |
Inductive.the_inductive ctxt (long_name ctxt pred_name) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
400 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
401 |
val rule_names = hd names |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
402 |
|> the o Induct.lookup_inductP ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
403 |
|> fst o Rule_Cases.get |
2987
27aab7a105eb
updated for new Isabelle (11. Aug.)
Christian Urban <urbanc@in.tum.de>
parents:
2768
diff
changeset
|
404 |
|> map (fst o fst) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
405 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
406 |
val case_names = map fst avoids |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
407 |
val _ = case duplicates (op =) case_names of |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
408 |
[] => () |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
409 |
| xs => error ("Duplicate case names: " ^ commas_quote xs) |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
410 |
val _ = case subtract (op =) rule_names case_names of |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
411 |
[] => () |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
412 |
| xs => error ("No such case(s) in inductive definition: " ^ commas_quote xs) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
413 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
414 |
val avoids_ordered = order_default (op =) [] rule_names avoids |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
415 |
|
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
416 |
fun read_avoids avoid_trms intr = |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
417 |
let |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
418 |
(* fixme hack *) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
419 |
val (((_, ctrms), _), ctxt') = Variable.import true [intr] ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
420 |
val trms = map (term_of o snd) ctrms |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
421 |
val ctxt'' = fold Variable.declare_term trms ctxt' |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
422 |
in |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
423 |
map (Syntax.read_term ctxt'') avoid_trms |
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
424 |
end |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
425 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
426 |
val avoid_trms = map2 read_avoids avoids_ordered intrs |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
427 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
428 |
prove_strong_inductive names rule_names avoid_trms raw_induct intrs ctxt |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
429 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
430 |
|
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
431 |
(* outer syntax *) |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
432 |
local |
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
433 |
val single_avoid_parser = |
3135
92b9b8d2888d
updated to new Isabelle (20 March)
Christian Urban <urbanc@in.tum.de>
parents:
3123
diff
changeset
|
434 |
Parse.name -- (@{keyword ":"} |-- Parse.and_list1 Parse.term) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
435 |
|
3214
13ab4f0a0b0e
Various changes to support Nominal2 commands in local contexts.
webertj
parents:
3190
diff
changeset
|
436 |
val avoids_parser = |
3135
92b9b8d2888d
updated to new Isabelle (20 March)
Christian Urban <urbanc@in.tum.de>
parents:
3123
diff
changeset
|
437 |
Scan.optional (@{keyword "avoids"} |-- Parse.enum1 "|" single_avoid_parser) [] |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
438 |
|
3135
92b9b8d2888d
updated to new Isabelle (20 March)
Christian Urban <urbanc@in.tum.de>
parents:
3123
diff
changeset
|
439 |
val main_parser = Parse.xname -- avoids_parser |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
440 |
in |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
441 |
val _ = |
3190
1b7c034c9e9e
used ML-antiquotation command_spec for new commands
Christian Urban <urbanc@in.tum.de>
parents:
3135
diff
changeset
|
442 |
Outer_Syntax.local_theory_to_proof @{command_spec "nominal_inductive"} |
3135
92b9b8d2888d
updated to new Isabelle (20 March)
Christian Urban <urbanc@in.tum.de>
parents:
3123
diff
changeset
|
443 |
"prove strong induction theorem for inductive predicate involving nominal datatypes" |
92b9b8d2888d
updated to new Isabelle (20 March)
Christian Urban <urbanc@in.tum.de>
parents:
3123
diff
changeset
|
444 |
(main_parser >> prove_strong_inductive_cmd) |
2639
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
445 |
end |
a8fc346deda3
exported the code into a separate file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
446 |
|
2994
4ee772b12032
Update to new Isabelle
Cezary Kaliszyk <kaliszyk@in.tum.de>
parents:
2987
diff
changeset
|
447 |
end |