src/ZF/Induct/Primrec.thy
author wenzelm
Wed, 03 Oct 2007 21:29:05 +0200
changeset 24825 c4f13ab78f9d
parent 20503 503ac4c5ef91
child 24892 c663e675e177
permissions -rw-r--r--
avoid unnamed infixes; tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
     1
(*  Title:      ZF/Induct/Primrec.thy
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     2
    ID:         $Id$
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     3
    Author:     Lawrence C Paulson, Cambridge University Computer Laboratory
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     4
    Copyright   1994  University of Cambridge
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     5
*)
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     6
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
     7
header {* Primitive Recursive Functions: the inductive definition *}
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
     8
16417
9bc16273c2d4 migrated theory headers to new format
haftmann
parents: 13339
diff changeset
     9
theory Primrec imports Main begin
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    10
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    11
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    12
  Proof adopted from \cite{szasz}.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    13
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    14
  See also \cite[page 250, exercise 11]{mendelson}.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    15
*}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    16
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    17
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    18
subsection {* Basic definitions *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    19
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    20
constdefs
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    21
  SC :: "i"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    22
  "SC == \<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. succ(x), l)"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    23
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    24
  CONSTANT :: "i=>i"
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    25
  "CONSTANT(k) == \<lambda>l \<in> list(nat). k"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    26
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    27
  PROJ :: "i=>i"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    28
  "PROJ(i) == \<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. x, drop(i,l))"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    29
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    30
  COMP :: "[i,i]=>i"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    31
  "COMP(g,fs) == \<lambda>l \<in> list(nat). g ` List.map(\<lambda>f. f`l, fs)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    32
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    33
  PREC :: "[i,i]=>i"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    34
  "PREC(f,g) ==
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    35
     \<lambda>l \<in> list(nat). list_case(0,
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    36
                      \<lambda>x xs. rec(x, f`xs, \<lambda>y r. g ` Cons(r, Cons(y, xs))), l)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    37
  -- {* Note that @{text g} is applied first to @{term "PREC(f,g)`y"} and then to @{text y}! *}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    38
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    39
consts
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    40
  ACK :: "i=>i"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    41
primrec
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    42
  "ACK(0) = SC"
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    43
  "ACK(succ(i)) = PREC (CONSTANT (ACK(i) ` [1]), COMP(ACK(i), [PROJ(0)]))"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    44
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    45
syntax
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    46
  ack :: "[i,i]=>i"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    47
translations
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    48
  "ack(x,y)" == "ACK(x) ` [y]"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    49
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    50
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    51
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    52
  \medskip Useful special cases of evaluation.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    53
*}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    54
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    55
lemma SC: "[| x \<in> nat;  l \<in> list(nat) |] ==> SC ` (Cons(x,l)) = succ(x)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    56
  by (simp add: SC_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    57
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    58
lemma CONSTANT: "l \<in> list(nat) ==> CONSTANT(k) ` l = k"
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    59
  by (simp add: CONSTANT_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    60
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    61
lemma PROJ_0: "[| x \<in> nat;  l \<in> list(nat) |] ==> PROJ(0) ` (Cons(x,l)) = x"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    62
  by (simp add: PROJ_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    63
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    64
lemma COMP_1: "l \<in> list(nat) ==> COMP(g,[f]) ` l = g` [f`l]"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    65
  by (simp add: COMP_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    66
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    67
lemma PREC_0: "l \<in> list(nat) ==> PREC(f,g) ` (Cons(0,l)) = f`l"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    68
  by (simp add: PREC_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    69
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    70
lemma PREC_succ:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    71
  "[| x \<in> nat;  l \<in> list(nat) |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    72
    ==> PREC(f,g) ` (Cons(succ(x),l)) =
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    73
      g ` Cons(PREC(f,g)`(Cons(x,l)), Cons(x,l))"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    74
  by (simp add: PREC_def)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    75
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    76
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    77
subsection {* Inductive definition of the PR functions *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    78
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    79
consts
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    80
  prim_rec :: i
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    81
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
    82
inductive
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    83
  domains prim_rec \<subseteq> "list(nat)->nat"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    84
  intros
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    85
    "SC \<in> prim_rec"
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    86
    "k \<in> nat ==> CONSTANT(k) \<in> prim_rec"
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    87
    "i \<in> nat ==> PROJ(i) \<in> prim_rec"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    88
    "[| g \<in> prim_rec; fs\<in>list(prim_rec) |] ==> COMP(g,fs) \<in> prim_rec"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    89
    "[| f \<in> prim_rec; g \<in> prim_rec |] ==> PREC(f,g) \<in> prim_rec"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    90
  monos list_mono
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
    91
  con_defs SC_def CONSTANT_def PROJ_def COMP_def PREC_def
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    92
  type_intros nat_typechecks list.intros
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    93
    lam_type list_case_type drop_type List.map_type
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    94
    apply_type rec_type
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    95
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    96
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    97
lemma prim_rec_into_fun [TC]: "c \<in> prim_rec ==> c \<in> list(nat) -> nat"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    98
  by (erule subsetD [OF prim_rec.dom_subset])
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    99
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   100
lemmas [TC] = apply_type [OF prim_rec_into_fun]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   101
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   102
declare prim_rec.intros [TC]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   103
declare nat_into_Ord [TC]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   104
declare rec_type [TC]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   105
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   106
lemma ACK_in_prim_rec [TC]: "i \<in> nat ==> ACK(i) \<in> prim_rec"
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   107
  by (induct set: nat) simp_all
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   108
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   109
lemma ack_type [TC]: "[| i \<in> nat;  j \<in> nat |] ==>  ack(i,j) \<in> nat"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   110
  by auto
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   111
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   112
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   113
subsection {* Ackermann's function cases *}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   114
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   115
lemma ack_0: "j \<in> nat ==> ack(0,j) = succ(j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   116
  -- {* PROPERTY A 1 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   117
  by (simp add: SC)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   118
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   119
lemma ack_succ_0: "ack(succ(i), 0) = ack(i,1)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   120
  -- {* PROPERTY A 2 *}
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   121
  by (simp add: CONSTANT PREC_0)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   122
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   123
lemma ack_succ_succ:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   124
  "[| i\<in>nat;  j\<in>nat |] ==> ack(succ(i), succ(j)) = ack(i, ack(succ(i), j))"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   125
  -- {* PROPERTY A 3 *}
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   126
  by (simp add: CONSTANT PREC_succ COMP_1 PROJ_0)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   127
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   128
lemmas [simp] = ack_0 ack_succ_0 ack_succ_succ ack_type
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   129
  and [simp del] = ACK.simps
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   130
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   131
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   132
lemma lt_ack2: "i \<in> nat ==> j \<in> nat ==> j < ack(i,j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   133
  -- {* PROPERTY A 4 *}
20503
503ac4c5ef91 induct method: renamed 'fixing' to 'arbitrary';
wenzelm
parents: 19676
diff changeset
   134
  apply (induct i arbitrary: j set: nat)
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   135
   apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   136
  apply (induct_tac j)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   137
   apply (erule_tac [2] succ_leI [THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   138
   apply (rule nat_0I [THEN nat_0_le, THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   139
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   140
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   141
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   142
lemma ack_lt_ack_succ2: "[|i\<in>nat; j\<in>nat|] ==> ack(i,j) < ack(i, succ(j))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   143
  -- {* PROPERTY A 5-, the single-step lemma *}
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   144
  by (induct set: nat) (simp_all add: lt_ack2)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   145
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   146
lemma ack_lt_mono2: "[| j<k; i \<in> nat; k \<in> nat |] ==> ack(i,j) < ack(i,k)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   147
  -- {* PROPERTY A 5, monotonicity for @{text "<"} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   148
  apply (frule lt_nat_in_nat, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   149
  apply (erule succ_lt_induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   150
    apply assumption
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   151
   apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   152
    apply (auto intro: ack_lt_ack_succ2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   153
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   154
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   155
lemma ack_le_mono2: "[|j\<le>k;  i\<in>nat;  k\<in>nat|] ==> ack(i,j) \<le> ack(i,k)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   156
  -- {* PROPERTY A 5', monotonicity for @{text \<le>} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   157
  apply (rule_tac f = "\<lambda>j. ack (i,j) " in Ord_lt_mono_imp_le_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   158
     apply (assumption | rule ack_lt_mono2 ack_type [THEN nat_into_Ord])+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   159
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   160
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   161
lemma ack2_le_ack1:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   162
  "[| i\<in>nat;  j\<in>nat |] ==> ack(i, succ(j)) \<le> ack(succ(i), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   163
  -- {* PROPERTY A 6 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   164
  apply (induct_tac j)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   165
   apply simp_all
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   166
  apply (rule ack_le_mono2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   167
    apply (rule lt_ack2 [THEN succ_leI, THEN le_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   168
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   169
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   170
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   171
lemma ack_lt_ack_succ1: "[| i \<in> nat; j \<in> nat |] ==> ack(i,j) < ack(succ(i),j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   172
  -- {* PROPERTY A 7-, the single-step lemma *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   173
  apply (rule ack_lt_mono2 [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   174
     apply (rule_tac [4] ack2_le_ack1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   175
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   176
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   177
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   178
lemma ack_lt_mono1: "[| i<j; j \<in> nat; k \<in> nat |] ==> ack(i,k) < ack(j,k)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   179
  -- {* PROPERTY A 7, monotonicity for @{text "<"} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   180
  apply (frule lt_nat_in_nat, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   181
  apply (erule succ_lt_induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   182
    apply assumption
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   183
   apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   184
    apply (auto intro: ack_lt_ack_succ1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   185
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   186
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   187
lemma ack_le_mono1: "[| i\<le>j; j \<in> nat; k \<in> nat |] ==> ack(i,k) \<le> ack(j,k)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   188
  -- {* PROPERTY A 7', monotonicity for @{text \<le>} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   189
  apply (rule_tac f = "\<lambda>j. ack (j,k) " in Ord_lt_mono_imp_le_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   190
     apply (assumption | rule ack_lt_mono1 ack_type [THEN nat_into_Ord])+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   191
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   192
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   193
lemma ack_1: "j \<in> nat ==> ack(1,j) = succ(succ(j))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   194
  -- {* PROPERTY A 8 *}
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   195
  by (induct set: nat) simp_all
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   196
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   197
lemma ack_2: "j \<in> nat ==> ack(succ(1),j) = succ(succ(succ(j#+j)))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   198
  -- {* PROPERTY A 9 *}
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   199
  by (induct set: nat) (simp_all add: ack_1)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   200
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   201
lemma ack_nest_bound:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   202
  "[| i1 \<in> nat; i2 \<in> nat; j \<in> nat |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   203
    ==> ack(i1, ack(i2,j)) < ack(succ(succ(i1#+i2)), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   204
  -- {* PROPERTY A 10 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   205
  apply (rule lt_trans2 [OF _ ack2_le_ack1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   206
    apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   207
    apply (rule add_le_self [THEN ack_le_mono1, THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   208
       apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   209
  apply (force intro: add_le_self2 [THEN ack_lt_mono1, THEN ack_lt_mono2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   210
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   211
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   212
lemma ack_add_bound:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   213
  "[| i1 \<in> nat; i2 \<in> nat; j \<in> nat |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   214
    ==> ack(i1,j) #+ ack(i2,j) < ack(succ(succ(succ(succ(i1#+i2)))), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   215
  -- {* PROPERTY A 11 *}
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12610
diff changeset
   216
  apply (rule_tac j = "ack (succ (1), ack (i1 #+ i2, j))" in lt_trans)
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   217
   apply (simp add: ack_2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   218
   apply (rule_tac [2] ack_nest_bound [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   219
      apply (rule add_le_mono [THEN leI, THEN leI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   220
         apply (auto intro: add_le_self add_le_self2 ack_le_mono1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   221
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   222
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   223
lemma ack_add_bound2:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   224
     "[| i < ack(k,j);  j \<in> nat;  k \<in> nat |]
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   225
      ==> i#+j < ack(succ(succ(succ(succ(k)))), j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   226
  -- {* PROPERTY A 12. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   227
  -- {* Article uses existential quantifier but the ALF proof used @{term "k#+#4"}. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   228
  -- {* Quantified version must be nested @{text "\<exists>k'. \<forall>i,j \<dots>"}. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   229
  apply (rule_tac j = "ack (k,j) #+ ack (0,j) " in lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   230
   apply (rule_tac [2] ack_add_bound [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   231
      apply (rule add_lt_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   232
         apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   233
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   234
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   235
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   236
subsection {* Main result *}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   237
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   238
declare list_add_type [simp]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   239
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   240
lemma SC_case: "l \<in> list(nat) ==> SC ` l < ack(1, list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   241
  apply (unfold SC_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   242
  apply (erule list.cases)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   243
   apply (simp add: succ_iff)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   244
  apply (simp add: ack_1 add_le_self)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   245
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   246
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   247
lemma lt_ack1: "[| i \<in> nat; j \<in> nat |] ==> i < ack(i,j)"
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   248
  -- {* PROPERTY A 4'? Extra lemma needed for @{text CONSTANT} case, constant functions. *}
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   249
  apply (induct_tac i)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   250
   apply (simp add: nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   251
  apply (erule lt_trans1 [OF succ_leI ack_lt_ack_succ1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   252
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   253
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   254
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   255
lemma CONSTANT_case:
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   256
    "[| l \<in> list(nat);  k \<in> nat |] ==> CONSTANT(k) ` l < ack(k, list_add(l))"
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   257
  by (simp add: CONSTANT_def lt_ack1)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   258
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   259
lemma PROJ_case [rule_format]:
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   260
    "l \<in> list(nat) ==> \<forall>i \<in> nat. PROJ(i) ` l < ack(0, list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   261
  apply (unfold PROJ_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   262
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   263
  apply (erule list.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   264
   apply (simp add: nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   265
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   266
  apply (rule ballI)
13339
0f89104dd377 Fixed quantified variable name preservation for ball and bex (bounded quants)
paulson
parents: 12610
diff changeset
   267
  apply (erule_tac n = i in natE)
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   268
   apply (simp add: add_le_self)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   269
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   270
  apply (erule bspec [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   271
   apply (rule_tac [2] add_le_self2 [THEN succ_leI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   272
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   273
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   274
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   275
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   276
  \medskip @{text COMP} case.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   277
*}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   278
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   279
lemma COMP_map_lemma:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   280
  "fs \<in> list({f \<in> prim_rec. \<exists>kf \<in> nat. \<forall>l \<in> list(nat). f`l < ack(kf, list_add(l))})
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   281
    ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat).
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   282
      list_add(map(\<lambda>f. f ` l, fs)) < ack(k, list_add(l))"
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   283
  apply (induct set: list)
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   284
   apply (rule_tac x = 0 in bexI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   285
    apply (simp_all add: lt_ack1 nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   286
  apply clarify
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   287
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   288
  apply (rule add_lt_mono [THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   289
       apply (rule_tac [5] ack_add_bound)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   290
         apply blast
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   291
        apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   292
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   293
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   294
lemma COMP_case:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   295
 "[| kg\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   296
     \<forall>l \<in> list(nat). g`l < ack(kg, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   297
     fs \<in> list({f \<in> prim_rec .
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   298
                 \<exists>kf \<in> nat. \<forall>l \<in> list(nat).
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   299
                        f`l < ack(kf, list_add(l))}) |]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   300
   ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat). COMP(g,fs)`l < ack(k, list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   301
  apply (simp add: COMP_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   302
  apply (frule list_CollectD)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   303
  apply (erule COMP_map_lemma [THEN bexE])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   304
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   305
   apply (erule bspec [THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   306
    apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   307
     apply (rule_tac [3] ack_nest_bound)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   308
       apply (erule_tac [2] bspec [THEN ack_lt_mono2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   309
         apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   310
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   311
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   312
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   313
  \medskip @{text PREC} case.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   314
*}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   315
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   316
lemma PREC_case_lemma:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   317
 "[| \<forall>l \<in> list(nat). f`l #+ list_add(l) < ack(kf, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   318
     \<forall>l \<in> list(nat). g`l #+ list_add(l) < ack(kg, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   319
     f \<in> prim_rec;  kf\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   320
     g \<in> prim_rec;  kg\<in>nat;
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   321
     l \<in> list(nat) |]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   322
  ==> PREC(f,g)`l #+ list_add(l) < ack(succ(kf#+kg), list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   323
  apply (unfold PREC_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   324
  apply (erule list.cases)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   325
   apply (simp add: lt_trans [OF nat_le_refl lt_ack2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   326
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   327
  apply (erule ssubst)  -- {* get rid of the needless assumption *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   328
  apply (induct_tac a)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   329
   apply simp_all
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   330
   txt {* base case *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   331
   apply (rule lt_trans, erule bspec, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   332
   apply (simp add: add_le_self [THEN ack_lt_mono1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   333
  txt {* ind step *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   334
  apply (rule succ_leI [THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   335
   apply (rule_tac j = "g ` ?ll #+ ?mm" in lt_trans1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   336
    apply (erule_tac [2] bspec)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   337
    apply (rule nat_le_refl [THEN add_le_mono])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   338
       apply typecheck
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   339
   apply (simp add: add_le_self2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   340
   txt {* final part of the simplification *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   341
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   342
  apply (rule add_le_self2 [THEN ack_le_mono1, THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   343
     apply (erule_tac [4] ack_lt_mono2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   344
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   345
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   346
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   347
lemma PREC_case:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   348
   "[| f \<in> prim_rec;  kf\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   349
       g \<in> prim_rec;  kg\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   350
       \<forall>l \<in> list(nat). f`l < ack(kf, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   351
       \<forall>l \<in> list(nat). g`l < ack(kg, list_add(l)) |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   352
    ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat). PREC(f,g)`l< ack(k, list_add(l))"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   353
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   354
   apply (rule lt_trans1 [OF add_le_self PREC_case_lemma])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   355
          apply typecheck
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   356
     apply (blast intro: ack_add_bound2 list_add_type)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   357
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   358
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   359
lemma ack_bounds_prim_rec:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   360
    "f \<in> prim_rec ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat). f`l < ack(k, list_add(l))"
18415
eb68dc98bda2 improved proofs;
wenzelm
parents: 16417
diff changeset
   361
  apply (induct set: prim_rec)
19676
187234ec6050 renamed CONST to CONSTANT;
wenzelm
parents: 18415
diff changeset
   362
  apply (auto intro: SC_case CONSTANT_case PROJ_case COMP_case PREC_case)
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   363
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   364
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   365
theorem ack_not_prim_rec:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   366
    "(\<lambda>l \<in> list(nat). list_case(0, \<lambda>x xs. ack(x,x), l)) \<notin> prim_rec"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   367
  apply (rule notI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   368
  apply (drule ack_bounds_prim_rec)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   369
  apply force
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   370
  done
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
   371
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
   372
end