\documentstyle[makeidx]{article}
\makeindex
%\setlength{\oddsidemargin}{.5in}
%\setlength{\evensidemargin}{.5in}
%\setlength{\textwidth}{5.8in}
\begin{document}
%\setlength{\parindent}{0pt}
%\newcounter{bean}
%\begin{list}{\arabic{bean}.}{\usecounter{bean}\setlength{\leftmargin}{0pt}\setlength{\rightmargin}{0pt}\setlength{\listparindent}{20pt}\setlength{\parsep}{5pt}}
%\item[]

\begin{verbatim}#|
 Copyright (C) 1994 by Ken Kunen.  All Rights Reserved.

 This script is hereby placed in the public domain, and therefore unlimited
 editing and redistribution is permitted.

 NO WARRANTY

 Ken Kunen PROVIDES ABSOLUTELY NO WARRANTY.  THE EVENT SCRIPT IS PROVIDED "AS
 IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT
 NOT LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
 PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
 SCRIPT IS WITH YOU.  SHOULD THE SCRIPT PROVE DEFECTIVE, YOU ASSUME THE COST OF
 ALL NECESSARY SERVICING, REPAIR OR CORRECTION.

 IN NO EVENT WILL Ken Kunen BE LIABLE TO YOU FOR ANY DAMAGES, ANY LOST
 PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
 ARISING OUT OF THE USE OR INABILITY TO USE THIS SCRIPT (INCLUDING BUT NOT
 LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED
 BY THIRD PARTIES), EVEN IF YOU HAVE ADVISED US OF THE POSSIBILITY OF SUCH
 DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
|#

\end{verbatim}
\noindent{\sc Event}:   Start with the initial {\bf nqthm} theory.

\addvspace{18pt} \begin{verbatim}; load basic definitions and lemmas

;  From kunen@cs.wisc.edu Mon Oct 21 08:56:34 1991
;  Date: Fri, 18 Oct 91 13:20:25 -0500
;  From: kunen@cs.wisc.edu (Ken Kunen)
;  To: boyer@CLI.COM, kaufmann@CLI.COM
;  Subject: nqthm
;  Cc: kunen@cs.wisc.edu
;  
;  The following is one of the examples I'm using in my course here
;  to illustrate nqthm.  In particular, note that the representation
;  of a pair of numbers by an ordinal, as described on p. 42, is more
;  complicated than it has to be.
;                                                        Ken
;
;  -------------------------------------------------------------------------


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;                CS761  --  SEMESTER I, 1991-92                       ;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; nqthm contains induction on epsilon_0, so it's stronger than pure primitive
; recursive arithmetic.  Presumably, it can prove Con(PA).
;         LONG project -- do this

; This file -- a simple example -- use recursion on pairs to define the
; Ackermann function, which grows faster than any primitive recursive function
; see Aho-Hopcroft-Ullman, "Data Structures and Algorithms", p. 189



; Representation of a pair of numbers, (i,j), as the ordinal omega^(i+1) + j;
; This is a little simpler than the one described on Boyer-Moore p. 42.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{rep}$\;\;$
{\rm{rep}}\,({\it{i\/}}, {\it{j\/}})\index{rep} $=$ {\rm{cons}}\,($1\;+$ {\it{i\/}}, {\it{j\/}})
\end{tabbing}
\begin{tabbing}{\sc Definition}:\index{lex2} \\  
{\rm{lex2}}\,({\it{i1\/}}, {\it{j1\/}}, {\it{i2\/}}, {\it{j2\/}})\index{lex2} $=$ (({\it{i1\/}} $<$ {\it{i2\/}}) $\vee$ (({\it{i1\/}} $=$ {\it{i2\/}}) $\wedge$ ({\it{j1\/}} $<$ {\it{j2\/}})))
\end{tabbing}
\begin{tabbing}{\sc Theorem}:  rep-respects-lex \\ \index{rep-respects-lex}
\=\+(({\it{i1\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{i2\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{j1\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{j2\/}} $\in\;${\bf{N}}${}$)) \\ 
$\rightarrow$$\;\;\;\;$({\rm{lex2}}\,({\it{i1\/}}, {\it{j1\/}}, {\it{i2\/}}, {\it{j2\/}})\index{lex2} $=$ {\rm{ord-lessp}}\,({\rm{rep}}\,({\it{i1\/}}, {\it{j1\/}})\index{rep}, {\rm{rep}}\,({\it{i2\/}}, {\it{j2\/}})\index{rep}))\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{ack} \\  
\=\+{\rm{ack}}\,({\it{x\/}}, {\it{y\/}})\index{ack} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{1}} \\ 
{\bf elseif }{\it{y\/}} $\simeq {\tt{0}}$ \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\tt{1}}$\;\;${\bf then }{\tt{2}} \\ 
{\bf else }{\it{x\/}} $+$ {\tt{2}}$\;${\bf  endif}\- \\ 
{\bf else }{\rm{ack}}\,({\rm{ack}}\,({\it{x\/}} $-\;1$, {\it{y\/}})\index{ack}, {\it{y\/}} $-\;1$)\index{ack}$\;${\bf  endif}\-\-
\end{tabbing}  \begin{verbatim}; hint
; "fix"  = "cast to numberp" 

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ack-is-positive \\ \index{ack-is-positive}
({\rm{ack}}\,({\it{x\/}}, {\it{y\/}})\index{ack} $\simeq {\tt{0}}$) $=$ {\bf{f}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ack-of-1 \\ \index{ack-of-1}
({\it{x\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ({\rm{ack}}\,({\it{x\/}}, {\tt{1}})\index{ack} $=$ ({\it{x\/}} $*$ {\tt{2}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{expt2} \\  
\=\+{\rm{expt2}}\,({\it{x\/}})\index{expt2} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{1}} \\ 
{\bf else }{\rm{expt2}}\,({\it{x\/}} $-\;1$)\index{expt2} $*$ {\tt{2}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ack-of-2-aux1 \\ \index{ack-of-2-aux1}
({\it{x\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ({\rm{ack}}\,({\it{x\/}}, {\tt{2}})\index{ack} $=$ {\rm{ack}}\,({\rm{ack}}\,({\it{x\/}} $-\;1$, {\tt{2}})\index{ack}, {\tt{1}})\index{ack})
\end{tabbing}  \begin{verbatim};
                                                  ;    ---------------------
\end{verbatim}\begin{tabbing}{\sc Theorem}:  ack-of-2-aux2 \\ \index{ack-of-2-aux2}
({\it{x\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ({\rm{ack}}\,({\it{x\/}}, {\tt{2}})\index{ack} $=$ ({\rm{ack}}\,({\it{x\/}} $-\;1$, {\tt{2}})\index{ack} $*$ {\tt{2}}))
\end{tabbing}                                                \begin{verbatim};
                                                  ;;;;;;;;;;;;;;;;;;;;;;;;;;
\end{verbatim}\begin{tabbing}{\sc Theorem}:  ack-of-2 \\ \index{ack-of-2}
{\rm{ack}}\,({\it{x\/}}, {\tt{2}})\index{ack} $=$ {\rm{expt2}}\,({\it{x\/}})\index{expt2}
\end{tabbing}

\begin{verbatim}; ack(x,3) = 2^2^2^ ...^2  (stack of x 2's, ^ assoc to right)



\end{verbatim}
%\end{list}
\printindex
\end{document}
