src/ZF/Induct/Primrec.thy
author paulson
Tue, 21 May 2002 13:06:36 +0200
changeset 13168 afcbca3498b0
parent 12610 8b9845807f77
child 13339 0f89104dd377
permissions -rw-r--r--
converted domrange to Isar and merged with equalities
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
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
     9
theory Primrec = Main:
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
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    24
  CONST :: "i=>i"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    25
  "CONST(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"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    43
  "ACK(succ(i)) = PREC (CONST (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
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    58
lemma CONST: "l \<in> list(nat) ==> CONST(k) ` l = k"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    59
  by (simp add: CONST_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"
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
    86
    "k \<in> nat ==> CONST(k) \<in> prim_rec"
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
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
    91
  con_defs SC_def CONST_def PROJ_def COMP_def PREC_def
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"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   107
  by (induct_tac i) 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 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   121
  by (simp add: CONST 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 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   126
  by (simp add: CONST 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
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   132
lemma lt_ack2 [rule_format]: "i \<in> nat ==> \<forall>j \<in> nat. j < ack(i,j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   133
  -- {* PROPERTY A 4 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   134
  apply (induct_tac i)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   135
   apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   136
  apply (rule ballI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   137
  apply (induct_tac j)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   138
   apply (erule_tac [2] succ_leI [THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   139
   apply (rule nat_0I [THEN nat_0_le, THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   140
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   141
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   142
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   143
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
   144
  -- {* PROPERTY A 5-, the single-step lemma *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   145
  by (induct_tac i) (simp_all add: lt_ack2)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   146
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   147
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
   148
  -- {* PROPERTY A 5, monotonicity for @{text "<"} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   149
  apply (frule lt_nat_in_nat, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   150
  apply (erule succ_lt_induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   151
    apply assumption
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   152
   apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   153
    apply (auto intro: ack_lt_ack_succ2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   154
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   155
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   156
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
   157
  -- {* PROPERTY A 5', monotonicity for @{text \<le>} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   158
  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
   159
     apply (assumption | rule ack_lt_mono2 ack_type [THEN nat_into_Ord])+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   160
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   161
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   162
lemma ack2_le_ack1:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   163
  "[| i\<in>nat;  j\<in>nat |] ==> ack(i, succ(j)) \<le> ack(succ(i), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   164
  -- {* PROPERTY A 6 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   165
  apply (induct_tac j)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   166
   apply simp_all
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   167
  apply (rule ack_le_mono2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   168
    apply (rule lt_ack2 [THEN succ_leI, THEN le_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   169
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   170
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   171
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   172
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
   173
  -- {* PROPERTY A 7-, the single-step lemma *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   174
  apply (rule ack_lt_mono2 [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   175
     apply (rule_tac [4] ack2_le_ack1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   176
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   177
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   178
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   179
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
   180
  -- {* PROPERTY A 7, monotonicity for @{text "<"} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   181
  apply (frule lt_nat_in_nat, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   182
  apply (erule succ_lt_induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   183
    apply assumption
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   184
   apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   185
    apply (auto intro: ack_lt_ack_succ1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   186
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   187
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   188
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
   189
  -- {* PROPERTY A 7', monotonicity for @{text \<le>} *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   190
  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
   191
     apply (assumption | rule ack_lt_mono1 ack_type [THEN nat_into_Ord])+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   192
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   193
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   194
lemma ack_1: "j \<in> nat ==> ack(1,j) = succ(succ(j))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   195
  -- {* PROPERTY A 8 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   196
  by (induct_tac j) simp_all
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   197
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   198
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
   199
  -- {* PROPERTY A 9 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   200
  by (induct_tac j) (simp_all add: ack_1)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   201
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   202
lemma ack_nest_bound:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   203
  "[| i1 \<in> nat; i2 \<in> nat; j \<in> nat |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   204
    ==> ack(i1, ack(i2,j)) < ack(succ(succ(i1#+i2)), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   205
  -- {* PROPERTY A 10 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   206
  apply (rule lt_trans2 [OF _ ack2_le_ack1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   207
    apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   208
    apply (rule add_le_self [THEN ack_le_mono1, THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   209
       apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   210
  apply (force intro: add_le_self2 [THEN ack_lt_mono1, THEN ack_lt_mono2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   211
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   212
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   213
lemma ack_add_bound:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   214
  "[| i1 \<in> nat; i2 \<in> nat; j \<in> nat |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   215
    ==> ack(i1,j) #+ ack(i2,j) < ack(succ(succ(succ(succ(i1#+i2)))), j)"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   216
  -- {* PROPERTY A 11 *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   217
  apply (rule_tac j = "ack (succ (1) , ack (i1 #+ i2, j))" in lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   218
   apply (simp add: ack_2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   219
   apply (rule_tac [2] ack_nest_bound [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   220
      apply (rule add_le_mono [THEN leI, THEN leI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   221
         apply (auto intro: add_le_self add_le_self2 ack_le_mono1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   222
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   223
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   224
lemma ack_add_bound2:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   225
     "[| i < ack(k,j);  j \<in> nat;  k \<in> nat |]
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   226
      ==> i#+j < ack(succ(succ(succ(succ(k)))), j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   227
  -- {* PROPERTY A 12. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   228
  -- {* Article uses existential quantifier but the ALF proof used @{term "k#+#4"}. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   229
  -- {* Quantified version must be nested @{text "\<exists>k'. \<forall>i,j \<dots>"}. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   230
  apply (rule_tac j = "ack (k,j) #+ ack (0,j) " in lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   231
   apply (rule_tac [2] ack_add_bound [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   232
      apply (rule add_lt_mono)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   233
         apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   234
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   235
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   236
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   237
subsection {* Main result *}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   238
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   239
declare list_add_type [simp]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   240
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   241
lemma SC_case: "l \<in> list(nat) ==> SC ` l < ack(1, list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   242
  apply (unfold SC_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   243
  apply (erule list.cases)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   244
   apply (simp add: succ_iff)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   245
  apply (simp add: ack_1 add_le_self)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   246
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   247
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   248
lemma lt_ack1: "[| i \<in> nat; j \<in> nat |] ==> i < ack(i,j)"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   249
  -- {* PROPERTY A 4'? Extra lemma needed for @{text CONST} case, constant functions. *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   250
  apply (induct_tac i)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   251
   apply (simp add: nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   252
  apply (erule lt_trans1 [OF succ_leI ack_lt_ack_succ1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   253
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   254
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   255
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   256
lemma CONST_case:
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   257
    "[| l \<in> list(nat);  k \<in> nat |] ==> CONST(k) ` l < ack(k, list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   258
  by (simp add: CONST_def lt_ack1)
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   259
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   260
lemma PROJ_case [rule_format]:
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   261
    "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
   262
  apply (unfold PROJ_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   263
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   264
  apply (erule list.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   265
   apply (simp add: nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   266
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   267
  apply (rule ballI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   268
  apply (erule_tac n = "x" in natE)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   269
   apply (simp add: add_le_self)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   270
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   271
  apply (erule bspec [THEN lt_trans2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   272
   apply (rule_tac [2] add_le_self2 [THEN succ_leI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   273
   apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   274
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   275
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   276
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   277
  \medskip @{text COMP} case.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   278
*}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   279
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   280
lemma COMP_map_lemma:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   281
  "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
   282
    ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat).
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   283
      list_add(map(\<lambda>f. f ` l, fs)) < ack(k, list_add(l))"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   284
  apply (erule list.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   285
   apply (rule_tac x = 0 in bexI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   286
    apply (simp_all add: lt_ack1 nat_0_le)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   287
  apply clarify
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   288
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   289
  apply (rule add_lt_mono [THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   290
       apply (rule_tac [5] ack_add_bound)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   291
         apply blast
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   292
        apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   293
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   294
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   295
lemma COMP_case:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   296
 "[| kg\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   297
     \<forall>l \<in> list(nat). g`l < ack(kg, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   298
     fs \<in> list({f \<in> prim_rec .
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   299
                 \<exists>kf \<in> nat. \<forall>l \<in> list(nat).
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   300
                        f`l < ack(kf, list_add(l))}) |]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   301
   ==> \<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
   302
  apply (simp add: COMP_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   303
  apply (frule list_CollectD)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   304
  apply (erule COMP_map_lemma [THEN bexE])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   305
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   306
   apply (erule bspec [THEN lt_trans])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   307
    apply (rule_tac [2] lt_trans)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   308
     apply (rule_tac [3] ack_nest_bound)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   309
       apply (erule_tac [2] bspec [THEN ack_lt_mono2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   310
         apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   311
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   312
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   313
text {*
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   314
  \medskip @{text PREC} case.
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   315
*}
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   316
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   317
lemma PREC_case_lemma:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   318
 "[| \<forall>l \<in> list(nat). f`l #+ list_add(l) < ack(kf, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   319
     \<forall>l \<in> list(nat). g`l #+ list_add(l) < ack(kg, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   320
     f \<in> prim_rec;  kf\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   321
     g \<in> prim_rec;  kg\<in>nat;
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   322
     l \<in> list(nat) |]
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   323
  ==> PREC(f,g)`l #+ list_add(l) < ack(succ(kf#+kg), list_add(l))"
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   324
  apply (unfold PREC_def)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   325
  apply (erule list.cases)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   326
   apply (simp add: lt_trans [OF nat_le_refl lt_ack2])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   327
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   328
  apply (erule ssubst)  -- {* get rid of the needless assumption *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   329
  apply (induct_tac a)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   330
   apply simp_all
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   331
   txt {* base case *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   332
   apply (rule lt_trans, erule bspec, assumption)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   333
   apply (simp add: add_le_self [THEN ack_lt_mono1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   334
  txt {* ind step *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   335
  apply (rule succ_leI [THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   336
   apply (rule_tac j = "g ` ?ll #+ ?mm" in lt_trans1)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   337
    apply (erule_tac [2] bspec)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   338
    apply (rule nat_le_refl [THEN add_le_mono])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   339
       apply typecheck
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   340
   apply (simp add: add_le_self2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   341
   txt {* final part of the simplification *}
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   342
  apply simp
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   343
  apply (rule add_le_self2 [THEN ack_le_mono1, THEN lt_trans1])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   344
     apply (erule_tac [4] ack_lt_mono2)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   345
      apply auto
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   346
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   347
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   348
lemma PREC_case:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   349
   "[| f \<in> prim_rec;  kf\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   350
       g \<in> prim_rec;  kg\<in>nat;
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   351
       \<forall>l \<in> list(nat). f`l < ack(kf, list_add(l));
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   352
       \<forall>l \<in> list(nat). g`l < ack(kg, list_add(l)) |]
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   353
    ==> \<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
   354
  apply (rule ballI [THEN bexI])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   355
   apply (rule lt_trans1 [OF add_le_self PREC_case_lemma])
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   356
          apply typecheck
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   357
     apply (blast intro: ack_add_bound2 list_add_type)+
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   358
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   359
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   360
lemma ack_bounds_prim_rec:
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   361
    "f \<in> prim_rec ==> \<exists>k \<in> nat. \<forall>l \<in> list(nat). f`l < ack(k, list_add(l))"
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   362
  apply (erule prim_rec.induct)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   363
  apply (auto intro: SC_case CONST_case PROJ_case COMP_case PREC_case)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   364
  done
12560
5820841f21fd converted some ZF/Induct examples to Isar
paulson
parents: 12088
diff changeset
   365
12610
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   366
theorem ack_not_prim_rec:
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   367
    "(\<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
   368
  apply (rule notI)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   369
  apply (drule ack_bounds_prim_rec)
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   370
  apply force
8b9845807f77 tuned document sources;
wenzelm
parents: 12560
diff changeset
   371
  done
12088
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
   372
6f463d16cbd0 reorganization of the ZF examples
paulson
parents:
diff changeset
   373
end