src/ZF/ex/Primrec.thy
author lcp
Tue Aug 16 18:58:42 1994 +0200 (1994-08-16)
changeset 532 851df239ac8b
parent 515 abcc438e7c27
child 753 ec86863e87c8
permissions -rw-r--r--
ZF/Makefile,ROOT.ML, ZF/ex/Integ.thy: updated for EquivClass
lcp@515
     1
(*  Title: 	ZF/ex/Primrec.thy
lcp@515
     2
    ID:         $Id$
lcp@515
     3
    Author: 	Lawrence C Paulson, Cambridge University Computer Laboratory
lcp@515
     4
    Copyright   1994  University of Cambridge
lcp@515
     5
lcp@515
     6
Primitive Recursive Functions
lcp@515
     7
lcp@515
     8
Proof adopted from
lcp@515
     9
Nora Szasz, 
lcp@515
    10
A Machine Checked Proof that Ackermann's Function is not Primitive Recursive,
lcp@515
    11
In: Huet & Plotkin, eds., Logical Environments (CUP, 1993), 317-338.
lcp@515
    12
lcp@515
    13
See also E. Mendelson, Introduction to Mathematical Logic.
lcp@515
    14
(Van Nostrand, 1964), page 250, exercise 11.
lcp@515
    15
*)
lcp@515
    16
lcp@515
    17
Primrec = List +
lcp@515
    18
consts
lcp@515
    19
    primrec :: "i"
lcp@515
    20
    SC      :: "i"
lcp@515
    21
    CONST   :: "i=>i"
lcp@515
    22
    PROJ    :: "i=>i"
lcp@515
    23
    COMP    :: "[i,i]=>i"
lcp@515
    24
    PREC    :: "[i,i]=>i"
lcp@515
    25
    ACK	    :: "i=>i"
lcp@515
    26
    ack	    :: "[i,i]=>i"
lcp@515
    27
lcp@515
    28
translations
lcp@515
    29
  "ack(x,y)"  == "ACK(x) ` [y]"
lcp@515
    30
lcp@515
    31
rules
lcp@515
    32
lcp@515
    33
  SC_def    "SC == lam l:list(nat).list_case(0, %x xs.succ(x), l)"
lcp@515
    34
lcp@515
    35
  CONST_def "CONST(k) == lam l:list(nat).k"
lcp@515
    36
lcp@515
    37
  PROJ_def  "PROJ(i) == lam l:list(nat). list_case(0, %x xs.x, drop(i,l))"
lcp@515
    38
lcp@515
    39
  COMP_def  "COMP(g,fs) == lam l:list(nat). g ` map(%f. f`l, fs)"
lcp@515
    40
lcp@515
    41
  (*Note that g is applied first to PREC(f,g)`y and then to y!*)
lcp@515
    42
  PREC_def  "PREC(f,g) == \
lcp@515
    43
\            lam l:list(nat). list_case(0, \
lcp@515
    44
\                      %x xs. rec(x, f`xs, %y r. g ` Cons(r, Cons(y, xs))), l)"
lcp@515
    45
  
lcp@515
    46
  ACK_def   "ACK(i) == rec(i, SC, \
lcp@515
    47
\                      %z r. PREC (CONST (r`[1]), COMP(r,[PROJ(0)])))"
lcp@515
    48
lcp@515
    49
lcp@515
    50
inductive
lcp@515
    51
  domains "primrec" <= "list(nat)->nat"
lcp@515
    52
  intrs
lcp@515
    53
    SC       "SC : primrec"
lcp@515
    54
    CONST    "k: nat ==> CONST(k) : primrec"
lcp@515
    55
    PROJ     "i: nat ==> PROJ(i) : primrec"
lcp@515
    56
    COMP     "[| g: primrec; fs: list(primrec) |] ==> COMP(g,fs): primrec"
lcp@515
    57
    PREC     "[| f: primrec; g: primrec |] ==> PREC(f,g): primrec"
lcp@515
    58
  monos      "[list_mono]"
lcp@515
    59
  con_defs   "[SC_def,CONST_def,PROJ_def,COMP_def,PREC_def]"
lcp@515
    60
  type_intrs "nat_typechecks @ list.intrs @   		        \
lcp@515
    61
\	      [lam_type, list_case_type, drop_type, map_type,   \
lcp@515
    62
\	      apply_type, rec_type]"
lcp@515
    63
lcp@515
    64
end