src/ZF/Epsilon.thy
author obua
Thu, 16 Feb 2006 04:17:19 +0100
changeset 19067 c0321d7d6b3d
parent 16417 9bc16273c2d4
child 24893 b8ef7afe3a6b
permissions -rw-r--r--
variable counter is now also cached
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     1
(*  Title:      ZF/epsilon.thy
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     2
    ID:         $Id$
1478
2b8c2a7547ab expanded tabs
clasohm
parents: 1401
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     4
    Copyright   1993  University of Cambridge
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     5
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     6
*)
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
     7
13328
703de709a64b better document preparation
paulson
parents: 13269
diff changeset
     8
header{*Epsilon Induction and Recursion*}
703de709a64b better document preparation
paulson
parents: 13269
diff changeset
     9
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 15481
diff changeset
    10
theory Epsilon imports Nat begin
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    11
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    12
constdefs
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    13
  eclose    :: "i=>i"
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
    14
    "eclose(A) == \<Union>n\<in>nat. nat_rec(n, A, %m r. Union(r))"
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
    15
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    16
  transrec  :: "[i, [i,i]=>i] =>i"
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    17
    "transrec(a,H) == wfrec(Memrel(eclose({a})), a, H)"
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    18
 
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    19
  rank      :: "i=>i"
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
    20
    "rank(a) == transrec(a, %x f. \<Union>y\<in>x. succ(f`y))"
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    21
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    22
  transrec2 :: "[i, i, [i,i]=>i] =>i"
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    23
    "transrec2(k, a, b) ==                     
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    24
       transrec(k, 
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    25
                %i r. if(i=0, a, 
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    26
                        if(EX j. i=succ(j),        
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    27
                           b(THE j. i=succ(j), r`(THE j. i=succ(j))),   
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
    28
                           \<Union>j<i. r`j)))"
2469
b50b8c0eec01 Implicit simpsets and clasets for FOL and ZF
paulson
parents: 1478
diff changeset
    29
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    30
  recursor  :: "[i, [i,i]=>i, i]=>i"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    31
    "recursor(a,b,k) ==  transrec(k, %n f. nat_case(a, %m. b(m, f`m), n))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    32
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    33
  rec  :: "[i, i, [i,i]=>i]=>i"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    34
    "rec(k,a,b) == recursor(a,b,k)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    35
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    36
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13328
diff changeset
    37
subsection{*Basic Closure Properties*}
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    38
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    39
lemma arg_subset_eclose: "A <= eclose(A)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    40
apply (unfold eclose_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    41
apply (rule nat_rec_0 [THEN equalityD2, THEN subset_trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    42
apply (rule nat_0I [THEN UN_upper])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    43
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    44
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    45
lemmas arg_into_eclose = arg_subset_eclose [THEN subsetD, standard]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    46
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    47
lemma Transset_eclose: "Transset(eclose(A))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    48
apply (unfold eclose_def Transset_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    49
apply (rule subsetI [THEN ballI])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    50
apply (erule UN_E)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    51
apply (rule nat_succI [THEN UN_I], assumption)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    52
apply (erule nat_rec_succ [THEN ssubst])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    53
apply (erule UnionI, assumption)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    54
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    55
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    56
(* x : eclose(A) ==> x <= eclose(A) *)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    57
lemmas eclose_subset =  
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    58
       Transset_eclose [unfolded Transset_def, THEN bspec, standard]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    59
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    60
(* [| A : eclose(B); c : A |] ==> c : eclose(B) *)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    61
lemmas ecloseD = eclose_subset [THEN subsetD, standard]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    62
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    63
lemmas arg_in_eclose_sing = arg_subset_eclose [THEN singleton_subsetD]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    64
lemmas arg_into_eclose_sing = arg_in_eclose_sing [THEN ecloseD, standard]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    65
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    66
(* This is epsilon-induction for eclose(A); see also eclose_induct_down...
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    67
   [| a: eclose(A);  !!x. [| x: eclose(A); ALL y:x. P(y) |] ==> P(x) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    68
   |] ==> P(a) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    69
*)
13203
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
    70
lemmas eclose_induct =
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
    71
     Transset_induct [OF _ Transset_eclose, induct set: eclose]
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
    72
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    73
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    74
(*Epsilon induction*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    75
lemma eps_induct:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    76
    "[| !!x. ALL y:x. P(y) ==> P(x) |]  ==>  P(a)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    77
by (rule arg_in_eclose_sing [THEN eclose_induct], blast) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    78
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    79
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13328
diff changeset
    80
subsection{*Leastness of @{term eclose}*}
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    81
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    82
(** eclose(A) is the least transitive set including A as a subset. **)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    83
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    84
lemma eclose_least_lemma: 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    85
    "[| Transset(X);  A<=X;  n: nat |] ==> nat_rec(n, A, %m r. Union(r)) <= X"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    86
apply (unfold Transset_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    87
apply (erule nat_induct) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    88
apply (simp add: nat_rec_0)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    89
apply (simp add: nat_rec_succ, blast)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    90
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    91
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    92
lemma eclose_least: 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    93
     "[| Transset(X);  A<=X |] ==> eclose(A) <= X"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    94
apply (unfold eclose_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    95
apply (rule eclose_least_lemma [THEN UN_least], assumption+)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    96
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    97
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
    98
(*COMPLETELY DIFFERENT induction principle from eclose_induct!!*)
13524
604d0f3622d6 *** empty log message ***
wenzelm
parents: 13387
diff changeset
    99
lemma eclose_induct_down [consumes 1]:
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   100
    "[| a: eclose(b);                                            
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   101
        !!y.   [| y: b |] ==> P(y);                              
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   102
        !!y z. [| y: eclose(b);  P(y);  z: y |] ==> P(z)         
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   103
     |] ==> P(a)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   104
apply (rule eclose_least [THEN subsetD, THEN CollectD2, of "eclose(b)"])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   105
  prefer 3 apply assumption
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   106
 apply (unfold Transset_def) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   107
 apply (blast intro: ecloseD)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   108
apply (blast intro: arg_subset_eclose [THEN subsetD])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   109
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   110
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   111
lemma Transset_eclose_eq_arg: "Transset(X) ==> eclose(X) = X"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   112
apply (erule equalityI [OF eclose_least arg_subset_eclose])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   113
apply (rule subset_refl)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   114
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   115
13387
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   116
text{*A transitive set either is empty or contains the empty set.*}
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   117
lemma Transset_0_lemma [rule_format]: "Transset(A) ==> x\<in>A --> 0\<in>A";
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   118
apply (simp add: Transset_def) 
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   119
apply (rule_tac a=x in eps_induct, clarify) 
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   120
apply (drule bspec, assumption) 
14153
76a6ba67bd15 new case_tac
paulson
parents: 13784
diff changeset
   121
apply (case_tac "x=0", auto)
13387
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   122
done
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   123
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   124
lemma Transset_0_disj: "Transset(A) ==> A=0 | 0\<in>A";
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   125
by (blast dest: Transset_0_lemma)
b7464ca2ebbb new theorems to support Constructible proofs
paulson
parents: 13357
diff changeset
   126
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   127
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13328
diff changeset
   128
subsection{*Epsilon Recursion*}
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   129
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   130
(*Unused...*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   131
lemma mem_eclose_trans: "[| A: eclose(B);  B: eclose(C) |] ==> A: eclose(C)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   132
by (rule eclose_least [OF Transset_eclose eclose_subset, THEN subsetD], 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   133
    assumption+)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   134
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   135
(*Variant of the previous lemma in a useable form for the sequel*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   136
lemma mem_eclose_sing_trans:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   137
     "[| A: eclose({B});  B: eclose({C}) |] ==> A: eclose({C})"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   138
by (rule eclose_least [OF Transset_eclose singleton_subsetI, THEN subsetD], 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   139
    assumption+)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   140
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   141
lemma under_Memrel: "[| Transset(i);  j:i |] ==> Memrel(i)-``{j} = j"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   142
by (unfold Transset_def, blast)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   143
13217
bc5dc2392578 new theorems
paulson
parents: 13203
diff changeset
   144
lemma lt_Memrel: "j < i ==> Memrel(i) -`` {j} = j"
bc5dc2392578 new theorems
paulson
parents: 13203
diff changeset
   145
by (simp add: lt_def Ord_def under_Memrel) 
bc5dc2392578 new theorems
paulson
parents: 13203
diff changeset
   146
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   147
(* j : eclose(A) ==> Memrel(eclose(A)) -`` j = j *)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   148
lemmas under_Memrel_eclose = Transset_eclose [THEN under_Memrel, standard]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   149
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   150
lemmas wfrec_ssubst = wf_Memrel [THEN wfrec, THEN ssubst]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   151
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   152
lemma wfrec_eclose_eq:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   153
    "[| k:eclose({j});  j:eclose({i}) |] ==>  
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   154
     wfrec(Memrel(eclose({i})), k, H) = wfrec(Memrel(eclose({j})), k, H)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   155
apply (erule eclose_induct)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   156
apply (rule wfrec_ssubst)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   157
apply (rule wfrec_ssubst)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   158
apply (simp add: under_Memrel_eclose mem_eclose_sing_trans [of _ j i])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   159
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   160
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   161
lemma wfrec_eclose_eq2: 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   162
    "k: i ==> wfrec(Memrel(eclose({i})),k,H) = wfrec(Memrel(eclose({k})),k,H)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   163
apply (rule arg_in_eclose_sing [THEN wfrec_eclose_eq])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   164
apply (erule arg_into_eclose_sing)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   165
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   166
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   167
lemma transrec: "transrec(a,H) = H(a, lam x:a. transrec(x,H))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   168
apply (unfold transrec_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   169
apply (rule wfrec_ssubst)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   170
apply (simp add: wfrec_eclose_eq2 arg_in_eclose_sing under_Memrel_eclose)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   171
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   172
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   173
(*Avoids explosions in proofs; resolve it with a meta-level definition.*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   174
lemma def_transrec:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   175
    "[| !!x. f(x)==transrec(x,H) |] ==> f(a) = H(a, lam x:a. f(x))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   176
apply simp
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   177
apply (rule transrec)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   178
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   179
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   180
lemma transrec_type:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   181
    "[| !!x u. [| x:eclose({a});  u: Pi(x,B) |] ==> H(x,u) : B(x) |]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   182
     ==> transrec(a,H) : B(a)"
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13615
diff changeset
   183
apply (rule_tac i = a in arg_in_eclose_sing [THEN eclose_induct])
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   184
apply (subst transrec)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   185
apply (simp add: lam_type) 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   186
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   187
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   188
lemma eclose_sing_Ord: "Ord(i) ==> eclose({i}) <= succ(i)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   189
apply (erule Ord_is_Transset [THEN Transset_succ, THEN eclose_least])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   190
apply (rule succI1 [THEN singleton_subsetI])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   191
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   192
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   193
lemma succ_subset_eclose_sing: "succ(i) <= eclose({i})"
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   194
apply (insert arg_subset_eclose [of "{i}"], simp) 
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   195
apply (frule eclose_subset, blast) 
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   196
done
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   197
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   198
lemma eclose_sing_Ord_eq: "Ord(i) ==> eclose({i}) = succ(i)"
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   199
apply (rule equalityI)
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   200
apply (erule eclose_sing_Ord)  
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   201
apply (rule succ_subset_eclose_sing) 
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   202
done
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   203
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   204
lemma Ord_transrec_type:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   205
  assumes jini: "j: i"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   206
      and ordi: "Ord(i)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   207
      and minor: " !!x u. [| x: i;  u: Pi(x,B) |] ==> H(x,u) : B(x)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   208
  shows "transrec(j,H) : B(j)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   209
apply (rule transrec_type)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   210
apply (insert jini ordi)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   211
apply (blast intro!: minor
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   212
             intro: Ord_trans 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   213
             dest: Ord_in_Ord [THEN eclose_sing_Ord, THEN subsetD])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   214
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   215
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13328
diff changeset
   216
subsection{*Rank*}
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   217
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   218
(*NOT SUITABLE FOR REWRITING -- RECURSIVE!*)
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
   219
lemma rank: "rank(a) = (\<Union>y\<in>a. succ(rank(y)))"
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   220
by (subst rank_def [THEN def_transrec], simp)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   221
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   222
lemma Ord_rank [simp]: "Ord(rank(a))"
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13615
diff changeset
   223
apply (rule_tac a=a in eps_induct) 
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   224
apply (subst rank)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   225
apply (rule Ord_succ [THEN Ord_UN])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   226
apply (erule bspec, assumption)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   227
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   228
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   229
lemma rank_of_Ord: "Ord(i) ==> rank(i) = i"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   230
apply (erule trans_induct)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   231
apply (subst rank)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   232
apply (simp add: Ord_equality)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   233
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   234
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   235
lemma rank_lt: "a:b ==> rank(a) < rank(b)"
13784
b9f6154427a4 tidying (by script)
paulson
parents: 13615
diff changeset
   236
apply (rule_tac a1 = b in rank [THEN ssubst])
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   237
apply (erule UN_I [THEN ltI])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   238
apply (rule_tac [2] Ord_UN, auto)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   239
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   240
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   241
lemma eclose_rank_lt: "a: eclose(b) ==> rank(a) < rank(b)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   242
apply (erule eclose_induct_down)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   243
apply (erule rank_lt)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   244
apply (erule rank_lt [THEN lt_trans], assumption)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   245
done
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 2469
diff changeset
   246
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   247
lemma rank_mono: "a<=b ==> rank(a) le rank(b)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   248
apply (rule subset_imp_le)
15481
fc075ae929e4 the new subst tactic, by Lucas Dixon
paulson
parents: 14153
diff changeset
   249
apply (auto simp add: rank [of a] rank [of b]) 
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   250
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   251
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   252
lemma rank_Pow: "rank(Pow(a)) = succ(rank(a))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   253
apply (rule rank [THEN trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   254
apply (rule le_anti_sym)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   255
apply (rule_tac [2] UN_upper_le)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   256
apply (rule UN_least_le)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   257
apply (auto intro: rank_mono simp add: Ord_UN)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   258
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   259
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   260
lemma rank_0 [simp]: "rank(0) = 0"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   261
by (rule rank [THEN trans], blast)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   262
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   263
lemma rank_succ [simp]: "rank(succ(x)) = succ(rank(x))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   264
apply (rule rank [THEN trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   265
apply (rule equalityI [OF UN_least succI1 [THEN UN_upper]])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   266
apply (erule succE, blast)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   267
apply (erule rank_lt [THEN leI, THEN succ_leI, THEN le_imp_subset])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   268
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   269
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
   270
lemma rank_Union: "rank(Union(A)) = (\<Union>x\<in>A. rank(x))"
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   271
apply (rule equalityI)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   272
apply (rule_tac [2] rank_mono [THEN le_imp_subset, THEN UN_least])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   273
apply (erule_tac [2] Union_upper)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   274
apply (subst rank)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   275
apply (rule UN_least)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   276
apply (erule UnionE)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   277
apply (rule subset_trans)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   278
apply (erule_tac [2] RepFunI [THEN Union_upper])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   279
apply (erule rank_lt [THEN succ_leI, THEN le_imp_subset])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   280
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   281
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   282
lemma rank_eclose: "rank(eclose(a)) = rank(a)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   283
apply (rule le_anti_sym)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   284
apply (rule_tac [2] arg_subset_eclose [THEN rank_mono])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   285
apply (rule_tac a1 = "eclose (a) " in rank [THEN ssubst])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   286
apply (rule Ord_rank [THEN UN_least_le])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   287
apply (erule eclose_rank_lt [THEN succ_leI])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   288
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   289
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   290
lemma rank_pair1: "rank(a) < rank(<a,b>)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   291
apply (unfold Pair_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   292
apply (rule consI1 [THEN rank_lt, THEN lt_trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   293
apply (rule consI1 [THEN consI2, THEN rank_lt])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   294
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   295
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   296
lemma rank_pair2: "rank(b) < rank(<a,b>)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   297
apply (unfold Pair_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   298
apply (rule consI1 [THEN consI2, THEN rank_lt, THEN lt_trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   299
apply (rule consI1 [THEN consI2, THEN rank_lt])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   300
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   301
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   302
(*Not clear how to remove the P(a) condition, since the "then" part
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   303
  must refer to "a"*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   304
lemma the_equality_if:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   305
     "P(a) ==> (THE x. P(x)) = (if (EX!x. P(x)) then a else 0)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   306
by (simp add: the_0 the_equality2)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   307
13175
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   308
(*The first premise not only fixs i but ensures f~=0.
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   309
  The second premise is now essential.  Consider otherwise the relation 
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   310
  r = {<0,0>,<0,1>,<0,2>,...}.  Then f`0 = Union(f``{0}) = Union(nat) = nat,
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   311
  whose rank equals that of r.*)
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   312
lemma rank_apply: "[|i : domain(f); function(f)|] ==> rank(f`i) < rank(f)"
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   313
apply clarify  
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   314
apply (simp add: function_apply_equality) 
13175
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   315
apply (blast intro: lt_trans rank_lt rank_pair2)
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   316
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   317
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   318
13356
c9cfe1638bf2 improved presentation markup
paulson
parents: 13328
diff changeset
   319
subsection{*Corollaries of Leastness*}
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   320
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   321
lemma mem_eclose_subset: "A:B ==> eclose(A)<=eclose(B)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   322
apply (rule Transset_eclose [THEN eclose_least])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   323
apply (erule arg_into_eclose [THEN eclose_subset])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   324
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   325
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   326
lemma eclose_mono: "A<=B ==> eclose(A) <= eclose(B)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   327
apply (rule Transset_eclose [THEN eclose_least])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   328
apply (erule subset_trans)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   329
apply (rule arg_subset_eclose)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   330
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   331
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   332
(** Idempotence of eclose **)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   333
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   334
lemma eclose_idem: "eclose(eclose(A)) = eclose(A)"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   335
apply (rule equalityI)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   336
apply (rule eclose_least [OF Transset_eclose subset_refl])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   337
apply (rule arg_subset_eclose)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   338
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   339
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   340
(** Transfinite recursion for definitions based on the 
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   341
    three cases of ordinals **)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   342
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   343
lemma transrec2_0 [simp]: "transrec2(0,a,b) = a"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   344
by (rule transrec2_def [THEN def_transrec, THEN trans], simp)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   345
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   346
lemma transrec2_succ [simp]: "transrec2(succ(i),a,b) = b(i, transrec2(i,a,b))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   347
apply (rule transrec2_def [THEN def_transrec, THEN trans])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   348
apply (simp add: the_equality if_P)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   349
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   350
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   351
lemma transrec2_Limit:
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
   352
     "Limit(i) ==> transrec2(i,a,b) = (\<Union>j<i. transrec2(j,a,b))"
13175
81082cfa5618 new definition of "apply" and new simprule "beta_if"
paulson
parents: 13164
diff changeset
   353
apply (rule transrec2_def [THEN def_transrec, THEN trans])
13269
3ba9be497c33 Tidying and introduction of various new theorems
paulson
parents: 13217
diff changeset
   354
apply (auto simp add: OUnion_def) 
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   355
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   356
13203
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   357
lemma def_transrec2:
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   358
     "(!!x. f(x)==transrec2(x,a,b))
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   359
      ==> f(0) = a & 
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   360
          f(succ(i)) = b(i, f(i)) & 
13615
449a70d88b38 Numerous cosmetic changes, prompted by the new simplifier
paulson
parents: 13524
diff changeset
   361
          (Limit(K) --> f(K) = (\<Union>j<K. f(j)))"
13203
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   362
by (simp add: transrec2_Limit)
fac77a839aa2 Tidying up. Mainly moving proofs from Main.thy to other (Isar) theory files.
paulson
parents: 13185
diff changeset
   363
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   364
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   365
(** recursor -- better than nat_rec; the succ case has no type requirement! **)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   366
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   367
(*NOT suitable for rewriting*)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   368
lemmas recursor_lemma = recursor_def [THEN def_transrec, THEN trans]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   369
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   370
lemma recursor_0: "recursor(a,b,0) = a"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   371
by (rule nat_case_0 [THEN recursor_lemma])
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   372
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   373
lemma recursor_succ: "recursor(a,b,succ(m)) = b(m, recursor(a,b,m))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   374
by (rule recursor_lemma, simp)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   375
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   376
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   377
(** rec: old version for compatibility **)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   378
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   379
lemma rec_0 [simp]: "rec(0,a,b) = a"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   380
apply (unfold rec_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   381
apply (rule recursor_0)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   382
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   383
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   384
lemma rec_succ [simp]: "rec(succ(m),a,b) = b(m, rec(m,a,b))"
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   385
apply (unfold rec_def)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   386
apply (rule recursor_succ)
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   387
done
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   388
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   389
lemma rec_type:
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   390
    "[| n: nat;   
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   391
        a: C(0);   
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   392
        !!m z. [| m: nat;  z: C(m) |] ==> b(m,z): C(succ(m)) |]
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   393
     ==> rec(n,a,b) : C(n)"
13185
da61bfa0a391 deleted some useless ML bindings
paulson
parents: 13175
diff changeset
   394
by (erule nat_induct, auto)
13164
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   395
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   396
ML
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   397
{*
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   398
val arg_subset_eclose = thm "arg_subset_eclose";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   399
val arg_into_eclose = thm "arg_into_eclose";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   400
val Transset_eclose = thm "Transset_eclose";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   401
val eclose_subset = thm "eclose_subset";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   402
val ecloseD = thm "ecloseD";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   403
val arg_in_eclose_sing = thm "arg_in_eclose_sing";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   404
val arg_into_eclose_sing = thm "arg_into_eclose_sing";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   405
val eclose_induct = thm "eclose_induct";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   406
val eps_induct = thm "eps_induct";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   407
val eclose_least = thm "eclose_least";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   408
val eclose_induct_down = thm "eclose_induct_down";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   409
val Transset_eclose_eq_arg = thm "Transset_eclose_eq_arg";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   410
val mem_eclose_trans = thm "mem_eclose_trans";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   411
val mem_eclose_sing_trans = thm "mem_eclose_sing_trans";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   412
val under_Memrel = thm "under_Memrel";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   413
val under_Memrel_eclose = thm "under_Memrel_eclose";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   414
val wfrec_ssubst = thm "wfrec_ssubst";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   415
val wfrec_eclose_eq = thm "wfrec_eclose_eq";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   416
val wfrec_eclose_eq2 = thm "wfrec_eclose_eq2";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   417
val transrec = thm "transrec";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   418
val def_transrec = thm "def_transrec";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   419
val transrec_type = thm "transrec_type";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   420
val eclose_sing_Ord = thm "eclose_sing_Ord";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   421
val Ord_transrec_type = thm "Ord_transrec_type";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   422
val rank = thm "rank";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   423
val Ord_rank = thm "Ord_rank";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   424
val rank_of_Ord = thm "rank_of_Ord";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   425
val rank_lt = thm "rank_lt";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   426
val eclose_rank_lt = thm "eclose_rank_lt";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   427
val rank_mono = thm "rank_mono";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   428
val rank_Pow = thm "rank_Pow";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   429
val rank_0 = thm "rank_0";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   430
val rank_succ = thm "rank_succ";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   431
val rank_Union = thm "rank_Union";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   432
val rank_eclose = thm "rank_eclose";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   433
val rank_pair1 = thm "rank_pair1";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   434
val rank_pair2 = thm "rank_pair2";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   435
val the_equality_if = thm "the_equality_if";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   436
val rank_apply = thm "rank_apply";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   437
val mem_eclose_subset = thm "mem_eclose_subset";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   438
val eclose_mono = thm "eclose_mono";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   439
val eclose_idem = thm "eclose_idem";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   440
val transrec2_0 = thm "transrec2_0";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   441
val transrec2_succ = thm "transrec2_succ";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   442
val transrec2_Limit = thm "transrec2_Limit";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   443
val recursor_0 = thm "recursor_0";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   444
val recursor_succ = thm "recursor_succ";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   445
val rec_0 = thm "rec_0";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   446
val rec_succ = thm "rec_succ";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   447
val rec_type = thm "rec_type";
dfc399c684e4 converted Epsilon to Isar
paulson
parents: 6070
diff changeset
   448
*}
6070
032babd0120b ZF: the natural numbers as a datatype
paulson
parents: 2469
diff changeset
   449
0
a5a9c433f639 Initial revision
clasohm
parents:
diff changeset
   450
end