src/ZF/ex/LList.thy
author haftmann
Fri, 17 Jun 2005 16:12:49 +0200
changeset 16417 9bc16273c2d4
parent 13339 0f89104dd377
child 24893 b8ef7afe3a6b
permissions -rw-r--r--
migrated theory headers to new format
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      ZF/ex/LList.thy
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     5
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     6
Codatatype definition of Lazy Lists
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     7
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     8
Equality for llist(A) as a greatest fixed point
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
     9
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    10
Functions for Lazy Lists
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    11
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    12
STILL NEEDS:
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    13
co_recursion for defining lconst, flip, etc.
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    14
a typing rule for it, based on some notion of "productivity..."
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    15
*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    16
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13339
diff changeset
    17
theory LList imports Main begin
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    18
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    19
consts
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    20
  llist  :: "i=>i";
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    21
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    22
codatatype
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    23
  "llist(A)" = LNil | LCons ("a \<in> A", "l \<in> llist(A)")
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    24
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    25
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    26
(*Coinductive definition of equality*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    27
consts
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    28
  lleq :: "i=>i"
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    29
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    30
(*Previously used <*> in the domain and variant pairs as elements.  But
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    31
  standard pairs work just as well.  To use variant pairs, must change prefix
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    32
  a q/Q to the Sigma, Pair and converse rules.*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    33
coinductive
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    34
  domains "lleq(A)" <= "llist(A) * llist(A)"
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    35
  intros
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    36
    LNil:  "<LNil, LNil> \<in> lleq(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    37
    LCons: "[| a \<in> A; <l,l'> \<in> lleq(A) |] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    38
            ==> <LCons(a,l), LCons(a,l')> \<in> lleq(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    39
  type_intros  llist.intros
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    40
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    41
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    42
(*Lazy list functions; flip is not definitional!*)
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    43
consts
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    44
  lconst   :: "i => i"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    45
  flip     :: "i => i"
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
    46
753
ec86863e87c8 replaced "rules" by "defs"
lcp
parents: 515
diff changeset
    47
defs
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    48
  lconst_def:  "lconst(a) == lfp(univ(a), %l. LCons(a,l))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    49
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    50
axioms
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    51
  flip_LNil:   "flip(LNil) = LNil"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    52
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    53
  flip_LCons:  "[| x \<in> bool; l \<in> llist(bool) |] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    54
                ==> flip(LCons(x,l)) = LCons(not(x), flip(l))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    55
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    56
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    57
(*These commands cause classical reasoning to regard the subset relation
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    58
  as primitive, not reducing it to membership*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    59
  
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    60
declare subsetI [rule del]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    61
        subsetCE [rule del]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    62
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    63
declare subset_refl [intro!] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    64
        cons_subsetI [intro!] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    65
        subset_consI [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    66
        Union_least [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    67
        UN_least [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    68
        Un_least [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    69
	Inter_greatest [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    70
        Int_greatest [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    71
        RepFun_subset [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    72
	Un_upper1 [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    73
        Un_upper2 [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    74
        Int_lower1 [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    75
        Int_lower2 [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    76
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    77
(*An elimination rule, for type-checking*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    78
inductive_cases LConsE: "LCons(a,l) \<in> llist(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    79
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    80
(*Proving freeness results*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    81
lemma LCons_iff: "LCons(a,l)=LCons(a',l') <-> a=a' & l=l'"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    82
by auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    83
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    84
lemma LNil_LCons_iff: "~ LNil=LCons(a,l)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    85
by auto
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    86
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    87
(*
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    88
lemma llist_unfold: "llist(A) = {0} <+> (A <*> llist(A))";
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    89
let open llist  val rew = rewrite_rule con_defs in  
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    90
by (fast_tac (claset() addSIs (subsetI ::map rew intros) addEs [rew elim]) 1)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    91
end
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    92
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    93
*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    94
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    95
(*** Lemmas to justify using "llist" in other recursive type definitions ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    96
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    97
lemma llist_mono: "A \<subseteq> B ==> llist(A) \<subseteq> llist(B)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    98
apply (unfold llist.defs )
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
    99
apply (rule gfp_mono)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   100
apply (rule llist.bnd_mono)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   101
apply (assumption | rule quniv_mono basic_monos)+
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   102
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   103
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   104
(** Closure of quniv(A) under llist -- why so complex?  Its a gfp... **)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   105
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   106
declare QPair_Int_Vset_subset_UN [THEN subset_trans, intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   107
        QPair_subset_univ [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   108
        empty_subsetI [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   109
        one_in_quniv [THEN qunivD, intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   110
declare qunivD [dest!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   111
declare Ord_in_Ord [elim!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   112
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   113
lemma llist_quniv_lemma [rule_format]:
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   114
     "Ord(i) ==> \<forall>l \<in> llist(quniv(A)). l Int Vset(i) \<subseteq> univ(eclose(A))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   115
apply (erule trans_induct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   116
apply (rule ballI)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   117
apply (erule llist.cases)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   118
apply (simp_all add: QInl_def QInr_def llist.con_defs)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   119
(*LCons case: I simply can't get rid of the deepen_tac*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   120
apply (tactic "deepen_tac (claset() addIs [Ord_trans] addIs [Int_lower1 RS subset_trans]) 2 1")
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   121
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   122
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   123
lemma llist_quniv: "llist(quniv(A)) \<subseteq> quniv(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   124
apply (rule qunivI [THEN subsetI])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   125
apply (rule Int_Vset_subset)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   126
apply (assumption | rule llist_quniv_lemma)+
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   127
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   128
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   129
lemmas llist_subset_quniv =
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   130
       subset_trans [OF llist_mono llist_quniv]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   131
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   132
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   133
(*** Lazy List Equality: lleq ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   134
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   135
declare QPair_Int_Vset_subset_UN [THEN subset_trans, intro!] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   136
        QPair_mono [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   137
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   138
declare Ord_in_Ord [elim!] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   139
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   140
(*Lemma for proving finality.  Unfold the lazy list; use induction hypothesis*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   141
lemma lleq_Int_Vset_subset [rule_format]:
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   142
     "Ord(i) ==> \<forall>l l'. <l,l'> \<in> lleq(A) --> l Int Vset(i) \<subseteq> l'"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   143
apply (erule trans_induct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   144
apply (intro allI impI)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   145
apply (erule lleq.cases)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   146
apply (unfold QInr_def llist.con_defs, safe)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   147
apply (fast elim!: Ord_trans bspec [elim_format])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   148
done
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   149
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   150
(*lleq(A) is a symmetric relation because qconverse(lleq(A)) is a fixedpoint*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   151
lemma lleq_symmetric: "<l,l'> \<in> lleq(A) ==> <l',l> \<in> lleq(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   152
apply (erule lleq.coinduct [OF converseI]) 
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   153
apply (rule lleq.dom_subset [THEN converse_type], safe)
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   154
apply (erule lleq.cases, blast+)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   155
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   156
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   157
lemma lleq_implies_equal: "<l,l'> \<in> lleq(A) ==> l=l'"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   158
apply (rule equalityI)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   159
apply (assumption | rule lleq_Int_Vset_subset [THEN Int_Vset_subset] | 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   160
       erule lleq_symmetric)+
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   161
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   162
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   163
lemma equal_llist_implies_leq:
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   164
     "[| l=l';  l \<in> llist(A) |] ==> <l,l'> \<in> lleq(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   165
apply (rule_tac X = "{<l,l>. l \<in> llist (A) }" in lleq.coinduct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   166
apply blast
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   167
apply safe
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   168
apply (erule_tac a=l in llist.cases, fast+)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   169
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   170
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   171
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   172
(*** Lazy List Functions ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   173
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   174
(*Examples of coinduction for type-checking and to prove llist equations*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   175
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   176
(*** lconst -- defined directly using lfp, but equivalent to a LList_corec ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   177
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   178
lemma lconst_fun_bnd_mono: "bnd_mono(univ(a), %l. LCons(a,l))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   179
apply (unfold llist.con_defs )
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   180
apply (rule bnd_monoI)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   181
apply (blast intro: A_subset_univ QInr_subset_univ)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   182
apply (blast intro: subset_refl QInr_mono QPair_mono)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   183
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   184
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   185
(* lconst(a) = LCons(a,lconst(a)) *)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   186
lemmas lconst = def_lfp_unfold [OF lconst_def lconst_fun_bnd_mono]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   187
lemmas lconst_subset = lconst_def [THEN def_lfp_subset]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   188
lemmas member_subset_Union_eclose = arg_into_eclose [THEN Union_upper]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   189
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   190
lemma lconst_in_quniv: "a \<in> A ==> lconst(a) \<in> quniv(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   191
apply (rule lconst_subset [THEN subset_trans, THEN qunivI])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   192
apply (erule arg_into_eclose [THEN eclose_subset, THEN univ_mono])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   193
done
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   194
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   195
lemma lconst_type: "a \<in> A ==> lconst(a): llist(A)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   196
apply (rule singletonI [THEN llist.coinduct])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   197
apply (erule lconst_in_quniv [THEN singleton_subsetI])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   198
apply (fast intro!: lconst)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   199
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   200
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   201
(*** flip --- equations merely assumed; certain consequences proved ***)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   202
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   203
declare flip_LNil [simp] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   204
        flip_LCons [simp] 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   205
        not_type [simp]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   206
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   207
lemma bool_Int_subset_univ: "b \<in> bool ==> b Int X \<subseteq> univ(eclose(A))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   208
by (fast intro: Int_lower1 [THEN subset_trans] elim!: boolE)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   209
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   210
declare not_type [intro!]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   211
declare bool_Int_subset_univ [intro]
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   212
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   213
(*Reasoning borrowed from lleq.ML; a similar proof works for all
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   214
  "productive" functions -- cf Coquand's "Infinite Objects in Type Theory".*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   215
lemma flip_llist_quniv_lemma [rule_format]:
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   216
     "Ord(i) ==> \<forall>l \<in> llist(bool). flip(l) Int Vset(i) \<subseteq> univ(eclose(bool))"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   217
apply (erule trans_induct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   218
apply (rule ballI)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   219
apply (erule llist.cases, simp_all)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   220
apply (simp_all add: QInl_def QInr_def llist.con_defs)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   221
(*LCons case: I simply can't get rid of the deepen_tac*)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   222
apply (tactic "deepen_tac (claset() addIs [Ord_trans] addIs [Int_lower1 RS subset_trans]) 2 1")
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   223
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   224
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   225
lemma flip_in_quniv: "l \<in> llist(bool) ==> flip(l) \<in> quniv(bool)"
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   226
by (rule flip_llist_quniv_lemma [THEN Int_Vset_subset, THEN qunivI], assumption+)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   227
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   228
lemma flip_type: "l \<in> llist(bool) ==> flip(l): llist(bool)"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   229
apply (rule_tac X = "{flip (l) . l \<in> llist (bool) }" in llist.coinduct)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   230
apply blast
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   231
apply (fast intro!: flip_in_quniv)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   232
apply (erule RepFunE)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   233
apply (erule_tac a=la in llist.cases, auto)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   234
done
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   235
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   236
lemma flip_flip: "l \<in> llist(bool) ==> flip(flip(l)) = l"
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   237
apply (rule_tac X1 = "{<flip (flip (l)),l> . l \<in> llist (bool) }" in 
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   238
       lleq.coinduct [THEN lleq_implies_equal])
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   239
apply blast
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   240
apply (fast intro!: flip_type)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   241
apply (erule RepFunE)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12867
diff changeset
   242
apply (erule_tac a=la in llist.cases)
12867
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   243
apply (simp_all add: flip_type not_not)
5c900a821a7c New-style versions of these old examples
paulson
parents: 11354
diff changeset
   244
done
515
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   245
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   246
end
abcc438e7c27 installation of new inductive/datatype sections
lcp
parents:
diff changeset
   247