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