src/ZF/ex/LList.ML
author lcp
Mon, 15 Aug 1994 18:38:38 +0200
changeset 529 f0d16216e394
parent 515 abcc438e7c27
child 576 469279790410
permissions -rw-r--r--
ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     1
(*  Title: 	ZF/ex/LList.ML
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     4
    Copyright   1994  University of Cambridge
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
     6
Codatatype definition of Lazy Lists
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     8
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
     9
open LList;
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    10
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    11
(*An elimination rule, for type-checking*)
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    12
val LConsE = llist.mk_cases llist.con_defs "LCons(a,l) : llist(A)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    13
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    14
(*Proving freeness results*)
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    15
val LCons_iff      = llist.mk_free "LCons(a,l)=LCons(a',l') <-> a=a' & l=l'";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    16
val LNil_LCons_iff = llist.mk_free "~ LNil=LCons(a,l)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    17
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    18
goal LList.thy "llist(A) = {0} <+> (A <*> llist(A))";
529
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    19
let open llist;  val rew = rewrite_rule con_defs in  
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    20
by (fast_tac (qsum_cs addSIs (equalityI :: map rew intrs)
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    21
                      addEs [rew elim]) 1)
f0d16216e394 ZF/List, ex/Brouwer,Data,LList,Ntree,TF,Term: much simplified proof of _unfold
lcp
parents: 515
diff changeset
    22
end;
434
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    23
val llist_unfold = result();
89d45187f04d Various updates and tidying
lcp
parents: 279
diff changeset
    24
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    25
(*** Lemmas to justify using "llist" in other recursive type definitions ***)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    26
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    27
goalw LList.thy llist.defs "!!A B. A<=B ==> llist(A) <= llist(B)";
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    28
by (rtac gfp_mono 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    29
by (REPEAT (rtac llist.bnd_mono 1));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    30
by (REPEAT (ares_tac (quniv_mono::basic_monos) 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    31
val llist_mono = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    32
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    33
(** Closure of quniv(A) under llist -- why so complex?  Its a gfp... **)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    34
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    35
val quniv_cs = subset_cs addSIs [QPair_Int_Vset_subset_UN RS subset_trans, 
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    36
				 QPair_subset_univ,
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    37
				 empty_subsetI, one_in_quniv RS qunivD]
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    38
                 addIs  [Int_lower1 RS subset_trans]
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    39
		 addSDs [qunivD]
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    40
                 addSEs [Ord_in_Ord];
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    41
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    42
goal LList.thy
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    43
   "!!i. Ord(i) ==> ALL l: llist(quniv(A)). l Int Vset(i) <= univ(eclose(A))";
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    44
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
    45
by (rtac ballI 1);
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    46
by (etac llist.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    47
by (rewrite_goals_tac ([QInl_def,QInr_def]@llist.con_defs));
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    48
(*LNil case*)
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    49
by (fast_tac quniv_cs 1);
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    50
(*LCons case*)
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    51
by (safe_tac quniv_cs);
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    52
by (ALLGOALS (fast_tac (quniv_cs addSEs [Ord_trans, make_elim bspec])));
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    53
val llist_quniv_lemma = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    54
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    55
goal LList.thy "llist(quniv(A)) <= quniv(A)";
173
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    56
by (rtac (qunivI RS subsetI) 1);
85071e6ad295 ZF/ex/llist_eq/lleq_Int_Vset_subset_lemma,
lcp
parents: 120
diff changeset
    57
by (rtac Int_Vset_subset 1);
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    58
by (REPEAT (ares_tac [llist_quniv_lemma RS bspec] 1));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    59
val llist_quniv = result();
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    60
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    61
val llist_subset_quniv = standard
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    62
    (llist_mono RS (llist_quniv RSN (2,subset_trans)));
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    63
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    64
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    65
(*** Lazy List Equality: lleq ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    66
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    67
val lleq_cs = subset_cs
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    68
	addSIs [QPair_Int_Vset_subset_UN RS subset_trans, QPair_mono]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    69
        addSEs [Ord_in_Ord, Pair_inject];
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    70
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    71
(*Lemma for proving finality.  Unfold the lazy list; use induction hypothesis*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    72
goal LList.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    73
   "!!i. Ord(i) ==> ALL l l'. <l,l'> : lleq(A) --> l Int Vset(i) <= l'";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    74
by (etac trans_induct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    75
by (REPEAT (resolve_tac [allI, impI] 1));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    76
by (etac lleq.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    77
by (rewrite_goals_tac (QInr_def::llist.con_defs));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    78
by (safe_tac lleq_cs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    79
by (fast_tac (subset_cs addSEs [Ord_trans, make_elim bspec]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    80
val lleq_Int_Vset_subset_lemma = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    81
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    82
val lleq_Int_Vset_subset = standard
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    83
	(lleq_Int_Vset_subset_lemma RS spec RS spec RS mp);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    84
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    85
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    86
(*lleq(A) is a symmetric relation because qconverse(lleq(A)) is a fixedpoint*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    87
val [prem] = goal LList.thy "<l,l'> : lleq(A) ==> <l',l> : lleq(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    88
by (rtac (prem RS converseI RS lleq.coinduct) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    89
by (rtac (lleq.dom_subset RS converse_type) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    90
by (safe_tac converse_cs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    91
by (etac lleq.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    92
by (ALLGOALS (fast_tac qconverse_cs));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    93
val lleq_symmetric = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    94
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    95
goal LList.thy "!!l l'. <l,l'> : lleq(A) ==> l=l'";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    96
by (rtac equalityI 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    97
by (REPEAT (ares_tac [lleq_Int_Vset_subset RS Int_Vset_subset] 1
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    98
     ORELSE etac lleq_symmetric 1));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
    99
val lleq_implies_equal = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   100
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   101
val [eqprem,lprem] = goal LList.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   102
    "[| l=l';  l: llist(A) |] ==> <l,l'> : lleq(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   103
by (res_inst_tac [("X", "{<l,l>. l: llist(A)}")] lleq.coinduct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   104
by (rtac (lprem RS RepFunI RS (eqprem RS subst)) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   105
by (safe_tac qpair_cs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   106
by (etac llist.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   107
by (ALLGOALS (fast_tac pair_cs));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   108
val equal_llist_implies_leq = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   109
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   110
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   111
(*** Lazy List Functions ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   112
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   113
(*Examples of coinduction for type-checking and to prove llist equations*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   114
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   115
(*** lconst -- defined directly using lfp, but equivalent to a LList_corec ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   116
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   117
goalw LList.thy llist.con_defs "bnd_mono(univ(a), %l. LCons(a,l))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   118
by (rtac bnd_monoI 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   119
by (REPEAT (ares_tac [subset_refl, QInr_mono, QPair_mono] 2));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   120
by (REPEAT (ares_tac [subset_refl, A_subset_univ, 
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   121
		      QInr_subset_univ, QPair_subset_univ] 1));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   122
val lconst_fun_bnd_mono = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   123
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   124
(* lconst(a) = LCons(a,lconst(a)) *)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   125
val lconst = standard 
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   126
    ([lconst_def, lconst_fun_bnd_mono] MRS def_lfp_Tarski);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   127
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   128
val lconst_subset = lconst_def RS def_lfp_subset;
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   129
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   130
val member_subset_Union_eclose = standard (arg_into_eclose RS Union_upper);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   131
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   132
goal LList.thy "!!a A. a : A ==> lconst(a) : quniv(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   133
by (rtac (lconst_subset RS subset_trans RS qunivI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   134
by (etac (arg_into_eclose RS eclose_subset RS univ_mono) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   135
val lconst_in_quniv = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   136
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   137
goal LList.thy "!!a A. a:A ==> lconst(a): llist(A)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   138
by (rtac (singletonI RS llist.coinduct) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   139
by (fast_tac (ZF_cs addSIs [lconst_in_quniv]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   140
by (fast_tac (ZF_cs addSIs [lconst]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   141
val lconst_type = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   142
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   143
(*** flip --- equations merely assumed; certain consequences proved ***)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   144
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   145
val flip_ss = ZF_ss addsimps [flip_LNil, flip_LCons, not_type];
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   146
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   147
goal QUniv.thy "!!b. b:bool ==> b Int X <= univ(eclose(A))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   148
by (fast_tac (quniv_cs addSEs [boolE]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   149
val bool_Int_subset_univ = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   150
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   151
val flip_cs = quniv_cs addSIs [not_type]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   152
                       addIs  [bool_Int_subset_univ];
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   153
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   154
(*Reasoning borrowed from lleq.ML; a similar proof works for all
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   155
  "productive" functions -- cf Coquand's "Infinite Objects in Type Theory".*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   156
goal LList.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   157
   "!!i. Ord(i) ==> ALL l: llist(bool). flip(l) Int Vset(i) <= \
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   158
\                   univ(eclose(bool))";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   159
by (etac trans_induct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   160
by (rtac ballI 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   161
by (etac llist.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   162
by (asm_simp_tac flip_ss 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   163
by (asm_simp_tac flip_ss 2);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   164
by (rewrite_goals_tac ([QInl_def,QInr_def]@llist.con_defs));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   165
(*LNil case*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   166
by (fast_tac flip_cs 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   167
(*LCons case*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   168
by (safe_tac flip_cs);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   169
by (ALLGOALS (fast_tac (flip_cs addSEs [Ord_trans, make_elim bspec])));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   170
val flip_llist_quniv_lemma = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   171
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   172
goal LList.thy "!!l. l: llist(bool) ==> flip(l) : quniv(bool)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   173
by (rtac (flip_llist_quniv_lemma RS bspec RS Int_Vset_subset RS qunivI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   174
by (REPEAT (assume_tac 1));
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   175
val flip_in_quniv = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   176
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   177
val [prem] = goal LList.thy "l : llist(bool) ==> flip(l): llist(bool)";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   178
by (res_inst_tac [("X", "{flip(l) . l:llist(bool)}")]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   179
       llist.coinduct 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   180
by (rtac (prem RS RepFunI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   181
by (fast_tac (ZF_cs addSIs [flip_in_quniv]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   182
by (etac RepFunE 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   183
by (etac llist.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   184
by (asm_simp_tac flip_ss 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   185
by (asm_simp_tac flip_ss 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   186
by (fast_tac (ZF_cs addSIs [not_type]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   187
val flip_type = result();
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   188
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   189
val [prem] = goal LList.thy
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   190
    "l : llist(bool) ==> flip(flip(l)) = l";
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   191
by (res_inst_tac [("X1", "{<flip(flip(l)),l> . l:llist(bool)}")]
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   192
       (lleq.coinduct RS lleq_implies_equal) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   193
by (rtac (prem RS RepFunI) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   194
by (fast_tac (ZF_cs addSIs [flip_type]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   195
by (etac RepFunE 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   196
by (etac llist.elim 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   197
by (asm_simp_tac flip_ss 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   198
by (asm_simp_tac (flip_ss addsimps [flip_type, not_not]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   199
by (fast_tac (ZF_cs addSIs [not_type]) 1);
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents: 486
diff changeset
   200
val flip_flip = result();