1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
1 |
(* Title: nominal_library.ML
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
2 |
Author: Christian Urban
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
3 |
|
1979
|
4 |
Basic functions for nominal.
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
5 |
*)
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
6 |
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
7 |
signature NOMINAL_LIBRARY =
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
8 |
sig
|
2313
|
9 |
val last2: 'a list -> 'a * 'a
|
|
10 |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
11 |
val dest_listT: typ -> typ
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
12 |
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
13 |
val mk_minus: term -> term
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
14 |
val mk_plus: term -> term -> term
|
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
15 |
|
1899
|
16 |
val perm_ty: typ -> typ
|
1871
|
17 |
val mk_perm_ty: typ -> term -> term -> term
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
18 |
val mk_perm: term -> term -> term
|
1834
|
19 |
val dest_perm: term -> term * term
|
|
20 |
|
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
21 |
val mk_sort_of: term -> term
|
1979
|
22 |
val atom_ty: typ -> typ
|
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
23 |
val mk_atom_ty: typ -> term -> term
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
24 |
val mk_atom: term -> term
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
25 |
|
1979
|
26 |
val supp_ty: typ -> typ
|
2296
|
27 |
val supp_const: typ -> term
|
1979
|
28 |
val mk_supp_ty: typ -> term -> term
|
|
29 |
val mk_supp: term -> term
|
|
30 |
|
1834
|
31 |
val mk_equiv: thm -> thm
|
|
32 |
val safe_mk_equiv: thm -> thm
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
33 |
|
2289
|
34 |
val mk_diff: term * term -> term
|
2296
|
35 |
val mk_append: term * term -> term
|
2289
|
36 |
val mk_union: term * term -> term
|
|
37 |
val fold_union: term list -> term
|
|
38 |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
39 |
(* datatype operations *)
|
2296
|
40 |
val all_dtyps: Datatype_Aux.descr -> (string * sort) list -> typ list
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
41 |
val nth_dtyp: Datatype_Aux.descr -> (string * sort) list -> int -> typ
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
42 |
val all_dtyp_constrs_types: Datatype_Aux.descr -> (string * sort) list ->
|
2296
|
43 |
(term * typ * typ list * bool list) list list
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
44 |
val nth_dtyp_constrs_types: Datatype_Aux.descr -> (string * sort) list -> int ->
|
2296
|
45 |
(term * typ * typ list * bool list) list
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
46 |
val prefix_dt_names: Datatype_Aux.descr -> (string * sort) list -> string -> string list
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
47 |
|
2304
|
48 |
(* tactics for function package *)
|
|
49 |
val pat_completeness_auto: Proof.context -> tactic
|
|
50 |
val pat_completeness_simp: thm list -> Proof.context -> tactic
|
|
51 |
val prove_termination: Proof.context -> Function.info * local_theory
|
|
52 |
|
2311
|
53 |
(* transformations of premises in inductions *)
|
|
54 |
val transform_prem1: Proof.context -> string list -> thm -> thm
|
|
55 |
val transform_prem2: Proof.context -> string list -> thm -> thm
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
56 |
end
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
57 |
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
58 |
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
59 |
structure Nominal_Library: NOMINAL_LIBRARY =
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
60 |
struct
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
61 |
|
2313
|
62 |
fun last2 [] = raise Empty
|
|
63 |
| last2 [_] = raise Empty
|
2375
|
64 |
| last2 [x, y] = (x, y)
|
2313
|
65 |
| last2 (_ :: xs) = last2 xs
|
|
66 |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
67 |
fun dest_listT (Type (@{type_name list}, [T])) = T
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
68 |
| dest_listT T = raise TYPE ("dest_listT: list type expected", [T], [])
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
69 |
|
1979
|
70 |
fun mk_minus p = @{term "uminus::perm => perm"} $ p;
|
|
71 |
|
|
72 |
fun mk_plus p q = @{term "plus::perm => perm => perm"} $ p $ q;
|
1896
996d4411e95e
tuned; fleshed out some library functions about permutations; closed Datatype_Aux structure (increases readability)
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
73 |
|
1979
|
74 |
fun perm_ty ty = @{typ "perm"} --> ty --> ty;
|
|
75 |
fun mk_perm_ty ty p trm = Const (@{const_name "permute"}, perm_ty ty) $ p $ trm;
|
|
76 |
fun mk_perm p trm = mk_perm_ty (fastype_of trm) p trm;
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
77 |
|
1834
|
78 |
fun dest_perm (Const (@{const_name "permute"}, _) $ p $ t) = (p, t)
|
1979
|
79 |
| dest_perm t = raise TERM ("dest_perm", [t]);
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
80 |
|
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
81 |
fun mk_sort_of t = @{term "sort_of"} $ t;
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
82 |
|
1979
|
83 |
fun atom_ty ty = ty --> @{typ "atom"};
|
1963
|
84 |
fun mk_atom_ty ty t = Const (@{const_name "atom"}, atom_ty ty) $ t;
|
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
85 |
fun mk_atom t = mk_atom_ty (fastype_of t) t;
|
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
86 |
|
1979
|
87 |
|
|
88 |
fun supp_ty ty = ty --> @{typ "atom set"};
|
2296
|
89 |
fun supp_const ty = Const (@{const_name "supp"}, supp_ty ty)
|
|
90 |
fun mk_supp_ty ty t = supp_const ty $ t;
|
1979
|
91 |
fun mk_supp t = mk_supp_ty (fastype_of t) t;
|
|
92 |
|
|
93 |
|
1834
|
94 |
fun mk_equiv r = r RS @{thm eq_reflection};
|
|
95 |
fun safe_mk_equiv r = mk_equiv r handle Thm.THM _ => r;
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
96 |
|
1962
84a13d1e2511
moved mk_atom into the library; that meant that concrete atom classes need to be in Nominal2_Base
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
97 |
|
2296
|
98 |
(* functions that construct differences, appends and unions
|
|
99 |
but avoid producing empty atom sets or empty atom lists *)
|
2289
|
100 |
|
|
101 |
fun mk_diff (@{term "{}::atom set"}, _) = @{term "{}::atom set"}
|
|
102 |
| mk_diff (t1, @{term "{}::atom set"}) = t1
|
|
103 |
| mk_diff (t1, t2) = HOLogic.mk_binop @{const_name minus} (t1, t2)
|
|
104 |
|
2296
|
105 |
fun mk_append (@{term "[]::atom list"}, @{term "[]::atom list"}) = @{term "[]::atom list"}
|
|
106 |
| mk_append (t1, @{term "[]::atom list"}) = t1
|
|
107 |
| mk_append (@{term "[]::atom list"}, t2) = t2
|
|
108 |
| mk_append (t1, t2) = HOLogic.mk_binop @{const_name "append"} (t1, t2)
|
|
109 |
|
2289
|
110 |
fun mk_union (@{term "{}::atom set"}, @{term "{}::atom set"}) = @{term "{}::atom set"}
|
|
111 |
| mk_union (t1 , @{term "{}::atom set"}) = t1
|
|
112 |
| mk_union (@{term "{}::atom set"}, t2) = t2
|
2296
|
113 |
| mk_union (t1, t2) = HOLogic.mk_binop @{const_name "sup"} (t1, t2)
|
2289
|
114 |
|
|
115 |
fun fold_union trms = fold (curry mk_union) trms @{term "{}::atom set"}
|
|
116 |
|
|
117 |
|
2296
|
118 |
|
|
119 |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
120 |
(** datatypes **)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
121 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
122 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
123 |
(* returns the type of the nth datatype *)
|
2296
|
124 |
fun all_dtyps descr sorts =
|
|
125 |
map (fn n => Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec n)) (0 upto (length descr - 1))
|
|
126 |
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
127 |
fun nth_dtyp descr sorts n =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
128 |
Datatype_Aux.typ_of_dtyp descr sorts (Datatype_Aux.DtRec n);
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
129 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
130 |
(* returns info about constructors in a datatype *)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
131 |
fun all_dtyp_constrs_info descr =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
132 |
map (fn (_, (ty, vs, constrs)) => map (pair (ty, vs)) constrs) descr
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
133 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
134 |
(* returns the constants of the constructors plus the
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
135 |
corresponding type and types of arguments *)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
136 |
fun all_dtyp_constrs_types descr sorts =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
137 |
let
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
138 |
fun aux ((ty_name, vs), (cname, args)) =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
139 |
let
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
140 |
val vs_tys = map (Datatype_Aux.typ_of_dtyp descr sorts) vs
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
141 |
val ty = Type (ty_name, vs_tys)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
142 |
val arg_tys = map (Datatype_Aux.typ_of_dtyp descr sorts) args
|
2296
|
143 |
val is_rec = map Datatype_Aux.is_rec_type args
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
144 |
in
|
2296
|
145 |
(Const (cname, arg_tys ---> ty), ty, arg_tys, is_rec)
|
2288
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
146 |
end
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
147 |
in
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
148 |
map (map aux) (all_dtyp_constrs_info descr)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
149 |
end
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
150 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
151 |
fun nth_dtyp_constrs_types descr sorts n =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
152 |
nth (all_dtyp_constrs_types descr sorts) n
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
153 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
154 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
155 |
(* generates for every datatype a name str ^ dt_name
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
156 |
plus and index for multiple occurences of a string *)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
157 |
fun prefix_dt_names descr sorts str =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
158 |
let
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
159 |
fun get_nth_name (i, _) =
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
160 |
Datatype_Aux.name_of_typ (nth_dtyp descr sorts i)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
161 |
in
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
162 |
Datatype_Prop.indexify_names
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
163 |
(map (prefix str o get_nth_name) descr)
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
164 |
end
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
165 |
|
3b83960f9544
new fv/fv_bn function (supp breaks now); exported raw perms and raw funs into separate ML-files
Christian Urban <urbanc@in.tum.de>
diff
changeset
|
166 |
|
2311
|
167 |
|
|
168 |
(** function package tactics **)
|
|
169 |
|
2304
|
170 |
fun pat_completeness_auto lthy =
|
|
171 |
Pat_Completeness.pat_completeness_tac lthy 1
|
|
172 |
THEN auto_tac (clasimpset_of lthy)
|
|
173 |
|
|
174 |
fun pat_completeness_simp simps lthy =
|
|
175 |
let
|
|
176 |
val simp_set = HOL_basic_ss addsimps (@{thms sum.inject sum.distinct} @ simps)
|
|
177 |
in
|
|
178 |
Pat_Completeness.pat_completeness_tac lthy 1
|
|
179 |
THEN ALLGOALS (asm_full_simp_tac simp_set)
|
|
180 |
end
|
|
181 |
|
|
182 |
fun prove_termination lthy =
|
|
183 |
Function.prove_termination NONE
|
|
184 |
(Lexicographic_Order.lexicographic_order_tac true lthy) lthy
|
|
185 |
|
2311
|
186 |
|
|
187 |
(** transformations of premises (in inductive proofs) **)
|
|
188 |
|
|
189 |
(*
|
|
190 |
given the theorem F[t]; proves the theorem F[f t]
|
|
191 |
|
|
192 |
- F needs to be monotone
|
|
193 |
- f returns either SOME for a term it fires on
|
|
194 |
and NONE elsewhere
|
|
195 |
*)
|
|
196 |
fun map_term f t =
|
|
197 |
(case f t of
|
|
198 |
NONE => map_term' f t
|
|
199 |
| x => x)
|
|
200 |
and map_term' f (t $ u) =
|
|
201 |
(case (map_term f t, map_term f u) of
|
|
202 |
(NONE, NONE) => NONE
|
|
203 |
| (SOME t'', NONE) => SOME (t'' $ u)
|
|
204 |
| (NONE, SOME u'') => SOME (t $ u'')
|
|
205 |
| (SOME t'', SOME u'') => SOME (t'' $ u''))
|
|
206 |
| map_term' f (Abs (s, T, t)) =
|
|
207 |
(case map_term f t of
|
|
208 |
NONE => NONE
|
|
209 |
| SOME t'' => SOME (Abs (s, T, t'')))
|
|
210 |
| map_term' _ _ = NONE;
|
|
211 |
|
|
212 |
fun map_thm_tac ctxt tac thm =
|
|
213 |
let
|
|
214 |
val monos = Inductive.get_monos ctxt
|
|
215 |
val simps = HOL_basic_ss addsimps @{thms split_def}
|
|
216 |
in
|
|
217 |
EVERY [cut_facts_tac [thm] 1, etac rev_mp 1,
|
|
218 |
REPEAT_DETERM (FIRSTGOAL (simp_tac simps THEN' resolve_tac monos)),
|
|
219 |
REPEAT_DETERM (rtac impI 1 THEN (atac 1 ORELSE tac))]
|
|
220 |
end
|
|
221 |
|
|
222 |
fun map_thm ctxt f tac thm =
|
|
223 |
let
|
|
224 |
val opt_goal_trm = map_term f (prop_of thm)
|
|
225 |
in
|
|
226 |
case opt_goal_trm of
|
|
227 |
NONE => thm
|
|
228 |
| SOME goal =>
|
|
229 |
Goal.prove ctxt [] [] goal (fn _ => map_thm_tac ctxt tac thm)
|
|
230 |
end
|
|
231 |
|
|
232 |
(*
|
|
233 |
inductive premises can be of the form
|
|
234 |
R ... /\ P ...; split_conj_i picks out
|
|
235 |
the part R or P part
|
|
236 |
*)
|
|
237 |
fun split_conj1 names (Const ("op &", _) $ f1 $ f2) =
|
|
238 |
(case head_of f1 of
|
|
239 |
Const (name, _) => if member (op =) names name then SOME f1 else NONE
|
|
240 |
| _ => NONE)
|
|
241 |
| split_conj1 _ _ = NONE;
|
|
242 |
|
|
243 |
fun split_conj2 names (Const ("op &", _) $ f1 $ f2) =
|
|
244 |
(case head_of f1 of
|
|
245 |
Const (name, _) => if member (op =) names name then SOME f2 else NONE
|
|
246 |
| _ => NONE)
|
|
247 |
| split_conj2 _ _ = NONE;
|
|
248 |
|
|
249 |
fun transform_prem1 ctxt names thm =
|
|
250 |
map_thm ctxt (split_conj1 names) (etac conjunct1 1) thm
|
|
251 |
|
|
252 |
fun transform_prem2 ctxt names thm =
|
|
253 |
map_thm ctxt (split_conj2 names) (etac conjunct2 1) thm
|
|
254 |
|
|
255 |
|
|
256 |
|
1833
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
257 |
end (* structure *)
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
258 |
|
2050b5723c04
added a library for basic nominal functions; separated nominal_eqvt file
Christian Urban <urbanc@in.tum.de>
parents:
diff
changeset
|
259 |
open Nominal_Library; |