author | lcp |
Fri, 22 Oct 1993 11:42:02 +0100 | |
changeset 71 | 729fe026c5f3 |
parent 56 | 2caa6f49f06e |
child 85 | 914270f33f2d |
permissions | -rw-r--r-- |
56 | 1 |
(* Title: ZF/ex/data.ML |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1993 University of Cambridge |
|
5 |
||
6 |
Sample datatype definition. |
|
7 |
It has four contructors, of arities 0-3, and two parameters A and B. |
|
8 |
*) |
|
9 |
||
10 |
structure Data = Datatype_Fun |
|
11 |
(val thy = Univ.thy; |
|
12 |
val rec_specs = |
|
13 |
[("data", "univ(A Un B)", |
|
14 |
[(["Zero"], "i"), |
|
15 |
(["One"], "i=>i"), |
|
16 |
(["Two"], "[i,i]=>i"), |
|
17 |
(["Three"], "[i,i,i]=>i")])]; |
|
18 |
val rec_styp = "[i,i]=>i"; |
|
19 |
val ext = None |
|
20 |
val sintrs = |
|
21 |
["Zero : data(A,B)", |
|
22 |
"[| a: A |] ==> One(a) : data(A,B)", |
|
23 |
"[| a: A; b: B |] ==> Two(a,b) : data(A,B)", |
|
24 |
"[| a: A; b: B; d: data(A,B) |] ==> Three(a,b,d) : data(A,B)"]; |
|
25 |
val monos = []; |
|
71
729fe026c5f3
sample datatype defs now use datatype_intrs, datatype_elims
lcp
parents:
56
diff
changeset
|
26 |
val type_intrs = datatype_intrs |
729fe026c5f3
sample datatype defs now use datatype_intrs, datatype_elims
lcp
parents:
56
diff
changeset
|
27 |
val type_elims = datatype_elims); |
56 | 28 |
|
29 |
||
30 |
(** Lemmas to justify using "data" in other recursive type definitions **) |
|
31 |
||
32 |
goalw Data.thy Data.defs "!!A B. [| A<=C; B<=D |] ==> data(A,B) <= data(C,D)"; |
|
33 |
by (rtac lfp_mono 1); |
|
34 |
by (REPEAT (rtac Data.bnd_mono 1)); |
|
35 |
by (REPEAT (ares_tac (univ_mono::Un_mono::basic_monos) 1)); |
|
36 |
val data_mono = result(); |
|
37 |
||
38 |
goalw Data.thy (Data.defs@Data.con_defs) "data(univ(A),univ(A)) <= univ(A)"; |
|
39 |
by (rtac lfp_lowerbound 1); |
|
40 |
by (rtac ([A_subset_univ, Un_upper1] MRS subset_trans RS univ_mono) 2); |
|
41 |
by (fast_tac (ZF_cs addSIs [zero_in_univ, Inl_in_univ, Inr_in_univ, |
|
42 |
Pair_in_univ]) 1); |
|
43 |
val data_univ = result(); |
|
44 |
||
45 |
val data_subset_univ = standard ([data_mono, data_univ] MRS subset_trans); |
|
46 |
||
47 |