src/ZF/ex/LList_Eq.ML
author clasohm
Fri, 15 Jul 1994 13:34:31 +0200
changeset 477 53fc8ad84b33
parent 445 7b6d8b8d4580
child 496 3fc829fa81d2
permissions -rw-r--r--
added thy_name to Datatype_Fun's parameter
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     1
(*  Title: 	ZF/ex/llist_eq.ML
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     2
    ID:         $Id$
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     5
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
     6
Equality for llist(A) as a greatest fixed point
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
     7
***)
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
     8
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
     9
(*Previously used <*> in the domain and variant pairs as elements.  But
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    10
  standard pairs work just as well.  To use variant pairs, must change prefix
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    11
  a q/Q to the Sigma, Pair and converse rules.*)
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    12
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    13
structure LList_Eq = CoInductive_Fun
445
7b6d8b8d4580 changed syntax of datatype declaration
clasohm
parents: 279
diff changeset
    14
 (val thy = LList.thy |> add_consts [("lleq","i=>i",NoSyn)]
477
53fc8ad84b33 added thy_name to Datatype_Fun's parameter
clasohm
parents: 445
diff changeset
    15
  val thy_name = "LList_Eq"
279
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    16
  val rec_doms   = [("lleq", "llist(A) * llist(A)")]
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    17
  val sintrs     = 
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    18
        ["<LNil, LNil> : lleq(A)",
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    19
         "[| a:A; <l,l'>: lleq(A) |] ==> <LCons(a,l), LCons(a,l')>: lleq(A)"]
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    20
  val monos      = []
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    21
  val con_defs   = []
7738aed3f84d Improved layout for inductive defs
lcp
parents: 173
diff changeset
    22
  val type_intrs = LList.intrs @ [SigmaI]
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    23
  val type_elims = [SigmaE2]);
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    24
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    25
(** Alternatives for above:
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    26
  val con_defs = LList.con_defs
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    27
  val type_intrs = codatatype_intrs
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    28
  val type_elims = [quniv_QPair_E]
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    29
**)
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    30
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    31
val lleq_cs = subset_cs
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    32
	addSIs [QPair_Int_Vset_subset_UN RS subset_trans, QPair_mono]
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    33
        addSEs [Ord_in_Ord, Pair_inject];
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    34
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    35
(*Lemma for proving finality.  Unfold the lazy list; use induction hypothesis*)
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    36
goal LList_Eq.thy
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    37
   "!!i. Ord(i) ==> ALL l l'. <l,l'> : lleq(A) --> l Int Vset(i) <= l'";
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    38
by (etac trans_induct 1);
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    39
by (REPEAT (resolve_tac [allI, impI] 1));
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    40
by (etac LList_Eq.elim 1);
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    41
by (rewrite_goals_tac (QInr_def::LList.con_defs));
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    42
by (safe_tac lleq_cs);
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    43
by (fast_tac (subset_cs addSEs [Ord_trans, make_elim bspec]) 1);
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    44
val lleq_Int_Vset_subset_lemma = result();
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    45
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    46
val lleq_Int_Vset_subset = standard
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    47
	(lleq_Int_Vset_subset_lemma RS spec RS spec RS mp);
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    48
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    49
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    50
(*lleq(A) is a symmetric relation because qconverse(lleq(A)) is a fixedpoint*)
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    51
val [prem] = goal LList_Eq.thy "<l,l'> : lleq(A) ==> <l',l> : lleq(A)";
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    52
by (rtac (prem RS converseI RS LList_Eq.coinduct) 1);
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    53
by (rtac (LList_Eq.dom_subset RS converse_type) 1);
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    54
by (safe_tac converse_cs);
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    55
by (etac LList_Eq.elim 1);
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    56
by (ALLGOALS (fast_tac qconverse_cs));
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    57
val lleq_symmetric = result();
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    58
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    59
goal LList_Eq.thy "!!l l'. <l,l'> : lleq(A) ==> l=l'";
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    60
by (rtac equalityI 1);
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    61
by (REPEAT (ares_tac [lleq_Int_Vset_subset RS Int_Vset_subset] 1
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    62
     ORELSE etac lleq_symmetric 1));
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    63
val lleq_implies_equal = result();
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    64
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    65
val [eqprem,lprem] = goal LList_Eq.thy
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    66
    "[| l=l';  l: llist(A) |] ==> <l,l'> : lleq(A)";
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    67
by (res_inst_tac [("X", "{<l,l>. l: llist(A)}")] LList_Eq.coinduct 1);
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    68
by (rtac (lprem RS RepFunI RS (eqprem RS subst)) 1);
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    69
by (safe_tac qpair_cs);
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    70
by (etac LList.elim 1);
120
09287f26bfb8 changed all co- and co_ to co
lcp
parents: 95
diff changeset
    71
by (ALLGOALS (fast_tac pair_cs));
34
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    72
val equal_llist_implies_leq = result();
747f1aad03cf changed filenames to lower case name of theory the file contains
clasohm
parents:
diff changeset
    73