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