53
|
1 |
(* Title: Datentypdeklarationen mit Isabelle
|
|
2 |
Author: Max Breitling
|
|
3 |
Copyright 1994 TU Muenchen
|
|
4 |
*)
|
|
5 |
|
|
6 |
|
|
7 |
signature DATATYPE =
|
|
8 |
sig
|
|
9 |
val thy : theory
|
|
10 |
val induct : thm
|
|
11 |
val inject : thm list
|
|
12 |
val ineq : thm list
|
|
13 |
val cases : thm list
|
60
|
14 |
val simps : thm list
|
53
|
15 |
val induct_tac : string -> int -> tactic
|
|
16 |
end;
|
|
17 |
|
|
18 |
signature DATATYPEDEF =
|
|
19 |
sig
|
|
20 |
val base : theory
|
|
21 |
val data : string
|
|
22 |
val declare_consts : bool
|
|
23 |
end;
|
|
24 |
|
|
25 |
|
|
26 |
functor DatatypeFUN(Input: DATATYPEDEF) : DATATYPE =
|
|
27 |
struct
|
|
28 |
|
|
29 |
structure Keyword =
|
|
30 |
struct
|
|
31 |
val alphas = []
|
|
32 |
val symbols = ["(",")",",","|","="]
|
|
33 |
end;
|
|
34 |
|
|
35 |
val K = 5; (* Diese Schranke enscheidet zwischen den beiden
|
|
36 |
Ci_neg-Axiomen-Schemata *)
|
|
37 |
|
|
38 |
structure Lex = LexicalFUN (Keyword);
|
|
39 |
structure Parse = ParseFUN(Lex);
|
|
40 |
|
|
41 |
datatype Typ = Var of string |
|
|
42 |
Id of string |
|
|
43 |
Comp of Typ list * string |
|
|
44 |
Rek of Typ list * string;
|
|
45 |
|
|
46 |
type InternalRep = (Typ list * string) * (string * Typ list) list;
|
|
47 |
|
|
48 |
exception Impossible;
|
|
49 |
|
|
50 |
open Parse;
|
|
51 |
|
|
52 |
fun list_of1 ph = ph -- repeat("," $$-- ph) >> (op::); (* Redefinition *)
|
|
53 |
|
|
54 |
(* ---------------------------------------------------------------------- *)
|
|
55 |
|
|
56 |
val type_var =
|
|
57 |
typevar >> Var;
|
|
58 |
|
|
59 |
|
|
60 |
val type_var_list =
|
|
61 |
type_var >> (fn s => s::nil)
|
|
62 |
||
|
|
63 |
"(" $$-- list_of1 (type_var) --$$ ")" ;
|
|
64 |
|
|
65 |
|
|
66 |
val typ =
|
|
67 |
|
|
68 |
id >> Id
|
|
69 |
||
|
|
70 |
type_var_list -- id >> Comp
|
|
71 |
||
|
|
72 |
type_var;
|
|
73 |
|
|
74 |
|
|
75 |
val typ_list =
|
|
76 |
(*
|
|
77 |
typ >> (fn t => t::nil)
|
|
78 |
output (std_out, || *)
|
|
79 |
"(" $$-- list_of1(typ) --$$ ")"
|
|
80 |
||
|
|
81 |
empty;
|
|
82 |
|
|
83 |
|
|
84 |
val cons =
|
|
85 |
|
|
86 |
( stg
|
|
87 |
||
|
|
88 |
id )
|
|
89 |
-- typ_list;
|
|
90 |
|
|
91 |
|
|
92 |
fun constructs toks =
|
|
93 |
(
|
|
94 |
cons --$$ "|" -- constructs >> op::
|
|
95 |
||
|
|
96 |
cons >> (fn c => c::nil)
|
|
97 |
) toks;
|
|
98 |
|
|
99 |
|
|
100 |
val type_def =
|
|
101 |
|
|
102 |
(type_var_list || empty) -- id --$$ "=" -- constructs;
|
|
103 |
|
|
104 |
(* ---------------------------------------------------------------------
|
|
105 |
Pretty-Printer fuer Typlisten
|
|
106 |
Variante 1 hat runde Klammern, Variante2 hat ganz aussen eckige Klammern
|
|
107 |
*)
|
|
108 |
fun pp_typ (Var s) = s
|
|
109 |
| pp_typ (Id s) =s
|
|
110 |
| pp_typ (Comp (typvars,id)) = (pp_typlist1 typvars) ^ id
|
|
111 |
| pp_typ (Rek (typvars,id)) = (pp_typlist1 typvars) ^ id
|
|
112 |
|
|
113 |
and
|
|
114 |
pp_typlist' (typ::typ2::ts) = (pp_typ typ) ^ "," ^ (pp_typlist' (typ2::ts))
|
|
115 |
| pp_typlist' (typ::nil) = pp_typ typ
|
|
116 |
| pp_typlist' [] = raise Impossible
|
|
117 |
|
|
118 |
and
|
|
119 |
pp_typlist1 (typ::ts) = "(" ^ (pp_typlist' (typ::ts)) ^ ")"
|
|
120 |
| pp_typlist1 [] = ""
|
|
121 |
;
|
|
122 |
|
|
123 |
fun pp_typlist2 (typ::ts) = "[" ^ pp_typlist' (typ::ts) ^ "]"
|
|
124 |
| pp_typlist2 [] = ""
|
|
125 |
|
|
126 |
(* ----------------------------------------------------------------------- *)
|
|
127 |
|
|
128 |
(* Ueberprueft, ob die Konstruktoren paarweise verschieden sind *)
|
|
129 |
|
|
130 |
fun check_cons cs =
|
|
131 |
(case findrep (map fst cs) of
|
|
132 |
[] => true
|
|
133 |
| c::_ => error("Constructor \"" ^ c ^ "\" occurs twice"));
|
|
134 |
|
|
135 |
(* ------------------------------------------------------------------------
|
|
136 |
Diese Funktion ueberprueft, ob alle Typvariablen nichtfrei sind und wandelt
|
|
137 |
erkannte rekursive Bezuege in den "Rek"-Konstruktor um *)
|
|
138 |
|
|
139 |
fun analyseOne ((typevars,id), (Var v)::typlist) =
|
|
140 |
if ((Var v) mem typevars) then (Var v)::analyseOne((typevars,id),typlist)
|
|
141 |
else error("Variable "^v^" is free.")
|
|
142 |
| analyseOne ((typevars,id), (Id s)::typlist) =
|
|
143 |
if id<>s then (Id s)::analyseOne((typevars,id),typlist)
|
|
144 |
else if typevars=[] then Rek([],id)
|
|
145 |
::analyseOne((typevars,id),typlist)
|
|
146 |
else error(s^" used in different ways")
|
|
147 |
| analyseOne ((typevars,id),(Comp(typl,s))::typlist) =
|
|
148 |
if id<>s then Comp(analyseOne((typevars,id),typl),s)
|
|
149 |
::analyseOne((typevars,id),typlist)
|
|
150 |
else if typevars=typl then
|
|
151 |
Rek(typl,s)::analyseOne((typevars,id),typlist)
|
|
152 |
else
|
|
153 |
error(s ^ " used in different ways")
|
|
154 |
| analyseOne (_,[]) = []
|
|
155 |
| analyseOne (_,(Rek _)::_) = raise Impossible;
|
|
156 |
|
|
157 |
|
|
158 |
fun analyse (deftyp,(cons,typlist) :: cs) =
|
|
159 |
(cons, analyseOne(deftyp,typlist))::analyse(deftyp,cs)
|
|
160 |
| analyse (_,[])=[];
|
|
161 |
|
|
162 |
|
|
163 |
(* ------------------------------------------------------------------------ *)
|
|
164 |
(* testet, ob nicht nur rekusive Elemente in den Typen vorkommen, also ob
|
|
165 |
der definierte Typ nichtleer ist *)
|
|
166 |
|
|
167 |
val contains_no_rek = forall (fn Rek _ => false | _ => true);
|
|
168 |
|
|
169 |
fun one_not_rek cs = exists (contains_no_rek o snd) cs orelse
|
|
170 |
error("Empty type not allowed!");
|
|
171 |
|
|
172 |
|
|
173 |
(* ------------------------------------------------------------------------ *)
|
|
174 |
(* Hilfsfunktionen *)
|
|
175 |
|
|
176 |
(* gibt 'var_n' bis 'var_m' aus, getrennt durch 'delim' *)
|
|
177 |
fun Args(var,delim,n,m) = if n=m then var ^ string_of_int(n)
|
|
178 |
else var ^ string_of_int(n) ^delim^ Args(var,delim,n+1,m);
|
|
179 |
|
|
180 |
(* gibt 'name_1', ... , 'name_n' zurueck *)
|
|
181 |
fun C_exp(name,n,var) =
|
|
182 |
if n>0 then name ^ "(" ^ Args(var,",",1,n) ^ ")"
|
|
183 |
else name;
|
|
184 |
|
|
185 |
(* gibt 'x_n = y_n, ... , x_m = y_m' zurueck *)
|
|
186 |
fun Arg_eql(n,m) =
|
|
187 |
if n=m
|
|
188 |
then "x" ^ string_of_int(n) ^ "=y" ^ string_of_int(n)
|
|
189 |
else "x" ^ string_of_int(n) ^ "=y" ^ string_of_int(n) ^ " & " ^ Arg_eql(n+1,m);
|
|
190 |
|
|
191 |
(* --------------------------------------------------------------------- *)
|
|
192 |
(* Ausgabe der Typdeklarationen fuer die einzelnen Konstruktoren *)
|
|
193 |
|
|
194 |
fun const_types ((typevars,id),((c,typlist)::cs)) =
|
|
195 |
([c],
|
|
196 |
(if typlist =[] then "" else pp_typlist2(typlist) ^ " => ") ^
|
|
197 |
pp_typlist1(typevars) ^ id
|
|
198 |
)
|
|
199 |
:: const_types ((typevars,id),cs)
|
|
200 |
| const_types (_,[]) = [];
|
|
201 |
|
|
202 |
(* --------------------------------------------------------------------- *)
|
|
203 |
|
|
204 |
|
|
205 |
fun Ci_ing (c :: cs) =
|
|
206 |
let val (name,typlist) = c
|
|
207 |
val arity = length typlist
|
|
208 |
in
|
|
209 |
if arity>0
|
|
210 |
then ("inject_" ^ name,
|
|
211 |
"(" ^ C_exp(name,arity,"x") ^ "=" ^ C_exp(name,arity,"y") ^ ") = ("
|
|
212 |
^ Arg_eql(1,arity) ^ ")") :: (Ci_ing cs)
|
|
213 |
|
|
214 |
else (Ci_ing cs)
|
|
215 |
end
|
|
216 |
| Ci_ing [] = [];
|
|
217 |
|
|
218 |
|
|
219 |
(* ----------------------------------------------------------------------- *)
|
|
220 |
|
|
221 |
fun Ci_negOne (c::nil) = []
|
|
222 |
| Ci_negOne (c::c1::cs) =
|
|
223 |
let val (name1,tl1) = c
|
|
224 |
val (name2,tl2) = c1
|
|
225 |
val arit1 = length tl1
|
|
226 |
val arit2 = length tl2
|
|
227 |
val h = "(" ^ C_exp(name1,arit1,"x") ^ "~=" ^
|
|
228 |
C_exp(name2,arit2,"y") ^ ")"
|
|
229 |
in ("ineq_"^name1^"_"^name2,h):: (Ci_negOne (c::cs))
|
|
230 |
end
|
|
231 |
| Ci_negOne [] = [];
|
|
232 |
|
|
233 |
fun Ci_neg1 (c1::c2::nil) = Ci_negOne(c1::c2::nil)
|
|
234 |
| Ci_neg1 (c1::c2::cs) = Ci_negOne(c1::c2::cs) @ Ci_neg1(c2::cs)
|
|
235 |
| Ci_neg1 _ = [];
|
|
236 |
|
|
237 |
fun suc_expr n = if n=0 then "0"
|
|
238 |
else "Suc(" ^ suc_expr(n-1) ^ ")";
|
|
239 |
|
|
240 |
|
|
241 |
fun Ci_neg2equals (ord_t,((c,typlist)::cs), n) =
|
|
242 |
let val h = ord_t ^ "(" ^ (C_exp(c,length typlist,"x")) ^ ") = " ^
|
|
243 |
(suc_expr n)
|
|
244 |
in
|
|
245 |
(ord_t^(string_of_int(n+1)),h) :: (Ci_neg2equals (ord_t, cs ,n+1))
|
|
246 |
end
|
|
247 |
| Ci_neg2equals (_, [], _) = [];
|
|
248 |
|
|
249 |
|
|
250 |
fun Ci_neg2 ((typlist,id),conslist) =
|
|
251 |
let val ord_t = id ^ "_ord"
|
|
252 |
in
|
|
253 |
(Ci_neg2equals (ord_t, conslist, 0)) @
|
|
254 |
[(ord_t^"0",
|
|
255 |
"(" ^ ord_t ^ "(x) ~= " ^ ord_t ^ "(y)) ==> (x ~= y)")]
|
|
256 |
end;
|
|
257 |
|
|
258 |
|
|
259 |
(* --------------------------------------------------------------------- *)
|
|
260 |
(* Die Funktionen fuer das Induktionsaxiom, mit komplizierer Vergabestrategie
|
|
261 |
fuer die Variablennamen *)
|
|
262 |
|
|
263 |
(* fuegt einen Typ mit dem vorgeschlagenen Namen varname in die Tabelle ein *)
|
|
264 |
fun insert typ varname ((t,s,n)::xs) =
|
|
265 |
if typ=t then (t,s,n+1)::xs
|
|
266 |
else if varname=s then (t,s,n)::(insert typ (varname^"'") xs)
|
|
267 |
else (t,s,n)::(insert typ varname xs)
|
|
268 |
| insert typ varname [] = [(typ,varname,1)];
|
|
269 |
|
|
270 |
|
|
271 |
fun insert_types ((Rek(l,id))::ts) tab =
|
|
272 |
insert_types ts (insert (Rek(l,id)) id tab)
|
|
273 |
| insert_types ((Var s)::ts) tab =
|
|
274 |
insert_types ts (insert (Var s) (implode(tl(explode s))) tab)
|
|
275 |
| insert_types ((Id s)::ts) tab =
|
|
276 |
insert_types ts (insert (Id s) s tab)
|
|
277 |
| insert_types (Comp(l,id)::ts) tab =
|
|
278 |
insert_types ts (insert (Comp(l,id)) id tab)
|
|
279 |
| insert_types [] tab = tab;
|
|
280 |
|
|
281 |
|
|
282 |
fun update(Rek(_),s,v::vs,(Rek(_))::ts) = s::vs
|
|
283 |
| update(t, s,v::vs,t1::ts ) = if t=t1 then s::vs
|
|
284 |
else v::(update(t,s,vs,ts))
|
|
285 |
| update(_,_,_,_) = raise Impossible;
|
|
286 |
|
|
287 |
fun update_n(Rek(r1),s,v::vs,(Rek(r2))::ts,n) =
|
|
288 |
if r1=r2 then (s^(string_of_int n))::(update_n(Rek(r1),s,vs,ts,n+1))
|
|
289 |
else v::(update_n(Rek(r1),s,vs,ts,n))
|
|
290 |
| update_n(t,s,v::vs,t1::ts,n) =
|
|
291 |
if t=t1 then (s^(string_of_int n))::(update_n(t,s,vs,ts,n+1))
|
|
292 |
else v::(update_n(t,s,vs,ts,n))
|
|
293 |
| update_n(_,_,[],[],_) = []
|
|
294 |
| update_n(_,_,_,_,_) = raise Impossible;
|
|
295 |
|
|
296 |
(* geht durch die Tabelle und traegt die Typvariablen ein *)
|
|
297 |
fun convert ((t,s,n)::ts) var_list typ_list =
|
|
298 |
let val h = ( if n=1 then update(t,s,var_list,typ_list)
|
|
299 |
else update_n(t,s,var_list,typ_list,1))
|
|
300 |
in convert ts h typ_list
|
|
301 |
end
|
|
302 |
| convert [] var_list _ = var_list;
|
|
303 |
|
|
304 |
|
|
305 |
fun empty_list n = replicate n "";
|
|
306 |
|
|
307 |
fun assumpt (Rek(_)::ts, v::vs ,found) =
|
|
308 |
let val h = if found then ";P(" ^ v ^ ")"
|
|
309 |
else "[| P(" ^ v ^ ")"
|
|
310 |
in h ^ (assumpt (ts, vs, true))
|
|
311 |
end
|
|
312 |
| assumpt ((t::ts), v::vs, found) =
|
|
313 |
assumpt (ts, vs, found)
|
|
314 |
| assumpt ([], [], found) =
|
|
315 |
if found then "|] ==>"
|
|
316 |
else ""
|
|
317 |
| assumpt(_,_,_) = raise Impossible;
|
|
318 |
|
|
319 |
fun t_inducting ((name,typl)::cs) =
|
|
320 |
let val tab = insert_types typl []
|
|
321 |
val arity = length typl
|
|
322 |
val var_list = convert tab (empty_list arity) typl
|
|
323 |
val h = if arity=0 then " P(" ^ name ^ ")"
|
|
324 |
else " !!" ^ (space_implode " " var_list) ^ "." ^
|
|
325 |
(assumpt (typl, var_list, false))
|
|
326 |
^ "P(" ^ name ^ "(" ^ (space_implode "," var_list) ^ "))"
|
|
327 |
val rest = t_inducting cs
|
|
328 |
in if rest="" then h
|
|
329 |
else h ^ "; " ^ rest
|
|
330 |
end
|
|
331 |
| t_inducting [] = "";
|
|
332 |
|
|
333 |
|
|
334 |
fun t_induct cl typ_name=
|
|
335 |
"[|" ^ (t_inducting cl) ^ "|] ==> P("^typ_name^")";
|
|
336 |
|
|
337 |
(* -------------------------------------------------------------------- *)
|
|
338 |
(* Die Funktionen fuer die t_case - Funktion *)
|
|
339 |
fun case_typlist typevar ((c,typlist)::cs) =
|
|
340 |
let val h = if (length typlist) > 0 then (pp_typlist2 typlist) ^ "=>"
|
|
341 |
else ""
|
|
342 |
in "," ^ h ^ typevar ^ (case_typlist typevar cs)
|
|
343 |
end
|
|
344 |
| case_typlist _ [] = "";
|
|
345 |
|
|
346 |
fun case_rules t_case arity n ((id,typlist)::cs) =
|
|
347 |
let val args = if (length typlist)>0 then "("^Args("x",",",1,length typlist)
|
|
348 |
^ ")"
|
|
349 |
else ""
|
|
350 |
in (t_case ^ "_" ^ id,
|
|
351 |
t_case ^ "(" ^ id ^ args ^ "," ^ Args("f",",",1,arity) ^ ") = f" ^
|
|
352 |
string_of_int(n) ^ args)
|
|
353 |
:: (case_rules t_case arity (n+1) cs)
|
|
354 |
end
|
|
355 |
| case_rules _ _ _ [] = [];
|
|
356 |
|
|
357 |
fun create_typevar (Var s) typlist =
|
|
358 |
if (Var s) mem typlist then create_typevar (Var (s^"'")) typlist else s
|
|
359 |
| create_typevar _ _ = raise Impossible;
|
|
360 |
|
|
361 |
|
|
362 |
fun case_consts ((typlist,id),conslist) =
|
|
363 |
let val typevar = create_typevar (Var "'beta") typlist
|
|
364 |
val t_case = id ^ "_case"
|
|
365 |
val arity = length conslist
|
|
366 |
val dekl = ([t_case],"[" ^ (pp_typlist1 typlist) ^ id ^
|
|
367 |
(case_typlist typevar conslist) ^ "]=>" ^ typevar)::nil
|
|
368 |
val rules = case_rules t_case arity 1 conslist
|
|
369 |
in (dekl,rules)
|
|
370 |
end;
|
|
371 |
(* ------------------------------------------------------------------------- *)
|
|
372 |
(* Die Funktionen fuer das Erzeugen der Syntax-Umsetzung der case-Regeln *)
|
|
373 |
|
|
374 |
fun calc_xrules c_nr y_nr ((c,typlist)::cs) =
|
|
375 |
let val arity = length typlist
|
|
376 |
val body = "z" ^ string_of_int(c_nr)
|
|
377 |
val args1 = if arity=0 then ""
|
|
378 |
else "("^Args("y",",",y_nr,y_nr+arity-1) ^ ")"
|
|
379 |
val args2 = if arity=0 then ""
|
|
380 |
else "% "^Args("y"," ",y_nr,y_nr+arity-1) ^ ". "
|
|
381 |
val (rest1,rest2) = if cs = [] then ("","")
|
|
382 |
else let val (h1,h2) = calc_xrules (c_nr+1) (y_nr+arity) cs
|
|
383 |
in (" | " ^ h1, ", " ^ h2)
|
|
384 |
end
|
|
385 |
in (c^args1^" => "^body^rest1,
|
|
386 |
args2 ^ body ^ rest2)
|
|
387 |
end
|
|
388 |
| calc_xrules _ _ [] = raise Impossible;
|
|
389 |
|
|
390 |
fun xrules ((typlist,id),conslist) =
|
|
391 |
let val (first_part,scnd_part) = calc_xrules 1 1 conslist
|
|
392 |
in [("logic","case x of " ^ first_part) <->
|
|
393 |
("logic",id ^ "_case(x," ^ scnd_part ^ ")" )]
|
|
394 |
end;
|
|
395 |
|
|
396 |
(* ------------------------------------------------------------------------- *)
|
|
397 |
|
|
398 |
fun parse InputString =
|
|
399 |
let val (deftyp,conslist') = ((reader type_def) o explode) InputString
|
|
400 |
val test = check_cons(conslist')
|
|
401 |
val conslist = analyse (deftyp,conslist')
|
|
402 |
val test2 = one_not_rek conslist
|
|
403 |
in (deftyp,conslist)
|
|
404 |
end;
|
|
405 |
|
|
406 |
|
|
407 |
(* -------------------------------------------------------------------------- *)
|
|
408 |
|
|
409 |
val Datatype = parse Input.data;
|
|
410 |
|
|
411 |
val datatype_id = (#2 o #1) Datatype;
|
|
412 |
val datatype_arity = length ((#1 o #1) Datatype);
|
|
413 |
val cons_list = #2 Datatype;
|
|
414 |
val datatype_name = pp_typlist1((#1 o #1) Datatype) ^ datatype_id;
|
|
415 |
|
|
416 |
val thy_name = datatype_id;
|
|
417 |
|
|
418 |
val base_thy = if length(cons_list) < K then Input.base
|
|
419 |
else merge_theories(Input.base,Arith.thy);
|
|
420 |
|
|
421 |
val (case_const,rules_case) = case_consts Datatype;
|
|
422 |
|
|
423 |
val q = (case_const);
|
|
424 |
|
|
425 |
val types = if Input.declare_consts then [([datatype_id],datatype_arity)]
|
|
426 |
else [];
|
|
427 |
|
|
428 |
fun term_list n = replicate n ["term"];
|
|
429 |
|
|
430 |
val arities :(string list * (sort list * class))list
|
|
431 |
= if Input.declare_consts then
|
|
432 |
[([datatype_id],((term_list datatype_arity),"term"))]
|
|
433 |
else [];
|
|
434 |
|
|
435 |
|
|
436 |
val consts = (if Input.declare_consts then
|
|
437 |
(const_types Datatype) else []) @
|
|
438 |
(if length(cons_list) < K then []
|
|
439 |
else [([datatype_id^"_ord"],datatype_name^"=>nat")]) @
|
|
440 |
case_const;
|
|
441 |
|
|
442 |
val sextopt = Some(NewSext{mixfix=[],
|
|
443 |
xrules=(xrules Datatype),
|
|
444 |
parse_ast_translation=[],
|
|
445 |
parse_translation=[],
|
|
446 |
print_translation=[],
|
|
447 |
print_ast_translation=[]});
|
|
448 |
|
|
449 |
val rules_ineq = if (length cons_list) < K then Ci_neg1 cons_list
|
|
450 |
else Ci_neg2 Datatype;
|
|
451 |
|
|
452 |
val rules_inject = Ci_ing cons_list;
|
|
453 |
|
|
454 |
|
|
455 |
val rule_induct = ("induct",t_induct cons_list datatype_id);
|
|
456 |
|
|
457 |
val rules = rule_induct::(rules_inject @ rules_ineq @ rules_case);
|
|
458 |
|
|
459 |
fun getaxioms ((name,axiom)::axioms) thy = (get_axiom thy name)::
|
|
460 |
(getaxioms axioms thy)
|
|
461 |
| getaxioms [] _ = [];
|
|
462 |
|
|
463 |
fun sym_ineq (t::ts) = (sym COMP (t RS contrapos)) :: (sym_ineq ts)
|
|
464 |
| sym_ineq [] = [];
|
|
465 |
|
|
466 |
(* -----------------------------------------------------------------------*)
|
|
467 |
(* Das folgende wird exportiert *)
|
|
468 |
|
|
469 |
val thy = extend_theory base_thy thy_name
|
|
470 |
([],[],types,[],arities,consts,sextopt) rules;
|
|
471 |
|
|
472 |
|
|
473 |
val inject = getaxioms rules_inject thy;
|
|
474 |
|
|
475 |
val ineq = let val ineq' = getaxioms rules_ineq thy
|
|
476 |
in if length(cons_list) < K then ineq' @ (sym_ineq ineq')
|
|
477 |
else ineq'
|
|
478 |
end;
|
|
479 |
|
|
480 |
val induct = get_axiom thy "induct";
|
|
481 |
|
|
482 |
val cases = getaxioms rules_case thy;
|
|
483 |
|
60
|
484 |
val simps = inject @ ineq @ cases;
|
|
485 |
|
53
|
486 |
fun induct_tac a = res_inst_tac [(datatype_id,a)] induct;
|
|
487 |
|
|
488 |
(* ------------------------------------------------------------------- *)
|
|
489 |
|
|
490 |
|
|
491 |
end;
|
|
492 |
|
|
493 |
|
|
494 |
|
|
495 |
functor Datatype(val base:theory and data:string) : DATATYPE =
|
|
496 |
DatatypeFUN(val base=base and data=data and declare_consts=true);
|
|
497 |
|
|
498 |
functor DeclaredDatatype(val base:theory and data:string) : DATATYPE =
|
|
499 |
DatatypeFUN(val base=base and data=data and declare_consts=false);
|
|
500 |
|
|
501 |
|
|
502 |
|