src/ZF/ex/LList_Eq.ML
author lcp
Tue Aug 16 18:58:42 1994 +0200 (1994-08-16)
changeset 532 851df239ac8b
parent 496 3fc829fa81d2
permissions -rw-r--r--
ZF/Makefile,ROOT.ML, ZF/ex/Integ.thy: updated for EquivClass
     1 (*  Title: 	ZF/ex/llist_eq.ML
     2     ID:         $Id$
     3     Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
     4     Copyright   1993  University of Cambridge
     5 
     6 Equality for llist(A) as a greatest fixed point
     7 ***)
     8 
     9 (*Previously used <*> in the domain and variant pairs as elements.  But
    10   standard pairs work just as well.  To use variant pairs, must change prefix
    11   a q/Q to the Sigma, Pair and converse rules.*)
    12 
    13 structure LList_Eq = CoInductive_Fun
    14  (val thy 	 = LList.thy |> add_consts [("lleq","i=>i",NoSyn)]
    15   val thy_name 	 = "LList_Eq"
    16   val rec_doms   = [("lleq", "llist(A) * llist(A)")]
    17   val sintrs     = 
    18         ["<LNil, LNil> : lleq(A)",
    19          "[| a:A; <l,l'>: lleq(A) |] ==> <LCons(a,l), LCons(a,l')>: lleq(A)"]
    20   val monos      = []
    21   val con_defs   = []
    22   val type_intrs = LList.intrs
    23   val type_elims = []);
    24 
    25 (** Alternatives for above:
    26   val con_defs = LList.con_defs
    27   val type_intrs = codatatype_intrs
    28   val type_elims = [quniv_QPair_E]
    29 **)
    30 
    31 val lleq_cs = subset_cs
    32 	addSIs [QPair_Int_Vset_subset_UN RS subset_trans, QPair_mono]
    33         addSEs [Ord_in_Ord, Pair_inject];
    34 
    35 (*Lemma for proving finality.  Unfold the lazy list; use induction hypothesis*)
    36 goal LList_Eq.thy
    37    "!!i. Ord(i) ==> ALL l l'. <l,l'> : lleq(A) --> l Int Vset(i) <= l'";
    38 by (etac trans_induct 1);
    39 by (REPEAT (resolve_tac [allI, impI] 1));
    40 by (etac LList_Eq.elim 1);
    41 by (rewrite_goals_tac (QInr_def::LList.con_defs));
    42 by (safe_tac lleq_cs);
    43 by (fast_tac (subset_cs addSEs [Ord_trans, make_elim bspec]) 1);
    44 val lleq_Int_Vset_subset_lemma = result();
    45 
    46 val lleq_Int_Vset_subset = standard
    47 	(lleq_Int_Vset_subset_lemma RS spec RS spec RS mp);
    48 
    49 
    50 (*lleq(A) is a symmetric relation because qconverse(lleq(A)) is a fixedpoint*)
    51 val [prem] = goal LList_Eq.thy "<l,l'> : lleq(A) ==> <l',l> : lleq(A)";
    52 by (rtac (prem RS converseI RS LList_Eq.coinduct) 1);
    53 by (rtac (LList_Eq.dom_subset RS converse_type) 1);
    54 by (safe_tac converse_cs);
    55 by (etac LList_Eq.elim 1);
    56 by (ALLGOALS (fast_tac qconverse_cs));
    57 val lleq_symmetric = result();
    58 
    59 goal LList_Eq.thy "!!l l'. <l,l'> : lleq(A) ==> l=l'";
    60 by (rtac equalityI 1);
    61 by (REPEAT (ares_tac [lleq_Int_Vset_subset RS Int_Vset_subset] 1
    62      ORELSE etac lleq_symmetric 1));
    63 val lleq_implies_equal = result();
    64 
    65 val [eqprem,lprem] = goal LList_Eq.thy
    66     "[| l=l';  l: llist(A) |] ==> <l,l'> : lleq(A)";
    67 by (res_inst_tac [("X", "{<l,l>. l: llist(A)}")] LList_Eq.coinduct 1);
    68 by (rtac (lprem RS RepFunI RS (eqprem RS subst)) 1);
    69 by (safe_tac qpair_cs);
    70 by (etac LList.elim 1);
    71 by (ALLGOALS (fast_tac pair_cs));
    72 val equal_llist_implies_leq = result();
    73