src/ZF/ex/llist.ML
author lcp
Tue Aug 16 18:58:42 1994 +0200 (1994-08-16)
changeset 532 851df239ac8b
parent 279 7738aed3f84d
permissions -rw-r--r--
ZF/Makefile,ROOT.ML, ZF/ex/Integ.thy: updated for EquivClass
clasohm@0
     1
(*  Title: 	ZF/ex/llist.ML
clasohm@0
     2
    ID:         $Id$
clasohm@0
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
clasohm@0
     4
    Copyright   1993  University of Cambridge
clasohm@0
     5
lcp@173
     6
Codatatype definition of Lazy Lists
clasohm@0
     7
*)
clasohm@0
     8
lcp@120
     9
structure LList = CoDatatype_Fun
lcp@279
    10
 (val thy        = QUniv.thy
lcp@279
    11
  val rec_specs  = [("llist", "quniv(A)",
lcp@279
    12
                      [(["LNil"],   "i"), 
lcp@279
    13
                       (["LCons"],  "[i,i]=>i")])]
lcp@279
    14
  val rec_styp   = "i=>i"
lcp@279
    15
  val ext        = None
lcp@279
    16
  val sintrs     = ["LNil : llist(A)",
lcp@279
    17
                    "[| a: A;  l: llist(A) |] ==> LCons(a,l) : llist(A)"]
lcp@279
    18
  val monos      = []
lcp@120
    19
  val type_intrs = codatatype_intrs
lcp@120
    20
  val type_elims = codatatype_elims);
lcp@279
    21
clasohm@0
    22
val [LNilI, LConsI] = LList.intrs;
clasohm@0
    23
clasohm@0
    24
(*An elimination rule, for type-checking*)
clasohm@0
    25
val LConsE = LList.mk_cases LList.con_defs "LCons(a,l) : llist(A)";
clasohm@0
    26
clasohm@0
    27
(*Proving freeness results*)
clasohm@0
    28
val LCons_iff      = LList.mk_free "LCons(a,l)=LCons(a',l') <-> a=a' & l=l'";
clasohm@0
    29
val LNil_LCons_iff = LList.mk_free "~ LNil=LCons(a,l)";
clasohm@0
    30
clasohm@0
    31
(*** Lemmas to justify using "llist" in other recursive type definitions ***)
clasohm@0
    32
clasohm@0
    33
goalw LList.thy LList.defs "!!A B. A<=B ==> llist(A) <= llist(B)";
clasohm@0
    34
by (rtac gfp_mono 1);
clasohm@0
    35
by (REPEAT (rtac LList.bnd_mono 1));
clasohm@0
    36
by (REPEAT (ares_tac (quniv_mono::basic_monos) 1));
clasohm@0
    37
val llist_mono = result();
clasohm@0
    38
clasohm@0
    39
(** Closure of quniv(A) under llist -- why so complex?  Its a gfp... **)
clasohm@0
    40
lcp@173
    41
val quniv_cs = subset_cs addSIs [QPair_Int_Vset_subset_UN RS subset_trans, 
lcp@173
    42
				 QPair_subset_univ,
lcp@173
    43
				 empty_subsetI, one_in_quniv RS qunivD]
lcp@173
    44
                 addIs  [Int_lower1 RS subset_trans]
lcp@173
    45
		 addSDs [qunivD]
lcp@173
    46
                 addSEs [Ord_in_Ord];
clasohm@0
    47
clasohm@0
    48
goal LList.thy
lcp@173
    49
   "!!i. Ord(i) ==> ALL l: llist(quniv(A)). l Int Vset(i) <= univ(eclose(A))";
lcp@173
    50
by (etac trans_induct 1);
lcp@16
    51
by (rtac ballI 1);
lcp@16
    52
by (etac LList.elim 1);
lcp@16
    53
by (rewrite_goals_tac ([QInl_def,QInr_def]@LList.con_defs));
lcp@173
    54
(*LNil case*)
clasohm@0
    55
by (fast_tac quniv_cs 1);
lcp@173
    56
(*LCons case*)
lcp@173
    57
by (safe_tac quniv_cs);
lcp@173
    58
by (ALLGOALS (fast_tac (quniv_cs addSEs [Ord_trans, make_elim bspec])));
clasohm@0
    59
val llist_quniv_lemma = result();
clasohm@0
    60
clasohm@0
    61
goal LList.thy "llist(quniv(A)) <= quniv(A)";
lcp@173
    62
by (rtac (qunivI RS subsetI) 1);
lcp@173
    63
by (rtac Int_Vset_subset 1);
clasohm@0
    64
by (REPEAT (ares_tac [llist_quniv_lemma RS bspec] 1));
clasohm@0
    65
val llist_quniv = result();
clasohm@0
    66
clasohm@0
    67
val llist_subset_quniv = standard
clasohm@0
    68
    (llist_mono RS (llist_quniv RSN (2,subset_trans)));
clasohm@0
    69
clasohm@34
    70
(* Definition and use of LList_Eq has been moved to llist_eq.ML to allow
clasohm@34
    71
   automatic association between theory name and filename. *)