src/ZF/ex/Primrec.thy
author clasohm
Sat Dec 09 13:36:11 1995 +0100 (1995-12-09 ago)
changeset 1401 0c439768f45c
parent 1155 928a16e02f9f
child 1478 2b8c2a7547ab
permissions -rw-r--r--
removed quotes from consts and syntax sections
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
clasohm@1401
    19
    primrec :: i
clasohm@1401
    20
    SC      :: i
clasohm@1401
    21
    CONST   :: i=>i
clasohm@1401
    22
    PROJ    :: i=>i
clasohm@1401
    23
    COMP    :: [i,i]=>i
clasohm@1401
    24
    PREC    :: [i,i]=>i
clasohm@1401
    25
    ACK	    :: i=>i
clasohm@1401
    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@753
    31
defs
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!*)
clasohm@1155
    42
  PREC_def  "PREC(f,g) == 
clasohm@1155
    43
            lam l:list(nat). list_case(0, 
clasohm@1155
    44
                      %x xs. rec(x, f`xs, %y r. g ` Cons(r, Cons(y, xs))), l)"
lcp@515
    45
  
clasohm@1155
    46
  ACK_def   "ACK(i) == rec(i, SC, 
clasohm@1155
    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]"
clasohm@1155
    60
  type_intrs "nat_typechecks @ list.intrs @   		        
clasohm@1155
    61
	      [lam_type, list_case_type, drop_type, map_type,   
clasohm@1155
    62
	      apply_type, rec_type]"
lcp@515
    63
lcp@515
    64
end