author | clasohm |
Fri, 15 Jul 1994 13:34:31 +0200 | |
changeset 477 | 53fc8ad84b33 |
parent 445 | 7b6d8b8d4580 |
child 486 | 6b58082796f6 |
permissions | -rw-r--r-- |
0 | 1 |
(* Title: ZF/ex/llist.ML |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1993 University of Cambridge |
|
5 |
||
173 | 6 |
Codatatype definition of Lazy Lists |
0 | 7 |
*) |
8 |
||
120 | 9 |
structure LList = CoDatatype_Fun |
279 | 10 |
(val thy = QUniv.thy |
477 | 11 |
val thy_name = "LList" |
279 | 12 |
val rec_specs = [("llist", "quniv(A)", |
445 | 13 |
[(["LNil"], "i",NoSyn), |
14 |
(["LCons"], "[i,i]=>i",NoSyn)])] |
|
279 | 15 |
val rec_styp = "i=>i" |
16 |
val sintrs = ["LNil : llist(A)", |
|
17 |
"[| a: A; l: llist(A) |] ==> LCons(a,l) : llist(A)"] |
|
18 |
val monos = [] |
|
120 | 19 |
val type_intrs = codatatype_intrs |
20 |
val type_elims = codatatype_elims); |
|
279 | 21 |
|
0 | 22 |
val [LNilI, LConsI] = LList.intrs; |
23 |
||
24 |
(*An elimination rule, for type-checking*) |
|
25 |
val LConsE = LList.mk_cases LList.con_defs "LCons(a,l) : llist(A)"; |
|
26 |
||
27 |
(*Proving freeness results*) |
|
28 |
val LCons_iff = LList.mk_free "LCons(a,l)=LCons(a',l') <-> a=a' & l=l'"; |
|
29 |
val LNil_LCons_iff = LList.mk_free "~ LNil=LCons(a,l)"; |
|
30 |
||
434 | 31 |
goal LList.thy "llist(A) = {0} <+> (A <*> llist(A))"; |
32 |
by (rtac (LList.unfold RS trans) 1); |
|
33 |
bws LList.con_defs; |
|
34 |
by (fast_tac (qsum_cs addIs ([equalityI] @ codatatype_intrs) |
|
35 |
addDs [LList.dom_subset RS subsetD] |
|
36 |
addEs [A_into_quniv] |
|
37 |
addSEs [QSigmaE]) 1); |
|
38 |
val llist_unfold = result(); |
|
39 |
||
0 | 40 |
(*** Lemmas to justify using "llist" in other recursive type definitions ***) |
41 |
||
42 |
goalw LList.thy LList.defs "!!A B. A<=B ==> llist(A) <= llist(B)"; |
|
43 |
by (rtac gfp_mono 1); |
|
44 |
by (REPEAT (rtac LList.bnd_mono 1)); |
|
45 |
by (REPEAT (ares_tac (quniv_mono::basic_monos) 1)); |
|
46 |
val llist_mono = result(); |
|
47 |
||
48 |
(** Closure of quniv(A) under llist -- why so complex? Its a gfp... **) |
|
49 |
||
173 | 50 |
val quniv_cs = subset_cs addSIs [QPair_Int_Vset_subset_UN RS subset_trans, |
51 |
QPair_subset_univ, |
|
52 |
empty_subsetI, one_in_quniv RS qunivD] |
|
53 |
addIs [Int_lower1 RS subset_trans] |
|
54 |
addSDs [qunivD] |
|
55 |
addSEs [Ord_in_Ord]; |
|
0 | 56 |
|
57 |
goal LList.thy |
|
173 | 58 |
"!!i. Ord(i) ==> ALL l: llist(quniv(A)). l Int Vset(i) <= univ(eclose(A))"; |
59 |
by (etac trans_induct 1); |
|
16
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
7
diff
changeset
|
60 |
by (rtac ballI 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
7
diff
changeset
|
61 |
by (etac LList.elim 1); |
0b033d50ca1c
ex/{bin.ML,comb.ML,prop.ML}: replaced NewSext by Syntax.simple_sext
lcp
parents:
7
diff
changeset
|
62 |
by (rewrite_goals_tac ([QInl_def,QInr_def]@LList.con_defs)); |
173 | 63 |
(*LNil case*) |
0 | 64 |
by (fast_tac quniv_cs 1); |
173 | 65 |
(*LCons case*) |
66 |
by (safe_tac quniv_cs); |
|
67 |
by (ALLGOALS (fast_tac (quniv_cs addSEs [Ord_trans, make_elim bspec]))); |
|
0 | 68 |
val llist_quniv_lemma = result(); |
69 |
||
70 |
goal LList.thy "llist(quniv(A)) <= quniv(A)"; |
|
173 | 71 |
by (rtac (qunivI RS subsetI) 1); |
72 |
by (rtac Int_Vset_subset 1); |
|
0 | 73 |
by (REPEAT (ares_tac [llist_quniv_lemma RS bspec] 1)); |
74 |
val llist_quniv = result(); |
|
75 |
||
76 |
val llist_subset_quniv = standard |
|
77 |
(llist_mono RS (llist_quniv RSN (2,subset_trans))); |
|
78 |
||
34
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
16
diff
changeset
|
79 |
(* Definition and use of LList_Eq has been moved to llist_eq.ML to allow |
747f1aad03cf
changed filenames to lower case name of theory the file contains
clasohm
parents:
16
diff
changeset
|
80 |
automatic association between theory name and filename. *) |