author | paulson |
Mon, 07 Oct 1996 10:23:35 +0200 | |
changeset 2054 | bf3891343aa5 |
parent 2036 | 62ff902eeffc |
child 2082 | 8659e3063a30 |
permissions | -rw-r--r-- |
1465 | 1 |
(* Title: HOL/simpdata.ML |
923 | 2 |
ID: $Id$ |
1465 | 3 |
Author: Tobias Nipkow |
923 | 4 |
Copyright 1991 University of Cambridge |
5 |
||
6 |
Instantiation of the generic simplifier |
|
7 |
*) |
|
8 |
||
1984 | 9 |
section "Simplifier"; |
10 |
||
923 | 11 |
open Simplifier; |
12 |
||
1922 | 13 |
(*** Integration of simplifier with classical reasoner ***) |
14 |
||
15 |
(*Add a simpset to a classical set!*) |
|
16 |
infix 4 addss; |
|
17 |
fun cs addss ss = cs addbefore asm_full_simp_tac ss 1; |
|
18 |
||
19 |
fun Addss ss = (claset := !claset addbefore asm_full_simp_tac ss 1); |
|
20 |
||
1968
daa97cc96feb
Beefed-up auto-tactic: now repeatedly simplifies if needed
paulson
parents:
1948
diff
changeset
|
21 |
(*Designed to be idempotent, except if best_tac instantiates variables |
daa97cc96feb
Beefed-up auto-tactic: now repeatedly simplifies if needed
paulson
parents:
1948
diff
changeset
|
22 |
in some of the subgoals*) |
1922 | 23 |
fun auto_tac (cs,ss) = |
24 |
ALLGOALS (asm_full_simp_tac ss) THEN |
|
1968
daa97cc96feb
Beefed-up auto-tactic: now repeatedly simplifies if needed
paulson
parents:
1948
diff
changeset
|
25 |
REPEAT (safe_tac cs THEN ALLGOALS (asm_full_simp_tac ss)) THEN |
2036 | 26 |
REPEAT (FIRSTGOAL (best_tac (cs addss ss))) THEN |
27 |
prune_params_tac; |
|
1922 | 28 |
|
29 |
fun Auto_tac() = auto_tac (!claset, !simpset); |
|
30 |
||
31 |
fun auto() = by (Auto_tac()); |
|
32 |
||
33 |
||
1984 | 34 |
(*** Addition of rules to simpsets and clasets simultaneously ***) |
35 |
||
36 |
(*Takes UNCONDITIONAL theorems of the form A<->B to |
|
2031 | 37 |
the Safe Intr rule B==>A and |
38 |
the Safe Destruct rule A==>B. |
|
1984 | 39 |
Also ~A goes to the Safe Elim rule A ==> ?R |
40 |
Failing other cases, A is added as a Safe Intr rule*) |
|
41 |
local |
|
42 |
val iff_const = HOLogic.eq_const HOLogic.boolT; |
|
43 |
||
44 |
fun addIff th = |
|
45 |
(case HOLogic.dest_Trueprop (#prop(rep_thm th)) of |
|
2031 | 46 |
(Const("not",_) $ A) => |
47 |
AddSEs [zero_var_indexes (th RS notE)] |
|
48 |
| (con $ _ $ _) => |
|
49 |
if con=iff_const |
|
50 |
then (AddSIs [zero_var_indexes (th RS iffD2)]; |
|
51 |
AddSDs [zero_var_indexes (th RS iffD1)]) |
|
52 |
else AddSIs [th] |
|
53 |
| _ => AddSIs [th]; |
|
1984 | 54 |
Addsimps [th]) |
55 |
handle _ => error ("AddIffs: theorem must be unconditional\n" ^ |
|
2031 | 56 |
string_of_thm th) |
1984 | 57 |
|
58 |
fun delIff th = |
|
59 |
(case HOLogic.dest_Trueprop (#prop(rep_thm th)) of |
|
2031 | 60 |
(Const("not",_) $ A) => |
61 |
Delrules [zero_var_indexes (th RS notE)] |
|
62 |
| (con $ _ $ _) => |
|
63 |
if con=iff_const |
|
64 |
then Delrules [zero_var_indexes (th RS iffD2), |
|
65 |
zero_var_indexes (th RS iffD1)] |
|
66 |
else Delrules [th] |
|
67 |
| _ => Delrules [th]; |
|
1984 | 68 |
Delsimps [th]) |
69 |
handle _ => warning("DelIffs: ignoring conditional theorem\n" ^ |
|
2031 | 70 |
string_of_thm th) |
1984 | 71 |
in |
72 |
val AddIffs = seq addIff |
|
73 |
val DelIffs = seq delIff |
|
74 |
end; |
|
75 |
||
76 |
||
923 | 77 |
local |
78 |
||
1922 | 79 |
fun prover s = prove_goal HOL.thy s (fn _ => [fast_tac HOL_cs 1]); |
923 | 80 |
|
1922 | 81 |
val P_imp_P_iff_True = prover "P --> (P = True)" RS mp; |
82 |
val P_imp_P_eq_True = P_imp_P_iff_True RS eq_reflection; |
|
923 | 83 |
|
1922 | 84 |
val not_P_imp_P_iff_F = prover "~P --> (P = False)" RS mp; |
85 |
val not_P_imp_P_eq_False = not_P_imp_P_iff_F RS eq_reflection; |
|
923 | 86 |
|
1922 | 87 |
fun atomize pairs = |
88 |
let fun atoms th = |
|
2031 | 89 |
(case concl_of th of |
90 |
Const("Trueprop",_) $ p => |
|
91 |
(case head_of p of |
|
92 |
Const(a,_) => |
|
93 |
(case assoc(pairs,a) of |
|
94 |
Some(rls) => flat (map atoms ([th] RL rls)) |
|
95 |
| None => [th]) |
|
96 |
| _ => [th]) |
|
97 |
| _ => [th]) |
|
1922 | 98 |
in atoms end; |
923 | 99 |
|
1922 | 100 |
fun mk_meta_eq r = case concl_of r of |
2031 | 101 |
Const("==",_)$_$_ => r |
1922 | 102 |
| _$(Const("op =",_)$_$_) => r RS eq_reflection |
103 |
| _$(Const("not",_)$_) => r RS not_P_imp_P_eq_False |
|
104 |
| _ => r RS P_imp_P_eq_True; |
|
105 |
(* last 2 lines requires all formulae to be of the from Trueprop(.) *) |
|
923 | 106 |
|
1922 | 107 |
fun gen_all th = forall_elim_vars (#maxidx(rep_thm th)+1) th; |
923 | 108 |
|
1922 | 109 |
val simp_thms = map prover |
110 |
[ "(x=x) = True", |
|
111 |
"(~True) = False", "(~False) = True", "(~ ~ P) = P", |
|
112 |
"(~P) ~= P", "P ~= (~P)", "(P ~= Q) = (P = (~Q))", |
|
113 |
"(True=P) = P", "(P=True) = P", |
|
114 |
"(True --> P) = P", "(False --> P) = True", |
|
115 |
"(P --> True) = True", "(P --> P) = True", |
|
116 |
"(P --> False) = (~P)", "(P --> ~P) = (~P)", |
|
117 |
"(P & True) = P", "(True & P) = P", |
|
118 |
"(P & False) = False", "(False & P) = False", "(P & P) = P", |
|
119 |
"(P | True) = True", "(True | P) = True", |
|
120 |
"(P | False) = P", "(False | P) = P", "(P | P) = P", |
|
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
121 |
"((~P) = (~Q)) = (P=Q)", |
1922 | 122 |
"(!x.P) = P", "(? x.P) = P", "? x. x=t", |
2054 | 123 |
"(? x. x=t & P(x)) = P(t)", "(? x. t=x & P(x)) = P(t)", |
124 |
"(! x. x=t --> P(x)) = P(t)", "(! x. t=x --> P(x)) = P(t)" ]; |
|
923 | 125 |
|
126 |
in |
|
127 |
||
128 |
val meta_eq_to_obj_eq = prove_goal HOL.thy "x==y ==> x=y" |
|
129 |
(fn [prem] => [rewtac prem, rtac refl 1]); |
|
130 |
||
131 |
val eq_sym_conv = prover "(x=y) = (y=x)"; |
|
132 |
||
133 |
val conj_assoc = prover "((P&Q)&R) = (P&(Q&R))"; |
|
134 |
||
1922 | 135 |
val disj_assoc = prover "((P|Q)|R) = (P|(Q|R))"; |
136 |
||
137 |
val imp_disj = prover "(P|Q --> R) = ((P-->R)&(Q-->R))"; |
|
138 |
||
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
139 |
(*Avoids duplication of subgoals after expand_if, when the true and false |
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
140 |
cases boil down to the same thing.*) |
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
141 |
val cases_simp = prover "((P --> Q) & (~P --> Q)) = Q"; |
1922 | 142 |
|
965 | 143 |
val if_True = prove_goalw HOL.thy [if_def] "(if True then x else y) = x" |
923 | 144 |
(fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]); |
145 |
||
965 | 146 |
val if_False = prove_goalw HOL.thy [if_def] "(if False then x else y) = y" |
923 | 147 |
(fn _=>[fast_tac (HOL_cs addIs [select_equality]) 1]); |
148 |
||
965 | 149 |
val if_P = prove_goal HOL.thy "P ==> (if P then x else y) = x" |
923 | 150 |
(fn [prem] => [ stac (prem RS eqTrueI) 1, rtac if_True 1 ]); |
151 |
||
965 | 152 |
val if_not_P = prove_goal HOL.thy "~P ==> (if P then x else y) = y" |
923 | 153 |
(fn [prem] => [ stac (prem RS not_P_imp_P_iff_F) 1, rtac if_False 1 ]); |
154 |
||
155 |
val expand_if = prove_goal HOL.thy |
|
965 | 156 |
"P(if Q then x else y) = ((Q --> P(x)) & (~Q --> P(y)))" |
923 | 157 |
(fn _=> [ (res_inst_tac [("Q","Q")] (excluded_middle RS disjE) 1), |
2031 | 158 |
stac if_P 2, |
159 |
stac if_not_P 1, |
|
1465 | 160 |
REPEAT(fast_tac HOL_cs 1) ]); |
923 | 161 |
|
965 | 162 |
val if_bool_eq = prove_goal HOL.thy |
163 |
"(if P then Q else R) = ((P-->Q) & (~P-->R))" |
|
164 |
(fn _ => [rtac expand_if 1]); |
|
923 | 165 |
|
988 | 166 |
(*Add congruence rules for = (instead of ==) *) |
167 |
infix 4 addcongs; |
|
923 | 168 |
fun ss addcongs congs = ss addeqcongs (congs RL [eq_reflection]); |
169 |
||
1264 | 170 |
fun Addcongs congs = (simpset := !simpset addcongs congs); |
171 |
||
923 | 172 |
val mksimps_pairs = |
173 |
[("op -->", [mp]), ("op &", [conjunct1,conjunct2]), |
|
174 |
("All", [spec]), ("True", []), ("False", []), |
|
965 | 175 |
("If", [if_bool_eq RS iffD1])]; |
923 | 176 |
|
177 |
fun mksimps pairs = map mk_meta_eq o atomize pairs o gen_all; |
|
178 |
||
1922 | 179 |
val imp_cong = impI RSN |
180 |
(2, prove_goal HOL.thy "(P=P')--> (P'--> (Q=Q'))--> ((P-->Q) = (P'-->Q'))" |
|
181 |
(fn _=> [fast_tac HOL_cs 1]) RS mp RS mp); |
|
182 |
||
183 |
val o_apply = prove_goalw HOL.thy [o_def] "(f o g)(x) = f(g(x))" |
|
184 |
(fn _ => [rtac refl 1]); |
|
185 |
||
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
186 |
(*Miniscoping: pushing in existential quantifiers*) |
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
187 |
val ex_simps = map prover |
2031 | 188 |
["(EX x. P x & Q) = ((EX x.P x) & Q)", |
189 |
"(EX x. P & Q x) = (P & (EX x.Q x))", |
|
190 |
"(EX x. P x | Q) = ((EX x.P x) | Q)", |
|
191 |
"(EX x. P | Q x) = (P | (EX x.Q x))", |
|
192 |
"(EX x. P x --> Q) = ((ALL x.P x) --> Q)", |
|
193 |
"(EX x. P --> Q x) = (P --> (EX x.Q x))"]; |
|
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
194 |
|
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
195 |
(*Miniscoping: pushing in universal quantifiers*) |
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
196 |
val all_simps = map prover |
2031 | 197 |
["(ALL x. P x & Q) = ((ALL x.P x) & Q)", |
198 |
"(ALL x. P & Q x) = (P & (ALL x.Q x))", |
|
199 |
"(ALL x. P x | Q) = ((ALL x.P x) | Q)", |
|
200 |
"(ALL x. P | Q x) = (P | (ALL x.Q x))", |
|
201 |
"(ALL x. P x --> Q) = ((EX x.P x) --> Q)", |
|
202 |
"(ALL x. P --> Q x) = (P --> (ALL x.Q x))"]; |
|
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
203 |
|
923 | 204 |
val HOL_ss = empty_ss |
205 |
setmksimps (mksimps mksimps_pairs) |
|
206 |
setsolver (fn prems => resolve_tac (TrueI::refl::prems) ORELSE' atac |
|
207 |
ORELSE' etac FalseE) |
|
208 |
setsubgoaler asm_simp_tac |
|
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
209 |
addsimps ([if_True, if_False, o_apply, imp_disj, conj_assoc, disj_assoc, |
2031 | 210 |
cases_simp] |
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
211 |
@ ex_simps @ all_simps @ simp_thms) |
923 | 212 |
addcongs [imp_cong]; |
213 |
||
1922 | 214 |
|
215 |
(*In general it seems wrong to add distributive laws by default: they |
|
1948
78e5bfcbc1e9
Added miniscoping to the simplifier: quantifiers are now pushed in
paulson
parents:
1922
diff
changeset
|
216 |
might cause exponential blow-up. But imp_disj has been in for a while |
1922 | 217 |
and cannot be removed without affecting existing proofs. Moreover, |
218 |
rewriting by "(P|Q --> R) = ((P-->R)&(Q-->R))" might be justified on the |
|
219 |
grounds that it allows simplification of R in the two cases.*) |
|
220 |
||
221 |
||
941 | 222 |
local val mktac = mk_case_split_tac (meta_eq_to_obj_eq RS iffD2) |
223 |
in |
|
224 |
fun split_tac splits = mktac (map mk_meta_eq splits) |
|
225 |
end; |
|
226 |
||
1722 | 227 |
local val mktac = mk_case_split_inside_tac (meta_eq_to_obj_eq RS iffD2) |
228 |
in |
|
229 |
fun split_inside_tac splits = mktac (map mk_meta_eq splits) |
|
230 |
end; |
|
231 |
||
923 | 232 |
|
2022 | 233 |
(* elimination of existential quantifiers in assumptions *) |
923 | 234 |
|
235 |
val ex_all_equiv = |
|
236 |
let val lemma1 = prove_goal HOL.thy |
|
237 |
"(? x. P(x) ==> PROP Q) ==> (!!x. P(x) ==> PROP Q)" |
|
238 |
(fn prems => [resolve_tac prems 1, etac exI 1]); |
|
239 |
val lemma2 = prove_goalw HOL.thy [Ex_def] |
|
240 |
"(!!x. P(x) ==> PROP Q) ==> (? x. P(x) ==> PROP Q)" |
|
241 |
(fn prems => [REPEAT(resolve_tac prems 1)]) |
|
242 |
in equal_intr lemma1 lemma2 end; |
|
243 |
||
244 |
(* '&' congruence rule: not included by default! |
|
245 |
May slow rewrite proofs down by as much as 50% *) |
|
246 |
||
2022 | 247 |
val conj_cong = |
248 |
let val th = prove_goal HOL.thy |
|
249 |
"(P=P')--> (P'--> (Q=Q'))--> ((P&Q) = (P'&Q'))" |
|
2031 | 250 |
(fn _=> [fast_tac HOL_cs 1]) |
2022 | 251 |
in standard (impI RSN (2, th RS mp RS mp)) end; |
923 | 252 |
|
2022 | 253 |
val rev_conj_cong = |
254 |
let val th = prove_goal HOL.thy |
|
255 |
"(Q=Q')--> (Q'--> (P=P'))--> ((P&Q) = (P'&Q'))" |
|
2031 | 256 |
(fn _=> [fast_tac HOL_cs 1]) |
2022 | 257 |
in standard (impI RSN (2, th RS mp RS mp)) end; |
258 |
||
259 |
(* '|' congruence rule: not included by default! *) |
|
260 |
||
261 |
val disj_cong = |
|
262 |
let val th = prove_goal HOL.thy |
|
263 |
"(P=P')--> (~P'--> (Q=Q'))--> ((P|Q) = (P'|Q'))" |
|
2031 | 264 |
(fn _=> [fast_tac HOL_cs 1]) |
2022 | 265 |
in standard (impI RSN (2, th RS mp RS mp)) end; |
1548 | 266 |
|
923 | 267 |
(** 'if' congruence rules: neither included by default! *) |
268 |
||
269 |
(*Simplifies x assuming c and y assuming ~c*) |
|
270 |
val if_cong = prove_goal HOL.thy |
|
965 | 271 |
"[| b=c; c ==> x=u; ~c ==> y=v |] ==>\ |
272 |
\ (if b then x else y) = (if c then u else v)" |
|
923 | 273 |
(fn rew::prems => |
274 |
[stac rew 1, stac expand_if 1, stac expand_if 1, |
|
275 |
fast_tac (HOL_cs addDs prems) 1]); |
|
276 |
||
277 |
(*Prevents simplification of x and y: much faster*) |
|
278 |
val if_weak_cong = prove_goal HOL.thy |
|
965 | 279 |
"b=c ==> (if b then x else y) = (if c then x else y)" |
923 | 280 |
(fn [prem] => [rtac (prem RS arg_cong) 1]); |
281 |
||
282 |
(*Prevents simplification of t: much faster*) |
|
283 |
val let_weak_cong = prove_goal HOL.thy |
|
284 |
"a = b ==> (let x=a in t(x)) = (let x=b in t(x))" |
|
285 |
(fn [prem] => [rtac (prem RS arg_cong) 1]); |
|
286 |
||
287 |
end; |
|
288 |
||
289 |
fun prove nm thm = qed_goal nm HOL.thy thm (fn _ => [fast_tac HOL_cs 1]); |
|
290 |
||
291 |
prove "conj_commute" "(P&Q) = (Q&P)"; |
|
292 |
prove "conj_left_commute" "(P&(Q&R)) = (Q&(P&R))"; |
|
293 |
val conj_comms = [conj_commute, conj_left_commute]; |
|
294 |
||
1922 | 295 |
prove "disj_commute" "(P|Q) = (Q|P)"; |
296 |
prove "disj_left_commute" "(P|(Q|R)) = (Q|(P|R))"; |
|
297 |
val disj_comms = [disj_commute, disj_left_commute]; |
|
298 |
||
923 | 299 |
prove "conj_disj_distribL" "(P&(Q|R)) = (P&Q | P&R)"; |
300 |
prove "conj_disj_distribR" "((P|Q)&R) = (P&R | Q&R)"; |
|
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1465
diff
changeset
|
301 |
|
1892 | 302 |
prove "disj_conj_distribL" "(P|(Q&R)) = ((P|Q) & (P|R))"; |
303 |
prove "disj_conj_distribR" "((P&Q)|R) = ((P|R) & (Q|R))"; |
|
304 |
||
305 |
prove "imp_conj_distrib" "(P --> (Q&R)) = ((P-->Q) & (P-->R))"; |
|
1922 | 306 |
prove "imp_conj" "((P&Q)-->R) = (P --> (Q --> R))"; |
1892 | 307 |
|
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1465
diff
changeset
|
308 |
prove "de_Morgan_disj" "(~(P | Q)) = (~P & ~Q)"; |
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1465
diff
changeset
|
309 |
prove "de_Morgan_conj" "(~(P & Q)) = (~P | ~Q)"; |
1922 | 310 |
prove "not_iff" "(P~=Q) = (P = (~Q))"; |
1485
240cc98b94a7
Added qed_spec_mp to avoid renaming of bound vars in 'th RS spec'
nipkow
parents:
1465
diff
changeset
|
311 |
|
1660 | 312 |
prove "not_all" "(~ (! x.P(x))) = (? x.~P(x))"; |
1922 | 313 |
prove "imp_all" "((! x. P x) --> Q) = (? x. P x --> Q)"; |
1660 | 314 |
prove "not_ex" "(~ (? x.P(x))) = (! x.~P(x))"; |
1922 | 315 |
prove "imp_ex" "((? x. P x) --> Q) = (! x. P x --> Q)"; |
1660 | 316 |
|
1655 | 317 |
prove "ex_disj_distrib" "(? x. P(x) | Q(x)) = ((? x. P(x)) | (? x. Q(x)))"; |
318 |
prove "all_conj_distrib" "(!x. P(x) & Q(x)) = ((! x. P(x)) & (! x. Q(x)))"; |
|
319 |
||
1758 | 320 |
|
1655 | 321 |
qed_goal "if_cancel" HOL.thy "(if c then x else x) = x" |
322 |
(fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]); |
|
323 |
||
324 |
qed_goal "if_distrib" HOL.thy |
|
325 |
"f(if c then x else y) = (if c then f x else f y)" |
|
326 |
(fn _ => [simp_tac (HOL_ss setloop (split_tac [expand_if])) 1]); |
|
327 |
||
1874 | 328 |
qed_goalw "o_assoc" HOL.thy [o_def] "f o (g o h) = (f o g o h)" |
1655 | 329 |
(fn _=>[rtac ext 1, rtac refl 1]); |
1984 | 330 |
|
331 |
||
332 |
||
333 |
||
334 |
(*** Install simpsets and datatypes in theory structure ***) |
|
335 |
||
336 |
simpset := HOL_ss; |
|
337 |
||
338 |
exception SS_DATA of simpset; |
|
339 |
||
340 |
let fun merge [] = SS_DATA empty_ss |
|
341 |
| merge ss = let val ss = map (fn SS_DATA x => x) ss; |
|
342 |
in SS_DATA (foldl merge_ss (hd ss, tl ss)) end; |
|
343 |
||
344 |
fun put (SS_DATA ss) = simpset := ss; |
|
345 |
||
346 |
fun get () = SS_DATA (!simpset); |
|
347 |
in add_thydata "HOL" |
|
348 |
("simpset", ThyMethods {merge = merge, put = put, get = get}) |
|
349 |
end; |
|
350 |
||
351 |
type dtype_info = {case_const:term, case_rewrites:thm list, |
|
352 |
constructors:term list, nchotomy:thm, case_cong:thm}; |
|
353 |
||
354 |
exception DT_DATA of (string * dtype_info) list; |
|
355 |
val datatypes = ref [] : (string * dtype_info) list ref; |
|
356 |
||
357 |
let fun merge [] = DT_DATA [] |
|
358 |
| merge ds = |
|
359 |
let val ds = map (fn DT_DATA x => x) ds; |
|
360 |
in DT_DATA (foldl (gen_union eq_fst) (hd ds, tl ds)) end; |
|
361 |
||
362 |
fun put (DT_DATA ds) = datatypes := ds; |
|
363 |
||
364 |
fun get () = DT_DATA (!datatypes); |
|
365 |
in add_thydata "HOL" |
|
366 |
("datatypes", ThyMethods {merge = merge, put = put, get = get}) |
|
367 |
end; |
|
368 |
||
369 |
||
370 |
add_thy_reader_file "thy_data.ML"; |