\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 Computational Logic, Inc.  All Rights Reserved.

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

 NO WARRANTY

 Computational Logic, Inc. 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 Computational Logic, Inc. 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.

|#

; ------------------------------------------------------------
; was bags.events
; ------------------------------------------------------------
\end{verbatim}
\noindent{\sc Event}:   Start with the initial {\bf nqthm} theory.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{delete} \\  
\=\+{\rm{delete}}\,({\it{x\/}}, {\it{l\/}})\index{delete} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{car}}\,({\it{l\/}})$\;\;${\bf then }{\rm{cdr}}\,({\it{l\/}}) \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{l\/}}), {\rm{delete}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{l\/}}))\index{delete})$\;${\bf  endif}\- \\ 
{\bf else }{\it{l\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bagdiff} \\  
\=\+{\rm{bagdiff}}\,({\it{x\/}}, {\it{y\/}})\index{bagdiff} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{y\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{y\/}}) $\in$ {\it{x\/}}$\;\;${\bf then }{\rm{bagdiff}}\,({\rm{delete}}\,({\rm{car}}\,({\it{y\/}}), {\it{x\/}})\index{delete}, {\rm{cdr}}\,({\it{y\/}}))\index{bagdiff} \\ 
{\bf else }{\rm{bagdiff}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{y\/}}))\index{bagdiff}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bagint} \\  
\=\+{\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $\in$ {\it{y\/}} \\ 
{\bf then }{\rm{cons}}\,({\rm{car}}\,({\it{x\/}}), {\rm{bagint}}\,({\rm{cdr}}\,({\it{x\/}}), {\rm{delete}}\,({\rm{car}}\,({\it{x\/}}), {\it{y\/}})\index{delete})\index{bagint}) \\ 
{\bf else }{\rm{bagint}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{y\/}})\index{bagint}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{occurrences} \\  
\=\+{\rm{occurrences}}\,({\it{x\/}}, {\it{l\/}})\index{occurrences} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{car}}\,({\it{l\/}})$\;\;${\bf then }$1\;+$ {\rm{occurrences}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{l\/}}))\index{occurrences} \\ 
{\bf else }{\rm{occurrences}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{l\/}}))\index{occurrences}$\;${\bf  endif}\- \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{subbagp} \\  
\=\+{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $\in$ {\it{y\/}}$\;\;${\bf then }{\rm{subbagp}}\,({\rm{cdr}}\,({\it{x\/}}), {\rm{delete}}\,({\rm{car}}\,({\it{x\/}}), {\it{y\/}})\index{delete})\index{subbagp} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-delete \\ \index{listp-delete}
\=\+{\rm{listp}}\,({\rm{delete}}\,({\it{x\/}}, {\it{l\/}})\index{delete}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }({\it{x\/}} $\not=$ {\rm{car}}\,({\it{l\/}})) $\vee$ {\rm{listp}}\,({\rm{cdr}}\,({\it{l\/}})) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable listp-delete.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  delete-non-member \\ \index{delete-non-member}
({\it{x\/}} $\not\in$ {\it{y\/}}) $\rightarrow$ ({\rm{delete}}\,({\it{x\/}}, {\it{y\/}})\index{delete} $=$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  delete-delete \\ \index{delete-delete}
{\rm{delete}}\,({\it{y\/}}, {\rm{delete}}\,({\it{x\/}}, {\it{z\/}})\index{delete})\index{delete} $=$ {\rm{delete}}\,({\it{x\/}}, {\rm{delete}}\,({\it{y\/}}, {\it{z\/}})\index{delete})\index{delete}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-occurrences-zero \\ \index{equal-occurrences-zero}
({\rm{occurrences}}\,({\it{x\/}}, {\it{l\/}})\index{occurrences} $=$ {\tt{0}}) $=$ ({\it{x\/}} $\not\in$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-non-list \\ \index{member-non-list}
($\neg$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\it{x\/}} $\not\in$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-delete \\ \index{member-delete}
\=\+({\it{x\/}} $\in$ {\rm{delete}}\,({\it{y\/}}, {\it{l\/}})\index{delete}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\in$ {\it{l\/}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\it{y\/}}$\;\;${\bf then }{\tt{1}} $<$ {\rm{occurrences}}\,({\it{x\/}}, {\it{l\/}})\index{occurrences} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  member-delete-implies-membership \\ \index{member-delete-implies-membership}
({\it{x\/}} $\in$ {\rm{delete}}\,({\it{y\/}}, {\it{l\/}})\index{delete}) $\rightarrow$ ({\it{x\/}} $\in$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  occurrences-delete \\ \index{occurrences-delete}
\=\+{\rm{occurrences}}\,({\it{x\/}}, {\rm{delete}}\,({\it{y\/}}, {\it{l\/}})\index{delete})\index{occurrences} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\it{y\/}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $\in$ {\it{l\/}}$\;\;${\bf then }{\rm{occurrences}}\,({\it{x\/}}, {\it{l\/}})\index{occurrences} $-\;1$ \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\- \\ 
{\bf else }{\rm{occurrences}}\,({\it{x\/}}, {\it{l\/}})\index{occurrences}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-bagdiff \\ \index{member-bagdiff}
({\it{x\/}} $\in$ {\rm{bagdiff}}\,({\it{a\/}}, {\it{b\/}})\index{bagdiff}) $=$ ({\rm{occurrences}}\,({\it{x\/}}, {\it{b\/}})\index{occurrences} $<$ {\rm{occurrences}}\,({\it{x\/}}, {\it{a\/}})\index{occurrences})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  bagdiff-delete \\ \index{bagdiff-delete}
{\rm{bagdiff}}\,({\rm{delete}}\,({\it{e\/}}, {\it{x\/}})\index{delete}, {\it{y\/}})\index{bagdiff} $=$ {\rm{delete}}\,({\it{e\/}}, {\rm{bagdiff}}\,({\it{x\/}}, {\it{y\/}})\index{bagdiff})\index{delete}
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  subbagp-delete \\ \index{subbagp-delete}
{\rm{subbagp}}\,({\it{x\/}}, {\rm{delete}}\,({\it{u\/}}, {\it{y\/}})\index{delete})\index{subbagp} $\rightarrow$ {\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subbagp-cdr1 \\ \index{subbagp-cdr1}
{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\rightarrow$ {\rm{subbagp}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{y\/}})\index{subbagp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subbagp-cdr2 \\ \index{subbagp-cdr2}
{\rm{subbagp}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{y\/}}))\index{subbagp} $\rightarrow$ {\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subbagp-bagint1 \\ \index{subbagp-bagint1}
{\rm{subbagp}}\,({\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{x\/}})\index{subbagp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subbagp-bagint2 \\ \index{subbagp-bagint2}
{\rm{subbagp}}\,({\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{y\/}})\index{subbagp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  occurrences-bagint \\ \index{occurrences-bagint}
\=\+{\rm{occurrences}}\,({\it{x\/}}, {\rm{bagint}}\,({\it{a\/}}, {\it{b\/}})\index{bagint})\index{occurrences} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{occurrences}}\,({\it{x\/}}, {\it{a\/}})\index{occurrences} $<$ {\rm{occurrences}}\,({\it{x\/}}, {\it{b\/}})\index{occurrences}$\;\;${\bf then }{\rm{occurrences}}\,({\it{x\/}}, {\it{a\/}})\index{occurrences} \\ 
{\bf else }{\rm{occurrences}}\,({\it{x\/}}, {\it{b\/}})\index{occurrences}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  occurrences-bagdiff \\ \index{occurrences-bagdiff}
{\rm{occurrences}}\,({\it{x\/}}, {\rm{bagdiff}}\,({\it{a\/}}, {\it{b\/}})\index{bagdiff})\index{occurrences} $=$ ({\rm{occurrences}}\,({\it{x\/}}, {\it{a\/}})\index{occurrences} $-$ {\rm{occurrences}}\,({\it{x\/}}, {\it{b\/}})\index{occurrences})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-bagint \\ \index{member-bagint}
({\it{x\/}} $\in$ {\rm{bagint}}\,({\it{a\/}}, {\it{b\/}})\index{bagint}) $=$ (({\it{x\/}} $\in$ {\it{a\/}}) $\wedge$ ({\it{x\/}} $\in$ {\it{b\/}}))
\end{tabbing}


\noindent{\sc Event}:   Let us define the theory {\it{bags}} to consist of the following events: occurrences-bagint,
bagdiff-delete,
occurrences-bagdiff,
member-bagint,
member-bagdiff,
subbagp-bagint2,
subbagp-bagint1,
subbagp-cdr2,
subbagp-cdr1,
subbagp-delete.\index{bags}

\addvspace{18pt}

\begin{verbatim}; ------------------------------------------------------------
; was naturals.events
; ------------------------------------------------------------


;; Tue Sep 26 10:20:45 1989, from ~wilding/numerical/newnat.events

;; NATURALS Theory

;; Created by Bill Bevier 1988 (see CLI internal note 057)

;; Modifications by Bill Bevier and Matt Wilding (9/89) including
;; adding some new metalemmas for times, reorganizing the theories,
;; removing some extraneous lemmas, and removing dependence upon
;; other theories (by adding the pertinent lemmas).

;; This script requires the bags theory

;; This script sets up a theory for the NATURALS with the following subtheories
;; ADDITION
;; MULTIPLICATION
;; REMAINDER
;; QUOTIENT
;; EXPONENTIATION 
;; LOGS
;; GCDS

;; The theories of EXPONENTIATION, LOGS, and GCDS still need a lot of work

; --------------------------------------------------------------------------------
; ARITHMETIC
; --------------------------------------------------------------------------------

; -------------------- PLUS & DIFFERENCE --------------------

; ---------- EQUAL ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-plus-0 \\ \index{equal-plus-0}
(({\it{a\/}} $+$ {\it{b\/}}) $=$ {\tt{0}}) $=$ (({\it{a\/}} $\simeq {\tt{0}}$) $\wedge$ ({\it{b\/}} $\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-cancellation \\ \index{plus-cancellation}
(({\it{a\/}} $+$ {\it{b\/}}) $=$ ({\it{a\/}} $+$ {\it{c\/}})) $=$ ({\rm{fix}}\,({\it{b\/}}) $=$ {\rm{fix}}\,({\it{c\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable plus-cancellation.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  equal-difference-0 \\ \index{equal-difference-0}
((({\it{x\/}} $-$ {\it{y\/}}) $=$ {\tt{0}}) $=$ ({\it{y\/}} $\not<$ {\it{x\/}})) $\wedge$ (({\tt{0}} $=$ ({\it{x\/}} $-$ {\it{y\/}})) $=$ ({\it{y\/}} $\not<$ {\it{x\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-cancellation \\ \index{difference-cancellation}
\=\+(({\it{x\/}} $-$ {\it{y\/}}) $=$ ({\it{z\/}} $-$ {\it{y\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $<$ {\it{y\/}}$\;\;${\bf then }{\it{y\/}} $\not<$ {\it{z\/}} \\ 
{\bf elseif }{\it{z\/}} $<$ {\it{y\/}}$\;\;${\bf then }{\it{y\/}} $\not<$ {\it{x\/}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}}) $=$ {\rm{fix}}\,({\it{z\/}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable difference-cancellation.

\addvspace{18pt}

\begin{verbatim}; ---------- PLUS ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  commutativity-of-plus \\ \index{commutativity-of-plus}
({\it{x\/}} $+$ {\it{y\/}}) $=$ ({\it{y\/}} $+$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-plus \\ \index{commutativity2-of-plus}
({\it{x\/}} $+$ ({\it{y\/}} $+$ {\it{z\/}})) $=$ ({\it{y\/}} $+$ ({\it{x\/}} $+$ {\it{z\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-zero-arg2 \\ \index{plus-zero-arg2}
({\it{y\/}} $\simeq {\tt{0}}$) $\rightarrow$ (({\it{x\/}} $+$ {\it{y\/}}) $=$ {\rm{fix}}\,({\it{x\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-add1-arg1 \\ \index{plus-add1-arg1}
(($1\;+$ {\it{a\/}}) $+$ {\it{b\/}}) $=$ ($1\;+$ ({\it{a\/}} $+$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-add1-arg2 \\ \index{plus-add1-arg2}
\=\+({\it{x\/}} $+$ ($1\;+$ {\it{y\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\in\;${\bf{N}}${}$$\;\;${\bf then }$1\;+$ ({\it{x\/}} $+$ {\it{y\/}}) \\ 
{\bf else }$1\;+$ {\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-plus \\ \index{associativity-of-plus}
(({\it{x\/}} $+$ {\it{y\/}}) $+$ {\it{z\/}}) $=$ ({\it{x\/}} $+$ ({\it{y\/}} $+$ {\it{z\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-difference-arg1 \\ \index{plus-difference-arg1}
\=\+(({\it{a\/}} $-$ {\it{b\/}}) $+$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} $+$ {\it{c\/}}) $-$ {\it{b\/}} \\ 
{\bf else }{\tt{0}} $+$ {\it{c\/}}$\;${\bf  endif}\-\-
\end{tabbing}
       
\begin{tabbing}{\sc Theorem}:  plus-difference-arg2 \\ \index{plus-difference-arg2}
\=\+({\it{a\/}} $+$ ({\it{b\/}} $-$ {\it{c\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{c\/}} $<$ {\it{b\/}}$\;\;${\bf then }({\it{a\/}} $+$ {\it{b\/}}) $-$ {\it{c\/}} \\ 
{\bf else }{\it{a\/}} $+$ {\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; ---------- DIFFERENCE-PLUS cancellation rules ----------
;
; Here are the basic canonicalization rules for differences of sums. These
; are subsumed by the meta lemmas and are therefore globally disabled.
; They are here merely to prove the meta lemmas.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  difference-plus-cancellation-proof \\ \index{difference-plus-cancellation-pr!oof}
(({\it{x\/}} $+$ {\it{y\/}}) $-$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}})
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  difference-plus-cancellation \\ \index{difference-plus-cancellation}
((({\it{x\/}} $+$ {\it{y\/}}) $-$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}})) $\wedge$ ((({\it{y\/}} $+$ {\it{x\/}}) $-$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable difference-plus-cancellation.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  difference-plus-plus-cancellation-proof \\ \index{difference-plus-plus-cancellati!on-proof}
(({\it{x\/}} $+$ {\it{y\/}}) $-$ ({\it{x\/}} $+$ {\it{z\/}})) $=$ ({\it{y\/}} $-$ {\it{z\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-plus-plus-cancellation \\ \index{difference-plus-plus-cancellati!on}
\=\+((({\it{x\/}} $+$ {\it{y\/}}) $-$ ({\it{x\/}} $+$ {\it{z\/}})) $=$ ({\it{y\/}} $-$ {\it{z\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{y\/}} $+$ {\it{x\/}}) $-$ ({\it{x\/}} $+$ {\it{z\/}})) $=$ ({\it{y\/}} $-$ {\it{z\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ {\it{y\/}}) $-$ ({\it{z\/}} $+$ {\it{x\/}})) $=$ ({\it{y\/}} $-$ {\it{z\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{y\/}} $+$ {\it{x\/}}) $-$ ({\it{z\/}} $+$ {\it{x\/}})) $=$ ({\it{y\/}} $-$ {\it{z\/}}))\-
\end{tabbing}


\noindent{\sc Event}:   Disable difference-plus-plus-cancellation.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  difference-plus-plus-cancellation-hack \\ \index{difference-plus-plus-cancellati!on-hack}
(({\it{w\/}} $+$ {\it{x\/}} $+$ {\it{a\/}}) $-$ ({\it{y\/}} $+$ {\it{z\/}} $+$ {\it{a\/}})) $=$ (({\it{w\/}} $+$ {\it{x\/}}) $-$ ({\it{y\/}} $+$ {\it{z\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable difference-plus-plus-cancellation-hack.

\addvspace{18pt}

\begin{verbatim}; Here are a few more facts about difference needed to prove the meta lemmas.
; These are disabled here. We re-prove them after the proof of the meta
; lemmas so that they will fire before the meta lemmas in subsequent proofs.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  diff-sub1-arg2 \\ \index{diff-sub1-arg2}
\=\+({\it{a\/}} $-$ ({\it{b\/}} $-\;1$)) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{fix}}\,({\it{a\/}}) \\ 
{\bf elseif }{\it{a\/}} $<$ {\it{b\/}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ ({\it{a\/}} $-$ {\it{b\/}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable diff-sub1-arg2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  diff-diff-arg1 \\ \index{diff-diff-arg1}
(({\it{x\/}} $-$ {\it{y\/}}) $-$ {\it{z\/}}) $=$ ({\it{x\/}} $-$ ({\it{y\/}} $+$ {\it{z\/}}))
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  diff-diff-arg2 \\ \index{diff-diff-arg2}
\=\+({\it{a\/}} $-$ ({\it{b\/}} $-$ {\it{c\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{c\/}}$\;\;${\bf then }{\rm{fix}}\,({\it{a\/}}) \\ 
{\bf else }({\it{a\/}} $+$ {\it{c\/}}) $-$ {\it{b\/}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; diff-diff-diff should be removed, but since the hack lemmas for
; correctness-of-cancel-difference-plus are designed for it, we'll
; keep it around.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  diff-diff-diff \\ \index{diff-diff-diff}
\=\+(({\it{b\/}} $\leq$ {\it{a\/}}) $\wedge$ ({\it{d\/}} $\leq$ {\it{c\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $-$ {\it{b\/}}) $-$ ({\it{c\/}} $-$ {\it{d\/}})) $=$ (({\it{a\/}} $+$ {\it{d\/}}) $-$ ({\it{b\/}} $+$ {\it{c\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable diff-diff-diff.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  difference-lessp-arg1 \\ \index{difference-lessp-arg1}
({\it{a\/}} $<$ {\it{b\/}}) $\rightarrow$ (({\it{a\/}} $-$ {\it{b\/}}) $=$ {\tt{0}})
\end{tabbing}


\noindent{\sc Event}:   Disable difference-lessp-arg1.

\addvspace{18pt}

\begin{verbatim}; --------------------------------------------------------------------------------
; Meta Lemmas to Cancel PLUS and DIFFERENCE expressions
; --------------------------------------------------------------------------------

; ---------- PLUS-TREE and PLUS-FRINGE ----------

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{plus-fringe} \\  
\=\+{\rm{plus-fringe}}\,({\it{x\/}})\index{plus-fringe} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
{\bf then }{\rm{append}}\,({\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe}) \\ 
{\bf else }{\rm{cons}}\,({\it{x\/}}, {\bf{nil}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{plus-tree} \\  
\=\+{\rm{plus-tree}}\,({\it{l\/}})\index{plus-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{l\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf elseif }{\rm{cdr}}\,({\it{l\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{fix}}, {\rm{car}}\,({\it{l\/}})) \\ 
{\bf elseif }{\rm{cddr}}\,({\it{l\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{plus}}, {\rm{car}}\,({\it{l\/}}), {\rm{cadr}}\,({\it{l\/}})) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{plus}}, {\rm{car}}\,({\it{l\/}}), {\rm{plus-tree}}\,({\rm{cdr}}\,({\it{l\/}}))\index{plus-tree})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  numberp-eval\$-plus \\ \index{numberp-eval\$-plus}
({\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}})) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $\in\;${\bf{N}}${}$)
\end{tabbing}


\noindent{\sc Event}:   Disable numberp-eval\$-plus.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  numberp-eval\$-plus-tree \\ \index{numberp-eval\$-plus-tree}
{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{l\/}})\index{plus-tree}, {\it{a\/}}) $\in\;${\bf{N}}${}$
\end{tabbing}


\noindent{\sc Event}:   Disable numberp-eval\$-plus-tree.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  member-implies-plus-tree-greatereqp \\ \index{member-implies-plus-tree-greate!reqp}
({\it{x\/}} $\in$ {\it{y\/}}) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}}) $\not<$ {\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable member-implies-plus-tree-greatereqp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  plus-tree-delete \\ \index{plus-tree-delete}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\rm{delete}}\,({\it{x\/}}, {\it{y\/}})\index{delete})\index{plus-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\in$ {\it{y\/}}$\;\;${\bf then }{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}}) $-$ {\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable plus-tree-delete.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  subbagp-implies-plus-tree-greatereqp \\ \index{subbagp-implies-plus-tree-greate!reqp}
{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}}) $\not<$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{x\/}})\index{plus-tree}, {\it{a\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable subbagp-implies-plus-tree-greatereqp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  plus-tree-bagdiff \\ \index{plus-tree-bagdiff}
\=\+{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff})\index{plus-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}}) $-$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{x\/}})\index{plus-tree}, {\it{a\/}})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable plus-tree-bagdiff.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  numberp-eval\$-bridge \\ \index{numberp-eval\$-bridge}
({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{x\/}})\index{plus-tree}, {\it{a\/}})) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}) $\in\;${\bf{N}}${}$)
\end{tabbing}


\noindent{\sc Event}:   Disable numberp-eval\$-bridge.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  bridge-to-subbagp-implies-plus-tree-greatereqp \\ \index{bridge-to-subbagp-implies-plus-t!ree-greatereqp}
\=\+(\=\+{\rm{subbagp}}\,({\it{y\/}}, {\rm{plus-fringe}}\,({\it{z\/}})\index{plus-fringe})\index{subbagp} \\ 
$\wedge$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\rm{plus-fringe}}\,({\it{z\/}})\index{plus-fringe})\index{plus-tree}, {\it{a\/}})))\- \\ 
$\rightarrow$$\;\;\;\;$(({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}) $<$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}})) $=$ {\bf{f}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable bridge-to-subbagp-implies-plus-tree-greatereqp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-plus-tree-append \\ \index{eval\$-plus-tree-append}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{plus-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{x\/}})\index{plus-tree}, {\it{a\/}}) $+$ {\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\it{y\/}})\index{plus-tree}, {\it{a\/}}))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-plus-tree-append.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  plus-tree-plus-fringe \\ \index{plus-tree-plus-fringe}
{\rm{eval\$}}\,({\bf{t}}, {\rm{plus-tree}}\,({\rm{plus-fringe}}\,({\it{x\/}})\index{plus-fringe})\index{plus-tree}, {\it{a\/}}) $=$ {\rm{fix}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable plus-tree-plus-fringe.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  member-implies-numberp \\ \index{member-implies-numberp}
(({\it{c\/}} $\in$ {\rm{plus-fringe}}\,({\it{x\/}})\index{plus-fringe}) $\wedge$ ({\rm{eval\$}}\,({\bf{t}}, {\it{c\/}}, {\it{a\/}}) $\in\;${\bf{N}}${}$)) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $\in\;${\bf{N}}${}$)
\end{tabbing}


\noindent{\sc Event}:   Disable member-implies-numberp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  cadr-eval\$-list \\ \index{cadr-eval\$-list}
\=\+({\rm{car}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}})) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{car}}\,({\it{x\/}}), {\it{a\/}})) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{x\/}}), {\it{a\/}}) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable cadr-eval\$-list.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-quote \\ \index{eval\$-quote}
{\rm{eval\$}}\,({\bf{t}}, {\rm{cons}}\,({\tt{'}}{\tt{quote}}, {\it{args\/}}), {\it{a\/}}) $=$ {\rm{car}}\,({\it{args\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-quote.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  listp-eval\$ \\ \index{listp-eval\$}
{\rm{listp}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}})) $=$ {\rm{listp}}\,({\it{x\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable listp-eval\$.

\addvspace{18pt}

\begin{verbatim}; ---------- CANCEL PLUS ----------

; CANCEL-EQUAL-PLUS cancels identical terms in a term which is the equality
; of two sums. For example,
; 
;   (EQUAL (PLUS A B C) (PLUS B D E)) => (EQUAL (PLUS A C) (PLUS D E))
;

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-equal-plus} \\  
\=\+{\rm{cancel-equal-plus}}\,({\it{x\/}})\index{cancel-equal-plus} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
{\bf then }\=\+{\bf if }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree})\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{numberp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{plus-tree}}\,({\rm{delete}}\,({\rm{caddr}}\,({\it{x\/}}), {\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe})\index{delete})\index{plus-tree}, \\ 
{\tt{'}}{\tt{'}}{\tt{0}})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{numberp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\tt{'}}{\tt{'}}{\tt{0}}, \\ 
{\rm{plus-tree}}\,({\rm{delete}}\,({\rm{cadr}}\,({\it{x\/}}), {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\index{delete})\index{plus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-equal-plus \\ \index{correctness-of-cancel-equal-plu!s}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-equal-plus}}\,({\it{x\/}})\index{cancel-equal-plus}, {\it{a\/}})
\end{tabbing}

\begin{verbatim}; ---------- CANCEL-DIFFERENCE-PLUS ----------

; CANCEL-DIFFERENCE-PLUS cancels identical terms in a term which is the 
; difference of two sums. For example,
; 
;  (DIFFERENCE (PLUS A B C) (PLUS B D E)) => (DIFFERENCE (PLUS A C) (PLUS D E))
;
; Using rewrite rules, we canonicalize terms involving  PLUS and DIFFERENCE 
; to be the DIFFERENCE of two sums. Then CANCEL-DIFFERENCE-PLUS cancels out 
; like terms.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-difference-plus} \\  
\=\+{\rm{cancel-difference-plus}}\,({\it{x\/}})\index{cancel-difference-plus} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{difference}}) \\ 
{\bf then }\=\+{\bf if }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{difference}}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree})\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe})\- \\ 
{\bf then }{\rm{plus-tree}}\,({\rm{delete}}\,({\rm{caddr}}\,({\it{x\/}}), {\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe})\index{delete})\index{plus-tree} \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-difference-plus \\ \index{correctness-of-cancel-difference!-plus}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-difference-plus}}\,({\it{x\/}})\index{cancel-difference-plus}, {\it{a\/}})
\end{tabbing}

\begin{verbatim}; ---------- DIFFERENCE ----------

; Here are the rules for difference terms which we want to try before
; the meta lemmas. They help canonicalize terms to differences of sums.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  difference-elim \\ \index{difference-elim}
(({\it{y\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{y\/}} $\not<$ {\it{x\/}})) $\rightarrow$ (({\it{x\/}} $+$ ({\it{y\/}} $-$ {\it{x\/}})) $=$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-leq-arg1 \\ \index{difference-leq-arg1}
({\it{a\/}} $\leq$ {\it{b\/}}) $\rightarrow$ (({\it{a\/}} $-$ {\it{b\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-add1-arg2 \\ \index{difference-add1-arg2}
\=\+({\it{a\/}} $-$ ($1\;+$ {\it{b\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} $-$ {\it{b\/}}) $-\;1$ \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-sub1-arg2 \\ \index{difference-sub1-arg2}
\=\+({\it{a\/}} $-$ ({\it{b\/}} $-\;1$)) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{fix}}\,({\it{a\/}}) \\ 
{\bf elseif }{\it{a\/}} $<$ {\it{b\/}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ ({\it{a\/}} $-$ {\it{b\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-difference-arg1 \\ \index{difference-difference-arg1}
(({\it{x\/}} $-$ {\it{y\/}}) $-$ {\it{z\/}}) $=$ ({\it{x\/}} $-$ ({\it{y\/}} $+$ {\it{z\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-difference-arg2 \\ \index{difference-difference-arg2}
\=\+({\it{a\/}} $-$ ({\it{b\/}} $-$ {\it{c\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{c\/}}$\;\;${\bf then }{\rm{fix}}\,({\it{a\/}}) \\ 
{\bf else }({\it{a\/}} $+$ {\it{c\/}}) $-$ {\it{b\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-x-x \\ \index{difference-x-x}
({\it{x\/}} $-$ {\it{x\/}}) $=$ {\tt{0}}
\end{tabbing}

\begin{verbatim}; ---------- LESSP ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  lessp-difference-cancellation \\ \index{lessp-difference-cancellation}
\=\+(({\it{a\/}} $-$ {\it{c\/}}) $<$ ({\it{b\/}} $-$ {\it{c\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{c\/}} $\leq$ {\it{a\/}}$\;\;${\bf then }{\it{a\/}} $<$ {\it{b\/}} \\ 
{\bf else }{\it{c\/}} $<$ {\it{b\/}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable lessp-difference-cancellation.

\addvspace{18pt}

\begin{verbatim}; CANCEL-LESSP-PLUS cancels LESSP terms whose arguments are sums.
; Examples:
; (LESSP (PLUS A B C) (PLUS A C D)) -> (LESSP (FIX B) (FIX D))
; (LESSP A (PLUS A B))  -> (NOT (ZEROP (FIX B)))
; (LESSP (PLUS A B) A)  -> F

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-lessp-plus} \\  
\=\+{\rm{cancel-lessp-plus}}\,({\it{x\/}})\index{cancel-lessp-plus} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{lessp}}) \\ 
{\bf then }\=\+{\bf if }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{lessp}}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree}, \\ 
{\rm{plus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe}, \\ 
{\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\-\index{bagint})\-\index{bagdiff})\index{plus-tree})\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{plus-fringe})\- \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}) \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{plus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\- \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{not}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{zerop}}, \\ 
{\rm{plus-tree}}\,({\rm{delete}}\,({\rm{cadr}}\,({\it{x\/}}), {\rm{plus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{plus-fringe})\index{delete})\index{plus-tree})\-)\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-lessp-plus \\ \index{correctness-of-cancel-lessp-plu!s}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-lessp-plus}}\,({\it{x\/}})\index{cancel-lessp-plus}, {\it{a\/}})
\end{tabbing}


\begin{verbatim}; Define the available theory of addition.  To get the list of events to
; put in the theory, evaluate the following form in NQTHM at this point
; in the script. This form lists all  lemmas which are globally enabled,
; and which have non-null lemma type.
;
; (remove-if-not (function (lambda (x)
; 			   (and (member x (lemmas))
; 				(not (assoc x disabled-lemmas))
; 				(not (null (nth 2 (get x 'event)))))))
; 	       chronology)


\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{addition}} to consist of the following events: equal-plus-0,
equal-difference-0,
commutativity-of-plus,
commutativity2-of-plus,
plus-zero-arg2,
plus-add1-arg2,
plus-add1-arg1,
associativity-of-plus,
plus-difference-arg1,
plus-difference-arg2,
diff-diff-arg1,
diff-diff-arg2,
correctness-of-cancel-equal-plus,
correctness-of-cancel-difference-plus,
difference-elim,
difference-leq-arg1,
difference-add1-arg2,
difference-sub1-arg2,
difference-difference-arg1,
difference-difference-arg2,
difference-x-x,
correctness-of-cancel-lessp-plus.\index{addition}

\addvspace{18pt}





\begin{verbatim}; ---------- TIMES ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-times-0 \\ \index{equal-times-0}
(({\it{x\/}} $*$ {\it{y\/}}) $=$ {\tt{0}}) $=$ (({\it{x\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{y\/}} $\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-times-1 \\ \index{equal-times-1}
(({\it{a\/}} $*$ {\it{b\/}}) $=$ {\tt{1}}) $=$ (({\it{a\/}} $=$ {\tt{1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{1}}))
\end{tabbing}

\begin{verbatim};(lemma equal-sub1-times-0 (rewrite)
;       (equal (equal (sub1 (times a b)) 0)
;	      (or (zerop a)
;		  (zerop b)
;		  (and (equal a 1) (equal b 1)))))

\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-sub1-0 \\ \index{equal-sub1-0}
(({\it{x\/}} $-\;1$) $=$ {\tt{0}}) $=$ (({\it{x\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{x\/}} $=$ {\tt{1}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-zero \\ \index{times-zero}
({\it{y\/}} $\simeq {\tt{0}}$) $\rightarrow$ (({\it{x\/}} $*$ {\it{y\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-add1 \\ \index{times-add1}
\=\+({\it{x\/}} $*$ ($1\;+$ {\it{y\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\in\;${\bf{N}}${}$$\;\;${\bf then }{\it{x\/}} $+$ ({\it{x\/}} $*$ {\it{y\/}}) \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity-of-times \\ \index{commutativity-of-times}
({\it{y\/}} $*$ {\it{x\/}}) $=$ ({\it{x\/}} $*$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-distributes-over-plus-proof \\ \index{times-distributes-over-plus-pro!of}
({\it{x\/}} $*$ ({\it{y\/}} $+$ {\it{z\/}})) $=$ (({\it{x\/}} $*$ {\it{y\/}}) $+$ ({\it{x\/}} $*$ {\it{z\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-distributes-over-plus \\ \index{times-distributes-over-plus}
\=\+(({\it{x\/}} $*$ ({\it{y\/}} $+$ {\it{z\/}})) $=$ (({\it{x\/}} $*$ {\it{y\/}}) $+$ ({\it{x\/}} $*$ {\it{z\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ {\it{y\/}}) $*$ {\it{z\/}}) $=$ (({\it{x\/}} $*$ {\it{z\/}}) $+$ ({\it{y\/}} $*$ {\it{z\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-times \\ \index{commutativity2-of-times}
({\it{x\/}} $*$ {\it{y\/}} $*$ {\it{z\/}}) $=$ ({\it{y\/}} $*$ {\it{x\/}} $*$ {\it{z\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-times \\ \index{associativity-of-times}
(({\it{x\/}} $*$ {\it{y\/}}) $*$ {\it{z\/}}) $=$ ({\it{x\/}} $*$ {\it{y\/}} $*$ {\it{z\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-distributes-over-difference-proof \\ \index{times-distributes-over-differen!ce-proof}
(({\it{a\/}} $-$ {\it{b\/}}) $*$ {\it{c\/}}) $=$ (({\it{a\/}} $*$ {\it{c\/}}) $-$ ({\it{b\/}} $*$ {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-distributes-over-difference \\ \index{times-distributes-over-differen!ce}
\=\+((({\it{a\/}} $-$ {\it{b\/}}) $*$ {\it{c\/}}) $=$ (({\it{a\/}} $*$ {\it{c\/}}) $-$ ({\it{b\/}} $*$ {\it{c\/}}))) \\ 
$\wedge$$\;\;\;\;$(({\it{a\/}} $*$ ({\it{b\/}} $-$ {\it{c\/}})) $=$ (({\it{a\/}} $*$ {\it{b\/}}) $-$ ({\it{a\/}} $*$ {\it{c\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-quotient-proof \\ \index{times-quotient-proof}
(({\it{x\/}} $\not\simeq {\tt{0}}$) $\wedge$ (({\it{y\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}})) $\rightarrow$ ((({\it{y\/}} $\div$ {\it{x\/}}) $*$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-quotient \\ \index{times-quotient}
\=\+(({\it{y\/}} $\not\simeq {\tt{0}}$) $\wedge$ (({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(((({\it{x\/}} $\div$ {\it{y\/}}) $*$ {\it{y\/}}) $=$ {\rm{fix}}\,({\it{x\/}})) $\wedge$ (({\it{y\/}} $*$ ({\it{x\/}} $\div$ {\it{y\/}})) $=$ {\rm{fix}}\,({\it{x\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  times-1-arg1 \\ \index{times-1-arg1}
({\tt{1}} $*$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times1-proof \\ \index{lessp-times1-proof}
(({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\not\simeq {\tt{0}}$)) $\rightarrow$ (({\it{a\/}} $<$ ({\it{b\/}} $*$ {\it{c\/}})) $=$ {\bf{t}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times1 \\ \index{lessp-times1}
\=\+(({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $<$ ({\it{b\/}} $*$ {\it{c\/}})) $=$ {\bf{t}}) $\wedge$ (({\it{a\/}} $<$ ({\it{c\/}} $*$ {\it{b\/}})) $=$ {\bf{t}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times2-proof \\ \index{lessp-times2-proof}
(({\it{a\/}} $\leq$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\not\simeq {\tt{0}}$)) $\rightarrow$ ((({\it{b\/}} $*$ {\it{c\/}}) $<$ {\it{a\/}}) $=$ {\bf{f}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times2 \\ \index{lessp-times2}
\=\+(({\it{a\/}} $\leq$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$(((({\it{b\/}} $*$ {\it{c\/}}) $<$ {\it{a\/}}) $=$ {\bf{f}}) $\wedge$ ((({\it{c\/}} $*$ {\it{b\/}}) $<$ {\it{a\/}}) $=$ {\bf{f}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times3-proof1 \\ \index{lessp-times3-proof1}
(({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\tt{1}} $<$ {\it{b\/}})) $\rightarrow$ ({\it{a\/}} $<$ ({\it{a\/}} $*$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times3-proof2 \\ \index{lessp-times3-proof2}
({\it{a\/}} $<$ ({\it{a\/}} $*$ {\it{b\/}})) $\rightarrow$ (({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\tt{1}} $<$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-times3 \\ \index{lessp-times3}
\=\+(({\it{a\/}} $<$ ({\it{a\/}} $*$ {\it{b\/}})) $=$ (({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\tt{1}} $<$ {\it{b\/}}))) \\ 
$\wedge$$\;\;\;\;$(({\it{a\/}} $<$ ({\it{b\/}} $*$ {\it{a\/}})) $=$ (({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\tt{1}} $<$ {\it{b\/}})))\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  lessp-times-cancellation-proof \\ \index{lessp-times-cancellation-proof}
(({\it{x\/}} $*$ {\it{z\/}}) $<$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ (({\it{z\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{y\/}}))
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  lessp-times-cancellation1 \\ \index{lessp-times-cancellation1}
\=\+((({\it{x\/}} $*$ {\it{z\/}}) $<$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ (({\it{z\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{y\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{z\/}} $*$ {\it{x\/}}) $<$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ (({\it{z\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{y\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $*$ {\it{z\/}}) $<$ ({\it{z\/}} $*$ {\it{y\/}})) $=$ (({\it{z\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{y\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{z\/}} $*$ {\it{x\/}}) $<$ ({\it{z\/}} $*$ {\it{y\/}})) $=$ (({\it{z\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{y\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable lessp-times-cancellation1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  lessp-plus-times-proof \\ \index{lessp-plus-times-proof}
({\it{x\/}} $<$ {\it{a\/}}) $\rightarrow$ ((({\it{x\/}} $+$ ({\it{a\/}} $*$ {\it{b\/}})) $<$ ({\it{a\/}} $*$ {\it{c\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-plus-times1 \\ \index{lessp-plus-times1}
\=\+((({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) $<$ {\it{b\/}}) $=$ (({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\simeq {\tt{0}}$))) \\ 
$\wedge$$\;\;\;\;$((({\it{a\/}} $+$ ({\it{c\/}} $*$ {\it{b\/}})) $<$ {\it{b\/}}) $=$ (({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\simeq {\tt{0}}$))) \\ 
$\wedge$$\;\;\;\;$(((({\it{c\/}} $*$ {\it{b\/}}) $+$ {\it{a\/}}) $<$ {\it{b\/}}) $=$ (({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\simeq {\tt{0}}$))) \\ 
$\wedge$$\;\;\;\;$(((({\it{b\/}} $*$ {\it{c\/}}) $+$ {\it{a\/}}) $<$ {\it{b\/}}) $=$ (({\it{a\/}} $<$ {\it{b\/}}) $\wedge$ ({\it{c\/}} $\simeq {\tt{0}}$)))\-
\end{tabbing}       

\begin{tabbing}{\sc Theorem}:  lessp-plus-times2 \\ \index{lessp-plus-times2}
\=\+(({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $<$ {\it{a\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+((({\it{x\/}} $+$ ({\it{a\/}} $*$ {\it{b\/}})) $<$ ({\it{a\/}} $*$ {\it{c\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ ({\it{b\/}} $*$ {\it{a\/}})) $<$ ({\it{a\/}} $*$ {\it{c\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ ({\it{a\/}} $*$ {\it{b\/}})) $<$ ({\it{c\/}} $*$ {\it{a\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ ({\it{b\/}} $*$ {\it{a\/}})) $<$ ({\it{c\/}} $*$ {\it{a\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$(((({\it{a\/}} $*$ {\it{b\/}}) $+$ {\it{x\/}}) $<$ ({\it{a\/}} $*$ {\it{c\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$(((({\it{b\/}} $*$ {\it{a\/}}) $+$ {\it{x\/}}) $<$ ({\it{a\/}} $*$ {\it{c\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$(((({\it{a\/}} $*$ {\it{b\/}}) $+$ {\it{x\/}}) $<$ ({\it{c\/}} $*$ {\it{a\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$(((({\it{b\/}} $*$ {\it{a\/}}) $+$ {\it{x\/}}) $<$ ({\it{c\/}} $*$ {\it{a\/}})) $=$ ({\it{b\/}} $<$ {\it{c\/}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-1-times \\ \index{lessp-1-times}
\=\+({\tt{1}} $<$ ({\it{a\/}} $*$ {\it{b\/}})) \\ 
$=$$\;\;\;\;$($\neg$ (({\it{a\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{b\/}} $\simeq {\tt{0}}$) $\vee$ (({\it{a\/}} $=$ {\tt{1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{1}}))))\-
\end{tabbing}




\begin{verbatim};;; meta lemmas to cancel lessp-times and equal-times expressions
;; examples
;; (lessp (times b (times d a)) (times b (times e (times a f)))) -> 
;;                                            (and (and (not (zerop a)) 
;;                                                      (not (zerop b)))
;;                                                 (lessp (fix d) (times e f)))
;;
;; (equal (times b (times c d)) (times b d))    -> 
;;                                           (or (or (zerop b) (zerop d))
;;                                               (equal (fix c) 1))


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{times-tree} \\  
\=\+{\rm{times-tree}}\,({\it{x\/}})\index{times-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{1}} \\ 
{\bf elseif }{\rm{cdr}}\,({\it{x\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{fix}}, {\rm{car}}\,({\it{x\/}})) \\ 
{\bf elseif }{\rm{cddr}}\,({\it{x\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{times}}, {\rm{car}}\,({\it{x\/}}), {\rm{cadr}}\,({\it{x\/}})) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{times}}, {\rm{car}}\,({\it{x\/}}), {\rm{times-tree}}\,({\rm{cdr}}\,({\it{x\/}}))\index{times-tree})$\;${\bf  endif}\-\-
\end{tabbing}
		    
\begin{tabbing}{\sc Definition}:\index{times-fringe} \\  
\=\+{\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
{\bf then }{\rm{append}}\,({\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, {\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe}) \\ 
{\bf else }{\rm{cons}}\,({\it{x\/}}, {\bf{nil}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{or-zerop-tree} \\  
\=\+{\rm{or-zerop-tree}}\,({\it{x\/}})\index{or-zerop-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{'}}{\tt{(}}{\tt{false}}{\tt{)}} \\ 
{\bf elseif }{\rm{cdr}}\,({\it{x\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{car}}\,({\it{x\/}})) \\ 
{\bf elseif }{\rm{cddr}}\,({\it{x\/}}) $\simeq\;${{\bf{nil}}}${}$ \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{or}}, {\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{car}}\,({\it{x\/}})), {\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{cadr}}\,({\it{x\/}}))) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{or}}, {\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{car}}\,({\it{x\/}})), {\rm{or-zerop-tree}}\,({\rm{cdr}}\,({\it{x\/}}))\index{or-zerop-tree})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{and-not-zerop-tree} \\  
\=\+{\rm{and-not-zerop-tree}}\,({\it{x\/}})\index{and-not-zerop-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{'}}{\tt{(}}{\tt{true}}{\tt{)}} \\ 
{\bf elseif }{\rm{cdr}}\,({\it{x\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{not}}, {\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{car}}\,({\it{x\/}}))) \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{not}}, {\rm{list}}\,({\tt{'}}{\tt{zerop}}, {\rm{car}}\,({\it{x\/}}))), \\ 
{\rm{and-not-zerop-tree}}\,({\rm{cdr}}\,({\it{x\/}}))\index{and-not-zerop-tree})\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  numberp-eval\$-times \\ \index{numberp-eval\$-times}
({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $\in\;${\bf{N}}${}$)
\end{tabbing}


\noindent{\sc Event}:   Disable numberp-eval\$-times.

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  eval\$-times \\ \index{eval\$-times}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-times.

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  eval\$-or \\ \index{eval\$-or}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{or}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $\vee$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-or.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-equal \\ \index{eval\$-equal}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-equal.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-lessp \\ \index{eval\$-lessp}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{lessp}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $<$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-lessp.

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  eval\$-quotient \\ \index{eval\$-quotient}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{quotient}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ ({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $\div$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-quotient.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-if \\ \index{eval\$-if}
\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}})$\;\;${\bf then }{\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}}) \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{x\/}}), {\it{a\/}})$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-if.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  numberp-eval\$-times-tree \\ \index{numberp-eval\$-times-tree}
{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{x\/}})\index{times-tree}, {\it{a\/}}) $\in\;${\bf{N}}${}$
\end{tabbing}


\noindent{\sc Event}:   Disable numberp-eval\$-times-tree.

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  lessp-times-arg1 \\ \index{lessp-times-arg1}
({\it{a\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ((({\it{a\/}} $*$ {\it{x\/}}) $\not<$ ({\it{a\/}} $*$ {\it{y\/}})) $=$ ({\it{x\/}} $\not<$ {\it{y\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  infer-equality-from-not-lessp \\ \index{infer-equality-from-not-lessp}
(({\it{a\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{b\/}} $\in\;${\bf{N}}${}$)) $\rightarrow$ ((({\it{a\/}} $\not<$ {\it{b\/}}) $\wedge$ ({\it{b\/}} $\not<$ {\it{a\/}})) $=$ ({\it{a\/}} $=$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-times-arg1 \\ \index{equal-times-arg1}
({\it{a\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ((({\it{a\/}} $*$ {\it{x\/}}) $=$ ({\it{a\/}} $*$ {\it{y\/}})) $=$ ({\rm{fix}}\,({\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable equal-times-arg1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  equal-times-bridge \\ \index{equal-times-bridge}
(({\it{a\/}} $*$ {\it{b\/}}) $=$ ({\it{c\/}} $*$ ({\it{a\/}} $*$ {\it{d\/}}))) $=$ (({\it{a\/}} $\simeq {\tt{0}}$) $\vee$ ({\rm{fix}}\,({\it{b\/}}) $=$ ({\it{c\/}} $*$ {\it{d\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable equal-times-bridge.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-times-member \\ \index{eval\$-times-member}
\=\+({\it{e\/}} $\in$ {\it{x\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{x\/}})\index{times-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{e\/}}, {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{delete}}\,({\it{e\/}}, {\it{x\/}})\index{delete})\index{times-tree}, {\it{a\/}})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-times-member.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  zerop-makes-times-tree-zero \\ \index{zerop-makes-times-tree-zero}
\=\+(($\neg$ {\rm{eval\$}}\,({\bf{t}}, {\rm{and-not-zerop-tree}}\,({\it{x\/}})\index{and-not-zerop-tree}, {\it{a\/}})) $\wedge$ {\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}) $=$ {\tt{0}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable zerop-makes-times-tree-zero.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  or-zerop-tree-is-not-zerop-tree \\ \index{or-zerop-tree-is-not-zerop-tree}
{\rm{eval\$}}\,({\bf{t}}, {\rm{or-zerop-tree}}\,({\it{x\/}})\index{or-zerop-tree}, {\it{a\/}}) $=$ ($\neg$ {\rm{eval\$}}\,({\bf{t}}, {\rm{and-not-zerop-tree}}\,({\it{x\/}})\index{and-not-zerop-tree}, {\it{a\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable or-zerop-tree-is-not-zerop-tree.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  zerop-makes-times-tree-zero2 \\ \index{zerop-makes-times-tree-zero2}
\=\+({\rm{eval\$}}\,({\bf{t}}, {\rm{or-zerop-tree}}\,({\it{x\/}})\index{or-zerop-tree}, {\it{a\/}}) $\wedge$ {\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}) $=$ {\tt{0}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable zerop-makes-times-tree-zero2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  times-tree-append \\ \index{times-tree-append}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{times-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{x\/}})\index{times-tree}, {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}))\-
\end{tabbing}


\noindent{\sc Event}:   Disable times-tree-append.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  times-tree-of-times-fringe \\ \index{times-tree-of-times-fringe}
{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe})\index{times-tree}, {\it{a\/}}) $=$ {\rm{fix}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable times-tree-of-times-fringe.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{cancel-lessp-times} \\  
\=\+{\rm{cancel-lessp-times}}\,({\it{x\/}})\index{cancel-lessp-times} \\ 
$=$$\;\;\;\;$\=\+{\bf if }\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{lessp}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}})\- \\ 
{\bf then }\=\+{\bf let }\=\+{\it{inboth\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe})\-\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{inboth\/}}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{and-not-zerop-tree}}\,({\it{inboth\/}})\index{and-not-zerop-tree}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{lessp}}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree})\-)\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}



\begin{tabbing}{\sc Theorem}:  eval\$-lessp-times-tree-bagdiff \\ \index{eval\$-lessp-times-tree-bagdiff}
\=\+({\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\wedge$ {\rm{subbagp}}\,({\it{x\/}}, {\it{z\/}})\index{subbagp} $\wedge$ {\rm{eval\$}}\,({\bf{t}}, {\rm{and-not-zerop-tree}}\,({\it{x\/}})\index{and-not-zerop-tree}, {\it{a\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}) \\ 
$<$$\;\;\;\;${\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{z\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}))\- \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}) $<$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{z\/}})\index{times-tree}, {\it{a\/}})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-lessp-times-tree-bagdiff.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  zerop-makes-lessp-false-bridge \\ \index{zerop-makes-lessp-false-bridge}
\=\+(\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{and-not-zerop-tree}}\,({\rm{bagint}}\,({\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, {\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe})\index{bagint})\index{and-not-zerop-tree}, \\ 
{\it{a\/}})\-))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})) \\ 
$<$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{y\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{y\/}}), {\it{a\/}})))\- \\ 
$=$$\;\;\;\;${\bf{f}})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable zerop-makes-lessp-false-bridge.

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-lessp-times \\ \index{correctness-of-cancel-lessp-time!s}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-lessp-times}}\,({\it{x\/}})\index{cancel-lessp-times}, {\it{a\/}})
\end{tabbing}



\begin{tabbing}{\sc Definition}:\index{cancel-equal-times} \\  
\=\+{\rm{cancel-equal-times}}\,({\it{x\/}})\index{cancel-equal-times} \\ 
$=$$\;\;\;\;$\=\+{\bf if }\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}})\- \\ 
{\bf then }\=\+{\bf let }\=\+{\it{inboth\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe})\-\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{inboth\/}}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{or}}, \\ 
{\rm{or-zerop-tree}}\,({\it{inboth\/}})\index{or-zerop-tree}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree})\-)\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  zerop-makes-equal-true-bridge \\ \index{zerop-makes-equal-true-bridge}
\=\+(\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;${\rm{eval\$}}\,({\bf{t}}, {\rm{or-zerop-tree}}\,({\rm{bagint}}\,({\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, {\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe})\index{bagint})\index{or-zerop-tree}, {\it{a\/}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})) \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{y\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{y\/}}), {\it{a\/}})))\- \\ 
$=$$\;\;\;\;${\bf{t}})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable zerop-makes-equal-true-bridge.

\addvspace{18pt}
		       
\begin{tabbing}{\sc Theorem}:  eval\$-equal-times-tree-bagdiff \\ \index{eval\$-equal-times-tree-bagdiff}
\=\+({\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\wedge$ {\rm{subbagp}}\,({\it{x\/}}, {\it{z\/}})\index{subbagp} $\wedge$ ($\neg$ {\rm{eval\$}}\,({\bf{t}}, {\rm{or-zerop-tree}}\,({\it{x\/}})\index{or-zerop-tree}, {\it{a\/}}))) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}) \\ 
$=$$\;\;\;\;${\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{z\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}))\- \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{z\/}})\index{times-tree}, {\it{a\/}})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-equal-times-tree-bagdiff.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  cancel-equal-times-preserves-inequality \\ \index{cancel-equal-times-preserves-ineq!uality}
\=\+(\=\+{\rm{subbagp}}\,({\it{z\/}}, {\it{x\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{z\/}}, {\it{y\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{x\/}})\index{times-tree}, {\it{a\/}}) $\not=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{z\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}) \\ 
$\not=$$\;\;\;\;${\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{z\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-equal-times-preserves-inequality.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  cancel-equal-times-preserves-inequality-bridge \\ \index{cancel-equal-times-preserves-ineq!uality-bridge}
\=\+(\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})) \\ 
$\not=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{y\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{y\/}}), {\it{a\/}})))\-)\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, \\ 
{\rm{bagint}}\,({\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, {\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe})\index{bagint})\-\index{bagdiff})\index{times-tree}, \\ 
{\it{a\/}})\- \\ 
$\not=$$\;\;\;\;${\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, \\ 
{\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe})\-\index{bagint})\-\index{bagdiff})\index{times-tree}, \\ 
{\it{a\/}})\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-equal-times-preserves-inequality-bridge.

\addvspace{18pt}
		    
\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-equal-times \\ \index{correctness-of-cancel-equal-time!s}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-equal-times}}\,({\it{x\/}})\index{cancel-equal-times}, {\it{a\/}})
\end{tabbing}





\begin{verbatim}; Define the available  theory of  multiplication.   To  get the list of
; events to put in the theory,  evaluate the following  form in NQTHM at
; this point  in  the  script. This   form  lists all lemmas   which are
; globally enabled, and which have non-null lemma type.
;
; (remove-if-not (function (lambda (x)
; 			   (and (member x (lemmas))
; 				(not (assoc x disabled-lemmas))
; 				(not (null (nth 2 (get x 'event))))
; 				(not (member x (nth 2 (get 'addition 'event)))))))
; 	       chronology)


\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{multiplication}} to consist of the following events: equal-times-0,
equal-times-1,
equal-sub1-0,
times-zero,
times-add1,
commutativity-of-times,
times-distributes-over-plus,
commutativity2-of-times,
associativity-of-times,
times-distributes-over-difference,
times-quotient,
times-1-arg1,
lessp-times1,
lessp-times2,
lessp-times3,
lessp-plus-times1,
lessp-plus-times2,
lessp-1-times,
correctness-of-cancel-lessp-times,
correctness-of-cancel-equal-times.\index{multiplication}

\addvspace{18pt}

\begin{verbatim}; ---------- REMAINDER ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  lessp-remainder \\ \index{lessp-remainder}
(({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $<$ {\it{y\/}}) $=$ ({\it{y\/}} $\not\simeq {\tt{0}}$)
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-noop \\ \index{remainder-noop}
({\it{a\/}} $<$ {\it{b\/}}) $\rightarrow$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ {\rm{fix}}\,({\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-of-non-number \\ \index{remainder-of-non-number}
({\it{a\/}} $\not\in\;${\bf{N}}${}$) $\rightarrow$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{n\/}}) $=$ ({\tt{0}} ${}${\bf{mod}}${}$ {\it{n\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-zero \\ \index{remainder-zero}
({\it{x\/}} $\simeq {\tt{0}}$) $\rightarrow$ (({\it{y\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\rm{fix}}\,({\it{y\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plus-remainder-times-quotient \\ \index{plus-remainder-times-quotient}
(({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $+$ ({\it{y\/}} $*$ ({\it{x\/}} $\div$ {\it{y\/}}))) $=$ {\rm{fix}}\,({\it{x\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable plus-remainder-times-quotient.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  remainder-quotient-elim \\ \index{remainder-quotient-elim}
(({\it{y\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{x\/}} $\in\;${\bf{N}}${}$)) $\rightarrow$ ((({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $+$ ({\it{y\/}} $*$ ({\it{x\/}} $\div$ {\it{y\/}}))) $=$ {\it{x\/}})
\end{tabbing}

\begin{verbatim}; (lemma remainder-sub1 (rewrite)
;        (implies (and (not (zerop a))
; 		     (not (zerop b)))
; 		(equal (remainder (sub1 a) b)
; 		       (if (equal (remainder a b) 0)
; 			   (sub1 b)
; 			   (sub1 (remainder a b)))))
;        ((enable lessp-remainder
; 		remainder-noop
; 		remainder-quotient-elim)
; 	(enable-theory addition)
; 	(induct (remainder a b))))

\end{verbatim}\begin{tabbing}{\sc Theorem}:  remainder-add1 \\ \index{remainder-add1}
(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ {\tt{0}}) $\rightarrow$ ((($1\;+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ ({\tt{1}} ${}${\bf{mod}}${}$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-plus-proof \\ \index{remainder-plus-proof}
(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-plus \\ \index{remainder-plus}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{b\/}} $+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $+$ {\it{y\/}} $+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ (({\it{x\/}} $+$ {\it{y\/}}) ${}${\bf{mod}}${}$ {\it{c\/}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-remainder-plus-0-proof \\ \index{equal-remainder-plus-0-proof}
(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\rightarrow$ (((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $=$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-remainder-plus-0 \\ \index{equal-remainder-plus-0}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $=$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}})) \\ 
$\wedge$$\;\;\;\;$(((({\it{b\/}} $+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $=$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}})) \\ 
$\wedge$$\;\;\;\;$(\=\+((({\it{x\/}} $+$ {\it{y\/}} $+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$=$$\;\;\;\;$((({\it{x\/}} $+$ {\it{y\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}))\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-remainder-plus-remainder-proof \\ \index{equal-remainder-plus-remainder-p!roof}
({\it{a\/}} $<$ {\it{c\/}}) $\rightarrow$ (((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) $=$ ({\it{a\/}} $\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-remainder-plus-remainder \\ \index{equal-remainder-plus-remainder}
\=\+({\it{a\/}} $<$ {\it{c\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) $=$ ({\it{a\/}} $\simeq {\tt{0}}$)) \\ 
$\wedge$$\;\;\;\;$(((({\it{b\/}} $+$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) $=$ ({\it{a\/}} $\simeq {\tt{0}}$)))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable equal-remainder-plus-remainder.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  remainder-times1-proof \\ \index{remainder-times1-proof}
(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{a\/}} $*$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times1 \\ \index{remainder-times1}
\=\+(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(((({\it{a\/}} $*$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ ((({\it{b\/}} $*$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times1-instance-proof \\ \index{remainder-times1-instance-proof}
(({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ {\it{y\/}}) $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times1-instance \\ \index{remainder-times1-instance}
((({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ {\it{y\/}}) $=$ {\tt{0}}) $\wedge$ ((({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times-times-proof \\ \index{remainder-times-times-proof}
(({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ ({\it{x\/}} $*$ {\it{z\/}})) $=$ ({\it{x\/}} $*$ ({\it{y\/}} ${}${\bf{mod}}${}$ {\it{z\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times-times \\ \index{remainder-times-times}
\=\+((({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ ({\it{x\/}} $*$ {\it{z\/}})) $=$ ({\it{x\/}} $*$ ({\it{y\/}} ${}${\bf{mod}}${}$ {\it{z\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $*$ {\it{z\/}}) ${}${\bf{mod}}${}$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ (({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $*$ {\it{z\/}}))\-
\end{tabbing}


\noindent{\sc Event}:   Disable remainder-times-times.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  remainder-times2-proof \\ \index{remainder-times2-proof}
(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}}) $\rightarrow$ (({\it{a\/}} ${}${\bf{mod}}${}$ ({\it{z\/}} $*$ {\it{y\/}})) $=$ ({\it{z\/}} $*$ (({\it{a\/}} $\div$ {\it{z\/}}) ${}${\bf{mod}}${}$ {\it{y\/}})))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times2 \\ \index{remainder-times2}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ ({\it{z\/}} $*$ (({\it{a\/}} $\div$ {\it{z\/}}) ${}${\bf{mod}}${}$ {\it{y\/}}))) \\ 
$\wedge$$\;\;\;\;$(({\it{a\/}} ${}${\bf{mod}}${}$ ({\it{z\/}} $*$ {\it{y\/}})) $=$ ({\it{z\/}} $*$ (({\it{a\/}} $\div$ {\it{z\/}}) ${}${\bf{mod}}${}$ {\it{y\/}}))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-times2-instance \\ \index{remainder-times2-instance}
\=\+((({\it{x\/}} $*$ {\it{y\/}}) ${}${\bf{mod}}${}$ ({\it{x\/}} $*$ {\it{z\/}})) $=$ ({\it{x\/}} $*$ ({\it{y\/}} ${}${\bf{mod}}${}$ {\it{z\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{x\/}} $*$ {\it{z\/}}) ${}${\bf{mod}}${}$ ({\it{y\/}} $*$ {\it{z\/}})) $=$ (({\it{x\/}} ${}${\bf{mod}}${}$ {\it{y\/}}) $*$ {\it{z\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-difference1 \\ \index{remainder-difference1}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $-$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $-$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{double-remainder-induction} \\  
\=\+{\rm{double-remainder-induction}}\,({\it{a\/}}, {\it{b\/}}, {\it{c\/}})\index{double-remainder-induction} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{c\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{a\/}} $<$ {\it{c\/}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{b\/}} $<$ {\it{c\/}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{double-remainder-induction}}\,({\it{a\/}} $-$ {\it{c\/}}, {\it{b\/}} $-$ {\it{c\/}}, {\it{c\/}})\index{double-remainder-induction}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-difference2 \\ \index{remainder-difference2}
\=\+((({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }{\it{c\/}} $-$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-difference3 \\ \index{remainder-difference3}
\=\+((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }{\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable remainder-difference3.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  equal-remainder-difference-0 \\ \index{equal-remainder-difference-0}
\=\+((({\it{a\/}} $-$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\leq$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable equal-remainder-difference-0.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  lessp-plus-fact \\ \index{lessp-plus-fact}
\=\+((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{c\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ ({\it{b\/}} $<$ {\it{c\/}}) $\wedge$ ({\it{a\/}} $<$ {\it{x\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $+$ {\it{b\/}}) $<$ {\it{c\/}}) $=$ {\bf{t}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable lessp-plus-fact.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  remainder-plus-fact \\ \index{remainder-plus-fact}
\=\+((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{c\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ ({\it{a\/}} $<$ {\it{x\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $+$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{a\/}} $+$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-plus-times-times-proof \\ \index{remainder-plus-times-times-proo!f}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) ${}${\bf{mod}}${}$ ({\it{b\/}} $*$ {\it{d\/}})) \\ 
$=$$\;\;\;\;$({\it{a\/}} $+$ (({\it{b\/}} $*$ {\it{c\/}}) ${}${\bf{mod}}${}$ ({\it{b\/}} $*$ {\it{d\/}}))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-plus-times-times \\ \index{remainder-plus-times-times}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+(({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) ${}${\bf{mod}}${}$ ({\it{b\/}} $*$ {\it{d\/}})) \\ 
$=$$\;\;\;\;$({\it{a\/}} $+$ (({\it{b\/}} $*$ {\it{c\/}}) ${}${\bf{mod}}${}$ ({\it{b\/}} $*$ {\it{d\/}}))))\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{a\/}} $+$ ({\it{c\/}} $*$ {\it{b\/}})) ${}${\bf{mod}}${}$ ({\it{d\/}} $*$ {\it{b\/}})) \\ 
$=$$\;\;\;\;$({\it{a\/}} $+$ (({\it{c\/}} $*$ {\it{b\/}}) ${}${\bf{mod}}${}$ ({\it{d\/}} $*$ {\it{b\/}}))))\-)\-\-
\end{tabbing}

\begin{verbatim}; REMAINDER-PLUS-TIMES-TIMES-INSTANCE is the completion of the rules
; TIMES-DISTRIBUTES-OVER-PLUS, REMAINDER-TIMES-TIMES and REMAINDER-PLUS-TIMES-TIMES

\end{verbatim}\begin{tabbing}{\sc Theorem}:  remainder-plus-times-times-instance \\ \index{remainder-plus-times-times-inst!ance}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+(({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}}) $+$ ({\it{b\/}} $*$ {\it{d\/}})) ${}${\bf{mod}}${}$ ({\it{b\/}} $*$ {\it{e\/}})) \\ 
$=$$\;\;\;\;$({\it{a\/}} $+$ ({\it{b\/}} $*$ (({\it{c\/}} $+$ {\it{d\/}}) ${}${\bf{mod}}${}$ {\it{e\/}}))))\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{a\/}} $+$ ({\it{c\/}} $*$ {\it{b\/}}) $+$ ({\it{d\/}} $*$ {\it{b\/}})) ${}${\bf{mod}}${}$ ({\it{e\/}} $*$ {\it{b\/}})) \\ 
$=$$\;\;\;\;$({\it{a\/}} $+$ ({\it{b\/}} $*$ (({\it{c\/}} $+$ {\it{d\/}}) ${}${\bf{mod}}${}$ {\it{e\/}}))))\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-remainder \\ \index{remainder-remainder}
(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{a\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{n\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) ${}${\bf{mod}}${}$ {\it{a\/}}) $=$ ({\it{n\/}} ${}${\bf{mod}}${}$ {\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-1-arg1 \\ \index{remainder-1-arg1}
\=\+({\tt{1}} ${}${\bf{mod}}${}$ {\it{x\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\tt{1}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-1-arg2 \\ \index{remainder-1-arg2}
({\it{y\/}} ${}${\bf{mod}}${}$ {\tt{1}}) $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-x-x \\ \index{remainder-x-x}
({\it{x\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  transitivity-of-divides \\ \index{transitivity-of-divides}
((({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}})) $\rightarrow$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}})
\end{tabbing}


\begin{verbatim}; Define the available  theory of  remainder.   To  get the list of
; events to put in the theory,  evaluate the following  form in NQTHM at
; this point  in  the  script. This   form  lists all lemmas   which are
; globally enabled, and which have non-null lemma type.
;
; 
; (let ((lemmas (lemmas)))
;   (remove-if-not (function (lambda (x)
; 			     (and (member x lemmas)
; 				  (not (assoc x disabled-lemmas))
; 				  (not (null (nth 2 (get x 'event))))
; 				  (not (member x (nth 2 (get 'addition 'event))))
; 				  (not (member x (nth 2 (get 'multiplication 'event)))))))
; 		 chronology))


\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{remainders}} to consist of the following events: lessp-remainder,
remainder-noop,
remainder-of-non-number,
remainder-zero,
remainder-quotient-elim,
remainder-add1,
remainder-plus,
equal-remainder-plus-0,
remainder-times1,
remainder-times1-instance,
remainder-times2,
remainder-times2-instance,
remainder-difference1,
remainder-difference2,
remainder-plus-times-times,
remainder-plus-times-times-instance,
remainder-remainder,
remainder-1-arg1,
remainder-1-arg2,
remainder-x-x.\index{remainders}

\addvspace{18pt}

\begin{verbatim}; ---------- QUOTIENT, DIVIDES  ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  quotient-noop \\ \index{quotient-noop}
({\it{b\/}} $=$ {\tt{1}}) $\rightarrow$ (({\it{a\/}} $\div$ {\it{b\/}}) $=$ {\rm{fix}}\,({\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-of-non-number \\ \index{quotient-of-non-number}
({\it{a\/}} $\not\in\;${\bf{N}}${}$) $\rightarrow$ (({\it{a\/}} $\div$ {\it{n\/}}) $=$ ({\tt{0}} $\div$ {\it{n\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-zero \\ \index{quotient-zero}
({\it{x\/}} $\simeq {\tt{0}}$) $\rightarrow$ (({\it{y\/}} $\div$ {\it{x\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-add1 \\ \index{quotient-add1}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(($1\;+$ {\it{a\/}}) $\div$ {\it{b\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $=$ {\tt{1}}$\;\;${\bf then }$1\;+$ ({\it{a\/}} $\div$ {\it{b\/}}) \\ 
{\bf else }{\it{a\/}} $\div$ {\it{b\/}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-quotient-0 \\ \index{equal-quotient-0}
(({\it{a\/}} $\div$ {\it{b\/}}) $=$ {\tt{0}}) $=$ (({\it{b\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{a\/}} $<$ {\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-sub1 \\ \index{quotient-sub1}
\=\+(({\it{a\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{b\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-\;1$) $\div$ {\it{b\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}}) $=$ {\tt{0}}$\;\;${\bf then }({\it{a\/}} $\div$ {\it{b\/}}) $-\;1$ \\ 
{\bf else }{\it{a\/}} $\div$ {\it{b\/}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-plus-proof \\ \index{quotient-plus-proof}
(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{a\/}} $+$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ (({\it{a\/}} $\div$ {\it{c\/}}) $+$ ({\it{b\/}} $\div$ {\it{c\/}})))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-plus \\ \index{quotient-plus}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+((({\it{a\/}} $+$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ (({\it{a\/}} $\div$ {\it{c\/}}) $+$ ({\it{b\/}} $\div$ {\it{c\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{b\/}} $+$ {\it{a\/}}) $\div$ {\it{c\/}}) $=$ (({\it{a\/}} $\div$ {\it{c\/}}) $+$ ({\it{b\/}} $\div$ {\it{c\/}}))) \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{x\/}} $+$ {\it{y\/}} $+$ {\it{a\/}}) $\div$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$((({\it{x\/}} $+$ {\it{y\/}}) $\div$ {\it{c\/}}) $+$ ({\it{a\/}} $\div$ {\it{c\/}})))\-)\-\-
\end{tabbing}

\begin{verbatim}; I need QUOTIENT-TIMES-INSTANCE to prove the more general QUOTIENT-TIMES,
; but I want QUOTIENT-TIMES-INSTANCE to be tried first (i.e. come after
; QUOTIENT-TIMES in the event list.) So first, prove QUOTIENT-TIMES-INSTANCE-TEMP,
; then prove QUOTIENT-TIMES, and finally give QUOTIENT-TIMES-INSTANCE.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  quotient-times-instance-temp-proof \\ \index{quotient-times-instance-temp-pr!oof}
\=\+(({\it{y\/}} $*$ {\it{x\/}}) $\div$ {\it{y\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-times-instance-temp \\ \index{quotient-times-instance-temp}
\=\+(\=\+(({\it{y\/}} $*$ {\it{x\/}}) $\div$ {\it{y\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{x\/}} $*$ {\it{y\/}}) $\div$ {\it{y\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable quotient-times-instance-temp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  quotient-times-proof \\ \index{quotient-times-proof}
(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{a\/}} $*$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ ({\it{b\/}} $*$ ({\it{a\/}} $\div$ {\it{c\/}})))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-times \\ \index{quotient-times}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+((({\it{a\/}} $*$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ ({\it{b\/}} $*$ ({\it{a\/}} $\div$ {\it{c\/}}))) \\ 
$\wedge$$\;\;\;\;$((({\it{b\/}} $*$ {\it{a\/}}) $\div$ {\it{c\/}}) $=$ ({\it{b\/}} $*$ ({\it{a\/}} $\div$ {\it{c\/}}))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-times-instance \\ \index{quotient-times-instance}
\=\+(\=\+(({\it{y\/}} $*$ {\it{x\/}}) $\div$ {\it{y\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{x\/}} $*$ {\it{y\/}}) $\div$ {\it{y\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{fix}}\,({\it{x\/}})$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-times-times-proof \\ \index{quotient-times-times-proof}
\=\+(({\it{x\/}} $*$ {\it{y\/}}) $\div$ ({\it{x\/}} $*$ {\it{z\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\it{y\/}} $\div$ {\it{z\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-times-times \\ \index{quotient-times-times}
\=\+(\=\+(({\it{x\/}} $*$ {\it{y\/}}) $\div$ ({\it{x\/}} $*$ {\it{z\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\it{y\/}} $\div$ {\it{z\/}}$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{x\/}} $*$ {\it{z\/}}) $\div$ ({\it{y\/}} $*$ {\it{z\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{z\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\it{x\/}} $\div$ {\it{y\/}}$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable quotient-times-times.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  quotient-difference1 \\ \index{quotient-difference1}
\=\+(({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ ({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $-$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ (({\it{a\/}} $\div$ {\it{c\/}}) $-$ ({\it{b\/}} $\div$ {\it{c\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-lessp-arg1 \\ \index{quotient-lessp-arg1}
({\it{a\/}} $<$ {\it{b\/}}) $\rightarrow$ (({\it{a\/}} $\div$ {\it{b\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-difference2 \\ \index{quotient-difference2}
\=\+((({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-$ {\it{b\/}}) $\div$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} $\div$ {\it{c\/}}) $-$ ($1\;+$ ({\it{b\/}} $\div$ {\it{c\/}})) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-difference3 \\ \index{quotient-difference3}
\=\+((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-$ {\it{b\/}}) $\div$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} $\div$ {\it{c\/}}) $-$ ({\it{b\/}} $\div$ {\it{c\/}}) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-equals-its-first-argument \\ \index{remainder-equals-its-first-argu!ment}
({\it{a\/}} $=$ ({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}})) $=$ (({\it{a\/}} $\in\;${\bf{N}}${}$) $\wedge$ (({\it{b\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{a\/}} $<$ {\it{b\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable remainder-equals-its-first-argument.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  quotient-remainder-times \\ \index{quotient-remainder-times}
(({\it{x\/}} ${}${\bf{mod}}${}$ ({\it{a\/}} $*$ {\it{b\/}})) $\div$ {\it{a\/}}) $=$ (({\it{x\/}} $\div$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{b\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-remainder \\ \index{quotient-remainder}
(({\it{c\/}} ${}${\bf{mod}}${}$ {\it{a\/}}) $=$ {\tt{0}}) $\rightarrow$ ((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $\div$ {\it{a\/}}) $=$ (({\it{b\/}} $\div$ {\it{a\/}}) ${}${\bf{mod}}${}$ ({\it{c\/}} $\div$ {\it{a\/}})))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-remainder-instance \\ \index{quotient-remainder-instance}
(({\it{x\/}} ${}${\bf{mod}}${}$ ({\it{a\/}} $*$ {\it{b\/}})) $\div$ {\it{a\/}}) $=$ (({\it{x\/}} $\div$ {\it{a\/}}) ${}${\bf{mod}}${}$ {\it{b\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-plus-fact \\ \index{quotient-plus-fact}
\=\+((({\it{b\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{c\/}} ${}${\bf{mod}}${}$ {\it{x\/}}) $=$ {\tt{0}}) $\wedge$ ({\it{a\/}} $<$ {\it{x\/}})) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $+$ {\it{b\/}}) $\div$ {\it{c\/}}) $=$ ({\it{b\/}} $\div$ {\it{c\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-plus-times-times-proof \\ \index{quotient-plus-times-times-proof}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$((({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) $\div$ ({\it{b\/}} $*$ {\it{d\/}})) $=$ (({\it{b\/}} $*$ {\it{c\/}}) $\div$ ({\it{b\/}} $*$ {\it{d\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-plus-times-times \\ \index{quotient-plus-times-times}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+((({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) $\div$ ({\it{b\/}} $*$ {\it{d\/}})) $=$ (({\it{b\/}} $*$ {\it{c\/}}) $\div$ ({\it{b\/}} $*$ {\it{d\/}}))) \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}})) $\div$ ({\it{b\/}} $*$ {\it{d\/}})) \\ 
$=$$\;\;\;\;$(({\it{b\/}} $*$ {\it{c\/}}) $\div$ ({\it{b\/}} $*$ {\it{d\/}})))\-)\-\-
\end{tabbing}

\begin{verbatim}; QUOTIENT-PLUS-TIMES-TIMES-INSTANCE is the completion of the rules
; QUOTIENT-TIMES-TIMES, QUOTIENT-PLUS-TIMES-TIMES and TIMES-DISTRIBUTES-OVER-PLUS

\end{verbatim}\begin{tabbing}{\sc Theorem}:  quotient-plus-times-times-instance \\ \index{quotient-plus-times-times-insta!nce}
\=\+({\it{a\/}} $<$ {\it{b\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+(({\it{a\/}} $+$ ({\it{b\/}} $*$ {\it{c\/}}) $+$ ({\it{b\/}} $*$ {\it{d\/}})) $\div$ ({\it{b\/}} $*$ {\it{e\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }({\it{c\/}} $+$ {\it{d\/}}) $\div$ {\it{e\/}}$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{a\/}} $+$ ({\it{c\/}} $*$ {\it{b\/}}) $+$ ({\it{d\/}} $*$ {\it{b\/}})) $\div$ ({\it{e\/}} $*$ {\it{b\/}})) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }({\it{d\/}} $+$ {\it{c\/}}) $\div$ {\it{e\/}}$\;${\bf  endif}\-)\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-quotient \\ \index{quotient-quotient}
(({\it{b\/}} $\div$ {\it{a\/}}) $\div$ {\it{c\/}}) $=$ ({\it{b\/}} $\div$ ({\it{a\/}} $*$ {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  leq-quotient \\ \index{leq-quotient}
({\it{a\/}} $<$ {\it{b\/}}) $\rightarrow$ (({\it{a\/}} $\div$ {\it{c\/}}) $\leq$ ({\it{b\/}} $\div$ {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-1-arg2 \\ \index{quotient-1-arg2}
({\it{n\/}} $\div$ {\tt{1}}) $=$ {\rm{fix}}\,({\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-1-arg1-casesplit \\ \index{quotient-1-arg1-casesplit}
({\it{n\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{n\/}} $=$ {\tt{1}}) $\vee$ ({\tt{1}} $<$ {\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-1-arg1 \\ \index{quotient-1-arg1}
\=\+({\tt{1}} $\div$ {\it{n\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $=$ {\tt{1}}$\;\;${\bf then }{\tt{1}} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  quotient-x-x \\ \index{quotient-x-x}
({\it{x\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ (({\it{x\/}} $\div$ {\it{x\/}}) $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-quotient \\ \index{lessp-quotient}
(({\it{i\/}} $\div$ {\it{j\/}}) $<$ {\it{i\/}}) $=$ (({\it{i\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{j\/}} $\not=$ {\tt{1}}))
\end{tabbing}


\begin{verbatim};; Metalemma to cancel quotient-times expressions

;; ex.
;; (quotient (times a b) (times c (times d a)))  -> 
;;                                           (if (not (zerop a))
;;                                               (quotient (fix b) (times c d))
;;                                            (zero))
;;

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-quotient-times} \\  
\=\+{\rm{cancel-quotient-times}}\,({\it{x\/}})\index{cancel-quotient-times} \\ 
$=$$\;\;\;\;$\=\+{\bf if }\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{quotient}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}})\- \\ 
{\bf then }\=\+{\bf let }\=\+{\it{inboth\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe})\-\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{inboth\/}}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{and-not-zerop-tree}}\,({\it{inboth\/}})\index{and-not-zerop-tree}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{quotient}}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree}, \\ 
{\rm{times-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{times-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{times-fringe}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{times-tree})\-, \\ 
{\tt{'}}{\tt{(}}{\tt{zero}}{\tt{)}})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  zerop-makes-quotient-zero-bridge \\ \index{zerop-makes-quotient-zero-bridge}
\=\+(\=\+({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{times}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{and-not-zerop-tree}}\,({\rm{bagint}}\,({\rm{times-fringe}}\,({\it{x\/}})\index{times-fringe}, {\rm{times-fringe}}\,({\it{y\/}})\index{times-fringe})\index{bagint})\index{and-not-zerop-tree}, \\ 
{\it{a\/}})\-))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}})) \\ 
$\div$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{y\/}}), {\it{a\/}}) $*$ {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{y\/}}), {\it{a\/}})))\- \\ 
$=$$\;\;\;\;${\tt{0}})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable zerop-makes-quotient-zero-bridge.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-quotient-times-tree-bagdiff \\ \index{eval\$-quotient-times-tree-bagdi!ff}
\=\+({\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\wedge$ {\rm{subbagp}}\,({\it{x\/}}, {\it{z\/}})\index{subbagp} $\wedge$ {\rm{eval\$}}\,({\bf{t}}, {\rm{and-not-zerop-tree}}\,({\it{x\/}})\index{and-not-zerop-tree}, {\it{a\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}) \\ 
$\div$$\;\;\;\;${\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\rm{bagdiff}}\,({\it{z\/}}, {\it{x\/}})\index{bagdiff})\index{times-tree}, {\it{a\/}}))\- \\ 
$=$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{y\/}})\index{times-tree}, {\it{a\/}}) $\div$ {\rm{eval\$}}\,({\bf{t}}, {\rm{times-tree}}\,({\it{z\/}})\index{times-tree}, {\it{a\/}})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$-quotient-times-tree-bagdiff.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-quotient-times \\ \index{correctness-of-cancel-quotient-ti!mes}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-quotient-times}}\,({\it{x\/}})\index{cancel-quotient-times}, {\it{a\/}})
\end{tabbing}

\begin{verbatim}; Define the available theory of quotient.  To get the list of events to
; put in the theory, evaluate the following form in NQTHM at  this point
; in the script. This form lists all  lemmas which are globally enabled,
; and which have non-null lemma type.
;
; 
; (let ((lemmas (lemmas)))
;   (remove-if-not (function (lambda (x)
; 			     (and (member x lemmas)
; 				  (not (assoc x disabled-lemmas))
; 				  (not (null (nth 2 (get x 'event))))
; 				  (not (member x (nth 2 (get 'addition 'event))))
; 				  (not (member x (nth 2 (get 'multiplication 'event))))
; 				  (not (member x (nth 2 (get 'remainders 'event)))))))
; 		 chronology))



\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{quotients}} to consist of the following events: quotient-noop,
quotient-of-non-number,
quotient-zero,
quotient-add1,
equal-quotient-0,
quotient-sub1,
quotient-plus,
quotient-times,
quotient-times-instance,
quotient-difference1,
quotient-lessp-arg1,
quotient-difference2,
quotient-difference3,
quotient-remainder-times,
quotient-remainder,
quotient-remainder-instance,
quotient-plus-times-times,
quotient-plus-times-times-instance,
quotient-quotient,
quotient-1-arg2,
quotient-1-arg1,
quotient-x-x,
lessp-quotient,
correctness-of-cancel-quotient-times.\index{quotients}

\addvspace{18pt}


\begin{verbatim};;; exp, log, and gcd

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


\begin{tabbing}{\sc Definition}:\index{log} \\  
\=\+{\rm{log}}\,({\it{base\/}}, {\it{n\/}})\index{log} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{base\/}} $<$ {\tt{2}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ {\rm{log}}\,({\it{base\/}}, {\it{n\/}} $\div$ {\it{base\/}})\index{log}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{gcd} \\  
\=\+{\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{fix}}\,({\it{y\/}}) \\ 
{\bf elseif }{\it{y\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\it{x\/}} \\ 
{\bf elseif }{\it{x\/}} $<$ {\it{y\/}}$\;\;${\bf then }{\rm{gcd}}\,({\it{x\/}}, {\it{y\/}} $-$ {\it{x\/}})\index{gcd} \\ 
{\bf else }{\rm{gcd}}\,({\it{x\/}} $-$ {\it{y\/}}, {\it{y\/}})\index{gcd}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-exp \\ \index{remainder-exp}
({\it{k\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ (({\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp} ${}${\bf{mod}}${}$ {\it{n\/}}) $=$ {\tt{0}})
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{double-number-induction} \\  
\=\+{\rm{double-number-induction}}\,({\it{i\/}}, {\it{j\/}})\index{double-number-induction} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{i\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{j\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{double-number-induction}}\,({\it{i\/}} $-\;1$, {\it{j\/}} $-\;1$)\index{double-number-induction}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  remainder-exp-exp \\ \index{remainder-exp-exp}
({\it{i\/}} $\leq$ {\it{j\/}}) $\rightarrow$ (({\rm{exp}}\,({\it{a\/}}, {\it{j\/}})\index{exp} ${}${\bf{mod}}${}$ {\rm{exp}}\,({\it{a\/}}, {\it{i\/}})\index{exp}) $=$ {\tt{0}})
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  quotient-exp \\ \index{quotient-exp}
\=\+({\it{k\/}} $\not\simeq {\tt{0}}$) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp} $\div$ {\it{n\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{exp}}\,({\it{n\/}}, {\it{k\/}} $-\;1$)\index{exp}$\;${\bf  endif}\-)\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  exp-zero \\ \index{exp-zero}
({\it{k\/}} $\simeq {\tt{0}}$) $\rightarrow$ ({\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-add1 \\ \index{exp-add1}
{\rm{exp}}\,({\it{n\/}}, $1\;+$ {\it{k\/}})\index{exp} $=$ ({\it{n\/}} $*$ {\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-plus \\ \index{exp-plus}
{\rm{exp}}\,({\it{i\/}}, {\it{j\/}} $+$ {\it{k\/}})\index{exp} $=$ ({\rm{exp}}\,({\it{i\/}}, {\it{j\/}})\index{exp} $*$ {\rm{exp}}\,({\it{i\/}}, {\it{k\/}})\index{exp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-0-arg1 \\ \index{exp-0-arg1}
\=\+{\rm{exp}}\,({\tt{0}}, {\it{k\/}})\index{exp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{k\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{1}} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-1-arg1 \\ \index{exp-1-arg1}
{\rm{exp}}\,({\tt{1}}, {\it{k\/}})\index{exp} $=$ {\tt{1}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-0-arg2 \\ \index{exp-0-arg2}
{\rm{exp}}\,({\it{n\/}}, {\tt{0}})\index{exp} $=$ {\tt{1}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-times \\ \index{exp-times}
{\rm{exp}}\,({\it{i\/}} $*$ {\it{j\/}}, {\it{k\/}})\index{exp} $=$ ({\rm{exp}}\,({\it{i\/}}, {\it{k\/}})\index{exp} $*$ {\rm{exp}}\,({\it{j\/}}, {\it{k\/}})\index{exp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-exp \\ \index{exp-exp}
{\rm{exp}}\,({\rm{exp}}\,({\it{i\/}}, {\it{j\/}})\index{exp}, {\it{k\/}})\index{exp} $=$ {\rm{exp}}\,({\it{i\/}}, {\it{j\/}} $*$ {\it{k\/}})\index{exp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-exp-0 \\ \index{equal-exp-0}
({\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp} $=$ {\tt{0}}) $=$ (({\it{n\/}} $\simeq {\tt{0}}$) $\wedge$ ({\it{k\/}} $\not\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-exp-1 \\ \index{equal-exp-1}
\=\+({\rm{exp}}\,({\it{n\/}}, {\it{k\/}})\index{exp} $=$ {\tt{1}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{k\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\it{n\/}} $=$ {\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  exp-difference \\ \index{exp-difference}
(({\it{c\/}} $\leq$ {\it{b\/}}) $\wedge$ ({\it{a\/}} $\not\simeq {\tt{0}}$)) $\rightarrow$ ({\rm{exp}}\,({\it{a\/}}, {\it{b\/}} $-$ {\it{c\/}})\index{exp} $=$ ({\rm{exp}}\,({\it{a\/}}, {\it{b\/}})\index{exp} $\div$ {\rm{exp}}\,({\it{a\/}}, {\it{c\/}})\index{exp}))
\end{tabbing}


\noindent{\sc Event}:   Let us define the theory {\it{exponentiation}} to consist of the following events: equal-exp-0,
equal-exp-1,
exp-exp,
exp-add1,
exp-times,
exp-1-arg1,
exp-zero,
exp-0-arg2,
exp-0-arg1,
exp-difference,
exp-plus,
quotient-exp,
remainder-exp-exp,
remainder-exp.\index{exponentiation}

\addvspace{18pt}


\begin{tabbing}{\sc Theorem}:  equal-log-0 \\ \index{equal-log-0}
({\rm{log}}\,({\it{base\/}}, {\it{n\/}})\index{log} $=$ {\tt{0}}) $=$ (({\it{base\/}} $<$ {\tt{2}}) $\vee$ ({\it{n\/}} $\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-0 \\ \index{log-0}
({\it{n\/}} $\simeq {\tt{0}}$) $\rightarrow$ ({\rm{log}}\,({\it{base\/}}, {\it{n\/}})\index{log} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-1 \\ \index{log-1}
({\tt{1}} $<$ {\it{base\/}}) $\rightarrow$ ({\rm{log}}\,({\it{base\/}}, {\tt{1}})\index{log} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{double-log-induction} \\  
\=\+{\rm{double-log-induction}}\,({\it{base\/}}, {\it{a\/}}, {\it{b\/}})\index{double-log-induction} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{base\/}} $<$ {\tt{2}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{a\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{double-log-induction}}\,({\it{base\/}}, {\it{a\/}} $\div$ {\it{base\/}}, {\it{b\/}} $\div$ {\it{base\/}})\index{double-log-induction}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  leq-log-log \\ \index{leq-log-log}
({\it{n\/}} $\leq$ {\it{m\/}}) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $\leq$ {\rm{log}}\,({\it{c\/}}, {\it{m\/}})\index{log})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-quotient \\ \index{log-quotient}
({\tt{1}} $<$ {\it{c\/}}) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ {\it{c\/}})\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $-\;1$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-quotient-times-proof \\ \index{log-quotient-times-proof}
({\tt{1}} $<$ {\it{c\/}}) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ ({\it{c\/}} $*$ {\it{m\/}}))\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ {\it{m\/}})\index{log} $-\;1$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-quotient-times \\ \index{log-quotient-times}
\=\+({\tt{1}} $<$ {\it{c\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ ({\it{c\/}} $*$ {\it{m\/}}))\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ {\it{m\/}})\index{log} $-\;1$)) \\ 
$\wedge$$\;\;\;\;$({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ ({\it{m\/}} $*$ {\it{c\/}}))\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ {\it{m\/}})\index{log} $-\;1$)))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-quotient-exp \\ \index{log-quotient-exp}
({\tt{1}} $<$ {\it{c\/}}) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $\div$ {\rm{exp}}\,({\it{c\/}}, {\it{m\/}})\index{exp})\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $-$ {\it{m\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-times-proof \\ \index{log-times-proof}
(({\tt{1}} $<$ {\it{c\/}}) $\wedge$ ({\it{n\/}} $\not\simeq {\tt{0}}$)) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{c\/}} $*$ {\it{n\/}})\index{log} $=$ ($1\;+$ {\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-times \\ \index{log-times}
\=\+(({\tt{1}} $<$ {\it{c\/}}) $\wedge$ ({\it{n\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{log}}\,({\it{c\/}}, {\it{c\/}} $*$ {\it{n\/}})\index{log} $=$ ($1\;+$ {\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log})) \\ 
$\wedge$$\;\;\;\;$({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $*$ {\it{c\/}})\index{log} $=$ ($1\;+$ {\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-times-exp-proof \\ \index{log-times-exp-proof}
(({\tt{1}} $<$ {\it{c\/}}) $\wedge$ ({\it{n\/}} $\not\simeq {\tt{0}}$)) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $*$ {\rm{exp}}\,({\it{c\/}}, {\it{m\/}})\index{exp})\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $+$ {\it{m\/}}))
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  log-times-exp \\ \index{log-times-exp}
\=\+(({\tt{1}} $<$ {\it{c\/}}) $\wedge$ ({\it{n\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{log}}\,({\it{c\/}}, {\it{n\/}} $*$ {\rm{exp}}\,({\it{c\/}}, {\it{m\/}})\index{exp})\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $+$ {\it{m\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{log}}\,({\it{c\/}}, {\rm{exp}}\,({\it{c\/}}, {\it{m\/}})\index{exp} $*$ {\it{n\/}})\index{log} $=$ ({\rm{log}}\,({\it{c\/}}, {\it{n\/}})\index{log} $+$ {\it{m\/}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  log-exp \\ \index{log-exp}
({\tt{1}} $<$ {\it{c\/}}) $\rightarrow$ ({\rm{log}}\,({\it{c\/}}, {\rm{exp}}\,({\it{c\/}}, {\it{n\/}})\index{exp})\index{log} $=$ ($1\;+$ {\it{n\/}}))
\end{tabbing}


\noindent{\sc Event}:   Let us define the theory {\it{logs}} to consist of the following events: log-exp,
log-times-exp,
log-times,
log-quotient-exp,
log-quotient-times,
log-quotient,
log-1,
log-0,
equal-log-0,
exp-exp.\index{logs}

\addvspace{18pt}



\begin{tabbing}{\sc Theorem}:  commutativity-of-gcd \\ \index{commutativity-of-gcd}
{\rm{gcd}}\,({\it{b\/}}, {\it{a\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{single-number-induction} \\  
\=\+{\rm{single-number-induction}}\,({\it{n\/}})\index{single-number-induction} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\rm{single-number-induction}}\,({\it{n\/}} $-\;1$)\index{single-number-induction}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-0 \\ \index{gcd-0}
({\rm{gcd}}\,({\tt{0}}, {\it{x\/}})\index{gcd} $=$ {\rm{fix}}\,({\it{x\/}})) $\wedge$ ({\rm{gcd}}\,({\it{x\/}}, {\tt{0}})\index{gcd} $=$ {\rm{fix}}\,({\it{x\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-1 \\ \index{gcd-1}
({\rm{gcd}}\,({\tt{1}}, {\it{x\/}})\index{gcd} $=$ {\tt{1}}) $\wedge$ ({\rm{gcd}}\,({\it{x\/}}, {\tt{1}})\index{gcd} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-gcd-0 \\ \index{equal-gcd-0}
({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd} $=$ {\tt{0}}) $=$ (({\it{a\/}} $\simeq {\tt{0}}$) $\wedge$ ({\it{b\/}} $\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-gcd \\ \index{lessp-gcd}
({\it{b\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ((({\it{b\/}} $<$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}) $=$ {\bf{f}}) $\wedge$ (({\it{b\/}} $<$ {\rm{gcd}}\,({\it{b\/}}, {\it{a\/}})\index{gcd}) $=$ {\bf{f}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-plus-instance-temp-proof \\ \index{gcd-plus-instance-temp-proof}
{\rm{gcd}}\,({\it{a\/}}, {\it{a\/}} $+$ {\it{b\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-plus-instance-temp \\ \index{gcd-plus-instance-temp}
({\rm{gcd}}\,({\it{a\/}}, {\it{a\/}} $+$ {\it{b\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}) $\wedge$ ({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}} $+$ {\it{a\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-plus-proof \\ \index{gcd-plus-proof}
(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{a\/}}) $=$ {\tt{0}}) $\rightarrow$ ({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}} $+$ {\it{c\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-plus \\ \index{gcd-plus}
\=\+(({\it{b\/}} ${}${\bf{mod}}${}$ {\it{a\/}}) $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}} $+$ {\it{c\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd}) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{a\/}}, {\it{c\/}} $+$ {\it{b\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd}) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{b\/}} $+$ {\it{c\/}}, {\it{a\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd}) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{c\/}} $+$ {\it{b\/}}, {\it{a\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-plus-instance \\ \index{gcd-plus-instance}
({\rm{gcd}}\,({\it{a\/}}, {\it{a\/}} $+$ {\it{b\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}) $\wedge$ ({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}} $+$ {\it{a\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-gcd \\ \index{remainder-gcd}
(({\it{a\/}} ${}${\bf{mod}}${}$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}) $=$ {\tt{0}}) $\wedge$ (({\it{b\/}} ${}${\bf{mod}}${}$ {\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  distributivity-of-times-over-gcd-proof \\ \index{distributivity-of-times-over-gc!d-proof}
{\rm{gcd}}\,({\it{x\/}} $*$ {\it{z\/}}, {\it{y\/}} $*$ {\it{z\/}})\index{gcd} $=$ ({\it{z\/}} $*$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  distributivity-of-times-over-gcd \\ \index{distributivity-of-times-over-gc!d}
\=\+({\rm{gcd}}\,({\it{x\/}} $*$ {\it{z\/}}, {\it{y\/}} $*$ {\it{z\/}})\index{gcd} $=$ ({\it{z\/}} $*$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{z\/}} $*$ {\it{x\/}}, {\it{y\/}} $*$ {\it{z\/}})\index{gcd} $=$ ({\it{z\/}} $*$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{x\/}} $*$ {\it{z\/}}, {\it{z\/}} $*$ {\it{y\/}})\index{gcd} $=$ ({\it{z\/}} $*$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})) \\ 
$\wedge$$\;\;\;\;$({\rm{gcd}}\,({\it{z\/}} $*$ {\it{x\/}}, {\it{z\/}} $*$ {\it{y\/}})\index{gcd} $=$ ({\it{z\/}} $*$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-is-the-greatest \\ \index{gcd-is-the-greatest}
\=\+(({\it{x\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\it{y\/}} $\not\simeq {\tt{0}}$) $\wedge$ (({\it{x\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{y\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$({\it{z\/}} $\leq$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  common-divisor-divides-gcd \\ \index{common-divisor-divides-gcd}
((({\it{x\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}}) $\wedge$ (({\it{y\/}} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}})) $\rightarrow$ (({\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd} ${}${\bf{mod}}${}$ {\it{z\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{verbatim}; We prove ASSOCIATIVITY-OF-GCD and COMMUTATIVITY2-OF-GCD roughly the same way.
; Use GCD-IS-THE-GREATEST twice to show that each side of the equality is
; less than or equal to the other side.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  associativity-of-gcd-zero-case \\ \index{associativity-of-gcd-zero-case}
(({\it{a\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{b\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{c\/}} $\simeq {\tt{0}}$)) $\rightarrow$ ({\rm{gcd}}\,({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}, {\it{c\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\rm{gcd}}\,({\it{b\/}}, {\it{c\/}})\index{gcd})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-gcd \\ \index{associativity-of-gcd}
{\rm{gcd}}\,({\rm{gcd}}\,({\it{a\/}}, {\it{b\/}})\index{gcd}, {\it{c\/}})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\rm{gcd}}\,({\it{b\/}}, {\it{c\/}})\index{gcd})\index{gcd}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-gcd-zero-case \\ \index{commutativity2-of-gcd-zero-case}
(({\it{a\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{b\/}} $\simeq {\tt{0}}$) $\vee$ ({\it{c\/}} $\simeq {\tt{0}}$)) $\rightarrow$ ({\rm{gcd}}\,({\it{b\/}}, {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\rm{gcd}}\,({\it{b\/}}, {\it{c\/}})\index{gcd})\index{gcd})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-gcd \\ \index{commutativity2-of-gcd}
{\rm{gcd}}\,({\it{b\/}}, {\rm{gcd}}\,({\it{a\/}}, {\it{c\/}})\index{gcd})\index{gcd} $=$ {\rm{gcd}}\,({\it{a\/}}, {\rm{gcd}}\,({\it{b\/}}, {\it{c\/}})\index{gcd})\index{gcd}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-x-x \\ \index{gcd-x-x}
{\rm{gcd}}\,({\it{x\/}}, {\it{x\/}})\index{gcd} $=$ {\rm{fix}}\,({\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  gcd-idempotence \\ \index{gcd-idempotence}
({\rm{gcd}}\,({\it{x\/}}, {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})\index{gcd} $=$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd}) $\wedge$ ({\rm{gcd}}\,({\it{y\/}}, {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})\index{gcd} $=$ {\rm{gcd}}\,({\it{x\/}}, {\it{y\/}})\index{gcd})
\end{tabbing}


\noindent{\sc Event}:   Let us define the theory {\it{gcds}} to consist of the following events: commutativity2-of-gcd,
associativity-of-gcd,
common-divisor-divides-gcd,
distributivity-of-times-over-gcd,
lessp-gcd,
equal-gcd-0,
gcd-0,
gcd-idempotence,
gcd-x-x,
remainder-gcd,
gcd-plus,
gcd-plus-instance,
gcd-1,
commutativity-of-gcd.\index{gcds}

\addvspace{18pt}




\noindent{\sc Event}:   Let us define the theory {\it{naturals}} to consist of the following events: addition,
multiplication,
remainders,
quotients,
exponentiation,
logs,
gcds.\index{naturals}

\addvspace{18pt}

\begin{verbatim}; ------------------------------------------------------------
; was integers.events
; ------------------------------------------------------------


;; By Matt Kaufmann, modified from earlier integer library of Bill
;; Bevier and Matt Wilding.  A few functions (even ILESSP) have
;; been changed, but I expect the functionality of this library to
;; include all the functionality of the old one in most or even all
;; cases.

;; Modified from /local/src/nqthm-libs/integers.events to get ILEQ
;; expressed in terms of ILESSP and IDIFFERENCE in terms of INEG and
;; IPLUS.  There are other changes too.  The highlights are the new
;; metalemmas.

;; I'm going to leave the eval$ rules on that are proved here, and
;; leave eval$ off.

;; My intention is that this library be used in a mode in which ILEQ
;; and IDIFFERENCE are left enabled.  Otherwise, the aforementioned
;; meta lemmas may not be very useful, and also a number of additional
;; replacement rules may be needed.

;; There are three theories created by this library.  INTEGER-DEFNS is
;; a list of definitions of all integer functions (not including the
;; cancellation metafunctions and their auxiliaries, though), except
;; that ILEQ and IDIFFERENCE have been omitted.  This is a useful
;; theory for an ENABLE-THEORY hint when one simply wants to blast all
;; integer functions open, and it's also useful if one wants to close
;; them down with a DISABLE-THEORY hint (perhaps to go with an
;; (ENABLE-THEORY T) hint).  Second, ALL-INTEGER-DEFNS is the same as
;; INTEGER-DEFNS except that ILEQ and IDIFFERENCE are included in this
;; one.  Finally, INTEGERS is a list of all events to be "exported as
;; enabled" from this file when working in a mode where everything not
;; enabled by an ENABLE-THEORY hint is to be disabled.  Notice that
;; some rewrite rules have been included that might appear to be
;; unnecessary in light of the metalemmas; that's because metalemmas
;; only work on tame terms.  However, there's no guarantee that the
;; rewrite rules alone will prove very useful (on non-tame terms).
;; Also notice that INTEGER-DEFNS is disjoint from INTEGERS, since we
;; expect the basic definitions (other than ILEQ and IDIFFERENCE) to
;; remain disabled.

;; It's easy to see what I have and haven't placed in INTEGERS, since
;; I'll simply comment out the event names that I want to exclude (see
;; end of this file).

;; One might wish to consider changing (fix-int (minus ...)) in some
;; of the definitions below to (ineg ...).

;; The following meta rules are in this library.  
;; (A little documentation added by Matt Wilding July 90)
;; 
;; CORRECTNESS-OF-CANCEL-INEG
;;  cancel the first argument of an iplus term with a member of the second 
;;  argument.
;; 
;;  ex:  (iplus (ineg y) (iplus (ineg x) (iplus y z)))  
;;     -->
;;       (iplus (ineg x) (fix-int z))
;; 
;; CORRECTNESS-OF-CANCEL-IPLUS
;;  cancel the sides of an equality of iplus sums
;; 
;;  ex:  (equal (iplus x (iplus y z)) (iplus a (iplus z x)))
;;     -->
;;       (equal (fix-int y) (fix-int a))
;; 
;; CORRECTNESS-OF-CANCEL-IPLUS-ILESSP
;;  cancel the sides of an ilessp inequality of sums
;; 
;;  ex:  (ilessp (iplus x (iplus y z)) (iplus a (iplus z x)))
;;     -->
;;       (ilessp y a)
;; 
;; CORRECTNESS-OF-CANCEL-ITIMES
;;  cancel the sides of an equality of itimes products
;;  
;;  ex: (equal (itimes x (itimes y z)) (itimes a (itimes z x)))
;;     -->
;;      (if (equal (itimes x z) '0)
;;        t
;;        (equal (fix-int y) (fix-int a)))
;; 
;; CORRECTNESS-OF-CANCEL-ITIMES-ILESSP
;;  cancel the sides of an inequality of itimes products
;; 
;;  ex: (ilessp (itimes x (itimes y z)) (itimes a (itimes z x)))
;;     -->
;;      (if (ilessp (itimes x z) '0)
;;         (ilessp a y)
;;        (if (ilessp 0 (itimes x z))
;;           (ilessp y a)
;;           f))
;; 
;; CORRECTNESS-OF-CANCEL-ITIMES-FACTORS
;;  cancel factors in equality terms
;;  ex: (equal (iplus (itimes x y) x) (itimes z x))
;;     -->
;;      (if (equal (fix-int x) '0)
;;         t
;;        (equal (fix-int (plus y 1)) (fix-int z)))
;; 
;; CORRECTNESS-OF-CANCEL-ITIMES-ILESSP-FACTORS
;;  cancel factors in ilessp terms
;;  ex: (equal (iplus (itimes x y) x) (itimes z x))
;;     -->
;;      (if (ilessp x '0)
;;         (ilessp z (iplus y 1))
;;        (if (ilessp '0 x)
;;           (ilessp (iplus y '1) z)
;;          f))
;; 
;; CORRECTNESS-OF-CANCEL-FACTORS-0
;;  factor one side of equality when other side is constant 0
;; 
;;  ex: (equal (iplus x (itimes x y)) '0)
;;     -->
;;      (or (equal (fix-int (iplus '1 y)) '0)
;;          (equal (fix-int x) '0))
;; 
;; CORRECTNESS-OF-CANCEL-FACTORS-ILESSP-0
;;  factor one side of inequality when other side is constant 0
;; 
;;  ex: (ilessp (iplus x (itimes x y)) '0)
;;     -->
;;      (or (and (ilessp (iplus '1 y) '0)
;;               (ilessp '0 x))
;;          (and (ilessp '0 (iplus '1 y))
;;               (ilessp x '0)))
;; 
;; CORRECTNESS-OF-CANCEL-INEG-TERMS-FROM-EQUALITY
;;  rewrite equality to remove ineg terms
;; 
;;  ex: (equal (iplus (ineg x) (ineg y)) (iplus (ineg z) w))
;;     --> 
;;      (equal (fix-int z) (iplus x (iplus y w)))
;; 
;; CORRECTNESS-OF-CANCEL-INEG-TERMS-FROM-INEQUALITY
;;  rewrite inequalities to remove ineg terms
;; 
;;  ex: (ilessp (iplus (ineg x) (ineg y)) (iplus (ineg z) w))
;;     -->
;;      (ilessp (fix-int z) (iplus x (iplus y w)))


;(note-lib "/local/src/nqthm-libs/naturals")

;(compile-uncompiled-defns "xxx")

; --------------------------------------------------------------------------------
; Integers
; --------------------------------------------------------------------------------

#| The function below has no AND or OR, for efficiency
(defn integerp (x)
  (or (numberp x)
      (and (negativep x)
	   (not (zerop (negative-guts x))))))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{integerp} \\  
\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\in\;${\bf{N}}${}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf elseif }{\rm{negativep}}\,({\it{x\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{x\/}}) $\not\simeq {\tt{0}}$ \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{fix-int} \\  
\=\+{\rm{fix-int}}\,({\it{x\/}})\index{fix-int} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{integerp}}\,({\it{x\/}})\index{integerp}$\;\;${\bf then }{\it{x\/}} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; Even though I'll include a definition for izerop here, I'll
;; often avoid using it.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{izerop}$\;\;$
{\rm{izerop}}\,({\it{i\/}})\index{izerop} $=$ ({\rm{fix-int}}\,({\it{i\/}})\index{fix-int} $=$ {\tt{0}})
\end{tabbing}

\begin{verbatim}#| old version:
(defn izerop (i)
  (if (integerp i)
      (equal i 0)
      t))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{ilessp} \\  
\=\+{\rm{ilessp}}\,({\it{i\/}}, {\it{j\/}})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{negativep}}\,({\it{i\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{j\/}}) $<$ {\rm{negative-guts}}\,({\it{i\/}}) \\ 
{\bf elseif }{\it{i\/}} $=$ ($-$ {\tt{0}})$\;\;${\bf then }{\tt{0}} $<$ {\it{j\/}} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\bf{f}} \\ 
{\bf else }{\it{i\/}} $<$ {\it{j\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{ileq}$\;\;$
{\rm{ileq}}\,({\it{i\/}}, {\it{j\/}})\index{ileq} $=$ ($\neg$ {\rm{ilessp}}\,({\it{j\/}}, {\it{i\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus} \\  
\=\+{\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{negativep}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{y\/}}) \\ 
{\bf then }\=\+{\bf if }({\rm{negative-guts}}\,({\it{x\/}}) $\simeq {\tt{0}}$) $\wedge$ ({\rm{negative-guts}}\,({\it{y\/}}) $\simeq {\tt{0}}$)$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$-$ ({\rm{negative-guts}}\,({\it{x\/}}) $+$ {\rm{negative-guts}}\,({\it{y\/}}))$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{y\/}} $<$ {\rm{negative-guts}}\,({\it{x\/}})$\;\;${\bf then }$-$ ({\rm{negative-guts}}\,({\it{x\/}}) $-$ {\it{y\/}}) \\ 
{\bf else }{\it{y\/}} $-$ {\rm{negative-guts}}\,({\it{x\/}})$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{y\/}}) \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $<$ {\rm{negative-guts}}\,({\it{y\/}})$\;\;${\bf then }$-$ ({\rm{negative-guts}}\,({\it{y\/}}) $-$ {\it{x\/}}) \\ 
{\bf else }{\it{x\/}} $-$ {\rm{negative-guts}}\,({\it{y\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}} $+$ {\it{y\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{ineg} \\  
\=\+{\rm{ineg}}\,({\it{x\/}})\index{ineg} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{negativep}}\,({\it{x\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{x\/}}) \\ 
{\bf elseif }{\it{x\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$-$ {\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{idifference}$\;\;$
{\rm{idifference}}\,({\it{x\/}}, {\it{y\/}})\index{idifference} $=$ {\rm{iplus}}\,({\it{x\/}}, {\rm{ineg}}\,({\it{y\/}})\index{ineg})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iabs} \\  
\=\+{\rm{iabs}}\,({\it{i\/}})\index{iabs} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{negativep}}\,({\it{i\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{i\/}}) \\ 
{\bf else }{\rm{fix}}\,({\it{i\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{itimes} \\  
\=\+{\rm{itimes}}\,({\it{i\/}}, {\it{j\/}})\index{itimes} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{negativep}}\,({\it{i\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{i\/}}) $*$ {\rm{negative-guts}}\,({\it{j\/}}) \\ 
{\bf else }{\rm{fix-int}}\,($-$ ({\rm{negative-guts}}\,({\it{i\/}}) $*$ {\it{j\/}}))\index{fix-int}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{fix-int}}\,($-$ ({\it{i\/}} $*$ {\rm{negative-guts}}\,({\it{j\/}})))\index{fix-int} \\ 
{\bf else }{\it{i\/}} $*$ {\it{j\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iquotient} \\  
\=\+{\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{fix-int}}\,({\it{j\/}})\index{fix-int} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\rm{negativep}}\,({\it{i\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{j\/}}) \\ 
{\bf then }\=\+{\bf if }({\rm{negative-guts}}\,({\it{i\/}}) ${}${\bf{mod}}${}$ {\rm{negative-guts}}\,({\it{j\/}})) $=$ {\tt{0}} \\ 
{\bf then }{\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\rm{negative-guts}}\,({\it{j\/}}) \\ 
{\bf else }$1\;+$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\rm{negative-guts}}\,({\it{j\/}}))$\;${\bf  endif}\- \\ 
{\bf elseif }({\rm{negative-guts}}\,({\it{i\/}}) ${}${\bf{mod}}${}$ {\it{j\/}}) $=$ {\tt{0}} \\ 
{\bf then }{\rm{fix-int}}\,($-$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\it{j\/}}))\index{fix-int} \\ 
{\bf else }{\rm{fix-int}}\,($-$ ($1\;+$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\it{j\/}})))\index{fix-int}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{fix-int}}\,($-$ ({\it{i\/}} $\div$ {\rm{negative-guts}}\,({\it{j\/}})))\index{fix-int} \\ 
{\bf else }{\it{i\/}} $\div$ {\it{j\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iremainder} \\  
{\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder} $=$ {\rm{idifference}}\,({\it{i\/}}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient})\index{itimes})\index{idifference}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{idiv} \\  
\=\+{\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{fix-int}}\,({\it{j\/}})\index{fix-int} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\rm{negativep}}\,({\it{i\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\rm{negative-guts}}\,({\it{j\/}}) \\ 
{\bf elseif }({\rm{negative-guts}}\,({\it{i\/}}) ${}${\bf{mod}}${}$ {\it{j\/}}) $=$ {\tt{0}} \\ 
{\bf then }{\rm{fix-int}}\,($-$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\it{j\/}}))\index{fix-int} \\ 
{\bf else }{\rm{fix-int}}\,($-$ ($1\;+$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\it{j\/}})))\index{fix-int}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{j\/}}) \\ 
{\bf then }\=\+{\bf if }({\it{i\/}} ${}${\bf{mod}}${}$ {\rm{negative-guts}}\,({\it{j\/}})) $=$ {\tt{0}} \\ 
{\bf then }{\rm{fix-int}}\,($-$ ({\it{i\/}} $\div$ {\rm{negative-guts}}\,({\it{j\/}})))\index{fix-int} \\ 
{\bf else }{\rm{fix-int}}\,($-$ ($1\;+$ ({\it{i\/}} $\div$ {\rm{negative-guts}}\,({\it{j\/}}))))\index{fix-int}$\;${\bf  endif}\- \\ 
{\bf else }{\it{i\/}} $\div$ {\it{j\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{imod} \\  
{\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod} $=$ {\rm{idifference}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\rm{itimes}}\,({\it{j\/}}, {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv})\index{itimes})\index{idifference}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iquo} \\  
\=\+{\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{fix-int}}\,({\it{j\/}})\index{fix-int} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\rm{negativep}}\,({\it{i\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\rm{negative-guts}}\,({\it{j\/}}) \\ 
{\bf else }{\rm{fix-int}}\,($-$ ({\rm{negative-guts}}\,({\it{i\/}}) $\div$ {\it{j\/}}))\index{fix-int}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{negativep}}\,({\it{j\/}})$\;\;${\bf then }{\rm{fix-int}}\,($-$ ({\it{i\/}} $\div$ {\rm{negative-guts}}\,({\it{j\/}})))\index{fix-int} \\ 
{\bf else }{\it{i\/}} $\div$ {\it{j\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{irem} \\  
{\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem} $=$ {\rm{idifference}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo})\index{itimes})\index{idifference}
\end{tabbing}

\begin{verbatim}; ---------- DEFTHEORY events for definitions ----------

\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{integer-defns}} to consist of the following events: integerp,
fix-int,
ilessp,
iplus,
ineg,
iabs,
itimes,
iquotient,
iremainder,
idiv,
imod,
iquo,
irem.\index{integer-defns}

\addvspace{18pt}


\noindent{\sc Event}:   Let us define the theory {\it{all-integer-defns}} to consist of the following events: integerp,
fix-int,
izerop,
ilessp,
ileq,
iplus,
ineg,
idifference,
iabs,
itimes,
iquotient,
iremainder,
idiv,
imod,
iquo,
irem.\index{all-integer-defns}

\addvspace{18pt}


\noindent{\sc Event}:   Disable integerp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable fix-int.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable iplus.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ineg.

\addvspace{18pt}

\noindent{\sc Event}:   Disable iabs.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes.

\addvspace{18pt}
\begin{verbatim};; I've disabled the rest later in the file, just because the lemmas
;; about division were (re-)proved with the remaining functions enabled.

; ---------- INTEGERP ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  integerp-fix-int \\ \index{integerp-fix-int}
{\rm{integerp}}\,({\rm{fix-int}}\,({\it{x\/}})\index{fix-int})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-iplus \\ \index{integerp-iplus}
{\rm{integerp}}\,({\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-idifference \\ \index{integerp-idifference}
{\rm{integerp}}\,({\rm{idifference}}\,({\it{x\/}}, {\it{y\/}})\index{idifference})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-ineg \\ \index{integerp-ineg}
{\rm{integerp}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-iabs \\ \index{integerp-iabs}
{\rm{integerp}}\,({\rm{iabs}}\,({\it{x\/}})\index{iabs})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-itimes \\ \index{integerp-itimes}
{\rm{integerp}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes})\index{integerp}
\end{tabbing}

\begin{verbatim}; ---------- FIX-INT ----------

;; The first of these, FIX-INT-REMOVER, is potentially dangerous from
;; a backchaining point of view, but I believe it's necessary.  At least
;; the lemmas below it should go a long way toward preventing its application.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  fix-int-remover \\ \index{fix-int-remover}
{\rm{integerp}}\,({\it{x\/}})\index{integerp} $\rightarrow$ ({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-fix-int \\ \index{fix-int-fix-int}
{\rm{fix-int}}\,({\rm{fix-int}}\,({\it{x\/}})\index{fix-int})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-iplus \\ \index{fix-int-iplus}
{\rm{fix-int}}\,({\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus})\index{fix-int} $=$ {\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-idifference \\ \index{fix-int-idifference}
{\rm{fix-int}}\,({\rm{idifference}}\,({\it{a\/}}, {\it{b\/}})\index{idifference})\index{fix-int} $=$ {\rm{idifference}}\,({\it{a\/}}, {\it{b\/}})\index{idifference}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-ineg \\ \index{fix-int-ineg}
{\rm{fix-int}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg})\index{fix-int} $=$ {\rm{ineg}}\,({\it{x\/}})\index{ineg}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-iabs \\ \index{fix-int-iabs}
{\rm{fix-int}}\,({\rm{iabs}}\,({\it{x\/}})\index{iabs})\index{fix-int} $=$ {\rm{iabs}}\,({\it{x\/}})\index{iabs}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-itimes \\ \index{fix-int-itimes}
{\rm{fix-int}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes})\index{fix-int} $=$ {\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes}
\end{tabbing}

\begin{verbatim}; ---------- INEG ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ineg-iplus \\ \index{ineg-iplus}
{\rm{ineg}}\,({\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus})\index{ineg} $=$ {\rm{iplus}}\,({\rm{ineg}}\,({\it{a\/}})\index{ineg}, {\rm{ineg}}\,({\it{b\/}})\index{ineg})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ineg-ineg \\ \index{ineg-ineg}
{\rm{ineg}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg})\index{ineg} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ineg-fix-int \\ \index{ineg-fix-int}
{\rm{ineg}}\,({\rm{fix-int}}\,({\it{x\/}})\index{fix-int})\index{ineg} $=$ {\rm{ineg}}\,({\it{x\/}})\index{ineg}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ineg-of-non-integerp \\ \index{ineg-of-non-integerp}
($\neg$ {\rm{integerp}}\,({\it{x\/}})\index{integerp}) $\rightarrow$ ({\rm{ineg}}\,({\it{x\/}})\index{ineg} $=$ {\tt{0}})
\end{tabbing}

\begin{verbatim};; I don't want the backchaining to slow down the prover.
\end{verbatim}
\noindent{\sc Event}:   Disable ineg-of-non-integerp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  ineg-0 \\ \index{ineg-0}
{\rm{ineg}}\,({\tt{0}})\index{ineg} $=$ {\tt{0}}
\end{tabbing}

\begin{verbatim}; ---------- IPLUS ----------

;; The first two of these really aren't necessary, in light
;; of the cancellation metalemma.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  iplus-left-id \\ \index{iplus-left-id}
($\neg$ {\rm{integerp}}\,({\it{x\/}})\index{integerp}) $\rightarrow$ ({\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int})
\end{tabbing}

\begin{verbatim};; I don't want the backchaining to slow down the prover.
\end{verbatim}
\noindent{\sc Event}:   Disable iplus-left-id.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  iplus-right-id \\ \index{iplus-right-id}
($\neg$ {\rm{integerp}}\,({\it{y\/}})\index{integerp}) $\rightarrow$ ({\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int})
\end{tabbing}

\begin{verbatim};; I don't want the backchaining to slow down the prover.
\end{verbatim}
\noindent{\sc Event}:   Disable iplus-right-id.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  iplus-0-left \\ \index{iplus-0-left}
{\rm{iplus}}\,({\tt{0}}, {\it{x\/}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-0-right \\ \index{iplus-0-right}
{\rm{iplus}}\,({\it{x\/}}, {\tt{0}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-iplus \\ \index{commutativity2-of-iplus}
{\rm{iplus}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{y\/}}, {\it{z\/}})\index{iplus})\index{iplus} $=$ {\rm{iplus}}\,({\it{y\/}}, {\rm{iplus}}\,({\it{x\/}}, {\it{z\/}})\index{iplus})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity-of-iplus \\ \index{commutativity-of-iplus}
{\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{y\/}}, {\it{x\/}})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-iplus \\ \index{associativity-of-iplus}
{\rm{iplus}}\,({\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus}, {\it{z\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{y\/}}, {\it{z\/}})\index{iplus})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-cancellation-1 \\ \index{iplus-cancellation-1}
({\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{a\/}}, {\it{c\/}})\index{iplus}) $=$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-cancellation-2 \\ \index{iplus-cancellation-2}
({\rm{iplus}}\,({\it{b\/}}, {\it{a\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{c\/}}, {\it{a\/}})\index{iplus}) $=$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg1 \\ \index{iplus-ineg1}
{\rm{iplus}}\,({\rm{ineg}}\,({\it{a\/}})\index{ineg}, {\it{a\/}})\index{iplus} $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg2 \\ \index{iplus-ineg2}
{\rm{iplus}}\,({\it{a\/}}, {\rm{ineg}}\,({\it{a\/}})\index{ineg})\index{iplus} $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-fix-int1 \\ \index{iplus-fix-int1}
{\rm{iplus}}\,({\rm{fix-int}}\,({\it{a\/}})\index{fix-int}, {\it{b\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-fix-int2 \\ \index{iplus-fix-int2}
{\rm{iplus}}\,({\it{a\/}}, {\rm{fix-int}}\,({\it{b\/}})\index{fix-int})\index{iplus} $=$ {\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus}
\end{tabbing}

\begin{verbatim}; ---------- IDIFFERENCE ----------

;; mostly omitted, but I'll keep a few

\end{verbatim}\begin{tabbing}{\sc Theorem}:  idifference-fix-int1 \\ \index{idifference-fix-int1}
{\rm{idifference}}\,({\rm{fix-int}}\,({\it{a\/}})\index{fix-int}, {\it{b\/}})\index{idifference} $=$ {\rm{idifference}}\,({\it{a\/}}, {\it{b\/}})\index{idifference}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  idifference-fix-int2 \\ \index{idifference-fix-int2}
{\rm{idifference}}\,({\it{a\/}}, {\rm{fix-int}}\,({\it{b\/}})\index{fix-int})\index{idifference} $=$ {\rm{idifference}}\,({\it{a\/}}, {\it{b\/}})\index{idifference}
\end{tabbing}


\begin{verbatim}; --------------------------------------------------------------------------------
; Cancel INEG
; --------------------------------------------------------------------------------

;; We assume that the given term (IPLUS x y) has the property that y has already
;; been reduced and x is not an iplus-term.  So, the only question is whether
;; or not the formal negative of x appears in the fringe of y.

#| The function below has no AND or OR, for efficiency
(defn cancel-ineg-aux (x y)
  ;; returns nil or else a new term provably equal to (IPLUS x y)
  (if (and (listp x)
	   (equal (car x) 'ineg))
      (cond 
       ((equal y (cadr x))
	''0)
       ((and (listp y)
	     (equal (car y) 'iplus))
	(let ((y1 (cadr y)) (y2 (caddr y)))
	  (if (equal y1 (cadr x))
	      (list 'fix-int y2)
	    (let ((z (cancel-ineg-aux x y2)))
	      (if z
		  (list 'iplus y1 z)
		f)))))
       (t f))
    (cond
     ((nlistp y)
      f)
     ((equal (car y) 'ineg)
      (if (equal x (cadr y))
	  ''0
	f))
     ((equal (car y) 'iplus)
      (let ((y1 (cadr y)) (y2 (caddr y)))
	(if (and (listp y1)
		 (equal (car y1) 'ineg)
		 (equal x (cadr y1)))
	    (list 'fix-int y2)
	  (let ((z (cancel-ineg-aux x y2)))
	    (if z
		(list 'iplus y1 z)
	      f)))))
     (t f))))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-ineg-aux} \\  
\=\+{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\it{y\/}})\index{cancel-ineg-aux} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }\=\+{\bf if }{\it{y\/}} $=$ {\rm{cadr}}\,({\it{x\/}})$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf elseif }{\rm{listp}}\,({\it{y\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{y\/}}) $=$ {\rm{cadr}}\,({\it{x\/}}) \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{caddr}}\,({\it{y\/}})) \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{iplus}}, \\ 
{\rm{cadr}}\,({\it{y\/}}), \\ 
{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux})\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{y\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{cadr}}\,({\it{y\/}})$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{y\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caadr}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{cadadr}}\,({\it{y\/}}) \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{caddr}}\,({\it{y\/}})) \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{iplus}}, \\ 
{\rm{cadr}}\,({\it{y\/}}), \\ 
{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux})\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{cadr}}\,({\it{y\/}}), {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux}) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{cadr}}\,({\it{y\/}}), {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux}) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{y\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{cadr}}\,({\it{y\/}})$\;\;${\bf then }{\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{y\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caadr}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{cadadr}}\,({\it{y\/}})$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{caddr}}\,({\it{y\/}})) \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{cadr}}\,({\it{y\/}}), {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux}) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{cadr}}\,({\it{y\/}}), {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux}) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{cadr}}\,({\it{y\/}}), {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\rm{caddr}}\,({\it{y\/}}))\index{cancel-ineg-aux}) \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-ineg (x)
  (if (and (listp x)
	   (equal (car x) 'iplus))
      (let ((temp (cancel-ineg-aux (cadr x) (caddr x))))
	(if temp
	    temp
	  x))
    x))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-ineg} \\  
\=\+{\rm{cancel-ineg}}\,({\it{x\/}})\index{cancel-ineg} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{cancel-ineg-aux}}\,({\rm{cadr}}\,({\it{x\/}}), {\rm{caddr}}\,({\it{x\/}}))\index{cancel-ineg-aux} \\ 
{\bf then }{\rm{cancel-ineg-aux}}\,({\rm{cadr}}\,({\it{x\/}}), {\rm{caddr}}\,({\it{x\/}}))\index{cancel-ineg-aux} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; It seems a big win to turn off eval$.  I'll leave the recursive step out in
;; hopes that rewrite-eval$ handles it OK.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  eval\$-list-cons \\ \index{eval\$-list-cons}
{\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cons}}\,({\it{x\/}}, {\it{y\/}}), {\it{a\/}}) $=$ {\rm{cons}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-nlistp \\ \index{eval\$-list-nlistp}
({\it{x\/}} $\simeq\;${{\bf{nil}}}${}$) $\rightarrow$ ({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}) $=$ {\bf{nil}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-litatom \\ \index{eval\$-litatom}
{\rm{litatom}}\,({\it{x\/}}) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{cdr}}\,({\rm{assoc}}\,({\it{x\/}}, {\it{a\/}})))
\end{tabbing}

\begin{verbatim}#|
(prove-lemma eval$-quotep (rewrite)
  (equal (eval$ t (list 'quote x) a)
	 x))
|#

;; In place of the above I'll do the following, from
;; the naturals library.
\end{verbatim}
\noindent{\sc Event}:   Enable eval\$-quote.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-other \\ \index{eval\$-other}
(($\neg$ {\rm{litatom}}\,({\it{x\/}})) $\wedge$ ({\it{x\/}} $\simeq\;${{\bf{nil}}}${}$)) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\it{x\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable eval\$.

\addvspace{18pt}

\begin{verbatim};; What I'd like to do is say what (eval$ t (cancel-ineg-aux x y) a),
;; but a rewrite rule will loop because of the recursion.  So I
;; introduce a silly auxiliary function so that the opening-up
;; heuristics can help me.  The function body has (listp y) tests
;; so that it can be accepted.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{eval\$-cancel-ineg-aux-fn} \\  
\=\+{\rm{eval\$-cancel-ineg-aux-fn}}\,({\it{x\/}}, {\it{y\/}}, {\it{a\/}})\index{eval\$-cancel-ineg-aux-fn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ineg}}) \\ 
{\bf then }\=\+{\bf if }{\it{y\/}} $=$ {\rm{cadr}}\,({\it{x\/}})$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }\=\+{\bf let }\=\+{\it{y1\/}}{\bf $\;$ be$\;\;$}{\rm{cadr}}\,({\it{y\/}}), \\ 
{\it{y2\/}}{\bf $\;$ be$\;\;$}{\rm{caddr}}\,({\it{y\/}})\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\it{y1\/}} $=$ {\rm{cadr}}\,({\it{x\/}})$\;\;${\bf then }{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{y2\/}}, {\it{a\/}}))\index{fix-int} \\ 
{\bf elseif }{\rm{listp}}\,({\it{y\/}}) \\ 
{\bf then }{\rm{iplus}}\,(\=\+{\rm{eval\$}}\,({\bf{t}}, {\it{y1\/}}, {\it{a\/}}), \\ 
{\rm{eval\$-cancel-ineg-aux-fn}}\,({\it{x\/}}, {\it{y2\/}}, {\it{a\/}})\index{eval\$-cancel-ineg-aux-fn})\-\index{iplus} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endif}\- \\ 
{\bf else }\=\+{\bf if }{\rm{car}}\,({\it{y\/}}) $=$ {\tt{'}}{\tt{ineg}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }\=\+{\bf let }\=\+{\it{y1\/}}{\bf $\;$ be$\;\;$}{\rm{cadr}}\,({\it{y\/}}), \\ 
{\it{y2\/}}{\bf $\;$ be$\;\;$}{\rm{caddr}}\,({\it{y\/}})\- \\ 
{\bf in} \\ 
\=\+{\bf if }\=\+{\rm{listp}}\,({\it{y1\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{y1\/}}) $=$ {\tt{'}}{\tt{ineg}}) \\ 
$\wedge$$\;\;\;\;$({\it{x\/}} $=$ {\rm{cadr}}\,({\it{y1\/}}))\- \\ 
{\bf then }{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{y2\/}}, {\it{a\/}}))\index{fix-int} \\ 
{\bf elseif }{\rm{listp}}\,({\it{y\/}}) \\ 
{\bf then }{\rm{iplus}}\,(\=\+{\rm{eval\$}}\,({\bf{t}}, {\it{y1\/}}, {\it{a\/}}), \\ 
{\rm{eval\$-cancel-ineg-aux-fn}}\,(\=\+{\it{x\/}}, \\ 
{\it{y2\/}}, \\ 
{\it{a\/}})\-\index{eval\$-cancel-ineg-aux-fn})\-\index{iplus} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endif}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-cancel-ineg-aux-is-its-fn \\ \index{eval\$-cancel-ineg-aux-is-its-f!n}
\=\+({\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\it{y\/}})\index{cancel-ineg-aux} $\not=$ {\bf{f}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\it{y\/}})\index{cancel-ineg-aux}, {\it{a\/}}) $=$ {\rm{eval\$-cancel-ineg-aux-fn}}\,({\it{x\/}}, {\it{y\/}}, {\it{a\/}})\index{eval\$-cancel-ineg-aux-fn})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg3 \\ \index{iplus-ineg3}
{\rm{iplus}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg}, {\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg4 \\ \index{iplus-ineg4}
{\rm{iplus}}\,({\it{x\/}}, {\rm{iplus}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg}, {\it{y\/}})\index{iplus})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg-promote \\ \index{iplus-ineg-promote}
{\rm{iplus}}\,({\it{y\/}}, {\rm{ineg}}\,({\it{x\/}})\index{ineg})\index{iplus} $=$ {\rm{iplus}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg}, {\it{y\/}})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-x-y-ineg-x \\ \index{iplus-x-y-ineg-x}
{\rm{iplus}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{y\/}}, {\rm{ineg}}\,({\it{x\/}})\index{ineg})\index{iplus})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}
\end{tabbing}
	     

\noindent{\sc Event}:   Disable iplus-ineg-promote.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-ineg-aux \\ \index{correctness-of-cancel-ineg-aux}
\=\+({\rm{cancel-ineg-aux}}\,({\it{x\/}}, {\it{y\/}})\index{cancel-ineg-aux} $\not=$ {\bf{f}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$-cancel-ineg-aux-fn}}\,({\it{x\/}}, {\it{y\/}}, {\it{a\/}})\index{eval\$-cancel-ineg-aux-fn} $=$ {\rm{iplus}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\it{y\/}}, {\it{a\/}}))\index{iplus})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-ineg \\ \index{correctness-of-cancel-ineg}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-ineg}}\,({\it{x\/}})\index{cancel-ineg}, {\it{a\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable correctness-of-cancel-ineg-aux.

\addvspace{18pt}

\begin{verbatim}; --------------------------------------------------------------------------------
; Cancel IPLUS
; --------------------------------------------------------------------------------

;; All I do here is cancel like terms from both sides.  The problem of handling
;; INEG cancellation IS handled completely separately above.  That hasn't always
;; been the case -- in my first try I attempted to integrate the operations.
;; But now I see that for things like (equal z (iplus x (iplus y (ineg x))))
;; the integrated approach will fail.  Also, thanks to Matt Wilding, for pointing
;; out that the "four squares" example that Bill Pase sent me ran faster with
;; the newer approach (on his previously-implemented version for the rationals).

#| The function below has no AND or OR, for efficiency
(defn iplus-fringe (x)
  (if (and (listp x)
	   (equal (car x)
		  (quote iplus)))
      (append (iplus-fringe (cadr x))
	      (iplus-fringe (caddr x)))
      (cons x nil)))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{iplus-fringe} \\  
\=\+{\rm{iplus-fringe}}\,({\it{x\/}})\index{iplus-fringe} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }{\rm{append}}\,({\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, {\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe}) \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-count-listp-cdr \\ \index{lessp-count-listp-cdr}
{\rm{listp}}\,({\rm{cdr}}\,({\it{x\/}})) $\rightarrow$ ({\rm{count}}\,({\rm{cdr}}\,({\it{x\/}})) $<$ {\rm{count}}\,({\it{x\/}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus-tree-rec} \\  
\=\+{\rm{iplus-tree-rec}}\,({\it{l\/}})\index{iplus-tree-rec} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{cdr}}\,({\it{l\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{car}}\,({\it{l\/}}) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{iplus}}, {\rm{car}}\,({\it{l\/}}), {\rm{iplus-tree-rec}}\,({\rm{cdr}}\,({\it{l\/}}))\index{iplus-tree-rec})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus-tree} \\  
\=\+{\rm{iplus-tree}}\,({\it{l\/}})\index{iplus-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{l\/}}))$\;\;${\bf then }{\rm{iplus-tree-rec}}\,({\it{l\/}})\index{iplus-tree-rec} \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{car}}\,({\it{l\/}}))$\;${\bf  endif}\- \\ 
{\bf else }{\tt{'}}{\tt{'}}{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus-list} \\  
\=\+{\rm{iplus-list}}\,({\it{x\/}})\index{iplus-list} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{iplus}}\,({\rm{car}}\,({\it{x\/}}), {\rm{iplus-list}}\,({\rm{cdr}}\,({\it{x\/}}))\index{iplus-list})\index{iplus} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-iplus-list \\ \index{integerp-iplus-list}
{\rm{integerp}}\,({\rm{iplus-list}}\,({\it{x\/}})\index{iplus-list})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus-tree-rec \\ \index{eval\$-iplus-tree-rec}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree-rec}}\,({\it{x\/}})\index{iplus-tree-rec}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{x\/}}))$\;\;${\bf then }{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{iplus-list} \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\rm{car}}\,({\it{x\/}}), {\it{a\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}
	   
\begin{tabbing}{\sc Theorem}:  eval\$-iplus-tree \\ \index{eval\$-iplus-tree}
{\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree}}\,({\it{x\/}})\index{iplus-tree}, {\it{a\/}}) $=$ {\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{iplus-list}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-append \\ \index{eval\$-list-append}
\=\+{\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{append}}\,({\it{x\/}}, {\it{y\/}}), {\it{a\/}}) \\ 
$=$$\;\;\;\;${\rm{append}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-iplus (x)
  (if (and (listp x)
	   (equal (car x) (quote equal)))
      (if (and (listp (cadr x))
	       (equal (caadr x) (quote iplus))
	       (listp (caddr x))
	       (equal (caaddr x) (quote iplus)))
	  (let ((xs (iplus-fringe (cadr x)))
		(ys (iplus-fringe (caddr x))))
	    (let ((bagint (bagint xs ys)))
	      (if (listp bagint)
		  (list (quote equal)
			(iplus-tree (bagdiff xs bagint))
			(iplus-tree (bagdiff ys bagint)))
		x)))
	(if (and (listp (cadr x))
		 (equal (caadr x) (quote iplus))
		 ;; We don't want to introduce the IF below unless something
		 ;; is "gained", or else we may get into an infinite rewriting loop.
		 (member (caddr x) (iplus-fringe (cadr x))))
	    (list (quote if)
		  (list (quote integerp) (caddr x))
		  (list (quote equal)
			(iplus-tree (delete (caddr x) (iplus-fringe (cadr x))))
			''0)
		  (list (quote quote) f))
	  (if (and (listp (caddr x))
		   (equal (caaddr x) (quote iplus))
		   (member (cadr x) (iplus-fringe (caddr x))))
	      (list (quote if)
		    (list (quote integerp) (cadr x))
		    (list (quote equal)
			  ''0
			  (iplus-tree (delete (cadr x) (iplus-fringe (caddr x)))))
		    (list (quote quote) f))
	    x)))
    x))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-iplus} \\  
\=\+{\rm{cancel-iplus}}\,({\it{x\/}})\index{cancel-iplus} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint})\-\index{bagdiff})\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{bagdiff}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint})\-\index{bagdiff})\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{cons}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{cons}}\,(\=\+{\rm{iplus-tree}}\,({\rm{delete}}\,(\=\+{\rm{caddr}}\,({\it{x\/}}), \\ 
{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{delete})\index{iplus-tree}, \\ 
{\tt{'}}{\tt{(}}{\tt{'}}{\tt{0}}{\tt{)}})\-)\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{cons}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{cons}}\,(\=\+{\rm{iplus-tree}}\,({\rm{delete}}\,(\=\+{\rm{caddr}}\,({\it{x\/}}), \\ 
{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{delete})\index{iplus-tree}, \\ 
{\tt{'}}{\tt{(}}{\tt{'}}{\tt{0}}{\tt{)}})\-)\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\tt{'}}{\tt{'}}{\tt{0}}, \\ 
{\rm{iplus-tree}}\,({\rm{delete}}\,(\=\+{\rm{cadr}}\,({\it{x\/}}), \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{delete})\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\tt{'}}{\tt{'}}{\tt{0}}, \\ 
{\rm{iplus-tree}}\,({\rm{delete}}\,(\=\+{\rm{cadr}}\,({\it{x\/}}), \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{delete})\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-cancel-iplus \\ \index{eval\$-cancel-iplus}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-iplus}}\,({\it{x\/}})\index{cancel-iplus}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
{\bf then }\=\+{\bf if }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}})\- \\ 
{\bf then }\=\+{\bf let }\=\+{\it{xs\/}}{\bf $\;$ be$\;\;$}{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\it{ys\/}}{\bf $\;$ be$\;\;$}{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{bagint\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,({\it{xs\/}}, {\it{ys\/}})\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{bagint\/}}) \\ 
{\bf then }\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\it{xs\/}}, \\ 
{\rm{bagint}}\,({\it{xs\/}}, {\it{ys\/}})\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{iplus-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\it{ys\/}}, \\ 
{\rm{bagint}}\,(\=\+{\it{xs\/}}, \\ 
{\it{ys\/}})\-\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{iplus-list}\- \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}})$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe})\- \\ 
{\bf then }\=\+{\bf if }{\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}}))\index{integerp} \\ 
{\bf then }\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{delete}}\,({\rm{caddr}}\,({\it{x\/}}), {\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe})\index{delete}, \\ 
{\it{a\/}})\-)\index{iplus-list} \\ 
$=$$\;\;\;\;${\tt{0}}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }\=\+{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\- \\ 
{\bf then }\=\+{\bf if }{\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}))\index{integerp} \\ 
{\bf then }{\tt{0}} $=$ {\rm{iplus-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{delete}}\,(\=\+{\rm{cadr}}\,({\it{x\/}}), \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{delete}, \\ 
{\it{a\/}})\-)\index{iplus-list} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-iplus.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus-list-delete \\ \index{eval\$-iplus-list-delete}
\=\+({\it{z\/}} $\in$ {\it{y\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{z\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{idifference}}\,({\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{iplus-list}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{idifference})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus-list-bagdiff \\ \index{eval\$-iplus-list-bagdiff}
\=\+{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff}, {\it{a\/}}))\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{idifference}}\,(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{iplus-list}, \\ 
{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{iplus-list})\-\index{idifference})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-list-append \\ \index{iplus-list-append}
{\rm{iplus-list}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{iplus-list} $=$ {\rm{iplus}}\,({\rm{iplus-list}}\,({\it{x\/}})\index{iplus-list}, {\rm{iplus-list}}\,({\it{y\/}})\index{iplus-list})\index{iplus}
\end{tabbing}


\noindent{\sc Event}:   Disable iplus-tree.

\addvspace{18pt} \begin{verbatim};; because we want to use EVAL$-IPLUS-TREE for now

\end{verbatim}\begin{tabbing}{\sc Theorem}:  not-integerp-implies-not-equal-iplus \\ \index{not-integerp-implies-not-equal-ip!lus}
($\neg$ {\rm{integerp}}\,({\it{a\/}})\index{integerp}) $\rightarrow$ (({\it{a\/}} $=$ {\rm{iplus}}\,({\it{b\/}}, {\it{c\/}})\index{iplus}) $=$ {\bf{f}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-list-eval\$-fringe \\ \index{iplus-list-eval\$-fringe}
{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{iplus-fringe}}\,({\it{x\/}})\index{iplus-fringe}, {\it{a\/}}))\index{iplus-list} $=$ {\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int}
\end{tabbing}

\begin{verbatim};; The following two lemmas aren't needed but they sure do
;; shorten the total proof time!!!

\end{verbatim}\begin{tabbing}{\sc Theorem}:  iplus-ineg5-lemma-1 \\ \index{iplus-ineg5-lemma-1}
\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\it{x\/}} $=$ {\rm{iplus}}\,({\it{y\/}}, {\rm{iplus}}\,({\rm{ineg}}\,({\it{z\/}})\index{ineg}, {\it{w\/}})\index{iplus})\index{iplus}) \\ 
$=$$\;\;\;\;$({\it{x\/}} $=$ {\rm{iplus}}\,({\rm{ineg}}\,({\it{z\/}})\index{ineg}, {\rm{iplus}}\,({\it{y\/}}, {\it{w\/}})\index{iplus})\index{iplus}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg5-lemma-2 \\ \index{iplus-ineg5-lemma-2}
\=\+({\rm{integerp}}\,({\it{x\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{v\/}})\index{integerp}) \\ 
$\rightarrow$$\;\;\;\;$(({\it{x\/}} $=$ {\rm{iplus}}\,({\rm{ineg}}\,({\it{z\/}})\index{ineg}, {\it{v\/}})\index{iplus}) $=$ ({\rm{iplus}}\,({\it{x\/}}, {\it{z\/}})\index{iplus} $=$ {\it{v\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg5 \\ \index{iplus-ineg5}
\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\rightarrow$$\;\;\;\;$(({\it{x\/}} $=$ {\rm{iplus}}\,({\it{y\/}}, {\rm{iplus}}\,({\rm{ineg}}\,({\it{z\/}})\index{ineg}, {\it{w\/}})\index{iplus})\index{iplus}) $=$ ({\rm{iplus}}\,({\it{x\/}}, {\it{z\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{y\/}}, {\it{w\/}})\index{iplus}))\-
\end{tabbing}


\noindent{\sc Event}:   Disable iplus-ineg5-lemma-1.

\addvspace{18pt}


\noindent{\sc Event}:   Disable iplus-ineg5-lemma-2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  iplus-ineg6 \\ \index{iplus-ineg6}
\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\rightarrow$$\;\;\;\;$(({\it{x\/}} $=$ {\rm{iplus}}\,({\it{y\/}}, {\rm{iplus}}\,({\it{w\/}}, {\rm{ineg}}\,({\it{z\/}})\index{ineg})\index{iplus})\index{iplus}) $=$ ({\rm{iplus}}\,({\it{x\/}}, {\it{z\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{y\/}}, {\it{w\/}})\index{iplus}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus \\ \index{eval\$-iplus}
\=\+({\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{iplus}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x\/}}), {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{x\/}}), {\it{a\/}}))\index{iplus})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-ineg7 \\ \index{iplus-ineg7}
({\tt{0}} $=$ {\rm{iplus}}\,({\it{x\/}}, {\rm{ineg}}\,({\it{y\/}})\index{ineg})\index{iplus}) $=$ ({\rm{fix-int}}\,({\it{y\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-iplus \\ \index{correctness-of-cancel-iplus}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-iplus}}\,({\it{x\/}})\index{cancel-iplus}, {\it{a\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable iplus-ineg5.

\addvspace{18pt}


\noindent{\sc Event}:   Disable iplus-ineg6.

\addvspace{18pt}

\begin{verbatim}; --------------------------------------------------------------------------------
; Cancel IPLUS from ILESSP
; --------------------------------------------------------------------------------

;; This is similar to the cancellation of IPLUS terms from equalities,
;; handled above, and uses many of the same lemmas.  A small but definite
;; difference however is that for ILESSP we don't have to fix integers.

;; By luck we have that iplus-tree-rec is appropriate here, since
;; the lemma eval$-iplus-tree-rec shows that it (accidentally) behaves
;; properly on the empty list.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ilessp-fix-int-1 \\ \index{ilessp-fix-int-1}
{\rm{ilessp}}\,({\rm{fix-int}}\,({\it{x\/}})\index{fix-int}, {\it{y\/}})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-fix-int-2 \\ \index{ilessp-fix-int-2}
{\rm{ilessp}}\,({\it{x\/}}, {\rm{fix-int}}\,({\it{y\/}})\index{fix-int})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp}
\end{tabbing}

\begin{verbatim};; Perhaps the easiest approach is to do everything with respect to the
;; same IPLUS-TREE function that we used before, and then once the
;; supposed meta-lemma is proved, go back and show that we get the
;; same answer if we use a version that doesn't fix-int singleton fringes.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{make-cancel-iplus-inequality-1} \\  
\=\+{\rm{make-cancel-iplus-inequality-1}}\,({\it{x\/}}, {\it{y\/}})\index{make-cancel-iplus-inequality-1} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint})\index{bagdiff})\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint})\index{bagdiff})\index{iplus-tree})\-\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-iplus-ilessp-1 (x)
  (if (and (listp x)
	   (equal (car x) (quote ilessp)))
      (make-cancel-iplus-inequality-1 (iplus-fringe (cadr x))
				      (iplus-fringe (caddr x)))
    x))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-iplus-ilessp-1} \\  
\=\+{\rm{cancel-iplus-ilessp-1}}\,({\it{x\/}})\index{cancel-iplus-ilessp-1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }{\rm{make-cancel-iplus-inequality-1}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{make-cancel-iplus-inequality-1} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; Notice that IPLUS-TREE-NO-FIX-INT is currently enabled, which is
;; good since we want to use EVAL$-IPLUS-TREE-NO-FIX-INT for now.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  lessp-difference-plus-arg1 \\ \index{lessp-difference-plus-arg1}
({\it{w\/}} $<$ (({\it{w\/}} $+$ {\it{y\/}}) $-$ {\it{x\/}})) $=$ ({\it{x\/}} $<$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-difference-plus-arg1-commuted \\ \index{lessp-difference-plus-arg1-comm!uted}
({\it{w\/}} $<$ (({\it{y\/}} $+$ {\it{w\/}}) $-$ {\it{x\/}})) $=$ ({\it{x\/}} $<$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-cancellation-1-for-ilessp \\ \index{iplus-cancellation-1-for-ilessp}
{\rm{ilessp}}\,({\rm{iplus}}\,({\it{a\/}}, {\it{b\/}})\index{iplus}, {\rm{iplus}}\,({\it{a\/}}, {\it{c\/}})\index{iplus})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{b\/}}, {\it{c\/}})\index{ilessp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-cancellation-2-for-ilessp \\ \index{iplus-cancellation-2-for-ilessp}
{\rm{ilessp}}\,({\rm{iplus}}\,({\it{b\/}}, {\it{a\/}})\index{iplus}, {\rm{iplus}}\,({\it{c\/}}, {\it{a\/}})\index{iplus})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{b\/}}, {\it{c\/}})\index{ilessp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-iplus-ilessp-lemma \\ \index{correctness-of-cancel-iplus-ile!ssp-lemma}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-iplus-ilessp-1}}\,({\it{x\/}})\index{cancel-iplus-ilessp-1}, {\it{a\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus-tree-no-fix-int} \\  
\=\+{\rm{iplus-tree-no-fix-int}}\,({\it{l\/}})\index{iplus-tree-no-fix-int} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\rm{iplus-tree-rec}}\,({\it{l\/}})\index{iplus-tree-rec} \\ 
{\bf else }{\tt{'}}{\tt{'}}{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-ilessp-iplus-tree-no-fix-int \\ \index{eval\$-ilessp-iplus-tree-no-fix!-int}
\=\+{\rm{ilessp}}\,(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree-no-fix-int}}\,({\it{x\/}})\index{iplus-tree-no-fix-int}, {\it{a\/}}), \\ 
{\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree-no-fix-int}}\,({\it{y\/}})\index{iplus-tree-no-fix-int}, {\it{a\/}}))\-\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree}}\,({\it{x\/}})\index{iplus-tree}, {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\rm{iplus-tree}}\,({\it{y\/}})\index{iplus-tree}, {\it{a\/}}))\index{ilessp}\-
\end{tabbing}


\noindent{\sc Event}:   Disable iplus-tree-no-fix-int.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  make-cancel-iplus-inequality-simplifier \\ \index{make-cancel-iplus-inequality-si!mplifier}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{make-cancel-iplus-inequality-1}}\,({\it{x\/}}, {\it{y\/}})\index{make-cancel-iplus-inequality-1}, {\it{a\/}}) \\ 
$=$$\;\;\;\;${\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint})\index{bagdiff})\index{iplus-tree-no-fix-int}, \\ 
{\rm{iplus-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint})\index{bagdiff})\index{iplus-tree-no-fix-int})\-, \\ 
{\it{a\/}})\-\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-iplus-ilessp (x)
  (if (and (listp x)
	   (equal (car x) (quote ilessp)))
      (let ((x1 (iplus-fringe (cadr x)))
	    (y1 (iplus-fringe (caddr x))))
	(let ((bagint (bagint x1 y1)))
	  (if (listp bagint)
	      ;; I check (listp bagint) only for efficiency
	      (list (quote ilessp)
		    (iplus-tree-no-fix-int (bagdiff x1 bagint))
		    (iplus-tree-no-fix-int (bagdiff y1 bagint)))
	    x)))
    x))
|#

;; **** Should perhaps check that some argument of the ILESSP has function
;; symbol IPLUS, or else we may wind up dealing with (ILESSP 0 0).  That should
;; be harmless enough, though, even if *1*IPLUS is disabled; we'll just get the
;; same term back, the hard way.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-iplus-ilessp} \\  
\=\+{\rm{cancel-iplus-ilessp}}\,({\it{x\/}})\index{cancel-iplus-ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree-no-fix-int}}\,({\rm{bagdiff}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint})\-\index{bagdiff})\index{iplus-tree-no-fix-int}, \\ 
{\rm{iplus-tree-no-fix-int}}\,({\rm{bagdiff}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{bagint})\-\index{bagdiff})\index{iplus-tree-no-fix-int})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable make-cancel-iplus-inequality-1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-iplus-ilessp \\ \index{correctness-of-cancel-iplus-ile!ssp}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-iplus-ilessp}}\,({\it{x\/}})\index{cancel-iplus-ilessp}, {\it{a\/}})
\end{tabbing}

\begin{verbatim}; ---------- Multiplication ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  itimes-zero1 \\ \index{itimes-zero1}
({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\tt{0}}) $\rightarrow$ ({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-0-left \\ \index{itimes-0-left}
{\rm{itimes}}\,({\tt{0}}, {\it{y\/}})\index{itimes} $=$ {\tt{0}}
\end{tabbing}

\begin{verbatim};; I don't want the backchaining to slow down the prover.
\end{verbatim}
\noindent{\sc Event}:   Disable itimes-zero1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  itimes-zero2 \\ \index{itimes-zero2}
({\rm{fix-int}}\,({\it{y\/}})\index{fix-int} $=$ {\tt{0}}) $\rightarrow$ ({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-0-right \\ \index{itimes-0-right}
{\rm{itimes}}\,({\it{x\/}}, {\tt{0}})\index{itimes} $=$ {\tt{0}}
\end{tabbing}

\begin{verbatim};; I don't want the backchaining to slow down the prover.
\end{verbatim}
\noindent{\sc Event}:   Disable itimes-zero2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  itimes-fix-int1 \\ \index{itimes-fix-int1}
{\rm{itimes}}\,({\rm{fix-int}}\,({\it{a\/}})\index{fix-int}, {\it{b\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-fix-int2 \\ \index{itimes-fix-int2}
{\rm{itimes}}\,({\it{a\/}}, {\rm{fix-int}}\,({\it{b\/}})\index{fix-int})\index{itimes} $=$ {\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity-of-itimes \\ \index{commutativity-of-itimes}
{\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{y\/}}, {\it{x\/}})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-distributes-over-iplus-proof \\ \index{itimes-distributes-over-iplus-p!roof}
{\rm{itimes}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{y\/}}, {\it{z\/}})\index{iplus})\index{itimes} $=$ {\rm{iplus}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes}, {\rm{itimes}}\,({\it{x\/}}, {\it{z\/}})\index{itimes})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-distributes-over-iplus \\ \index{itimes-distributes-over-iplus}
\=\+({\rm{itimes}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{y\/}}, {\it{z\/}})\index{iplus})\index{itimes} $=$ {\rm{iplus}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes}, {\rm{itimes}}\,({\it{x\/}}, {\it{z\/}})\index{itimes})\index{iplus}) \\ 
$\wedge$$\;\;\;\;$({\rm{itimes}}\,({\rm{iplus}}\,({\it{x\/}}, {\it{y\/}})\index{iplus}, {\it{z\/}})\index{itimes} $=$ {\rm{iplus}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{z\/}})\index{itimes}, {\rm{itimes}}\,({\it{y\/}}, {\it{z\/}})\index{itimes})\index{iplus})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  commutativity2-of-itimes \\ \index{commutativity2-of-itimes}
{\rm{itimes}}\,({\it{x\/}}, {\rm{itimes}}\,({\it{y\/}}, {\it{z\/}})\index{itimes})\index{itimes} $=$ {\rm{itimes}}\,({\it{y\/}}, {\rm{itimes}}\,({\it{x\/}}, {\it{z\/}})\index{itimes})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-itimes \\ \index{associativity-of-itimes}
{\rm{itimes}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes}, {\it{z\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{x\/}}, {\rm{itimes}}\,({\it{y\/}}, {\it{z\/}})\index{itimes})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-0 \\ \index{equal-itimes-0}
({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes} $=$ {\tt{0}}) $=$ (({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\tt{0}}) $\vee$ ({\rm{fix-int}}\,({\it{y\/}})\index{fix-int} $=$ {\tt{0}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-1 \\ \index{equal-itimes-1}
\=\+({\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes} $=$ {\tt{1}}) \\ 
$=$$\;\;\;\;$((({\it{a\/}} $=$ {\tt{1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{1}})) $\vee$ (({\it{a\/}} $=$ {\tt{-1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{-1}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-minus-1 \\ \index{equal-itimes-minus-1}
\=\+({\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes} $=$ {\tt{-1}}) \\ 
$=$$\;\;\;\;$((({\it{a\/}} $=$ {\tt{-1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{1}})) $\vee$ (({\it{a\/}} $=$ {\tt{1}}) $\wedge$ ({\it{b\/}} $=$ {\tt{-1}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-1-arg1 \\ \index{itimes-1-arg1}
{\rm{itimes}}\,({\tt{1}}, {\it{x\/}})\index{itimes} $=$ {\rm{fix-int}}\,({\it{x\/}})\index{fix-int}
\end{tabbing}

\begin{verbatim}; ---------- Division ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  quotient-remainder-uniqueness \\ \index{quotient-remainder-uniqueness}
\=\+(({\it{a\/}} $=$ ({\it{r\/}} $+$ ({\it{b\/}} $*$ {\it{q\/}}))) $\wedge$ ({\it{r\/}} $<$ {\it{b\/}})) \\ 
$\rightarrow$$\;\;\;\;$(({\rm{fix}}\,({\it{r\/}}) $=$ ({\it{a\/}} ${}${\bf{mod}}${}$ {\it{b\/}})) $\wedge$ ({\rm{fix}}\,({\it{q\/}}) $=$ ({\it{a\/}} $\div$ {\it{b\/}})))\-
\end{tabbing}


\begin{verbatim}; We want to define IQUOTIENT and IREMAINDER. The standard approach to
; integer division derives from from the following theorem.
;
; Division Theorem:
; For all integers i,j, j not 0, there exist unique integers q and r
; which satisfy  i = jq + r,  0 <= r < |j|.
;
; The functions IQUOTIENT and IREMAINDER are intended to compute q and r.
; Therefore, to be satisfied that we have the right definitions, we must
; prove the above theorem.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  division-theorem-part1 \\ \index{division-theorem-part1}
{\rm{integerp}}\,({\it{i\/}})\index{integerp} $\rightarrow$ ({\rm{iplus}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient})\index{itimes})\index{iplus} $=$ {\it{i\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-part2 \\ \index{division-theorem-part2}
({\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}})) $\rightarrow$ ($\neg$ {\rm{ilessp}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\tt{0}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-part3 \\ \index{division-theorem-part3}
({\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}})) $\rightarrow$ {\rm{ilessp}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem \\ \index{division-theorem}
\=\+({\rm{integerp}}\,({\it{i\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{iplus}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient})\index{itimes})\index{iplus} $=$ {\it{i\/}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\tt{0}})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  quotient-difference-lessp-arg2 \\ \index{quotient-difference-lessp-arg2}
\=\+((({\it{a\/}} ${}${\bf{mod}}${}$ {\it{c\/}}) $=$ {\tt{0}}) $\wedge$ ({\it{b\/}} $<$ {\it{c\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{a\/}} $-$ {\it{b\/}}) $\div$ {\it{c\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{b\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\it{a\/}} $\div$ {\it{c\/}} \\ 
{\bf elseif }{\it{b\/}} $<$ {\it{a\/}}$\;\;${\bf then }({\it{a\/}} $\div$ {\it{c\/}}) $-$ ($1\;+$ ({\it{b\/}} $\div$ {\it{c\/}})) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquotient-iremainder-uniqueness \\ \index{iquotient-iremainder-uniqueness}
\=\+(\=\+{\rm{integerp}}\,({\it{i\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{j\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{r\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{q\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$({\it{j\/}} $\not=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\it{i\/}} $=$ {\rm{iplus}}\,({\it{r\/}}, {\rm{itimes}}\,({\it{j\/}}, {\it{q\/}})\index{itimes})\index{iplus}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\it{r\/}}, {\tt{0}})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\it{r\/}}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp})\- \\ 
$\rightarrow$$\;\;\;\;$(({\it{r\/}} $=$ {\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}) $\wedge$ ({\it{q\/}} $=$ {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient}))\-
\end{tabbing}
 
\begin{verbatim}; It turns out that in computer arithmetic, notions of division other than that
; given by the division theorem are used. Two in particular, called
; "truncate towards negative infinity" and "truncate towards zero" are common.
; We present their definitions here. 

; Division Theorem (truncate towards negative infinity variant):
;
; For all integers i,j, j not 0, there exist unique integers q and r
; which satisfy  
;                i = jq + r,  0 <= r <  j  (j > 0)
;                             j <  r <= 0  (j < 0)
;
; In this version the integer quotient of two integers is the integer floor
; of the real quotient of the integers. The remainder has the sign of the
; divisor. The functions IDIV and IMOD are intended to compute q and r.
; Therefore, to be satisfied that we have the right definitions, we must
; prove the above theorem.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-neginf-part1 \\ \index{division-theorem-for-truncate-t!o-neginf-part1}
{\rm{integerp}}\,({\it{i\/}})\index{integerp} $\rightarrow$ ({\rm{iplus}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\rm{itimes}}\,({\it{j\/}}, {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv})\index{itimes})\index{iplus} $=$ {\it{i\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-neginf-part2 \\ \index{division-theorem-for-truncate-t!o-neginf-part2}
{\rm{ilessp}}\,({\tt{0}}, {\it{j\/}})\index{ilessp} $\rightarrow$ (($\neg$ {\rm{ilessp}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\tt{0}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\it{j\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-neginf-part3 \\ \index{division-theorem-for-truncate-t!o-neginf-part3}
\=\+({\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ {\rm{ilessp}}\,({\it{j\/}}, {\tt{0}})\index{ilessp}) \\ 
$\rightarrow$$\;\;\;\;$(($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\it{j\/}}, {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{ilessp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-neginf \\ \index{division-theorem-for-truncate-t!o-neginf}
\=\+({\rm{integerp}}\,({\it{i\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{iplus}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\rm{itimes}}\,({\it{j\/}}, {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv})\index{itimes})\index{iplus} $=$ {\it{i\/}}) \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }{\rm{ilessp}}\,({\tt{0}}, {\it{j\/}})\index{ilessp} \\ 
{\bf then }($\neg$ {\rm{ilessp}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\tt{0}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}, {\it{j\/}})\index{ilessp} \\ 
{\bf else }\=\+($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\it{j\/}}, {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{ilessp}\-$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  idiv-imod-uniqueness \\ \index{idiv-imod-uniqueness}
\=\+(\=\+{\rm{integerp}}\,({\it{i\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{j\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{r\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{q\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$({\it{j\/}} $\not=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\it{i\/}} $=$ {\rm{iplus}}\,({\it{r\/}}, {\rm{itimes}}\,({\it{j\/}}, {\it{q\/}})\index{itimes})\index{iplus}) \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }{\rm{ilessp}}\,({\tt{0}}, {\it{j\/}})\index{ilessp}$\;\;${\bf then }($\neg$ {\rm{ilessp}}\,({\it{r\/}}, {\tt{0}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\it{r\/}}, {\it{j\/}})\index{ilessp} \\ 
{\bf else }($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\it{r\/}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\it{j\/}}, {\it{r\/}})\index{ilessp}$\;${\bf  endif}\-)\- \\ 
$\rightarrow$$\;\;\;\;$(({\it{r\/}} $=$ {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}) $\wedge$ ({\it{q\/}} $=$ {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv}))\-
\end{tabbing}

\begin{verbatim}; Division Theorem (truncate towards zero variant):
;
; For all integers i,j, j not 0, there exist unique integers q and r
; which satisfy  
;                i = jq + r,     0 <=  r  <  |j|  (i => 0)
;                             -|j| <   r  <= 0    (i < 0)
;
; In this version (iquo, irem), the integer quotient of two integers is the integer floor
; of the real quotient of the integers, if the real quotient is positive. If the
; real quotient is negative, the integer quotient is the integer ceiling of the
; real quotient. The remainder has the sign of the dividend. The functions IQUO 
; and IREM are intended to compute q and r. Therefore, to be satisfied that we
; have the right definitions, we must prove the above theorem.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-zero-part1 \\ \index{division-theorem-for-truncate-t!o-zero-part1}
{\rm{integerp}}\,({\it{i\/}})\index{integerp} $\rightarrow$ ({\rm{iplus}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo})\index{itimes})\index{iplus} $=$ {\it{i\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-zero-part2 \\ \index{division-theorem-for-truncate-t!o-zero-part2}
\=\+({\rm{integerp}}\,({\it{i\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}}) $\wedge$ ($\neg$ {\rm{ilessp}}\,({\it{i\/}}, {\tt{0}})\index{ilessp})) \\ 
$\rightarrow$$\;\;\;\;$(($\neg$ {\rm{ilessp}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\tt{0}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-zero-part3 \\ \index{division-theorem-for-truncate-t!o-zero-part3}
\=\+({\rm{integerp}}\,({\it{i\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}}) $\wedge$ {\rm{ilessp}}\,({\it{i\/}}, {\tt{0}})\index{ilessp}) \\ 
$\rightarrow$$\;\;\;\;$(($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\rm{ineg}}\,({\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ineg}, {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{ilessp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  division-theorem-for-truncate-to-zero \\ \index{division-theorem-for-truncate-t!o-zero}
\=\+({\rm{integerp}}\,({\it{i\/}})\index{integerp} $\wedge$ {\rm{integerp}}\,({\it{j\/}})\index{integerp} $\wedge$ ({\it{j\/}} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{iplus}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\rm{itimes}}\,({\it{j\/}}, {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo})\index{itimes})\index{iplus} $=$ {\it{i\/}}) \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{ilessp}}\,({\it{i\/}}, {\tt{0}})\index{ilessp} \\ 
{\bf then }\=\+($\neg$ {\rm{ilessp}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\tt{0}})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp}\- \\ 
{\bf else }\=\+($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\rm{ineg}}\,({\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ineg}, {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{ilessp}\-$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquo-irem-uniqueness \\ \index{iquo-irem-uniqueness}
\=\+(\=\+{\rm{integerp}}\,({\it{i\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{j\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{r\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\it{q\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$({\it{j\/}} $\not=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\it{i\/}} $=$ {\rm{iplus}}\,({\it{r\/}}, {\rm{itimes}}\,({\it{j\/}}, {\it{q\/}})\index{itimes})\index{iplus}) \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{ilessp}}\,({\it{i\/}}, {\tt{0}})\index{ilessp}$\;\;${\bf then }($\neg$ {\rm{ilessp}}\,({\it{r\/}}, {\tt{0}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\it{r\/}}, {\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ilessp} \\ 
{\bf else }($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\it{r\/}})\index{ilessp}) $\wedge$ {\rm{ilessp}}\,({\rm{ineg}}\,({\rm{iabs}}\,({\it{j\/}})\index{iabs})\index{ineg}, {\it{r\/}})\index{ilessp}$\;${\bf  endif}\-)\- \\ 
$\rightarrow$$\;\;\;\;$(({\it{r\/}} $=$ {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}) $\wedge$ ({\it{q\/}} $=$ {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo}))\-
\end{tabbing}

\begin{verbatim}; ---------- Multiplication Facts

\end{verbatim}\begin{tabbing}{\sc Theorem}:  itimes-ineg-1 \\ \index{itimes-ineg-1}
{\rm{itimes}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg}, {\it{y\/}})\index{itimes} $=$ {\rm{ineg}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes})\index{ineg}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-ineg-2 \\ \index{itimes-ineg-2}
{\rm{itimes}}\,({\it{x\/}}, {\rm{ineg}}\,({\it{y\/}})\index{ineg})\index{itimes} $=$ {\rm{ineg}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes})\index{ineg}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-cancellation-1 \\ \index{itimes-cancellation-1}
\=\+({\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{a\/}}, {\it{c\/}})\index{itimes}) \\ 
$=$$\;\;\;\;$(({\rm{fix-int}}\,({\it{a\/}})\index{fix-int} $=$ {\tt{0}}) $\vee$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-cancellation-2 \\ \index{itimes-cancellation-2}
\=\+({\rm{itimes}}\,({\it{b\/}}, {\it{a\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{c\/}}, {\it{a\/}})\index{itimes}) \\ 
$=$$\;\;\;\;$(({\rm{fix-int}}\,({\it{a\/}})\index{fix-int} $=$ {\tt{0}}) $\vee$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-cancellation-3 \\ \index{itimes-cancellation-3}
\=\+({\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes} $=$ {\rm{itimes}}\,({\it{c\/}}, {\it{a\/}})\index{itimes}) \\ 
$=$$\;\;\;\;$(({\rm{fix-int}}\,({\it{a\/}})\index{fix-int} $=$ {\tt{0}}) $\vee$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int}))\-
\end{tabbing}

\begin{verbatim}; ---------- Division Facts

\end{verbatim}\begin{tabbing}{\sc Theorem}:  integerp-iquotient \\ \index{integerp-iquotient}
{\rm{integerp}}\,({\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-iremainder \\ \index{integerp-iremainder}
{\rm{integerp}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-idiv \\ \index{integerp-idiv}
{\rm{integerp}}\,({\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-imod \\ \index{integerp-imod}
{\rm{integerp}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-iquo \\ \index{integerp-iquo}
{\rm{integerp}}\,({\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-irem \\ \index{integerp-irem}
{\rm{integerp}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquotient-fix-int1 \\ \index{iquotient-fix-int1}
{\rm{iquotient}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{iquotient} $=$ {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquotient-fix-int2 \\ \index{iquotient-fix-int2}
{\rm{iquotient}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{iquotient} $=$ {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iremainder-fix-int1 \\ \index{iremainder-fix-int1}
{\rm{iremainder}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{iremainder} $=$ {\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iremainder-fix-int2 \\ \index{iremainder-fix-int2}
{\rm{iremainder}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{iremainder} $=$ {\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  idiv-fix-int1 \\ \index{idiv-fix-int1}
{\rm{idiv}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{idiv} $=$ {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  idiv-fix-int2 \\ \index{idiv-fix-int2}
{\rm{idiv}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{idiv} $=$ {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  imod-fix-int1 \\ \index{imod-fix-int1}
{\rm{imod}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{imod} $=$ {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  imod-fix-int2 \\ \index{imod-fix-int2}
{\rm{imod}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{imod} $=$ {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquo-fix-int1 \\ \index{iquo-fix-int1}
{\rm{iquo}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{iquo} $=$ {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iquo-fix-int2 \\ \index{iquo-fix-int2}
{\rm{iquo}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{iquo} $=$ {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  irem-fix-int1 \\ \index{irem-fix-int1}
{\rm{irem}}\,({\rm{fix-int}}\,({\it{i\/}})\index{fix-int}, {\it{j\/}})\index{irem} $=$ {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  irem-fix-int2 \\ \index{irem-fix-int2}
{\rm{irem}}\,({\it{i\/}}, {\rm{fix-int}}\,({\it{j\/}})\index{fix-int})\index{irem} $=$ {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-iquotient \\ \index{fix-int-iquotient}
{\rm{fix-int}}\,({\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient})\index{fix-int} $=$ {\rm{iquotient}}\,({\it{i\/}}, {\it{j\/}})\index{iquotient}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-iremainder \\ \index{fix-int-iremainder}
{\rm{fix-int}}\,({\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder})\index{fix-int} $=$ {\rm{iremainder}}\,({\it{i\/}}, {\it{j\/}})\index{iremainder}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-idiv \\ \index{fix-int-idiv}
{\rm{fix-int}}\,({\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv})\index{fix-int} $=$ {\rm{idiv}}\,({\it{i\/}}, {\it{j\/}})\index{idiv}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-imod \\ \index{fix-int-imod}
{\rm{fix-int}}\,({\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod})\index{fix-int} $=$ {\rm{imod}}\,({\it{i\/}}, {\it{j\/}})\index{imod}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-iquo \\ \index{fix-int-iquo}
{\rm{fix-int}}\,({\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo})\index{fix-int} $=$ {\rm{iquo}}\,({\it{i\/}}, {\it{j\/}})\index{iquo}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-irem \\ \index{fix-int-irem}
{\rm{fix-int}}\,({\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem})\index{fix-int} $=$ {\rm{irem}}\,({\it{i\/}}, {\it{j\/}})\index{irem}
\end{tabbing}


\noindent{\sc Event}:   Disable iquotient.

\addvspace{18pt}

\noindent{\sc Event}:   Disable iremainder.

\addvspace{18pt}

\noindent{\sc Event}:   Disable idiv.

\addvspace{18pt}

\noindent{\sc Event}:   Disable imod.

\addvspace{18pt}

\noindent{\sc Event}:   Disable iquo.

\addvspace{18pt}

\noindent{\sc Event}:   Disable irem.

\addvspace{18pt}

\begin{verbatim}; ---------- Meta lemma for itimes cancellation

;; I tried to adapt this somewhat from corresponding meta lemmas in
;; naturals library, but it seemed to get hairy.  So instead I'll try
;; to parallel the development I gave for IPLUS.  I'll be lazier here
;; about efficiency, so I'll use a completely analogous definition of
;; itimes-tree.  Notice that I've avoided the IZEROP-TREE approach
;; from the naturals version, in that I simply create the appropriate
;; common fringe into a product and say that this product is non-zero
;; when dividing both sides by it.  It can then be up to the user whether
;; or not to enable the (meta or rewrite) rule that says that izerop of a product reduces
;; to the disjunction of izerop of the factors.

#| The function below has no AND or OR, for efficiency
(defn itimes-fringe (x)
  (if (and (listp x)
	   (equal (car x)
		  (quote itimes)))
      (append (itimes-fringe (cadr x))
	      (itimes-fringe (caddr x)))
      (cons x nil)))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{itimes-fringe} \\  
\=\+{\rm{itimes-fringe}}\,({\it{x\/}})\index{itimes-fringe} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }{\rm{append}}\,({\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, {\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe}) \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{itimes-tree-rec} \\  
\=\+{\rm{itimes-tree-rec}}\,({\it{l\/}})\index{itimes-tree-rec} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{cdr}}\,({\it{l\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{car}}\,({\it{l\/}}) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{itimes}}, {\rm{car}}\,({\it{l\/}}), {\rm{itimes-tree-rec}}\,({\rm{cdr}}\,({\it{l\/}}))\index{itimes-tree-rec})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{itimes-tree} \\  
\=\+{\rm{itimes-tree}}\,({\it{l\/}})\index{itimes-tree} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{l\/}}))$\;\;${\bf then }{\rm{itimes-tree-rec}}\,({\it{l\/}})\index{itimes-tree-rec} \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{car}}\,({\it{l\/}}))$\;${\bf  endif}\- \\ 
{\bf else }{\tt{'}}{\tt{'}}{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{itimes-list} \\  
\=\+{\rm{itimes-list}}\,({\it{x\/}})\index{itimes-list} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{itimes}}\,({\rm{car}}\,({\it{x\/}}), {\rm{itimes-list}}\,({\rm{cdr}}\,({\it{x\/}}))\index{itimes-list})\index{itimes} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-itimes-list \\ \index{integerp-itimes-list}
{\rm{integerp}}\,({\rm{itimes-list}}\,({\it{x\/}})\index{itimes-list})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-itimes-tree-rec \\ \index{eval\$-itimes-tree-rec}
\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-rec}}\,({\it{x\/}})\index{itimes-tree-rec}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{x\/}}))$\;\;${\bf then }{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} \\ 
{\bf else }{\rm{eval\$}}\,({\bf{t}}, {\rm{car}}\,({\it{x\/}}), {\it{a\/}})$\;${\bf  endif}\-)\-\-
\end{tabbing}
	   
\begin{verbatim};; The following allows us to pretty much ignore itimes-tree forever.  (Notice
;; that it is disabled immediately below.)

\end{verbatim}\begin{tabbing}{\sc Theorem}:  eval\$-itimes-tree \\ \index{eval\$-itimes-tree}
{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree}}\,({\it{x\/}})\index{itimes-tree}, {\it{a\/}}) $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}
\end{tabbing}


\noindent{\sc Event}:   Disable itimes-tree.

\addvspace{18pt} \begin{verbatim};; because we want to use EVAL$-ITIMES-TREE for now

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{make-cancel-itimes-equality} \\  
\=\+{\rm{make-cancel-itimes-equality}}\,({\it{x\/}}, {\it{y\/}}, {\it{in-both\/}})\index{make-cancel-itimes-equality} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{equal}}, {\rm{itimes-tree}}\,({\it{in-both\/}})\index{itimes-tree}, {\tt{'}}{\tt{'}}{\tt{0}}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{t}}), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{itimes-tree}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree}, \\ 
{\rm{itimes-tree}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree})\-)\-\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-itimes (x)
  (if (and (listp x)
	   (equal (car x) (quote equal)))
      (if (and (listp (cadr x))
	       (equal (caadr x) (quote itimes))
	       (listp (caddr x))
	       (equal (caaddr x) (quote itimes)))
	  (if (listp (bagint (itimes-fringe (cadr x)) (itimes-fringe (caddr x))))
	      (make-cancel-itimes-equality (itimes-fringe (cadr x))
					   (itimes-fringe (caddr x))
					   (bagint (itimes-fringe (cadr x)) (itimes-fringe (caddr x))))
	    x)
	(if (and (listp (cadr x))
		 (equal (caadr x) (quote itimes)))
	    ;; We don't want to introduce the IF below unless something
	    ;; is "gained", or else we may get into an infinite rewriting loop.
	    (if (member (caddr x) (itimes-fringe (cadr x)))
		(list (quote if)
		      (list (quote integerp) (caddr x)) 
		      (make-cancel-itimes-equality (itimes-fringe (cadr x))
						   (list (caddr x))
						   (list (caddr x)))
		      (list (quote quote) f))
	      x)
	  (if (and (listp (caddr x))
		   (equal (caaddr x) (quote itimes)))
	      (if (member (cadr x) (itimes-fringe (caddr x)))
		  (list (quote if)
			(list (quote integerp) (cadr x))
			(make-cancel-itimes-equality (list (cadr x))
						     (itimes-fringe (caddr x))
						     (list (cadr x)))
			(list (quote quote) f))
		x)
	    x)))
    x))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-itimes} \\  
\=\+{\rm{cancel-itimes}}\,({\it{x\/}})\index{cancel-itimes} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe})\-\index{bagint}) \\ 
{\bf then }{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe})\-\index{bagint})\-\index{make-cancel-itimes-equality} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{list}}\,({\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,({\rm{caddr}}\,({\it{x\/}})))\-\index{make-cancel-itimes-equality}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $\in$ {\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{list}}\,({\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,({\rm{caddr}}\,({\it{x\/}})))\-\index{make-cancel-itimes-equality}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{list}}\,({\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{list}}\,({\rm{cadr}}\,({\it{x\/}})))\-\index{make-cancel-itimes-equality}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{caaddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $\in$ {\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{list}}\,({\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{list}}\,({\rm{cadr}}\,({\it{x\/}})))\-\index{make-cancel-itimes-equality}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-append \\ \index{itimes-list-append}
{\rm{itimes-list}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{itimes-list} $=$ {\rm{itimes}}\,({\rm{itimes-list}}\,({\it{x\/}})\index{itimes-list}, {\rm{itimes-list}}\,({\it{y\/}})\index{itimes-list})\index{itimes}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-fringe \\ \index{itimes-list-eval\$-fringe}
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{itimes-fringe}}\,({\it{x\/}})\index{itimes-fringe}, {\it{a\/}}))\index{itimes-list} $=$ {\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  integerp-eval\$-itimes \\ \index{integerp-eval\$-itimes}
({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}}) $\rightarrow$ {\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-integerp-implies-not-equal-itimes \\ \index{not-integerp-implies-not-equal-iti!mes}
($\neg$ {\rm{integerp}}\,({\it{a\/}})\index{integerp}) $\rightarrow$ (({\it{a\/}} $=$ {\rm{itimes}}\,({\it{b\/}}, {\it{c\/}})\index{itimes}) $=$ {\bf{f}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-delete \\ \index{itimes-list-eval\$-delete}
\=\+({\it{z\/}} $\in$ {\it{y\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}), {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{z\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{itimes-list})\index{itimes})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-bagdiff \\ \index{itimes-list-bagdiff}
\=\+{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{y\/}}, {\it{x\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\-\index{itimes})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-list-eval\$-list-delete \\ \index{equal-itimes-list-eval\$-list-de!lete}
\=\+(({\it{c\/}} $\in$ {\it{y\/}}) $\wedge$ ({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{c\/}}, {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\it{x\/}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{c\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{itimes-list}) \\ 
$=$$\;\;\;\;$(\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{c\/}}, {\it{a\/}}))\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list})\-)\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable itimes-list-eval\$-delete.

\addvspace{18pt}

\begin{verbatim};; I had trouble with the clausifier (thanks, J, for pointing that out
;; as the source of my trouble) in the proof of the meta lemma -- it's
;; getting rid of a case split.  So, I'll proceed by reducing
;; cancel-itimes in each case; see lemma eval$-make-cancel-itimes-equality
;; (and its -1 and -2 versions).

\end{verbatim}\begin{tabbing}{\sc Theorem}:  member-append \\ \index{member-append}
({\it{a\/}} $\in$ {\rm{append}}\,({\it{x\/}}, {\it{y\/}})) $=$ (({\it{a\/}} $\in$ {\it{x\/}}) $\vee$ ({\it{a\/}} $\in$ {\it{y\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-izerop-itimes-fringe \\ \index{member-izerop-itimes-fringe}
\=\+(({\it{z\/}} $\in$ {\rm{itimes-fringe}}\,({\it{x\/}})\index{itimes-fringe}) $\wedge$ ({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-hack-1 \\ \index{correctness-of-cancel-itimes-ha!ck-1}
\=\+(\=\+({\it{w\/}} $\in$ {\rm{itimes-fringe}}\,({\rm{cons}}\,({\tt{'}}{\tt{itimes}}, {\it{x1\/}}))\index{itimes-fringe}) \\ 
$\wedge$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{car}}\,({\it{x1\/}}), {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}}))\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{x1\/}}), {\it{a\/}}))\index{fix-int} $=$ {\tt{0}})\-
\end{tabbing}


\noindent{\sc Event}:   Enable eval\$-equal.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-make-cancel-itimes-equality \\ \index{eval\$-make-cancel-itimes-equalit!y}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{make-cancel-itimes-equality}}\,({\it{x\/}}, {\it{y\/}}, {\it{in-both\/}})\index{make-cancel-itimes-equality}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{eval\$}}\,({\bf{t}}, {\rm{list}}\,({\tt{'}}{\tt{equal}}, {\rm{itimes-tree}}\,({\it{in-both\/}})\index{itimes-tree}, {\tt{'}}{\tt{'}}{\tt{0}}), {\it{a\/}})$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}\-$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable make-cancel-itimes-equality.

\addvspace{18pt}

\begin{verbatim};; Here's a special case that I hope helps with the clausifier problem.
;; The lemma above seems necessary for its proof.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  eval\$-make-cancel-itimes-equality-1 \\ \index{eval\$-make-cancel-itimes-equalit!y-1}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{make-cancel-itimes-equality}}\,({\rm{list}}\,({\it{x\/}}), {\it{y\/}}, {\rm{list}}\,({\it{x\/}}))\index{make-cancel-itimes-equality}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}}$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\tt{1}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{x\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{itimes-list}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-fix-int \\ \index{equal-fix-int}
({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\it{x\/}}) $=$ {\rm{integerp}}\,({\it{x\/}})\index{integerp}
\end{tabbing}

\begin{verbatim};; Here's another special case that I hope helps with the clausifier problem.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  eval\$-make-cancel-itimes-equality-2 \\ \index{eval\$-make-cancel-itimes-equalit!y-2}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{make-cancel-itimes-equality}}\,({\it{x\/}}, {\rm{list}}\,({\it{y\/}}), {\rm{list}}\,({\it{y\/}}))\index{make-cancel-itimes-equality}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{y\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}}$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\tt{1}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{y\/}}, {\it{x\/}})\index{delete}, {\it{a\/}}))\index{itimes-list}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-equal-itimes-tree-itimes-fringe-0 \\ \index{eval\$-equal-itimes-tree-itimes!-fringe-0}
\=\+(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{list}}\,({\tt{'}}{\tt{equal}}, {\rm{itimes-tree}}\,({\rm{itimes-fringe}}\,({\it{x\/}})\index{itimes-fringe})\index{itimes-tree}, {\tt{'}}{\tt{'}}{\tt{0}}), {\it{a\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}}))\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  izerop-eval-of-member-implies-itimes-list-0 \\ \index{izerop-eval-of-member-implies-iti!mes-list-0}
\=\+(({\it{z\/}} $\in$ {\it{y\/}}) $\wedge$ ({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn subsetp (x y)
  (if (nlistp x)
      t
    (and (member (car x) y)
	 (subsetp (cdr x) y))))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{subsetp} \\  
\=\+{\rm{subsetp}}\,({\it{x\/}}, {\it{y\/}})\index{subsetp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf elseif }{\rm{car}}\,({\it{x\/}}) $\in$ {\it{y\/}}$\;\;${\bf then }{\rm{subsetp}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{y\/}})\index{subsetp} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-implies-itimes-list-eval\$-equals-0 \\ \index{subsetp-implies-itimes-list-eva!l\$-equals-0}
\=\+({\rm{subsetp}}\,({\it{x\/}}, {\it{y\/}})\index{subsetp} $\wedge$ ({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subbagp-subsetp \\ \index{subbagp-subsetp}
{\rm{subbagp}}\,({\it{x\/}}, {\it{y\/}})\index{subbagp} $\rightarrow$ {\rm{subsetp}}\,({\it{x\/}}, {\it{y\/}})\index{subsetp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-0-itimes-list-eval\$-bagint-1 \\ \index{equal-0-itimes-list-eval\$-bagi!nt-1}
\=\+({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-0-itimes-list-eval\$-bagint-2 \\ \index{equal-0-itimes-list-eval\$-bagi!nt-2}
\=\+({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-hack-2 \\ \index{correctness-of-cancel-itimes-ha!ck-2}
\=\+(\=\+{\rm{listp}}\,({\it{u\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{u\/}}) $=$ {\tt{'}}{\tt{itimes}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{v\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{v\/}}) $=$ {\tt{'}}{\tt{itimes}}) \\ 
$\wedge$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{u\/}}, {\it{a\/}}) $\not=$ {\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, \\ 
{\rm{bagint}}\,({\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, {\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{itimes-list} \\ 
$\not=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\-\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{itimes-list})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-hack-3-lemma \\ \index{correctness-of-cancel-itimes-ha!ck-3-lemma}
\=\+(({\it{u\/}} $=$ {\rm{itimes}}\,({\it{a\/}}, {\it{b\/}})\index{itimes}) $\wedge$ ({\rm{fix-int}}\,({\it{a\/}})\index{fix-int} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(({\it{u\/}} $=$ {\rm{itimes}}\,({\it{a\/}}, {\it{c\/}})\index{itimes}) $=$ ({\rm{fix-int}}\,({\it{b\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{c\/}})\index{fix-int}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-hack-3 \\ \index{correctness-of-cancel-itimes-ha!ck-3}
\=\+(\=\+{\rm{listp}}\,({\it{u\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{u\/}}) $=$ {\tt{'}}{\tt{itimes}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{v\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{v\/}}) $=$ {\tt{'}}{\tt{itimes}}) \\ 
$\wedge$$\;\;\;\;$({\rm{eval\$}}\,({\bf{t}}, {\it{u\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}})) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{eval\$}}\,(\=\+{\bf{t}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{itimes-tree}}\,({\rm{bagint}}\,({\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, {\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\index{bagint})\index{itimes-tree}, \\ 
{\tt{'}}{\tt{'}}{\tt{0}})\-, \\ 
{\it{a\/}})\-))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, \\ 
{\rm{bagint}}\,({\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, {\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagdiff}}\,(\=\+{\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\it{u\/}})\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\-\index{bagint})\-\index{bagdiff}, \\ 
{\it{a\/}})\-)\index{itimes-list})\- \\ 
$=$$\;\;\;\;${\bf{t}})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-hack-3-lemma.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes \\ \index{correctness-of-cancel-itimes}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-itimes}}\,({\it{x\/}})\index{cancel-itimes}, {\it{a\/}})
\end{tabbing}

\begin{verbatim}; ---------- Meta lemma for itimes cancellation on ilessp terms

;; I'll try to keep this similar to the approach for equalities above,
;; modified as in the iplus case (i.e. no fix-int is necessary).

;; EVAL$-EQUAL is currently enabled, but that's OK.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{itimes-tree-no-fix-int} \\  
\=\+{\rm{itimes-tree-no-fix-int}}\,({\it{l\/}})\index{itimes-tree-no-fix-int} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\rm{itimes-tree-rec}}\,({\it{l\/}})\index{itimes-tree-rec} \\ 
{\bf else }{\tt{'}}{\tt{'}}{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}
	   
\begin{verbatim};; The following allows us to pretty much ignore
;; itimes-tree-no-fix-int forever.  (Notice that it is disabled
;; immediately below.)

\end{verbatim}\begin{tabbing}{\sc Theorem}:  eval\$-itimes-tree-no-fix-int-1 \\ \index{eval\$-itimes-tree-no-fix-int-1}
\=\+{\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\it{x\/}})\index{itimes-tree-no-fix-int}, {\it{a\/}}), {\it{y\/}})\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree}}\,({\it{x\/}})\index{itimes-tree}, {\it{a\/}}), {\it{y\/}})\index{ilessp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-itimes-tree-no-fix-int-2 \\ \index{eval\$-itimes-tree-no-fix-int-2}
\=\+{\rm{ilessp}}\,({\it{y\/}}, {\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\it{x\/}})\index{itimes-tree-no-fix-int}, {\it{a\/}}))\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,({\it{y\/}}, {\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree}}\,({\it{x\/}})\index{itimes-tree}, {\it{a\/}}))\index{ilessp}\-
\end{tabbing}


\noindent{\sc Event}:   Disable itimes-tree-no-fix-int.

\addvspace{18pt}

\begin{verbatim};; We want to use EVAL$-ITIMES-TREE, and ITIMES-TREE is still disabled
;; so we're in good shape.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{make-cancel-itimes-inequality} \\  
\=\+{\rm{make-cancel-itimes-inequality}}\,({\it{x\/}}, {\it{y\/}}, {\it{in-both\/}})\index{make-cancel-itimes-inequality} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\rm{itimes-tree-no-fix-int}}\,({\it{in-both\/}})\index{itimes-tree-no-fix-int}, {\tt{'}}{\tt{'}}{\tt{0}}), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, \\ 
{\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int})\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\tt{'}}{\tt{'}}{\tt{0}}, {\rm{itimes-tree-no-fix-int}}\,({\it{in-both\/}})\index{itimes-tree-no-fix-int}), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, \\ 
{\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int})\-, \\ 
{\tt{'}}{\tt{(}}{\tt{false}}{\tt{)}})\-)\-\-
\end{tabbing}

\begin{verbatim}#| The function below has no AND or OR, for efficiency
(defn cancel-itimes-ilessp (x)
  (if (and (listp x)
	   (equal (car x) (quote ilessp))
	   (listp (bagint (itimes-fringe (cadr x)) (itimes-fringe (caddr x)))))
      (make-cancel-itimes-inequality (itimes-fringe (cadr x))
				     (itimes-fringe (caddr x))
				     (bagint (itimes-fringe (cadr x))
					     (itimes-fringe (caddr x))))
    x))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-itimes-ilessp} \\  
\=\+{\rm{cancel-itimes-ilessp}}\,({\it{x\/}})\index{cancel-itimes-ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe})\-\index{bagint}) \\ 
{\bf then }{\rm{make-cancel-itimes-inequality}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-fringe}, \\ 
{\rm{itimes-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-fringe})\-\index{bagint})\-\index{make-cancel-itimes-inequality} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-make-cancel-itimes-inequality \\ \index{eval\$-make-cancel-itimes-inequ!ality}
\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{make-cancel-itimes-inequality}}\,({\it{x\/}}, {\it{y\/}}, {\it{in-both\/}})\index{make-cancel-itimes-inequality}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{eval\$}}\,({\bf{t}}, {\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\rm{itimes-tree-no-fix-int}}\,({\it{in-both\/}})\index{itimes-tree-no-fix-int}, {\tt{'}}{\tt{'}}{\tt{0}}), {\it{a\/}}) \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, {\it{a\/}}), \\ 
{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, {\it{a\/}}))\-\index{ilessp} \\ 
{\bf elseif }{\rm{eval\$}}\,({\bf{t}}, {\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\tt{'}}{\tt{'}}{\tt{0}}, {\rm{itimes-tree-no-fix-int}}\,({\it{in-both\/}})\index{itimes-tree-no-fix-int}), {\it{a\/}}) \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{x\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, {\it{a\/}}), \\ 
{\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-no-fix-int}}\,({\rm{bagdiff}}\,({\it{y\/}}, {\it{in-both\/}})\index{bagdiff})\index{itimes-tree-no-fix-int}, {\it{a\/}}))\-\index{ilessp} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable make-cancel-itimes-inequality.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  listp-bagint-with-singleton-implies-member \\ \index{listp-bagint-with-singleton-imp!lies-member}
{\rm{listp}}\,({\rm{bagint}}\,({\it{y\/}}, {\rm{list}}\,({\it{z\/}}))\index{bagint}) $\rightarrow$ ({\it{z\/}} $\in$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-list-0 \\ \index{itimes-list-eval\$-list-0}
({\tt{0}} $\in$ {\it{x\/}}) $\rightarrow$ ({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-right-positive \\ \index{ilessp-itimes-right-positive}
{\rm{ilessp}}\,({\tt{0}}, {\it{x\/}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\it{y\/}}, {\it{z\/}})\index{ilessp} $=$ {\rm{ilessp}}\,({\rm{itimes}}\,({\it{y\/}}, {\it{x\/}})\index{itimes}, {\rm{itimes}}\,({\it{z\/}}, {\it{x\/}})\index{itimes})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-1 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-1}
\=\+(\=\+{\rm{subbagp}}\,({\it{bag\/}}, {\it{x\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{bag\/}}, {\it{y\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list})\index{ilessp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{x\/}}, {\it{bag\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{y\/}}, {\it{bag\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-bagint-with-singleton-member \\ \index{listp-bagint-with-singleton-mem!ber}
{\rm{listp}}\,({\rm{bagint}}\,({\it{y\/}}, {\rm{list}}\,({\it{z\/}}))\index{bagint}) $=$ ({\it{z\/}} $\in$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-2-lemma \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-2-lemma}
({\tt{0}} $\in$ {\rm{itimes-fringe}}\,({\it{w\/}})\index{itimes-fringe}) $\rightarrow$ ({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-2 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-2}
({\tt{0}} $\in$ {\rm{itimes-fringe}}\,({\it{w\/}})\index{itimes-fringe}) $\rightarrow$ ($\neg$ {\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}), {\tt{0}})\index{ilessp})
\end{tabbing}


\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-2-lemma.

\addvspace{18pt}

\begin{verbatim};;; Now hack-3 and hack-4 below are all that's left to prove before the
;;; main result.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ilessp-trichotomy \\ \index{ilessp-trichotomy}
($\neg$ {\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp}) $\rightarrow$ ({\rm{ilessp}}\,({\it{y\/}}, {\it{x\/}})\index{ilessp} $=$ ({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $\not=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-3-lemma-1 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-3-lemma-1}
\=\+(({\tt{0}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}) $\wedge$ {\rm{subsetp}}\,({\it{bag\/}}, {\it{z\/}})\index{subsetp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{z\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-3-lemma-2 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-3-lemma-2}
\=\+(({\tt{0}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}) $\wedge$ {\rm{subsetp}}\,({\it{bag\/}}, {\rm{itimes-fringe}}\,({\it{x\/}})\index{itimes-fringe})\index{subsetp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int} $=$ {\tt{0}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  same-fix-int-implies-not-ilessp \\ \index{same-fix-int-implies-not-ilessp}
({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}) $\rightarrow$ ($\neg$ {\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-3 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-3}
\=\+(\=\+($\neg$ {\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}, {\tt{0}})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{bag\/}}, {\rm{itimes-fringe}}\,({\it{w\/}})\index{itimes-fringe})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{bag\/}}, {\rm{itimes-fringe}}\,({\it{v\/}})\index{itimes-fringe})\index{subbagp})\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}))\index{ilessp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-right-negative \\ \index{ilessp-itimes-right-negative}
{\rm{ilessp}}\,({\it{x\/}}, {\tt{0}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\it{y\/}}, {\it{z\/}})\index{ilessp} $=$ {\rm{ilessp}}\,({\rm{itimes}}\,({\it{z\/}}, {\it{x\/}})\index{itimes}, {\rm{itimes}}\,({\it{y\/}}, {\it{x\/}})\index{itimes})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-hack-4 \\ \index{correctness-of-cancel-itimes-ile!ssp-hack-4}
\=\+(\=\+{\rm{subbagp}}\,({\it{bag\/}}, {\it{x\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{bag\/}}, {\it{y\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}, {\tt{0}})\index{ilessp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{x\/}}, {\it{bag\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{y\/}}, {\it{bag\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable ilessp-trichotomy.

\addvspace{18pt}


\noindent{\sc Event}:   Disable same-fix-int-implies-not-ilessp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp \\ \index{correctness-of-cancel-itimes-ile!ssp}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-itimes-ilessp}}\,({\it{x\/}})\index{cancel-itimes-ilessp}, {\it{a\/}})
\end{tabbing}

\begin{verbatim};; I think that the following lemma is safe because it won't be
;; called at all during relieve-hyps.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ilessp-strict \\ \index{ilessp-strict}
{\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp} $\rightarrow$ ($\neg$ {\rm{ilessp}}\,({\it{y\/}}, {\it{x\/}})\index{ilessp})
\end{tabbing}


\begin{verbatim}; ---------- Setting up the State ----------

;; I'll close by disabling (or enabling) those rules and definitions
;; whose status as left over from above isn't quite what I'd like.
;; I'm going to leave the eval$ rules on and eval$ off.

\end{verbatim}
\noindent{\sc Event}:   Disable eval\$-cancel-iplus.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-iplus.

\addvspace{18pt}


\noindent{\sc Event}:   Disable lessp-count-listp-cdr.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-iplus-tree-rec.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-iplus-tree.

\addvspace{18pt}
\begin{verbatim};;(disable eval$-list-append) ;; Nice rule -- I'll keep it enabled
\end{verbatim}
\noindent{\sc Event}:   Disable iplus-list-eval\$-fringe.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-iplus-list-bagdiff.

\addvspace{18pt}

\noindent{\sc Event}:   Disable lessp-difference-plus-arg1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable lessp-difference-plus-arg1-commuted.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-iplus-ilessp-lemma.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-ilessp-iplus-tree-no-fix-int.

\addvspace{18pt}

\noindent{\sc Event}:   Disable make-cancel-iplus-inequality-simplifier.

\addvspace{18pt}

\noindent{\sc Event}:   Disable quotient-difference-lessp-arg2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-itimes-tree-rec.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-itimes-tree.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-eval\$-fringe.

\addvspace{18pt}

\noindent{\sc Event}:   Disable integerp-eval\$-itimes.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-bagdiff.

\addvspace{18pt}

\noindent{\sc Event}:   Disable equal-itimes-list-eval\$-list-delete.

\addvspace{18pt}

\noindent{\sc Event}:   Disable member-izerop-itimes-fringe.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-hack-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-make-cancel-itimes-equality.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-make-cancel-itimes-equality-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-make-cancel-itimes-equality-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-equal-itimes-tree-itimes-fringe-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable izerop-eval-of-member-implies-itimes-list-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable subsetp-implies-itimes-list-eval\$-equals-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable equal-0-itimes-list-eval\$-bagint-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable equal-0-itimes-list-eval\$-bagint-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-hack-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-hack-3-lemma.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-hack-3.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-itimes-tree-no-fix-int-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-itimes-tree-no-fix-int-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-make-cancel-itimes-inequality.

\addvspace{18pt}

\noindent{\sc Event}:   Disable listp-bagint-with-singleton-implies-member.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-eval\$-list-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable listp-bagint-with-singleton-member.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-3-lemma-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-3-lemma-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-3.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp-hack-4.

\addvspace{18pt}
\begin{verbatim};; The last one is a tough call, but I think it's OK.
;; (disable ilessp-strict)

;;;;;; ***** EXTRA META STUFF ***** ;;;;;;

;; The next goal is to improve itimes cancellation so that it looks
;; for common factors, and hence works on equations like
;;    x*y + x = x*z
;; and, for that matter,
;; a*x + -b*x = 0.

;; Rather than changing the existing cancel-itimes function, I'll
;; leave that one but disable its metalemma at the end.  Then if the
;; new version, which I'll call cancel-itimes-factors, is found to be
;; too slow, one can always disable its metalemma and re-enable the
;; metalemma for cancel-itimes.

;; Notice, by the way, that the existing cancel-itimes function is
;; useless for something like the following, since there's no special
;; treatment for INEG.  I'll remedy that in this version.

#|
(IMPLIES (AND (NOT (IZEROP X))
	      (EQUAL (ITIMES A X) (INEG (ITIMES B X))))
	 (EQUAL (FIX-INT A) (INEG B)))
|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{itimes-tree-ineg} \\  
\=\+{\rm{itimes-tree-ineg}}\,({\it{l\/}})\index{itimes-tree-ineg} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{l\/}}) $=$ {\rm{list}}\,({\tt{'}}{\tt{quote}}, {\tt{-1}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{l\/}}))$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{ineg}}, {\rm{itimes-tree-rec}}\,({\rm{cdr}}\,({\it{l\/}}))\index{itimes-tree-rec}) \\ 
{\bf else }{\rm{car}}\,({\it{l\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{itimes-tree-rec}}\,({\it{l\/}})\index{itimes-tree-rec}$\;${\bf  endif}\- \\ 
{\bf else }{\tt{'}}{\tt{'}}{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{itimes-factors} \\  
\=\+{\rm{itimes-factors}}\,({\it{x\/}})\index{itimes-factors} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf then }{\rm{append}}\,({\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, {\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}) \\ 
{\bf elseif }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{bag1\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\it{bag2\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{inboth\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,({\it{bag1\/}}, {\it{bag2\/}})\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{inboth\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{list}}\,(\=\+{\tt{'}}{\tt{iplus}}, \\ 
{\rm{itimes-tree-ineg}}\,({\rm{bagdiff}}\,(\=\+{\it{bag1\/}}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{itimes-tree-ineg}, \\ 
{\rm{itimes-tree-ineg}}\,({\rm{bagdiff}}\,(\=\+{\it{bag2\/}}, \\ 
{\it{inboth\/}})\-\index{bagdiff})\index{itimes-tree-ineg})\-, \\ 
{\it{inboth\/}})\- \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }{\rm{cons}}\,({\rm{list}}\,({\tt{'}}{\tt{quote}}, {\tt{-1}}), {\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}) \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{list}}\,({\it{x\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes--1 \\ \index{itimes--1}
{\rm{itimes}}\,({\tt{-1}}, {\it{x\/}})\index{itimes} $=$ {\rm{ineg}}\,({\it{x\/}})\index{ineg}
\end{tabbing}

\begin{verbatim};; I'll need the following lemma because it's simplest not to deal with
;; e.g. (equal x x), where x is a variable, in the meta thing.  I'll do
;; the one after it too, simply because I'm thinking of it now.
\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-ineg-ineg \\ \index{equal-ineg-ineg}
({\rm{ineg}}\,({\it{x\/}})\index{ineg} $=$ {\rm{ineg}}\,({\it{y\/}})\index{ineg}) $=$ ({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-ineg-ineg \\ \index{ilessp-ineg-ineg}
{\rm{ilessp}}\,({\rm{ineg}}\,({\it{x\/}})\index{ineg}, {\rm{ineg}}\,({\it{y\/}})\index{ineg})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{y\/}}, {\it{x\/}})\index{ilessp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fix-int-eval\$-itimes-tree-rec \\ \index{fix-int-eval\$-itimes-tree-rec}
\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-rec}}\,({\it{x\/}})\index{itimes-tree-rec}, {\it{a\/}}))\index{fix-int} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-itimes-tree-ineg \\ \index{eval\$-itimes-tree-ineg}
{\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}))\index{fix-int} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}
\end{tabbing}

\begin{verbatim};; Now I want the above lemma to apply, but it doesn't, so the
;; following three lemmas are used instead.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ineg-eval\$-itimes-tree-ineg \\ \index{ineg-eval\$-itimes-tree-ineg}
\=\+{\rm{ineg}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}))\index{ineg} \\ 
$=$$\;\;\;\;${\rm{ineg}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\index{ineg}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-eval\$-itimes-tree-ineg \\ \index{iplus-eval\$-itimes-tree-ineg}
\=\+(\=\+{\rm{iplus}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}), {\it{y\/}})\index{iplus} \\ 
$=$$\;\;\;\;${\rm{iplus}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}, {\it{y\/}})\index{iplus})\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{iplus}}\,({\it{y\/}}, {\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}))\index{iplus} \\ 
$=$$\;\;\;\;${\rm{iplus}}\,({\it{y\/}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\index{iplus})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-eval\$-itimes-tree-ineg \\ \index{itimes-eval\$-itimes-tree-ineg}
\=\+(\=\+{\rm{itimes}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}), {\it{y\/}})\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}, {\it{y\/}})\index{itimes})\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{itimes}}\,({\it{y\/}}, {\rm{eval\$}}\,({\bf{t}}, {\rm{itimes-tree-ineg}}\,({\it{x\/}})\index{itimes-tree-ineg}, {\it{a\/}}))\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes}}\,({\it{y\/}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\index{itimes})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable itimes-tree-ineg.

\addvspace{18pt}

\begin{verbatim}#| ****** The following definitions are for efficient execution of
   metafunctions.  They should probably be applied to all the metafunctions
   with fns arguments AND and OR.

(defmacro nqthm-macroexpand (defn &rest fns)
  `(nqthm-macroexpand-fn ',defn ',fns))

(defun nqthm-macroexpand-fn (defn fns)
  (iterate for fn in fns
	   when (not (get fn 'sdefn))
	   do (er soft (fn) |Sorry| |,| |but| |there| |is| |no| SDEFN
		  |for| (!ppr fn (quote |.|))))
  (let (name args body)
    (match! defn (defn name args body))
    (let ((arity-alist (cons (cons name (length args)) arity-alist)))
      (list 'defn name args
	    (untranslate (normalize-ifs
			  (nqthm-macroexpand-term (translate body) fns)
			  nil nil nil))))))

(defun nqthm-macroexpand-term (term fns)
  (cond
   ((or (variablep term) (fquotep term))
    term)
   ((member-eq (ffn-symb term) fns)
    (let ((sdefn (get (ffn-symb term) 'sdefn)))
      (sub-pair-var (cadr sdefn)
		    (iterate for arg in (fargs term)
			     collect (nqthm-macroexpand-term arg fns))
		    (caddr sdefn))))
   (t (fcons-term (ffn-symb term)
		  (iterate for arg in (fargs term)
			   collect (nqthm-macroexpand-term arg fns))))))

|#

;; I "macroexpand" away the following below, so it's not really needed except
;; for the proof.  That is, I use it in the definition of cancel-itimes-factors,
;; but then get rid of it for cancel-itimes-factors-expanded, and although I
;; reason about the former, I USE the latter, for efficiency.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{iplus-or-itimes-term} \\  
\=\+{\rm{iplus-or-itimes-term}}\,({\it{x\/}})\index{iplus-or-itimes-term} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\it{x\/}}): \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf then }{\bf{t}} \\ 
{\bf case = }{\it{itimes\/}} \\ 
{\bf $\;\;$then }{\bf{t}} \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf $\;\;$then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}}))$\;\;${\bf then }{\rm{car}}\,({\rm{cadr}}\,({\it{x\/}})) $=$ {\tt{'}}{\tt{itimes}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{cancel-itimes-factors} \\  
\=\+{\rm{cancel-itimes-factors}}\,({\it{x\/}})\index{cancel-itimes-factors} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
{\bf then }\=\+{\bf let }\=\+{\it{bagint\/}}{\bf $\;$ be$\;\;$}{\rm{bagint}}\,(\=\+{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors})\-\index{bagint}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{new-equality\/}}{\bf $\;$ be$\;\;$}{\rm{make-cancel-itimes-equality}}\,(\=\+{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\it{bagint\/}})\-\index{make-cancel-itimes-equality}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{iplus-or-itimes-term}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-or-itimes-term} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{bagint\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{iplus-or-itimes-term}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-or-itimes-term} \\ 
{\bf then }{\it{new-equality\/}} \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{integerp}}, \\ 
{\rm{caddr}}\,({\it{x\/}}))\-, \\ 
{\it{new-equality\/}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{iplus-or-itimes-term}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-or-itimes-term} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{bagint\/}}) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\it{new-equality\/}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; The following was generated with the nqthm-macroexpand macro defined above.
\end{verbatim}%\item 
\begin{verbatim}


;; The following was generated with the nqthm-macroexpand macro defined above.
(DEFN CANCEL-ITIMES-FACTORS-expanded (X)
  (IF (LISTP X)
      (IF (EQUAL (CAR X) 'EQUAL)
	  (COND
	   ((LISTP (CADR X))
	    (CASE (CAR (CAR (CDR X)))
		  (IPLUS (IF (LISTP (BAGINT (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))))
			     (IF (LISTP (CADDR X))
				 (CASE (CAR (CAR (CDR (CDR X))))
				       (IPLUS
					(MAKE-CANCEL-ITIMES-EQUALITY
					 (ITIMES-FACTORS (CADR X))
					 (ITIMES-FACTORS (CADDR X))
					 (BAGINT (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X)))))
				       (ITIMES
					(MAKE-CANCEL-ITIMES-EQUALITY
					 (ITIMES-FACTORS (CADR X))
					 (ITIMES-FACTORS (CADDR X))
					 (BAGINT (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X)))))
				       (INEG
					(IF (LISTP (CADADDR X))
					    (IF (EQUAL (CAADADDR X) 'ITIMES)
						(MAKE-CANCEL-ITIMES-EQUALITY
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))
						 (BAGINT
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))))
						(LIST 'IF
						      (LIST 'INTEGERP (CADDR X))
						      (MAKE-CANCEL-ITIMES-EQUALITY
						       (ITIMES-FACTORS (CADR X))
						       (ITIMES-FACTORS (CADDR X))
						       (BAGINT
							(ITIMES-FACTORS (CADR X))
							(ITIMES-FACTORS (CADDR X))))
						      (LIST 'QUOTE F)))
					    (LIST 'IF
						  (LIST 'INTEGERP (CADDR X))
						  (MAKE-CANCEL-ITIMES-EQUALITY
						   (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))
						   (BAGINT
						    (ITIMES-FACTORS (CADR X))
						    (ITIMES-FACTORS (CADDR X))))
						  (LIST 'QUOTE F))))
				       (OTHERWISE
					(LIST 'IF
					      (LIST 'INTEGERP (CADDR X))
					      (MAKE-CANCEL-ITIMES-EQUALITY
					       (ITIMES-FACTORS (CADR X))
					       (ITIMES-FACTORS (CADDR X))
					       (BAGINT
						(ITIMES-FACTORS (CADR X))
						(ITIMES-FACTORS (CADDR X))))
					      (LIST 'QUOTE F))))
				 (LIST 'IF (LIST 'INTEGERP (CADDR X))
				       (MAKE-CANCEL-ITIMES-EQUALITY
					(ITIMES-FACTORS (CADR X))
					(ITIMES-FACTORS (CADDR X))
					(BAGINT
					 (ITIMES-FACTORS (CADR X))
					 (ITIMES-FACTORS (CADDR X))))
				       (LIST 'QUOTE F)))
			     X))
		  (ITIMES (IF (LISTP (BAGINT (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
			      (IF (LISTP (CADDR X))
				  (CASE (CAR (CAR (CDR (CDR X))))
					(IPLUS
					 (MAKE-CANCEL-ITIMES-EQUALITY
					  (ITIMES-FACTORS (CADR X))
					  (ITIMES-FACTORS (CADDR X))
					  (BAGINT
					   (ITIMES-FACTORS (CADR X))
					   (ITIMES-FACTORS (CADDR X)))))
					(ITIMES
					 (MAKE-CANCEL-ITIMES-EQUALITY
					  (ITIMES-FACTORS (CADR X))
					  (ITIMES-FACTORS (CADDR X))
					  (BAGINT
					   (ITIMES-FACTORS (CADR X))
					   (ITIMES-FACTORS (CADDR X)))))
					(INEG
					 (IF (LISTP (CADADDR X))
					     (IF (EQUAL (CAADADDR X) 'ITIMES)
						 (MAKE-CANCEL-ITIMES-EQUALITY
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))
						  (BAGINT
						   (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))))
						 (LIST 'IF
						       (LIST 'INTEGERP (CADDR X))
						       (MAKE-CANCEL-ITIMES-EQUALITY
							(ITIMES-FACTORS (CADR X))
							(ITIMES-FACTORS (CADDR X))
							(BAGINT
							 (ITIMES-FACTORS (CADR X))
							 (ITIMES-FACTORS (CADDR X))))
						       (LIST 'QUOTE F)))
					     (LIST 'IF
						   (LIST 'INTEGERP (CADDR X))
						   (MAKE-CANCEL-ITIMES-EQUALITY
						    (ITIMES-FACTORS (CADR X))
						    (ITIMES-FACTORS (CADDR X))
						    (BAGINT
						     (ITIMES-FACTORS (CADR X))
						     (ITIMES-FACTORS (CADDR X))))
						   (LIST 'QUOTE F))))
					(OTHERWISE
					 (LIST 'IF
					       (LIST 'INTEGERP (CADDR X))
					       (MAKE-CANCEL-ITIMES-EQUALITY
						(ITIMES-FACTORS (CADR X))
						(ITIMES-FACTORS (CADDR X))
						(BAGINT
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))))
					       (LIST 'QUOTE F))))
				  (LIST 'IF (LIST 'INTEGERP (CADDR X))
					(MAKE-CANCEL-ITIMES-EQUALITY
					 (ITIMES-FACTORS (CADR X))
					 (ITIMES-FACTORS (CADDR X))
					 (BAGINT (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))))
					(LIST 'QUOTE F)))
			      X))
		  (INEG (COND
			 ((LISTP (CADADR X))
			  (COND
			   ((EQUAL (CAADADR X) 'ITIMES)
			    (IF (LISTP
				 (BAGINT (ITIMES-FACTORS (CADR X))
					 (ITIMES-FACTORS (CADDR X))))
				(IF (LISTP (CADDR X))
                                    (CASE (CAR (CAR (CDR (CDR X))))
					  (IPLUS
					   (MAKE-CANCEL-ITIMES-EQUALITY
					    (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))
					    (BAGINT
					     (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X)))))
					  (ITIMES
					   (MAKE-CANCEL-ITIMES-EQUALITY
					    (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))
					    (BAGINT
					     (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X)))))
					  (INEG
					   (IF (LISTP (CADADDR X))
					       (IF
						(EQUAL (CAADADDR X) 'ITIMES)
						(MAKE-CANCEL-ITIMES-EQUALITY
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))
						 (BAGINT
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))))
						(LIST 'IF
						      (LIST 'INTEGERP (CADDR X))
						      (MAKE-CANCEL-ITIMES-EQUALITY
						       (ITIMES-FACTORS (CADR X))
						       (ITIMES-FACTORS (CADDR X))
						       (BAGINT
							(ITIMES-FACTORS (CADR X))
							(ITIMES-FACTORS (CADDR X))))
						      (LIST 'QUOTE F)))
					       (LIST 'IF
						     (LIST 'INTEGERP (CADDR X))
						     (MAKE-CANCEL-ITIMES-EQUALITY
						      (ITIMES-FACTORS (CADR X))
						      (ITIMES-FACTORS (CADDR X))
						      (BAGINT
						       (ITIMES-FACTORS (CADR X))
						       (ITIMES-FACTORS (CADDR X))))
						     (LIST 'QUOTE F))))
					  (OTHERWISE
					   (LIST 'IF
						 (LIST 'INTEGERP (CADDR X))
						 (MAKE-CANCEL-ITIMES-EQUALITY
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))
						  (BAGINT
						   (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))))
						 (LIST 'QUOTE F))))
                                    (LIST 'IF
					  (LIST 'INTEGERP (CADDR X))
					  (MAKE-CANCEL-ITIMES-EQUALITY
					   (ITIMES-FACTORS (CADR X))
					   (ITIMES-FACTORS (CADDR X))
					   (BAGINT (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))))
					  (LIST 'QUOTE F)))
				X))
			   ((LISTP (CADDR X))
			    (CASE (CAR (CAR (CDR (CDR X))))
				  (IPLUS (IF
					  (LISTP
					   (BAGINT
					    (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))))
					  (LIST 'IF
						(LIST 'INTEGERP (CADR X))
						(MAKE-CANCEL-ITIMES-EQUALITY
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))
						 (BAGINT
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))))
						(LIST 'QUOTE F))
					  X))
				  (ITIMES (IF
					   (LISTP
					    (BAGINT
					     (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
					   (LIST 'IF
						 (LIST 'INTEGERP (CADR X))
						 (MAKE-CANCEL-ITIMES-EQUALITY
						  (ITIMES-FACTORS (CADR X))
						  (ITIMES-FACTORS (CADDR X))
						  (BAGINT
						   (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))))
						 (LIST 'QUOTE F))
					   X))
				  (INEG (IF (LISTP (CADADDR X))
					    (IF
					     (EQUAL (CAADADDR X) 'ITIMES)
					     (IF
					      (LISTP
					       (BAGINT
						(ITIMES-FACTORS (CADR X))
						(ITIMES-FACTORS (CADDR X))))
					      (LIST 'IF
						    (LIST 'INTEGERP (CADR X))
						    (MAKE-CANCEL-ITIMES-EQUALITY
						     (ITIMES-FACTORS (CADR X))
						     (ITIMES-FACTORS (CADDR X))
						     (BAGINT
						      (ITIMES-FACTORS (CADR X))
						      (ITIMES-FACTORS (CADDR X))))
						    (LIST 'QUOTE F))
					      X)
					     X)
					    X))
				  (OTHERWISE X)))
			   (T X)))
			 ((LISTP (CADDR X))
			  (CASE (CAR (CAR (CDR (CDR X))))
				(IPLUS (IF
					(LISTP
					 (BAGINT
					  (ITIMES-FACTORS (CADR X))
					  (ITIMES-FACTORS (CADDR X))))
					(LIST 'IF
					      (LIST 'INTEGERP (CADR X))
					      (MAKE-CANCEL-ITIMES-EQUALITY
					       (ITIMES-FACTORS (CADR X))
					       (ITIMES-FACTORS (CADDR X))
					       (BAGINT
						(ITIMES-FACTORS (CADR X))
						(ITIMES-FACTORS (CADDR X))))
					      (LIST 'QUOTE F))
					X))
				(ITIMES (IF
					 (LISTP
					  (BAGINT
					   (ITIMES-FACTORS (CADR X))
					   (ITIMES-FACTORS (CADDR X))))
					 (LIST 'IF
					       (LIST 'INTEGERP (CADR X))
					       (MAKE-CANCEL-ITIMES-EQUALITY
						(ITIMES-FACTORS (CADR X))
						(ITIMES-FACTORS (CADDR X))
						(BAGINT
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))))
					       (LIST 'QUOTE F))
					 X))
				(INEG (IF (LISTP (CADADDR X))
					  (IF (EQUAL (CAADADDR X) 'ITIMES)
					      (IF
					       (LISTP
						(BAGINT
						 (ITIMES-FACTORS (CADR X))
						 (ITIMES-FACTORS (CADDR X))))
					       (LIST 'IF
						     (LIST 'INTEGERP (CADR X))
						     (MAKE-CANCEL-ITIMES-EQUALITY
						      (ITIMES-FACTORS (CADR X))
						      (ITIMES-FACTORS (CADDR X))
						      (BAGINT
						       (ITIMES-FACTORS (CADR X))
						       (ITIMES-FACTORS (CADDR X))))
						     (LIST 'QUOTE F))
					       X)
					      X)
					  X))
				(OTHERWISE X)))
			 (T X)))
		  (OTHERWISE
		   (IF (LISTP (CADDR X))
		       (CASE (CAR (CAR (CDR (CDR X))))
                             (IPLUS (IF
                                     (LISTP
                                      (BAGINT (ITIMES-FACTORS (CADR X))
					      (ITIMES-FACTORS (CADDR X))))
                                     (LIST 'IF
					   (LIST 'INTEGERP (CADR X))
					   (MAKE-CANCEL-ITIMES-EQUALITY
					    (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))
					    (BAGINT
					     (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
					   (LIST 'QUOTE F))
                                     X))
                             (ITIMES (IF
                                      (LISTP
                                       (BAGINT
                                        (ITIMES-FACTORS (CADR X))
                                        (ITIMES-FACTORS (CADDR X))))
                                      (LIST 'IF
					    (LIST 'INTEGERP (CADR X))
					    (MAKE-CANCEL-ITIMES-EQUALITY
					     (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))
					     (BAGINT
					      (ITIMES-FACTORS (CADR X))
					      (ITIMES-FACTORS (CADDR X))))
					    (LIST 'QUOTE F))
                                      X))
                             (INEG (IF (LISTP (CADADDR X))
				       (IF (EQUAL (CAADADDR X) 'ITIMES)
					   (IF
					    (LISTP
					     (BAGINT
					      (ITIMES-FACTORS (CADR X))
					      (ITIMES-FACTORS (CADDR X))))
					    (LIST 'IF
						  (LIST 'INTEGERP (CADR X))
						  (MAKE-CANCEL-ITIMES-EQUALITY
						   (ITIMES-FACTORS (CADR X))
						   (ITIMES-FACTORS (CADDR X))
						   (BAGINT
						    (ITIMES-FACTORS (CADR X))
						    (ITIMES-FACTORS (CADDR X))))
						  (LIST 'QUOTE F))
					    X)
					   X)
				       X))
                             (OTHERWISE X))
		       X))))
	   ((LISTP (CADDR X))
	    (CASE (CAR (CAR (CDR (CDR X))))
		  (IPLUS (IF (LISTP (BAGINT (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))))
			     (LIST 'IF (LIST 'INTEGERP (CADR X))
				   (MAKE-CANCEL-ITIMES-EQUALITY
				    (ITIMES-FACTORS (CADR X))
				    (ITIMES-FACTORS (CADDR X))
				    (BAGINT (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))))
				   (LIST 'QUOTE F))
			     X))
		  (ITIMES (IF (LISTP (BAGINT (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
			      (LIST 'IF (LIST 'INTEGERP (CADR X))
				    (MAKE-CANCEL-ITIMES-EQUALITY
				     (ITIMES-FACTORS (CADR X))
				     (ITIMES-FACTORS (CADDR X))
				     (BAGINT (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
				    (LIST 'QUOTE F))
			      X))
		  (INEG (IF (LISTP (CADADDR X))
			    (IF (EQUAL (CAADADDR X) 'ITIMES)
				(IF (LISTP
				     (BAGINT (ITIMES-FACTORS (CADR X))
					     (ITIMES-FACTORS (CADDR X))))
				    (LIST 'IF
					  (LIST 'INTEGERP (CADR X))
					  (MAKE-CANCEL-ITIMES-EQUALITY
					   (ITIMES-FACTORS (CADR X))
					   (ITIMES-FACTORS (CADDR X))
					   (BAGINT
					    (ITIMES-FACTORS (CADR X))
					    (ITIMES-FACTORS (CADDR X))))
					  (LIST 'QUOTE F))
				    X)
				X)
			    X))
		  (OTHERWISE X)))
	   (T X))
	  X)
      X))
\end{verbatim}


\begin{tabbing}{\sc Theorem}:  cancel-itimes-factors-expanded-cancel-itimes-factors \\ \index{cancel-itimes-factors-expanded-!cancel-itimes-factors}
{\rm{cancel-itimes-factors-expanded}}\,({\it{x\/}})\index{cancel-itimes-factors-expanded} $=$ {\rm{cancel-itimes-factors}}\,({\it{x\/}})\index{cancel-itimes-factors}
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-itimes-factors-expanded.

\addvspace{18pt}


\noindent{\sc Event}:   Disable iplus-or-itimes-term.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  equal-itimes-list-eval\$-list-delete-new-1 \\ \index{equal-itimes-list-eval\$-list-de!lete-new-1}
\=\+({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{elt\/}}, {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\it{x\/}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{elt\/}}, {\it{bag\/}})\index{delete}, {\it{a\/}}))\index{itimes-list}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{elt\/}} $\in$ {\it{bag\/}} \\ 
{\bf then }\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{elt\/}}, {\it{a\/}}))\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list})\-\- \\ 
{\bf else }{\it{x\/}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-list-eval\$-list-delete-new-2 \\ \index{equal-itimes-list-eval\$-list-de!lete-new-2}
\=\+({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{elt\/}}, {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{elt\/}}, {\it{bag\/}})\index{delete}, {\it{a\/}}))\index{itimes-list} $=$ {\it{x\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{elt\/}} $\in$ {\it{bag\/}} \\ 
{\bf then }\=\+{\rm{integerp}}\,({\it{x\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{elt\/}}, {\it{a\/}}))\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list})\-\- \\ 
{\bf else }{\it{x\/}} $=$ {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-itimes-list-eval\$-list-delete \\ \index{itimes-itimes-list-eval\$-list-!delete}
\=\+({\it{x\/}} $\in$ {\it{bag\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{itimes}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}), {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{x\/}}, {\it{bag\/}})\index{delete}, {\it{a\/}}))\index{itimes-list})\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag\/}}, {\it{a\/}}))\index{itimes-list})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-itimes-list-eval\$-list-bagdiff \\ \index{equal-itimes-list-eval\$-list-b!agdiff}
\=\+(\=\+{\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag1\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag2\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{in-both\/}}, {\it{a\/}}))\index{itimes-list} $\not=$ {\tt{0}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag1\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag2\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\- \\ 
$=$$\;\;\;\;$(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  membership-of-0-implies-itimes-list-is-0 \\ \index{membership-of-0-implies-itimes-!list-is-0}
({\tt{0}} $\in$ {\it{x\/}}) $\rightarrow$ ({\rm{itimes-list}}\,({\it{x\/}})\index{itimes-list} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-0-eval\$-list \\ \index{member-0-eval\$-list}
({\tt{0}} $\in$ {\it{x\/}}) $\rightarrow$ ({\tt{0}} $\in$ {\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-factors-lemma \\ \index{itimes-list-eval\$-factors-lemm!a}
\=\+{\rm{itimes}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{bag1\/}}, {\it{bag2\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag2\/}}, {\rm{bagint}}\,({\it{bag1\/}}, {\it{bag2\/}})\index{bagint})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-factors-lemma-prime \\ \index{itimes-list-eval\$-factors-lemm!a-prime}
\=\+{\rm{itimes}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{bag1\/}}, {\it{bag2\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag1\/}}, {\rm{bagint}}\,({\it{bag1\/}}, {\it{bag2\/}})\index{bagint})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{itimes} \\ 
$=$$\;\;\;\;${\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  itimes-list-eval\$-factors \\ \index{itimes-list-eval\$-factors}
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{itimes-factors}}\,({\it{x\/}})\index{itimes-factors}, {\it{a\/}}))\index{itimes-list} $=$ {\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{fix-int}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-or-itimes-term-integerp-eval\$ \\ \index{iplus-or-itimes-term-integerp-ev!al\$}
{\rm{iplus-or-itimes-term}}\,({\it{x\/}})\index{iplus-or-itimes-term} $\rightarrow$ {\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-bagint-0 \\ \index{eval\$-list-bagint-0}
\=\+({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-bagint-0-implies-equal \\ \index{eval\$-list-bagint-0-implies-eq!ual}
\=\+(\=\+(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors}, {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})\index{bagint}, {\it{a\/}}))\index{itimes-list} \\ 
$=$$\;\;\;\;${\tt{0}})\- \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}))\index{integerp} \\ 
$\wedge$$\;\;\;\;${\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}))\index{integerp})\- \\ 
$\rightarrow$$\;\;\;\;$(({\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}})) $=$ {\bf{t}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-factors \\ \index{correctness-of-cancel-itimes-fa!ctors}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-itimes-factors-expanded}}\,({\it{x\/}})\index{cancel-itimes-factors-expanded}, {\it{a\/}})
\end{tabbing}

\begin{verbatim};; OK -- now, the lessp case, finally.  Ugh!

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-itimes-ilessp-factors} \\  
\=\+{\rm{cancel-itimes-ilessp-factors}}\,({\it{x\/}})\index{cancel-itimes-ilessp-factors} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{bagint}}\,(\=\+{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors})\-\index{bagint}) \\ 
{\bf then }{\rm{make-cancel-itimes-inequality}}\,(\=\+{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors})\-\index{bagint})\-\index{make-cancel-itimes-inequality} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  bagint-singleton \\ \index{bagint-singleton}
\=\+{\rm{bagint}}\,({\it{x\/}}, {\rm{list}}\,({\it{y\/}}))\index{bagint} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{y\/}} $\in$ {\it{x\/}}$\;\;${\bf then }{\rm{list}}\,({\it{y\/}}) \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  izerop-ilessp-0-relationship \\ \index{izerop-ilessp-0-relationship}
({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\tt{0}}) $=$ (($\neg$ {\rm{ilessp}}\,({\it{x\/}}, {\tt{0}})\index{ilessp}) $\wedge$ ($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\it{x\/}})\index{ilessp}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete-helper-1 \\ \index{ilessp-itimes-list-eval\$-list-!delete-helper-1}
{\rm{ilessp}}\,({\tt{0}}, {\it{w\/}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{w\/}})\index{itimes}, {\rm{itimes}}\,({\it{w\/}}, {\it{u\/}})\index{itimes})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{x\/}}, {\it{u\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete-helper-2 \\ \index{ilessp-itimes-list-eval\$-list-!delete-helper-2}
{\rm{ilessp}}\,({\it{w\/}}, {\tt{0}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\rm{itimes}}\,({\it{w\/}}, {\it{u\/}})\index{itimes}, {\rm{itimes}}\,({\it{x\/}}, {\it{w\/}})\index{itimes})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{x\/}}, {\it{u\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete \\ \index{ilessp-itimes-list-eval\$-list-!delete}
\=\+(({\it{z\/}} $\in$ {\it{y\/}}) $\wedge$ ({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,({\it{x\/}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{z\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{itimes-list})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{ilessp}}\,({\tt{0}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{ilessp} \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{itimes}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
{\bf elseif }{\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}), {\tt{0}})\index{ilessp} \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{itimes})\-\index{ilessp} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete-prime-helper-1 \\ \index{ilessp-itimes-list-eval\$-list-!delete-prime-helper-1}
{\rm{ilessp}}\,({\tt{0}}, {\it{w\/}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\rm{itimes}}\,({\it{w\/}}, {\it{u\/}})\index{itimes}, {\rm{itimes}}\,({\it{x\/}}, {\it{w\/}})\index{itimes})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{u\/}}, {\it{x\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete-prime-helper-2 \\ \index{ilessp-itimes-list-eval\$-list-!delete-prime-helper-2}
{\rm{ilessp}}\,({\it{w\/}}, {\tt{0}})\index{ilessp} $\rightarrow$ ({\rm{ilessp}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{w\/}})\index{itimes}, {\rm{itimes}}\,({\it{w\/}}, {\it{u\/}})\index{itimes})\index{ilessp} $=$ {\rm{ilessp}}\,({\it{u\/}}, {\it{x\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-delete-prime \\ \index{ilessp-itimes-list-eval\$-list-!delete-prime}
\=\+(({\it{z\/}} $\in$ {\it{y\/}}) $\wedge$ ({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{fix-int} $\not=$ {\tt{0}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{delete}}\,({\it{z\/}}, {\it{y\/}})\index{delete}, {\it{a\/}}))\index{itimes-list}, {\it{x\/}})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{ilessp}}\,({\tt{0}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{ilessp} \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{itimes})\-\index{ilessp} \\ 
{\bf elseif }{\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}), {\tt{0}})\index{ilessp} \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{itimes}}\,({\it{x\/}}, {\rm{eval\$}}\,({\bf{t}}, {\it{z\/}}, {\it{a\/}}))\index{itimes}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{verbatim};; **** Do I have anything like the following two lemmas for the equality case?
;; Should I?

;;;***** I should also consider if I've dealt with things like 0 = a*x + b*x, and
;;; simlilarly for ilessp.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  ilessp-0-itimes \\ \index{ilessp-0-itimes}
\=\+{\rm{ilessp}}\,({\tt{0}}, {\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes})\index{ilessp} \\ 
$=$$\;\;\;\;$(({\rm{ilessp}}\,({\tt{0}}, {\it{x\/}})\index{ilessp} $\wedge$ {\rm{ilessp}}\,({\tt{0}}, {\it{y\/}})\index{ilessp}) $\vee$ ({\rm{ilessp}}\,({\it{x\/}}, {\tt{0}})\index{ilessp} $\wedge$ {\rm{ilessp}}\,({\it{y\/}}, {\tt{0}})\index{ilessp}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-0 \\ \index{ilessp-itimes-0}
\=\+{\rm{ilessp}}\,({\rm{itimes}}\,({\it{x\/}}, {\it{y\/}})\index{itimes}, {\tt{0}})\index{ilessp} \\ 
$=$$\;\;\;\;$(({\rm{ilessp}}\,({\tt{0}}, {\it{x\/}})\index{ilessp} $\wedge$ {\rm{ilessp}}\,({\it{y\/}}, {\tt{0}})\index{ilessp}) $\vee$ ({\rm{ilessp}}\,({\it{x\/}}, {\tt{0}})\index{ilessp} $\wedge$ {\rm{ilessp}}\,({\tt{0}}, {\it{y\/}})\index{ilessp}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-bagdiff \\ \index{ilessp-itimes-list-eval\$-list-!bagdiff}
\=\+(\=\+{\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag1\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag2\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;$({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{in-both\/}}, {\it{a\/}}))\index{itimes-list} $\not=$ {\tt{0}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag1\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag2\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{in-both\/}}, {\it{a\/}}))\index{itimes-list})\index{ilessp} \\ 
{\bf then }{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
{\bf else }{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  zero-ilessp-implies-not-equal \\ \index{zero-ilessp-implies-not-equal}
{\rm{ilessp}}\,({\tt{0}}, {\it{x\/}})\index{ilessp} $\rightarrow$ ({\tt{0}} $\not=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-bagdiff-corollary-1 \\ \index{ilessp-itimes-list-eval\$-list-!bagdiff-corollary-1}
\=\+(\=\+{\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag1\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag2\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{in-both\/}}, {\it{a\/}}))\index{itimes-list})\index{ilessp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag1\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag2\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-zero-implies-not-equal \\ \index{ilessp-zero-implies-not-equal}
{\rm{ilessp}}\,({\it{x\/}}, {\tt{0}})\index{ilessp} $\rightarrow$ ({\tt{0}} $\not=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-itimes-list-eval\$-list-bagdiff-corollary-2 \\ \index{ilessp-itimes-list-eval\$-list-!bagdiff-corollary-2}
\=\+(\=\+{\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag1\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{subbagp}}\,({\it{in-both\/}}, {\it{bag2\/}})\index{subbagp} \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{in-both\/}}, {\it{a\/}}))\index{itimes-list}, {\tt{0}})\index{ilessp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag1\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagdiff}}\,({\it{bag2\/}}, {\it{in-both\/}})\index{bagdiff}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp} \\ 
$=$$\;\;\;\;${\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag2\/}}, {\it{a\/}}))\index{itimes-list}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{bag1\/}}, {\it{a\/}}))\index{itimes-list})\-\index{ilessp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-0-itimes-factors-yields-0 \\ \index{member-0-itimes-factors-yields-!0}
({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}) $\not=$ {\tt{0}}) $\rightarrow$ ({\tt{0}} $\not\in$ {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-0-itimes-factors-yields-0-ilessp-consequence-1 \\ \index{member-0-itimes-factors-yields-!0-ilessp-consequence-1}
{\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}), {\tt{0}})\index{ilessp} $\rightarrow$ ({\tt{0}} $\not\in$ {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-0-itimes-factors-yields-0-ilessp-consequence-2 \\ \index{member-0-itimes-factors-yields-!0-ilessp-consequence-2}
{\rm{ilessp}}\,({\tt{0}}, {\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}))\index{ilessp} $\rightarrow$ ({\tt{0}} $\not\in$ {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})
\end{tabbing}

\begin{verbatim}#|
(prove-lemma eval$-list-bagint-0 nil
  (implies (equal (itimes-list (eval$ 'list (bagint x y) a)) 0)
	   (and (equal (itimes-list (eval$ 'list x a)) 0)
		(equal (itimes-list (eval$ 'list y a)) 0)))
  ((use (subsetp-implies-itimes-list-eval$-equals-0
	 (x (bagint x y))
	 (y x))
	(subsetp-implies-itimes-list-eval$-equals-0
	 (x (bagint x y))
	 (y y)))))
|#

#|
(prove-lemma eval$-list-bagint-0-implies-equal (rewrite)
  (implies (and (equal (itimes-list (eval$ 'list (bagint (itimes-factors v) (itimes-factors w)) a))
		       0)
		(integerp (eval$ t v a))
		(integerp (eval$ t w a)))
	   (equal (equal (eval$ t v a) (eval$ t w a))
		  t))
  ((use (eval$-list-bagint-0 (x (itimes-factors v))
			     (y (itimes-factors w))))))
|#

;; At this point I'm going to switch the states of ilessp-trichotomy and
;; izerop-ilessp-0-relationship, for good (or till I change my mind again!).

\end{verbatim}
\noindent{\sc Event}:   Enable ilessp-trichotomy.

\addvspace{18pt}

\noindent{\sc Event}:   Disable izerop-ilessp-0-relationship.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-list-bagint-0-for-ilessp \\ \index{eval\$-list-bagint-0-for-ilessp}
\=\+(\=\+($\neg$ {\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list}, {\tt{0}})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{bagint}}\,({\it{x\/}}, {\it{y\/}})\index{bagint}, {\it{a\/}}))\index{itimes-list})\index{ilessp}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{fix-int}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\index{fix-int} $=$ {\tt{0}}) \\ 
$\wedge$$\;\;\;\;$({\rm{fix-int}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{y\/}}, {\it{a\/}}))\index{itimes-list})\index{fix-int} $=$ {\tt{0}}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-bagint-0-implies-equal-for-ilessp-lemma \\ \index{eval\$-list-bagint-0-implies-eq!ual-for-ilessp-lemma}
\=\+(\=\+($\neg$ {\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagint}}\,({\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors}, {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})\index{bagint}, \\ 
{\it{a\/}})\-)\index{itimes-list}, \\ 
{\tt{0}})\-\index{ilessp}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,(\=\+{\tt{0}}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})\-\index{bagint}, \\ 
{\it{a\/}})\-)\index{itimes-list})\-\index{ilessp}))\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}))\index{fix-int} $=$ {\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}))\index{fix-int})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-fix-int-to-ilessp \\ \index{equal-fix-int-to-ilessp}
({\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}) $\rightarrow$ ($\neg$ {\rm{ilessp}}\,({\it{x\/}}, {\it{y\/}})\index{ilessp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-list-bagint-0-implies-equal-for-ilessp \\ \index{eval\$-list-bagint-0-implies-eq!ual-for-ilessp}
\=\+(\=\+($\neg$ {\rm{ilessp}}\,(\=\+{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagint}}\,({\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors}, {\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})\index{bagint}, \\ 
{\it{a\/}})\-)\index{itimes-list}, \\ 
{\tt{0}})\-\index{ilessp}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,(\=\+{\tt{0}}, \\ 
{\rm{itimes-list}}\,({\rm{eval\$}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{bagint}}\,(\=\+{\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors}, \\ 
{\rm{itimes-factors}}\,({\it{w\/}})\index{itimes-factors})\-\index{bagint}, \\ 
{\it{a\/}})\-)\index{itimes-list})\-\index{ilessp}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+($\neg$ {\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}))\index{ilessp}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{w\/}}, {\it{a\/}}), {\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}))\index{ilessp}))\-\-
\end{tabbing}

\begin{verbatim};; The rewrite rule ILESSP-TRICHOTOMY seemed to mess up the proof of the following,
;; so I'm just going to leave it disabled.
\end{verbatim}
\noindent{\sc Event}:   Disable ilessp-trichotomy.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-itimes-ilessp-factors \\ \index{correctness-of-cancel-itimes-ile!ssp-factors}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-itimes-ilessp-factors}}\,({\it{x\/}})\index{cancel-itimes-ilessp-factors}, {\it{a\/}})
\end{tabbing}

\begin{verbatim};; OK -- now, the zero cases.

\end{verbatim}
\noindent{\sc Event}:   Enable lessp-count-listp-cdr.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{disjoin-equalities-with-0} \\  
\=\+{\rm{disjoin-equalities-with-0}}\,({\it{factors\/}})\index{disjoin-equalities-with-0} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{or}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{equal}}, {\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{car}}\,({\it{factors\/}})), {\tt{'}}{\tt{'}}{\tt{0}}), \\ 
{\rm{disjoin-equalities-with-0}}\,({\rm{cdr}}\,({\it{factors\/}}))\index{disjoin-equalities-with-0})\- \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{equal}}, {\rm{list}}\,({\tt{'}}{\tt{fix-int}}, {\rm{car}}\,({\it{factors\/}})), {\tt{'}}{\tt{'}}{\tt{0}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable lessp-count-listp-cdr.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{cancel-factors-0} \\  
\=\+{\rm{cancel-factors-0}}\,({\it{x\/}})\index{cancel-factors-0} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{factors\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }{\rm{disjoin-equalities-with-0}}\,({\it{factors\/}})\index{disjoin-equalities-with-0} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{factors\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }{\rm{disjoin-equalities-with-0}}\,({\it{factors\/}})\index{disjoin-equalities-with-0} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{some-eval\$s-to-0} \\  
\=\+{\rm{some-eval\$s-to-0}}\,({\it{x\/}}, {\it{a\/}})\index{some-eval\$s-to-0} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+({\rm{fix-int}}\,({\rm{eval\$}}\,({\bf{t}}, {\rm{car}}\,({\it{x\/}}), {\it{a\/}}))\index{fix-int} $=$ {\tt{0}}) \\ 
$\vee$$\;\;\;\;${\rm{some-eval\$s-to-0}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{a\/}})\index{some-eval\$s-to-0}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-disjoin-equalities-with-0 \\ \index{eval\$-disjoin-equalities-with-!0}
\=\+{\rm{listp}}\,({\it{lst\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{disjoin-equalities-with-0}}\,({\it{lst\/}})\index{disjoin-equalities-with-0}, {\it{a\/}}) \\ 
$=$$\;\;\;\;${\rm{some-eval\$s-to-0}}\,({\it{lst\/}}, {\it{a\/}})\index{some-eval\$s-to-0})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  some-eval\$s-to-0-append \\ \index{some-eval\$s-to-0-append}
\=\+{\rm{some-eval\$s-to-0}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}), {\it{a\/}})\index{some-eval\$s-to-0} \\ 
$=$$\;\;\;\;$({\rm{some-eval\$s-to-0}}\,({\it{x\/}}, {\it{a\/}})\index{some-eval\$s-to-0} $\vee$ {\rm{some-eval\$s-to-0}}\,({\it{y\/}}, {\it{a\/}})\index{some-eval\$s-to-0})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  some-eval\$s-to-0-eliminator \\ \index{some-eval\$s-to-0-eliminator}
{\rm{some-eval\$s-to-0}}\,({\it{x\/}}, {\it{a\/}})\index{some-eval\$s-to-0} $=$ ({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-cdr-factors-implies-integerp \\ \index{listp-cdr-factors-implies-intege!rp}
{\rm{listp}}\,({\rm{cdr}}\,({\rm{itimes-factors}}\,({\it{v\/}})\index{itimes-factors})) $\rightarrow$ {\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{v\/}}, {\it{a\/}}))\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-factors-0 \\ \index{correctness-of-cancel-factors-0}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-factors-0}}\,({\it{x\/}})\index{cancel-factors-0}, {\it{a\/}})
\end{tabbing}

\begin{verbatim};; and now for inequalities...

\end{verbatim}
\noindent{\sc Event}:   Enable lessp-count-listp-cdr.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{conjoin-inequalities-with-0} \\  
\=\+{\rm{conjoin-inequalities-with-0}}\,({\it{factors\/}}, {\it{parity\/}})\index{conjoin-inequalities-with-0} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }\=\+{\bf if }{\it{parity\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{or}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\tt{'}}{\tt{'}}{\tt{0}}, {\rm{car}}\,({\it{factors\/}})), \\ 
{\rm{conjoin-inequalities-with-0}}\,({\rm{cdr}}\,({\it{factors\/}}), {\bf{t}})\index{conjoin-inequalities-with-0})\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\rm{car}}\,({\it{factors\/}}), {\tt{'}}{\tt{'}}{\tt{0}}), \\ 
{\rm{conjoin-inequalities-with-0}}\,({\rm{cdr}}\,({\it{factors\/}}), {\bf{f}})\index{conjoin-inequalities-with-0})\-)\- \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{or}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\rm{car}}\,({\it{factors\/}}), {\tt{'}}{\tt{'}}{\tt{0}}), \\ 
{\rm{conjoin-inequalities-with-0}}\,({\rm{cdr}}\,({\it{factors\/}}), {\bf{t}})\index{conjoin-inequalities-with-0})\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{and}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\tt{'}}{\tt{'}}{\tt{0}}, {\rm{car}}\,({\it{factors\/}})), \\ 
{\rm{conjoin-inequalities-with-0}}\,({\rm{cdr}}\,({\it{factors\/}}), {\bf{f}})\index{conjoin-inequalities-with-0})\-)\-$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{parity\/}}$\;\;${\bf then }{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\tt{'}}{\tt{'}}{\tt{0}}, {\rm{car}}\,({\it{factors\/}})) \\ 
{\bf else }{\rm{list}}\,({\tt{'}}{\tt{ilessp}}, {\rm{car}}\,({\it{factors\/}}), {\tt{'}}{\tt{'}}{\tt{0}})$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable lessp-count-listp-cdr.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{cancel-factors-ilessp-0} \\  
\=\+{\rm{cancel-factors-ilessp-0}}\,({\it{x\/}})\index{cancel-factors-ilessp-0} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{factors\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{caddr}}\,({\it{x\/}}))\index{itimes-factors}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }{\rm{conjoin-inequalities-with-0}}\,({\it{factors\/}}, {\bf{t}})\index{conjoin-inequalities-with-0} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{caddr}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{'}}{\tt{0}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{factors\/}}{\bf $\;$ be$\;\;$}{\rm{itimes-factors}}\,({\rm{cadr}}\,({\it{x\/}}))\index{itimes-factors}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{factors\/}})) \\ 
{\bf then }{\rm{conjoin-inequalities-with-0}}\,({\it{factors\/}}, {\bf{f}})\index{conjoin-inequalities-with-0} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  conjoin-inequalities-with-0-eliminator \\ \index{conjoin-inequalities-with-0-eli!minator}
\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{eval\$}}\,({\bf{t}}, {\rm{conjoin-inequalities-with-0}}\,({\it{x\/}}, {\it{parity\/}})\index{conjoin-inequalities-with-0}, {\it{a\/}}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{parity\/}}$\;\;${\bf then }{\rm{ilessp}}\,({\tt{0}}, {\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list})\index{ilessp} \\ 
{\bf else }{\rm{ilessp}}\,({\rm{itimes-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{itimes-list}, {\tt{0}})\index{ilessp}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-factors-ilessp-0 \\ \index{correctness-of-cancel-factors-i!lessp-0}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-factors-ilessp-0}}\,({\it{x\/}})\index{cancel-factors-ilessp-0}, {\it{a\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable equal-itimes-list-eval\$-list-delete-new-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable equal-itimes-list-eval\$-list-delete-new-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-itimes-list-eval\$-list-delete.

\addvspace{18pt}

\noindent{\sc Event}:   Disable equal-itimes-list-eval\$-list-bagdiff.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-eval\$-factors-lemma.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-eval\$-factors-lemma-prime.

\addvspace{18pt}

\noindent{\sc Event}:   Disable itimes-list-eval\$-factors.

\addvspace{18pt}

\noindent{\sc Event}:   Disable iplus-or-itimes-term-integerp-eval\$.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-list-bagint-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-list-bagint-0-implies-equal.

\addvspace{18pt}

\noindent{\sc Event}:   Disable izerop-ilessp-0-relationship.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete-helper-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete-helper-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete-prime-helper-1.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete-prime-helper-2.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-list-eval\$-list-delete-prime.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-0-itimes.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ilessp-itimes-0.

\addvspace{18pt}

\noindent{\sc Event}:   Disable listp-cdr-factors-implies-integerp.

\addvspace{18pt}


\begin{verbatim};; We presumably have better meta-lemmas now, but if we want we
;; can disable those (i.e., correctness-of-cancel-itimes-factors,
;; correctness-of-cancel-itimes-ilessp-factors,
;; correctness-of-cancel-factors-0, and
;; correctness-of-cancel-factors-ilessp-0) and enable the two
;; mentioned below:

\end{verbatim}
\noindent{\sc Event}:   Disable correctness-of-cancel-itimes.

\addvspace{18pt}

\noindent{\sc Event}:   Disable correctness-of-cancel-itimes-ilessp.

\addvspace{18pt}


\begin{verbatim};; I'll disable some rules now, finally, that I'd previously thought
;; would be OK but now fear because of potential nasty backchaining.

\end{verbatim}
\noindent{\sc Event}:   Disable not-integerp-implies-not-equal-iplus.

\addvspace{18pt}

\noindent{\sc Event}:   Disable not-integerp-implies-not-equal-itimes.

\addvspace{18pt}

\noindent{\sc Event}:   Disable subbagp-subsetp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable eval\$-list-bagint-0-implies-equal-for-ilessp.

\addvspace{18pt}

\begin{verbatim}; ---------- Cancel ineg terms from equalities and inequalities ----------

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{split-out-ineg-terms} \\  
\=\+{\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf let }\=\+{\it{pair\/}}{\bf $\;$ be$\;\;$}{\rm{split-out-ineg-terms}}\,({\rm{cdr}}\,({\it{x\/}}))\index{split-out-ineg-terms}, \\ 
{\it{a\/}}{\bf $\;$ be$\;\;$}{\rm{car}}\,({\it{x\/}})\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\it{a\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{a\/}}) $=$ {\tt{'}}{\tt{ineg}} \\ 
{\bf then }{\rm{cons}}\,({\rm{car}}\,({\it{pair\/}}), {\rm{cons}}\,({\rm{cadr}}\,({\it{a\/}}), {\rm{cdr}}\,({\it{pair\/}}))) \\ 
{\bf elseif }\=\+({\rm{car}}\,({\it{a\/}}) $=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{negativep}}\,({\rm{cadr}}\,({\it{a\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{negative-guts}}\,({\rm{cadr}}\,({\it{a\/}})) $\not=$ {\tt{0}})\- \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{car}}\,({\it{pair\/}}), \\ 
{\rm{cons}}\,(\=\+{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\rm{negative-guts}}\,({\rm{cadr}}\,({\it{a\/}}))), \\ 
{\rm{cdr}}\,({\it{pair\/}}))\-)\- \\ 
{\bf else }{\rm{cons}}\,({\rm{cons}}\,({\it{a\/}}, {\rm{car}}\,({\it{pair\/}})), {\rm{cdr}}\,({\it{pair\/}}))$\;${\bf  endif}\- \\ 
{\bf else }{\rm{cons}}\,({\rm{cons}}\,({\it{a\/}}, {\rm{car}}\,({\it{pair\/}})), {\rm{cdr}}\,({\it{pair\/}}))$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\rm{cons}}\,({\bf{nil}}, {\bf{nil}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{remove-inegs} \\  
\=\+{\rm{remove-inegs}}\,({\it{x\/}}, {\it{y\/}})\index{remove-inegs} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{xpair\/}}{\bf $\;$ be$\;\;$}{\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms}, \\ 
{\it{ypair\/}}{\bf $\;$ be$\;\;$}{\rm{split-out-ineg-terms}}\,({\it{y\/}})\index{split-out-ineg-terms}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{xpair\/}})) $\vee$ {\rm{listp}}\,({\rm{cdr}}\,({\it{ypair\/}})) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{append}}\,({\rm{cdr}}\,({\it{ypair\/}}), {\rm{car}}\,({\it{xpair\/}})), \\ 
{\rm{append}}\,({\rm{cdr}}\,({\it{xpair\/}}), {\rm{car}}\,({\it{ypair\/}})))\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{iplus-or-ineg-term} \\  
\=\+{\rm{iplus-or-ineg-term}}\,({\it{x\/}})\index{iplus-or-ineg-term} \\ 
$=$$\;\;\;\;$({\rm{listp}}\,({\it{x\/}}) $\wedge$ (({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ineg}}) $\vee$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{iplus}})))\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{make-cancel-ineg-terms-equality} \\  
\=\+{\rm{make-cancel-ineg-terms-equality}}\,({\it{x\/}})\index{make-cancel-ineg-terms-equality} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{new-fringes\/}}{\bf $\;$ be$\;\;$}{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\it{new-fringes\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{iplus-or-ineg-term}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-or-ineg-term} \\ 
{\bf then }\=\+{\bf if }{\rm{iplus-or-ineg-term}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-or-ineg-term} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\it{new-fringes\/}}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\it{new-fringes\/}}))\index{iplus-tree})\- \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\it{new-fringes\/}}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\it{new-fringes\/}}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{iplus-or-ineg-term}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-or-ineg-term} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\it{new-fringes\/}}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\it{new-fringes\/}}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{cancel-ineg-terms-from-equality} \\  
\=\+{\rm{cancel-ineg-terms-from-equality}}\,({\it{x\/}})\index{cancel-ineg-terms-from-equality} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}}) \\ 
{\bf then }{\rm{make-cancel-ineg-terms-equality}}\,({\it{x\/}})\index{make-cancel-ineg-terms-equality} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; The following was created from nqthm-macroexpand with arguments
;; and or make-cancel-ineg-terms-equality iplus-or-ineg-term
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-ineg-terms-from-equality!-expanded} \\  
\=\+{\rm{cancel-ineg-terms-from-equality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-equality!-expanded} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{equal}} \\ 
{\bf then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\it{x\/}}))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{integerp}}, \\ 
{\rm{caddr}}\,({\it{x\/}}))\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endcase}\- \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endif}\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{integerp}}, \\ 
{\rm{caddr}}\,({\it{x\/}}))\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endcase}\- \\ 
{\bf else }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{caddr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\-$\;${\bf  endif}\- \\ 
{\bf otherwise }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{integerp}}, \\ 
{\rm{cadr}}\,({\it{x\/}}))\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{integerp}}, \\ 
{\rm{cadr}}\,({\it{x\/}}))\-, \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf otherwise }{\it{x\/}}$\;${\bf  endcase}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endcase}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{integerp}}, {\rm{cadr}}\,({\it{x\/}})), \\ 
{\rm{list}}\,(\=\+{\tt{'}}{\tt{equal}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\-, \\ 
{\rm{list}}\,({\tt{'}}{\tt{quote}}, {\bf{f}}))\- \\ 
{\bf otherwise }{\it{x\/}}$\;${\bf  endcase}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-ineg-terms-from-equality-cancel-ineg-terms-from-equality-expanded \\ \index{cancel-ineg-terms-from-equality!-cancel-ineg-terms-from-equality-expanded}
\=\+{\rm{cancel-ineg-terms-from-equality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-equality!-expanded} \\ 
$=$$\;\;\;\;${\rm{cancel-ineg-terms-from-equality}}\,({\it{x\/}})\index{cancel-ineg-terms-from-equality}\-
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-ineg-terms-from-equality-expanded.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  integerp-eval\$-iplus-or-ineg-term \\ \index{integerp-eval\$-iplus-or-ineg-te!rm}
{\rm{iplus-or-ineg-term}}\,({\it{x\/}})\index{iplus-or-ineg-term} $\rightarrow$ {\rm{integerp}}\,({\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}))\index{integerp}
\end{tabbing}


\noindent{\sc Event}:   Disable iplus-or-ineg-term.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus-list-car-remove-inegs \\ \index{eval\$-iplus-list-car-remove-ine!gs}
\=\+{\rm{remove-inegs}}\,({\it{x\/}}, {\it{y\/}})\index{remove-inegs} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{car}}\,({\rm{remove-inegs}}\,({\it{x\/}}, {\it{y\/}})\index{remove-inegs}), {\it{a\/}}))\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{iplus}}\,(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{car}}\,({\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list}, \\ 
{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{split-out-ineg-terms}}\,({\it{y\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list})\-\index{iplus})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eval\$-iplus-list-cdr-remove-inegs \\ \index{eval\$-iplus-list-cdr-remove-ine!gs}
\=\+{\rm{remove-inegs}}\,({\it{x\/}}, {\it{y\/}})\index{remove-inegs} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{remove-inegs}}\,({\it{x\/}}, {\it{y\/}})\index{remove-inegs}), {\it{a\/}}))\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{iplus}}\,(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{car}}\,({\rm{split-out-ineg-terms}}\,({\it{y\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list}, \\ 
{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list})\-\index{iplus})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  minus-ineg \\ \index{minus-ineg}
(({\it{x\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{x\/}} $\not=$ {\tt{0}})) $\rightarrow$ (($-$ {\it{x\/}}) $=$ {\rm{ineg}}\,({\it{x\/}})\index{ineg})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-list-eval\$-car-split-out-ineg-terms \\ \index{iplus-list-eval\$-car-split-out!-ineg-terms}
\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{car}}\,({\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list} \\ 
$=$$\;\;\;\;${\rm{iplus}}\,(\=\+{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\it{x\/}}, {\it{a\/}}))\index{iplus-list}, \\ 
{\rm{iplus-list}}\,({\rm{eval\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{split-out-ineg-terms}}\,({\it{x\/}})\index{split-out-ineg-terms}), {\it{a\/}}))\index{iplus-list})\-\index{iplus}\-
\end{tabbing}


\noindent{\sc Event}:   Disable remove-inegs.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-ineg-terms-from-equality \\ \index{correctness-of-cancel-ineg-term!s-from-equality}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-ineg-terms-from-equality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-equality!-expanded}, {\it{a\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{make-cancel-ineg-terms-inequalit!y} \\  
\=\+{\rm{make-cancel-ineg-terms-inequality}}\,({\it{x\/}})\index{make-cancel-ineg-terms-inequalit!y} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{new-fringes\/}}{\bf $\;$ be$\;\;$}{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\it{new-fringes\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\it{new-fringes\/}}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\it{new-fringes\/}}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{cancel-ineg-terms-from-inequalit!y} \\  
\=\+{\rm{cancel-ineg-terms-from-inequality}}\,({\it{x\/}})\index{cancel-ineg-terms-from-inequalit!y} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) $\wedge$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}}) \\ 
{\bf then }\=\+{\bf if }{\rm{iplus-or-ineg-term}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-or-ineg-term} \\ 
{\bf then }{\rm{make-cancel-ineg-terms-inequality}}\,({\it{x\/}})\index{make-cancel-ineg-terms-inequalit!y} \\ 
{\bf elseif }{\rm{iplus-or-ineg-term}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-or-ineg-term} \\ 
{\bf then }{\rm{make-cancel-ineg-terms-inequality}}\,({\it{x\/}})\index{make-cancel-ineg-terms-inequalit!y} \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; The following was created from nqthm-macroexpand with arguments
;; and or make-cancel-ineg-terms-inequality iplus-or-ineg-term

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{cancel-ineg-terms-from-inequalit!y-expanded} \\  
\=\+{\rm{cancel-ineg-terms-from-inequality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-inequalit!y-expanded} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{ilessp}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cadr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\it{x\/}}))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf otherwise }\=\+{\bf if }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf otherwise }{\it{x\/}}$\;${\bf  endcase}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-$\;${\bf  endcase}\- \\ 
{\bf elseif }{\rm{listp}}\,({\rm{caddr}}\,({\it{x\/}})) \\ 
{\bf then }\=\+{\bf case on }{\rm{car}}\,({\rm{car}}\,({\rm{cdr}}\,({\rm{cdr}}\,({\it{x\/}})))): \\ 
{\bf case = }{\it{ineg\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf case = }{\it{iplus\/}} \\ 
{\bf $\;\;$then }\=\+{\bf if }{\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{ilessp}}, \\ 
{\rm{iplus-tree}}\,({\rm{car}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree}, \\ 
{\rm{iplus-tree}}\,({\rm{cdr}}\,({\rm{remove-inegs}}\,(\=\+{\rm{iplus-fringe}}\,({\rm{cadr}}\,({\it{x\/}}))\index{iplus-fringe}, \\ 
{\rm{iplus-fringe}}\,({\rm{caddr}}\,({\it{x\/}}))\index{iplus-fringe})\-\index{remove-inegs}))\index{iplus-tree})\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf otherwise }{\it{x\/}}$\;${\bf  endcase}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-ineg-terms-from-inequality-cancel-ineg-terms-from-inequality-expanded \\ \index{cancel-ineg-terms-from-inequalit!y-cancel-ineg-terms-from-inequality-expanded}
\=\+{\rm{cancel-ineg-terms-from-inequality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-inequalit!y-expanded} \\ 
$=$$\;\;\;\;${\rm{cancel-ineg-terms-from-inequality}}\,({\it{x\/}})\index{cancel-ineg-terms-from-inequalit!y}\-
\end{tabbing}


\noindent{\sc Event}:   Disable cancel-ineg-terms-from-inequality-expanded.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  correctness-of-cancel-ineg-terms-from-inequality \\ \index{correctness-of-cancel-ineg-term!s-from-inequality}
{\rm{eval\$}}\,({\bf{t}}, {\it{x\/}}, {\it{a\/}}) $=$ {\rm{eval\$}}\,({\bf{t}}, {\rm{cancel-ineg-terms-from-inequality-expanded}}\,({\it{x\/}})\index{cancel-ineg-terms-from-inequalit!y-expanded}, {\it{a\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable minus-ineg.

\addvspace{18pt}

\noindent{\sc Event}:   Disable integerp-eval\$-iplus-or-ineg-term.

\addvspace{18pt}

\begin{verbatim}; ---------- Eliminating constants ----------

;; We want to combine in terms like (iplus 3 (iplus x 7)).  Also, when
;; two iplus terms are equated or in-equated, there should only be a
;; natural number summand on at most one side.  Finally, if one adds 1
;; to the right side of a strict inequality, a stronger inequality (in
;; a certain sense) is obtained by removing the 1 and making a non-strict
;; inequality in the other direction.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  plus-iplus \\ \index{plus-iplus}
(({\it{i\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{j\/}} $\in\;${\bf{N}}${}$)) $\rightarrow$ (({\it{i\/}} $+$ {\it{j\/}}) $=$ {\rm{iplus}}\,({\it{i\/}}, {\it{j\/}})\index{iplus})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  iplus-constants \\ \index{iplus-constants}
{\rm{iplus}}\,($1\;+$ {\it{i\/}}, {\rm{iplus}}\,($1\;+$ {\it{j\/}}, {\it{x\/}})\index{iplus})\index{iplus} $=$ {\rm{iplus}}\,(($1\;+$ {\it{i\/}}) $+$ ($1\;+$ {\it{j\/}}), {\it{x\/}})\index{iplus}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  numberp-is-integerp \\ \index{numberp-is-integerp}
({\it{w\/}} $\in\;${\bf{N}}${}$) $\rightarrow$ {\rm{integerp}}\,({\it{w\/}})\index{integerp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  difference-idifference \\ \index{difference-idifference}
(({\it{x\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{y\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{x\/}} $\leq$ {\it{y\/}})) $\rightarrow$ (({\it{y\/}} $-$ {\it{x\/}}) $=$ {\rm{idifference}}\,({\it{y\/}}, {\it{x\/}})\index{idifference})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-constants-equal-lemma \\ \index{cancel-constants-equal-lemma}
\=\+(({\it{m\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{n\/}} $\in\;${\bf{N}}${}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{iplus}}\,({\it{m\/}}, {\it{x\/}})\index{iplus} $=$ {\rm{iplus}}\,({\it{n\/}}, {\it{y\/}})\index{iplus}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{m\/}} $<$ {\it{n\/}}$\;\;${\bf then }{\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\rm{iplus}}\,({\it{n\/}} $-$ {\it{m\/}}, {\it{y\/}})\index{iplus} \\ 
{\bf else }{\rm{iplus}}\,({\it{m\/}} $-$ {\it{n\/}}, {\it{x\/}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-constants-equal \\ \index{cancel-constants-equal}
\=\+({\rm{iplus}}\,($1\;+$ {\it{i\/}}, {\it{x\/}})\index{iplus} $=$ {\rm{iplus}}\,($1\;+$ {\it{j\/}}, {\it{y\/}})\index{iplus}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{i\/}} $<$ {\it{j\/}}$\;\;${\bf then }{\rm{fix-int}}\,({\it{x\/}})\index{fix-int} $=$ {\rm{iplus}}\,({\it{j\/}} $-$ {\it{i\/}}, {\it{y\/}})\index{iplus} \\ 
{\bf else }{\rm{iplus}}\,({\it{i\/}} $-$ {\it{j\/}}, {\it{x\/}})\index{iplus} $=$ {\rm{fix-int}}\,({\it{y\/}})\index{fix-int}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-add1 \\ \index{ilessp-add1}
({\it{y\/}} $\in\;${\bf{N}}${}$) $\rightarrow$ ({\rm{ilessp}}\,({\it{x\/}}, $1\;+$ {\it{y\/}})\index{ilessp} $=$ ($\neg$ {\rm{ilessp}}\,({\it{y\/}}, {\it{x\/}})\index{ilessp}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ilessp-add1-iplus \\ \index{ilessp-add1-iplus}
({\it{y\/}} $\in\;${\bf{N}}${}$) $\rightarrow$ ({\rm{ilessp}}\,({\it{x\/}}, {\rm{iplus}}\,($1\;+$ {\it{y\/}}, {\it{z\/}})\index{iplus})\index{ilessp} $=$ ($\neg$ {\rm{ilessp}}\,({\rm{iplus}}\,({\it{y\/}}, {\it{z\/}})\index{iplus}, {\it{x\/}})\index{ilessp}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-constants-ilessp-lemma-1 \\ \index{cancel-constants-ilessp-lemma-1}
\=\+(({\it{m\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{n\/}} $\in\;${\bf{N}}${}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,({\rm{iplus}}\,({\it{m\/}}, {\it{x\/}})\index{iplus}, {\rm{iplus}}\,({\it{n\/}}, {\it{y\/}})\index{iplus})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{m\/}} $<$ {\it{n\/}}$\;\;${\bf then }{\rm{ilessp}}\,({\it{x\/}}, {\rm{iplus}}\,({\it{n\/}} $-$ {\it{m\/}}, {\it{y\/}})\index{iplus})\index{ilessp} \\ 
{\bf else }{\rm{ilessp}}\,({\rm{iplus}}\,({\it{m\/}} $-$ {\it{n\/}}, {\it{x\/}})\index{iplus}, {\it{y\/}})\index{ilessp}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-constants-ilessp-lemma-2 \\ \index{cancel-constants-ilessp-lemma-2}
\=\+(({\it{m\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{n\/}} $\in\;${\bf{N}}${}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{ilessp}}\,({\rm{iplus}}\,({\it{m\/}}, {\it{x\/}})\index{iplus}, {\rm{iplus}}\,({\it{n\/}}, {\it{y\/}})\index{iplus})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{m\/}} $<$ {\it{n\/}}$\;\;${\bf then }$\neg$ {\rm{ilessp}}\,({\rm{iplus}}\,(({\it{n\/}} $-$ {\it{m\/}}) $-\;1$, {\it{y\/}})\index{iplus}, {\it{x\/}})\index{ilessp} \\ 
{\bf else }{\rm{ilessp}}\,({\rm{iplus}}\,({\it{m\/}} $-$ {\it{n\/}}, {\it{x\/}})\index{iplus}, {\it{y\/}})\index{ilessp}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cancel-constants-ilessp \\ \index{cancel-constants-ilessp}
\=\+{\rm{ilessp}}\,({\rm{iplus}}\,($1\;+$ {\it{i\/}}, {\it{x\/}})\index{iplus}, {\rm{iplus}}\,($1\;+$ {\it{j\/}}, {\it{y\/}})\index{iplus})\index{ilessp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{i\/}} $<$ {\it{j\/}}$\;\;${\bf then }$\neg$ {\rm{ilessp}}\,({\rm{iplus}}\,(({\it{j\/}} $-$ {\it{i\/}}) $-\;1$, {\it{y\/}})\index{iplus}, {\it{x\/}})\index{ilessp} \\ 
{\bf else }{\rm{ilessp}}\,({\rm{iplus}}\,({\it{i\/}} $-$ {\it{j\/}}, {\it{x\/}})\index{iplus}, {\it{y\/}})\index{ilessp}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable plus-iplus.

\addvspace{18pt}

\noindent{\sc Event}:   Disable numberp-is-integerp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable difference-idifference.

\addvspace{18pt}


\begin{verbatim}; ---------- Final DEFTHEORY event ----------

;; I'll go ahead and include iplus-list and itimes-list and lemmas
;; about them that were developed.

;; I've left out ILESSP-TRICHOTOMY because I'm scared it will slow
;; things down too much.  But it certainly represents useful
;; information.

\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{integers}} to consist of the following events: ileq,
idifference,
integerp-fix-int,
integerp-iplus,
integerp-idifference,
integerp-ineg,
integerp-iabs,
integerp-itimes,
fix-int-remover,
fix-int-fix-int,
fix-int-iplus,
fix-int-idifference,
fix-int-ineg,
fix-int-iabs,
fix-int-itimes,
ineg-iplus,
ineg-ineg,
ineg-fix-int,
ineg-of-non-integerp,
ineg-0,
iplus-left-id,
iplus-right-id,
iplus-0-left,
iplus-0-right,
commutativity2-of-iplus,
commutativity-of-iplus,
associativity-of-iplus,
iplus-cancellation-1,
iplus-cancellation-2,
iplus-ineg1,
iplus-ineg2,
iplus-fix-int1,
iplus-fix-int2,
idifference-fix-int1,
idifference-fix-int2,
iplus-list,
eval\$-list-append,
iplus-list-append,
iplus-ineg3,
iplus-ineg4,
correctness-of-cancel-iplus,
ilessp-fix-int-1,
ilessp-fix-int-2,
iplus-cancellation-1-for-ilessp,
iplus-cancellation-2-for-ilessp,
correctness-of-cancel-iplus-ilessp,
itimes-0-left,
itimes-0-right,
itimes-fix-int1,
itimes-fix-int2,
commutativity-of-itimes,
itimes-distributes-over-iplus-proof,
itimes-distributes-over-iplus,
commutativity2-of-itimes,
associativity-of-itimes,
equal-itimes-0,
equal-itimes-1,
equal-itimes-minus-1,
itimes-1-arg1,
quotient-remainder-uniqueness,
division-theorem,
itimes-ineg-1,
itimes-ineg-2,
itimes-cancellation-1,
itimes-cancellation-2,
itimes-cancellation-3,
integerp-iquotient,
integerp-iremainder,
integerp-idiv,
integerp-imod,
integerp-iquo,
integerp-irem,
iquotient-fix-int1,
iquotient-fix-int2,
iremainder-fix-int1,
iremainder-fix-int2,
idiv-fix-int1,
idiv-fix-int2,
imod-fix-int1,
imod-fix-int2,
iquo-fix-int1,
iquo-fix-int2,
irem-fix-int1,
irem-fix-int2,
fix-int-iquotient,
fix-int-iremainder,
fix-int-idiv,
fix-int-imod,
fix-int-iquo,
fix-int-irem,
itimes-list,
itimes-list-append,
member-append,
equal-fix-int,
subsetp,
correctness-of-cancel-itimes,
correctness-of-cancel-itimes-ilessp,
ilessp-strict,
eval\$-list-cons,
eval\$-list-nlistp,
eval\$-litatom,
eval\$-quote,
eval\$-other,
iplus-x-y-ineg-x,
correctness-of-cancel-ineg,
integerp-iplus-list,
eval\$-iplus-list-delete,
eval\$-iplus-list-bagdiff,
itimes-tree-ineg,
itimes-factors,
itimes--1,
equal-ineg-ineg,
ilessp-ineg-ineg,
fix-int-eval\$-itimes-tree-rec,
eval\$-itimes-tree-ineg,
ineg-eval\$-itimes-tree-ineg,
iplus-eval\$-itimes-tree-ineg,
itimes-eval\$-itimes-tree-ineg,
iplus-or-itimes-term,
cancel-itimes-factors,
cancel-itimes-factors-expanded,
cancel-itimes-factors-expanded-cancel-itimes-factors,
membership-of-0-implies-itimes-list-is-0,
member-0-eval\$-list,
correctness-of-cancel-itimes-factors,
cancel-itimes-ilessp-factors,
bagint-singleton,
ilessp-itimes-list-eval\$-list-bagdiff,
ilessp-itimes-list-eval\$-list-bagdiff-corollary-1,
member-0-itimes-factors-yields-0,
member-0-itimes-factors-yields-0-ilessp-consequence-1,
member-0-itimes-factors-yields-0-ilessp-consequence-2,
ilessp-itimes-list-eval\$-list-bagdiff-corollary-2,
correctness-of-cancel-itimes-ilessp-factors,
disjoin-equalities-with-0,
cancel-factors-0,
some-eval\$s-to-0,
eval\$-disjoin-equalities-with-0,
some-eval\$s-to-0-append,
some-eval\$s-to-0-eliminator,
correctness-of-cancel-factors-0,
conjoin-inequalities-with-0,
cancel-factors-ilessp-0,
split-out-ineg-terms,
correctness-of-cancel-ineg-terms-from-equality,
correctness-of-cancel-ineg-terms-from-inequality,
iplus-constants,
cancel-constants-equal,
ilessp-add1,
ilessp-add1-iplus,
cancel-constants-ilessp.\index{integers}

\addvspace{18pt} 

\begin{verbatim}; ------------------------------------------------------------
; was lists.events
; ------------------------------------------------------------


; --------------------------------------------------------------------------------
; Basic Functions on Lists
; --------------------------------------------------------------------------------

; --------------------------------- DEFINITIONS ----------------------------------

; Besides these functions, the theory of lists assumes APPEND is defined.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{firstn} \\  
\=\+{\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\bf{nil}} \\ 
{\bf elseif }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{l\/}}), {\rm{firstn}}\,({\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{l\/}}))\index{firstn})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{init} \\  
\=\+{\rm{init}}\,({\it{value\/}}, {\it{length\/}})\index{init} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{length\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\it{value\/}}, {\rm{init}}\,({\it{value\/}}, {\it{length\/}} $-\;1$)\index{init})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{lastcdr} \\  
\=\+{\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\it{l\/}} \\ 
{\bf else }{\rm{lastcdr}}\,({\rm{cdr}}\,({\it{l\/}}))\index{lastcdr}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{length} \\  
\=\+{\rm{length}}\,({\it{l\/}})\index{length} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ {\rm{length}}\,({\rm{cdr}}\,({\it{l\/}}))\index{length}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{plist} \\  
\=\+{\rm{plist}}\,({\it{l\/}})\index{plist} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{l\/}}), {\rm{plist}}\,({\rm{cdr}}\,({\it{l\/}}))\index{plist})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{plistp} \\  
\=\+{\rm{plistp}}\,({\it{l\/}})\index{plistp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\it{l\/}} $=$ {\bf{nil}} \\ 
{\bf else }{\rm{plistp}}\,({\rm{cdr}}\,({\it{l\/}}))\index{plistp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{restn} \\  
\=\+{\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\it{l\/}} \\ 
{\bf elseif }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\it{l\/}} \\ 
{\bf else }{\rm{restn}}\,({\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{l\/}}))\index{restn}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{reverse} \\  
\=\+{\rm{reverse}}\,({\it{l\/}})\index{reverse} \\ 
$=$$\;\;\;\;$\=\+{\bf if }$\neg$ {\rm{listp}}\,({\it{l\/}})$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{append}}\,({\rm{reverse}}\,({\rm{cdr}}\,({\it{l\/}}))\index{reverse}, {\rm{list}}\,({\rm{car}}\,({\it{l\/}})))$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; --------------------------------- THEOREMS ------------------------------------

; ---------- LISTP ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  listp-append \\ \index{listp-append}
{\rm{listp}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}})) $=$ ({\rm{listp}}\,({\it{a\/}}) $\vee$ {\rm{listp}}\,({\it{b\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-firstn \\ \index{listp-firstn}
{\rm{listp}}\,({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn}) $=$ ({\rm{listp}}\,({\it{l\/}}) $\wedge$ ({\it{n\/}} $\not\simeq {\tt{0}}$))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-init \\ \index{listp-init}
{\rm{listp}}\,({\rm{init}}\,({\it{val\/}}, {\it{n\/}})\index{init}) $=$ ({\it{n\/}} $\not\simeq {\tt{0}}$)
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-lastcdr \\ \index{listp-lastcdr}
{\rm{listp}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}) $=$ {\bf{f}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-plist \\ \index{listp-plist}
{\rm{listp}}\,({\rm{plist}}\,({\it{l\/}})\index{plist}) $=$ {\rm{listp}}\,({\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-restn \\ \index{listp-restn}
{\rm{listp}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn}) $=$ ({\it{n\/}} $<$ {\rm{length}}\,({\it{l\/}})\index{length})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-reverse \\ \index{listp-reverse}
{\rm{listp}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse}) $=$ {\rm{listp}}\,({\it{l\/}})
\end{tabbing}

\begin{verbatim}; ---------- plistp ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  plistp-nlistp \\ \index{plistp-nlistp}
({\it{l\/}} $\simeq\;${{\bf{nil}}}${}$) $\rightarrow$ ({\rm{plistp}}\,({\it{l\/}})\index{plistp} $=$ ({\it{l\/}} $=$ {\bf{nil}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-cons \\ \index{plistp-cons}
{\rm{plistp}}\,({\rm{cons}}\,({\it{a\/}}, {\it{l\/}}))\index{plistp} $=$ {\rm{plistp}}\,({\it{l\/}})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-append \\ \index{plistp-append}
{\rm{plistp}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{plistp} $=$ {\rm{plistp}}\,({\it{b\/}})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-firstn \\ \index{plistp-firstn}
{\rm{plistp}}\,({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-init \\ \index{plistp-init}
{\rm{plistp}}\,({\rm{init}}\,({\it{val\/}}, {\it{n\/}})\index{init})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-lastcdr \\ \index{plistp-lastcdr}
{\rm{plistp}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{plistp} $=$ {\rm{plistp}}\,({\it{l\/}})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-plist \\ \index{plistp-plist}
{\rm{plistp}}\,({\rm{plist}}\,({\it{l\/}})\index{plist})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-restn \\ \index{plistp-restn}
{\rm{plistp}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{plistp} $=$ {\rm{plistp}}\,({\it{l\/}})\index{plistp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plistp-reverse \\ \index{plistp-reverse}
{\rm{plistp}}\,({\rm{reverse}}\,({\it{a\/}})\index{reverse})\index{plistp}
\end{tabbing}


\begin{verbatim}; ---------- LENGTH ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-length-0 \\ \index{equal-length-0}
({\rm{length}}\,({\it{l\/}})\index{length} $=$ {\tt{0}}) $=$ ($\neg$ {\rm{listp}}\,({\it{l\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-nlistp \\ \index{length-nlistp}
({\it{x\/}} $\simeq\;${{\bf{nil}}}${}$) $\rightarrow$ ({\rm{length}}\,({\it{x\/}})\index{length} $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-cons \\ \index{length-cons}
{\rm{length}}\,({\rm{cons}}\,({\it{a\/}}, {\it{x\/}}))\index{length} $=$ ($1\;+$ {\rm{length}}\,({\it{x\/}})\index{length})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-append \\ \index{length-append}
{\rm{length}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{length} $=$ ({\rm{length}}\,({\it{a\/}})\index{length} $+$ {\rm{length}}\,({\it{b\/}})\index{length})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-firstn \\ \index{length-firstn}
\=\+{\rm{length}}\,({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn})\index{length} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\leq$ {\rm{length}}\,({\it{l\/}})\index{length}$\;\;${\bf then }{\rm{fix}}\,({\it{n\/}}) \\ 
{\bf else }{\rm{length}}\,({\it{l\/}})\index{length}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-init \\ \index{length-init}
{\rm{length}}\,({\rm{init}}\,({\it{bit\/}}, {\it{n\/}})\index{init})\index{length} $=$ {\rm{fix}}\,({\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-lastcdr \\ \index{length-lastcdr}
{\rm{length}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{length} $=$ {\tt{0}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-plist \\ \index{length-plist}
{\rm{length}}\,({\rm{plist}}\,({\it{l\/}})\index{plist})\index{length} $=$ {\rm{length}}\,({\it{l\/}})\index{length}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-restn \\ \index{length-restn}
{\rm{length}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{length} $=$ ({\rm{length}}\,({\it{l\/}})\index{length} $-$ {\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-reverse \\ \index{length-reverse}
{\rm{length}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse})\index{length} $=$ {\rm{length}}\,({\it{l\/}})\index{length}
\end{tabbing}


\begin{verbatim}; ---------- APPEND ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  append-left-id \\ \index{append-left-id}
($\neg$ {\rm{listp}}\,({\it{a\/}})) $\rightarrow$ ({\rm{append}}\,({\it{a\/}}, {\it{b\/}}) $=$ {\it{b\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-nil \\ \index{append-nil}
{\rm{append}}\,({\it{a\/}}, {\bf{nil}}) $=$ {\rm{plist}}\,({\it{a\/}})\index{plist}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-append \\ \index{associativity-of-append}
{\rm{append}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}), {\it{c\/}}) $=$ {\rm{append}}\,({\it{a\/}}, {\rm{append}}\,({\it{b\/}}, {\it{c\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  associativity-of-append-inverse \\ \index{associativity-of-append-inverse}
{\rm{append}}\,({\it{a\/}}, {\rm{append}}\,({\it{b\/}}, {\it{c\/}})) $=$ {\rm{append}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}), {\it{c\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable associativity-of-append-inverse.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  append-firstn-restn \\ \index{append-firstn-restn}
{\rm{append}}\,({\rm{firstn}}\,({\it{i\/}}, {\it{l\/}})\index{firstn}, {\rm{restn}}\,({\it{i\/}}, {\it{l\/}})\index{restn}) $=$ {\it{l\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-init-list \\ \index{append-init-list}
{\rm{append}}\,({\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init}, {\rm{list}}\,({\it{v\/}})) $=$ {\rm{init}}\,({\it{v\/}}, $1\;+$ {\it{n\/}})\index{init}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-init-init \\ \index{append-init-init}
{\rm{append}}\,({\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init}, {\rm{init}}\,({\it{v\/}}, {\it{j\/}})\index{init}) $=$ {\rm{init}}\,({\it{v\/}}, {\it{i\/}} $+$ {\it{j\/}})\index{init}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-lastcdr-arg1 \\ \index{append-lastcdr-arg1}
{\rm{append}}\,({\rm{lastcdr}}\,({\it{a\/}})\index{lastcdr}, {\it{b\/}}) $=$ {\it{b\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-lastcdr-arg2 \\ \index{append-lastcdr-arg2}
{\rm{append}}\,({\it{l\/}}, {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}) $=$ {\it{l\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-plist \\ \index{append-plist}
{\rm{append}}\,({\rm{plist}}\,({\it{a\/}})\index{plist}, {\it{b\/}}) $=$ {\rm{append}}\,({\it{a\/}}, {\it{b\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-plist-lastcdr \\ \index{append-plist-lastcdr}
{\rm{append}}\,({\rm{plist}}\,({\it{l\/}})\index{plist}, {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}) $=$ {\it{l\/}}
\end{tabbing}

\begin{verbatim}; ---------- FIRSTN ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  firstn-with-large-index \\ \index{firstn-with-large-index}
({\rm{length}}\,({\it{l\/}})\index{length} $\leq$ {\it{n\/}}) $\rightarrow$ ({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn} $=$ {\rm{plist}}\,({\it{l\/}})\index{plist})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-with-non-number-index \\ \index{firstn-with-non-number-index}
({\it{n\/}} $\not\in\;${\bf{N}}${}$) $\rightarrow$ ({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn} $=$ {\rm{firstn}}\,({\tt{0}}, {\it{l\/}})\index{firstn})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-nlistp \\ \index{firstn-nlistp}
($\neg$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn} $=$ {\bf{nil}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-0 \\ \index{firstn-0}
{\rm{firstn}}\,({\tt{0}}, {\it{l\/}})\index{firstn} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-cons \\ \index{firstn-cons}
\=\+{\rm{firstn}}\,({\it{n\/}}, {\rm{cons}}\,({\it{a\/}}, {\it{b\/}}))\index{firstn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\it{a\/}}, {\rm{firstn}}\,({\it{n\/}} $-\;1$, {\it{b\/}})\index{firstn})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-append \\ \index{firstn-append}
\=\+{\rm{firstn}}\,({\it{n\/}}, {\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{firstn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\leq$ {\rm{length}}\,({\it{a\/}})\index{length}$\;\;${\bf then }{\rm{firstn}}\,({\it{n\/}}, {\it{a\/}})\index{firstn} \\ 
{\bf else }{\rm{append}}\,({\it{a\/}}, {\rm{firstn}}\,({\it{n\/}} $-$ {\rm{length}}\,({\it{a\/}})\index{length}, {\it{b\/}})\index{firstn})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-firstn \\ \index{firstn-firstn}
\=\+{\rm{firstn}}\,({\it{i\/}}, {\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn})\index{firstn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{i\/}} $<$ {\it{n\/}}$\;\;${\bf then }{\rm{firstn}}\,({\it{i\/}}, {\it{l\/}})\index{firstn} \\ 
{\bf else }{\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-init \\ \index{firstn-init}
\=\+{\rm{firstn}}\,({\it{n\/}}, {\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init})\index{firstn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $<$ {\it{i\/}}$\;\;${\bf then }{\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init} \\ 
{\bf else }{\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-lastcdr \\ \index{firstn-lastcdr}
{\rm{firstn}}\,({\it{n\/}}, {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{firstn} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  firstn-plist \\ \index{firstn-plist}
{\rm{firstn}}\,({\it{n\/}}, {\rm{plist}}\,({\it{l\/}})\index{plist})\index{firstn} $=$ {\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn}
\end{tabbing}

\begin{verbatim}; FIRSTN-RESTN has no obvious reduction.


; ---------- INIT ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  car-init \\ \index{car-init}
({\it{n\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ({\rm{car}}\,({\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init}) $=$ {\it{v\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  init-with-non-number-index \\ \index{init-with-non-number-index}
({\it{n\/}} $\not\in\;${\bf{N}}${}$) $\rightarrow$ ({\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init} $=$ {\rm{init}}\,({\it{v\/}}, {\tt{0}})\index{init})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  init-add1 \\ \index{init-add1}
{\rm{init}}\,({\it{x\/}}, $1\;+$ {\it{n\/}})\index{init} $=$ {\rm{cons}}\,({\it{x\/}}, {\rm{init}}\,({\it{x\/}}, {\it{n\/}})\index{init})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  init-0 \\ \index{init-0}
{\rm{init}}\,({\it{v\/}}, {\tt{0}})\index{init} $=$ {\bf{nil}}
\end{tabbing}

\begin{verbatim}; ---------- LASTCDR ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  lastcdr-nlistp \\ \index{lastcdr-nlistp}
($\neg$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr} $=$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-cons \\ \index{lastcdr-cons}
{\rm{lastcdr}}\,({\rm{cons}}\,({\it{a\/}}, {\it{l\/}}))\index{lastcdr} $=$ {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-append \\ \index{lastcdr-append}
{\rm{lastcdr}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{lastcdr} $=$ {\rm{lastcdr}}\,({\it{b\/}})\index{lastcdr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-firstn \\ \index{lastcdr-firstn}
{\rm{lastcdr}}\,({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn})\index{lastcdr} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-init \\ \index{lastcdr-init}
{\rm{lastcdr}}\,({\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init})\index{lastcdr} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-lastcdr \\ \index{lastcdr-lastcdr}
{\rm{lastcdr}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{lastcdr} $=$ {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-plist \\ \index{lastcdr-plist}
{\rm{lastcdr}}\,({\rm{plist}}\,({\it{l\/}})\index{plist})\index{lastcdr} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-restn \\ \index{lastcdr-restn}
{\rm{lastcdr}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{lastcdr} $=$ {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lastcdr-reverse \\ \index{lastcdr-reverse}
{\rm{lastcdr}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse})\index{lastcdr} $=$ {\bf{nil}}
\end{tabbing}

\begin{verbatim}; ---------- PLIST ---------- 

\end{verbatim}\begin{tabbing}{\sc Theorem}:  equal-plist \\ \index{equal-plist}
{\rm{plistp}}\,({\it{l\/}})\index{plistp} $\rightarrow$ ({\rm{plist}}\,({\it{l\/}})\index{plist} $=$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-nlistp \\ \index{plist-nlistp}
($\neg$ {\rm{listp}}\,({\it{x\/}})) $\rightarrow$ ({\rm{plist}}\,({\it{x\/}})\index{plist} $=$ {\bf{nil}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-cons \\ \index{plist-cons}
{\rm{plist}}\,({\rm{cons}}\,({\it{a\/}}, {\it{l\/}}))\index{plist} $=$ {\rm{cons}}\,({\it{a\/}}, {\rm{plist}}\,({\it{l\/}})\index{plist})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-append \\ \index{plist-append}
{\rm{plist}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{plist} $=$ {\rm{append}}\,({\it{a\/}}, {\rm{plist}}\,({\it{b\/}})\index{plist})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-firstn \\ \index{plist-firstn}
{\rm{plist}}\,({\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn})\index{plist} $=$ {\rm{firstn}}\,({\it{n\/}}, {\it{l\/}})\index{firstn}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-init \\ \index{plist-init}
{\rm{plist}}\,({\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init})\index{plist} $=$ {\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-lastcdr \\ \index{plist-lastcdr}
{\rm{plist}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{plist} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-plist \\ \index{plist-plist}
{\rm{plist}}\,({\rm{plist}}\,({\it{l\/}})\index{plist})\index{plist} $=$ {\rm{plist}}\,({\it{l\/}})\index{plist}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-restn \\ \index{plist-restn}
{\rm{plist}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{plist} $=$ {\rm{restn}}\,({\it{n\/}}, {\rm{plist}}\,({\it{l\/}})\index{plist})\index{restn}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  plist-reverse \\ \index{plist-reverse}
{\rm{plist}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse})\index{plist} $=$ {\rm{reverse}}\,({\it{l\/}})\index{reverse}
\end{tabbing}

\begin{verbatim}; ---------- RESTN ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  restn-with-non-number-index \\ \index{restn-with-non-number-index}
({\it{n\/}} $\not\in\;${\bf{N}}${}$) $\rightarrow$ ({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn} $=$ {\rm{restn}}\,({\tt{0}}, {\it{l\/}})\index{restn})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-with-large-index \\ \index{restn-with-large-index}
({\rm{length}}\,({\it{l\/}})\index{length} $\leq$ {\it{n\/}}) $\rightarrow$ ({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn} $=$ {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-nlistp \\ \index{restn-nlistp}
($\neg$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn} $=$ {\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-0 \\ \index{restn-0}
{\rm{restn}}\,({\tt{0}}, {\it{l\/}})\index{restn} $=$ {\it{l\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-cons \\ \index{restn-cons}
\=\+{\rm{restn}}\,({\it{n\/}}, {\rm{cons}}\,({\it{a\/}}, {\it{b\/}}))\index{restn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{cons}}\,({\it{a\/}}, {\it{b\/}}) \\ 
{\bf else }{\rm{restn}}\,({\it{n\/}} $-\;1$, {\it{b\/}})\index{restn}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-append \\ \index{restn-append}
\=\+{\rm{restn}}\,({\it{n\/}}, {\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{restn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\leq$ {\rm{length}}\,({\it{a\/}})\index{length}$\;\;${\bf then }{\rm{append}}\,({\rm{restn}}\,({\it{n\/}}, {\it{a\/}})\index{restn}, {\it{b\/}}) \\ 
{\bf else }{\rm{restn}}\,({\it{n\/}} $-$ {\rm{length}}\,({\it{a\/}})\index{length}, {\it{b\/}})\index{restn}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-firstn \\ \index{restn-firstn}
\=\+{\rm{restn}}\,({\it{n\/}}, {\rm{firstn}}\,({\it{i\/}}, {\it{l\/}})\index{firstn})\index{restn} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{i\/}} $\leq$ {\it{n\/}}$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{firstn}}\,({\it{i\/}} $-$ {\it{n\/}}, {\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{firstn}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-init \\ \index{restn-init}
{\rm{restn}}\,({\it{n\/}}, {\rm{init}}\,({\it{v\/}}, {\it{i\/}})\index{init})\index{restn} $=$ {\rm{init}}\,({\it{v\/}}, {\it{i\/}} $-$ {\it{n\/}})\index{init}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-lastcdr \\ \index{restn-lastcdr}
{\rm{restn}}\,({\it{n\/}}, {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{restn} $=$ {\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-plist \\ \index{restn-plist}
{\rm{restn}}\,({\it{n\/}}, {\rm{plist}}\,({\it{l\/}})\index{plist})\index{restn} $=$ {\rm{plist}}\,({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn})\index{plist}
\end{tabbing}


\noindent{\sc Event}:   Disable restn-plist.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  restn-restn \\ \index{restn-restn}
{\rm{restn}}\,({\it{i\/}}, {\rm{restn}}\,({\it{j\/}}, {\it{l\/}})\index{restn})\index{restn} $=$ {\rm{restn}}\,({\it{j\/}} $+$ {\it{i\/}}, {\it{l\/}})\index{restn}
\end{tabbing}


\begin{verbatim}; ---------- REVERSE ----------

\end{verbatim}\begin{tabbing}{\sc Theorem}:  reverse-nlistp \\ \index{reverse-nlistp}
($\neg$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\rm{reverse}}\,({\it{l\/}})\index{reverse} $=$ {\bf{nil}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-cons \\ \index{reverse-cons}
{\rm{reverse}}\,({\rm{cons}}\,({\it{a\/}}, {\it{l\/}}))\index{reverse} $=$ {\rm{append}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse}, {\rm{list}}\,({\it{a\/}}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-append \\ \index{reverse-append}
{\rm{reverse}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}))\index{reverse} $=$ {\rm{append}}\,({\rm{reverse}}\,({\it{b\/}})\index{reverse}, {\rm{reverse}}\,({\it{a\/}})\index{reverse})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-init \\ \index{reverse-init}
{\rm{reverse}}\,({\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init})\index{reverse} $=$ {\rm{init}}\,({\it{v\/}}, {\it{n\/}})\index{init}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-lastcdr \\ \index{reverse-lastcdr}
{\rm{reverse}}\,({\rm{lastcdr}}\,({\it{l\/}})\index{lastcdr})\index{reverse} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-plist \\ \index{reverse-plist}
{\rm{reverse}}\,({\rm{plist}}\,({\it{l\/}})\index{plist})\index{reverse} $=$ {\rm{reverse}}\,({\it{l\/}})\index{reverse}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  reverse-reverse \\ \index{reverse-reverse}
{\rm{plistp}}\,({\it{l\/}})\index{plistp} $\rightarrow$ ({\rm{reverse}}\,({\rm{reverse}}\,({\it{l\/}})\index{reverse})\index{reverse} $=$ {\it{l\/}})
\end{tabbing}

\begin{verbatim}; ----------------------------------------------------------------------

\end{verbatim}
\noindent{\sc Event}:   Let us define the theory {\it{lists}} to consist of the following events: append-firstn-restn,
append-init-init,
append-init-list,
append-lastcdr-arg1,
append-lastcdr-arg2,
append-left-id,
append-nil,
append-plist,
append-plist-lastcdr,
associativity-of-append,
car-init,
equal-length-0,
equal-plist,
firstn-0,
firstn-append,
firstn-cons,
firstn-firstn,
firstn-init,
firstn-lastcdr,
firstn-nlistp,
firstn-plist,
firstn-with-large-index,
firstn-with-non-number-index,
init-0,
init-add1,
init-with-non-number-index,
lastcdr-append,
lastcdr-cons,
lastcdr-firstn,
lastcdr-init,
lastcdr-lastcdr,
lastcdr-nlistp,
lastcdr-plist,
lastcdr-restn,
lastcdr-reverse,
length-append,
length-cons,
length-firstn,
length-init,
length-lastcdr,
length-nlistp,
length-plist,
length-restn,
length-reverse,
listp-append,
listp-firstn,
listp-init,
listp-lastcdr,
listp-plist,
listp-restn,
listp-reverse,
plist-append,
plist-cons,
plist-firstn,
plist-init,
plist-lastcdr,
plist-nlistp,
plist-plist,
plist-restn,
plist-reverse,
plistp-append,
plistp-cons,
plistp-firstn,
plistp-init,
plistp-lastcdr,
plistp-nlistp,
plistp-plist,
plistp-restn,
plistp-reverse,
restn-0,
restn-append,
restn-cons,
restn-firstn,
restn-init,
restn-lastcdr,
restn-nlistp,
restn-restn,
restn-with-large-index,
restn-with-non-number-index,
reverse-append,
reverse-cons,
reverse-init,
reverse-lastcdr,
reverse-nlistp,
reverse-plist,
reverse-reverse.\index{lists}

\addvspace{18pt}

\begin{verbatim}; ------------------------------------------------------------
; was piton-basis.events
; ------------------------------------------------------------


;; The following stuff is from Piton, defs.events

\end{verbatim}
\noindent{\sc Event}:   Add the shell {\it{p-state\/}}\index{p-state}, with recognizer function symbol {\it{p-statep\/}} and 9 accessors: {\it{p-pc\/}}, with type restriction (none-of) and default value zero; {\it{p-ctrl-stk\/}}, with type restriction (none-of) and default value zero; {\it{p-temp-stk\/}}, with type restriction (none-of) and default value zero; {\it{p-prog-segment\/}}, with type restriction (none-of) and default value zero; {\it{p-data-segment\/}}, with type restriction (none-of) and default value zero; {\it{p-max-ctrl-stk-size\/}}, with type restriction (none-of) and default value zero; {\it{p-max-temp-stk-size\/}}, with type restriction (none-of) and default value zero; {\it{p-word-size\/}}, with type restriction (none-of) and default value zero; {\it{p-psw\/}}, with type restriction (none-of) and default value zero.

\addvspace{18pt}

\begin{verbatim}; Each element of the program segment is a program.  A program is a list
; of the form:

; (name (formal1 formal2 ... formaln)
;       ((temp1 init1)
;        ...
;        (tempk initk))
;       instr1
;       instr2
;       ...
;       instrm)

; The name and each formal and temp is a symbol.  The initial values
; of the temps are tagged values.  The instrs are either LISTP objects
; which may be optionalled labelled by litatoms.  To label an
; instruction ins with the label lab, write (dl lab comment ins).
; Comment may be any object.  It is completely ignored.

; Roughly speaking, a CALL of name binds the formals to the top n
; elements of the temp-stk (removing them from that stack and building
; a ctrl-stk frame), binds the temps to the corresponding tagged
; values (also in the ctrl-stk frame), and executes each instruction.

; When a symbol is used as a variable name in an instruction we will
; look for its value as though it were stored in an alist whose keys
; were listed in the following order:

;    formal1 ... formaln temp1 ... tempk.

; That is, a variable reference is first to the formals, then to the
; temps.  In the case of duplications we use the first occurrence in
; the list.

; The following function sets the psw to the one given.  If that is
; anything besides 'RUN the Piton machine halts.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-halt} \\  
\=\+{\rm{p-halt}}\,({\it{p\/}}, {\it{psw\/}})\index{p-halt} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{p-pc}}\,({\it{p\/}})\index{p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\it{psw\/}})\-\index{p-state}\-
\end{tabbing}

\begin{verbatim}; We characterize the errorneous psws as all those besides 'RUN and
; 'HALT:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{errorp} \\  
{\rm{errorp}}\,({\it{psw\/}})\index{errorp} $=$ (({\it{psw\/}} $\not=$ {\tt{'}}{\tt{run}}) $\wedge$ ({\it{psw\/}} $\not=$ {\tt{'}}{\tt{halt}}))
\end{tabbing}


\begin{verbatim}; Association lists.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{put-assoc} \\  
\=\+{\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{alist\/}})\index{put-assoc} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{alist\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{alist\/}} \\ 
{\bf elseif }{\it{name\/}} $=$ {\rm{caar}}\,({\it{alist\/}})$\;\;${\bf then }{\rm{cons}}\,({\rm{cons}}\,({\it{name\/}}, {\it{val\/}}), {\rm{cdr}}\,({\it{alist\/}})) \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{alist\/}}), {\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\rm{cdr}}\,({\it{alist\/}}))\index{put-assoc})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; The following function determines whether name is bound in alist.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{definedp} \\  
\=\+{\rm{definedp}}\,({\it{name\/}}, {\it{alist\/}})\index{definedp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{alist\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\it{name\/}} $=$ {\rm{caar}}\,({\it{alist\/}})$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\rm{definedp}}\,({\it{name\/}}, {\rm{cdr}}\,({\it{alist\/}}))\index{definedp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; This function is used to obtain the definition of a Piton variable
; or subroutine name.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{definition}$\;\;$
{\rm{definition}}\,({\it{name\/}}, {\it{alist\/}})\index{definition} $=$ {\rm{assoc}}\,({\it{name\/}}, {\it{alist\/}})
\end{tabbing}

\begin{verbatim}; These two functions are used for manipulating Piton variable values.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{value}$\;\;$
{\rm{value}}\,({\it{name\/}}, {\it{alist\/}})\index{value} $=$ {\rm{cdr}}\,({\rm{definition}}\,({\it{name\/}}, {\it{alist\/}})\index{definition})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{put-value} \\  
{\rm{put-value}}\,({\it{val\/}}, {\it{name\/}}, {\it{alist\/}})\index{put-value} $=$ {\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{alist\/}})\index{put-assoc}
\end{tabbing}

\begin{verbatim}; This function is used to strip the values out of an alist.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{strip-cdrs} \\  
\=\+{\rm{strip-cdrs}}\,({\it{alist\/}})\index{strip-cdrs} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{alist\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{cdr}}\,({\rm{car}}\,({\it{alist\/}})), {\rm{strip-cdrs}}\,({\rm{cdr}}\,({\it{alist\/}}))\index{strip-cdrs})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{strip-cadrs} \\  
\=\+{\rm{strip-cadrs}}\,({\it{alist\/}})\index{strip-cadrs} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{alist\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{cadr}}\,({\rm{car}}\,({\it{alist\/}})), {\rm{strip-cadrs}}\,({\rm{cdr}}\,({\it{alist\/}}))\index{strip-cadrs})$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; Piton programs.

; When I fetch the definitions of programs from the prog-segment I
; want to decompose them into the following pieces:


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{name}$\;\;$
{\rm{name}}\,({\it{d\/}})\index{name} $=$ {\rm{car}}\,({\it{d\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{formal-vars}$\;\;$
{\rm{formal-vars}}\,({\it{d\/}})\index{formal-vars} $=$ {\rm{cadr}}\,({\it{d\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{temp-var-dcls}$\;\;$
{\rm{temp-var-dcls}}\,({\it{d\/}})\index{temp-var-dcls} $=$ {\rm{caddr}}\,({\it{d\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{program-body}$\;\;$
{\rm{program-body}}\,({\it{d\/}})\index{program-body} $=$ {\rm{cdddr}}\,({\it{d\/}})
\end{tabbing}

\begin{verbatim}; The ``locals'' of a program is the union of the formal-vars
; and the temporaries.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{local-vars} \\  
{\rm{local-vars}}\,({\it{d\/}})\index{local-vars} $=$ {\rm{append}}\,({\rm{formal-vars}}\,({\it{d\/}})\index{formal-vars}, {\rm{strip-cars}}\,({\rm{temp-var-dcls}}\,({\it{d\/}})\index{temp-var-dcls}))
\end{tabbing}


\begin{verbatim}; Addresses

; Our addresses are tagged ``address pairs''.  The pair specifies
; an area name in some memory segment and an offset from the 
; base address of that area.  We call such a pair an ``adp''
; (pronounced ``a d p'').

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{adp-name}$\;\;$
{\rm{adp-name}}\,({\it{adp\/}})\index{adp-name} $=$ {\rm{car}}\,({\it{adp\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{adp-offset}$\;\;$
{\rm{adp-offset}}\,({\it{adp\/}})\index{adp-offset} $=$ {\rm{cdr}}\,({\it{adp\/}})
\end{tabbing}

\begin{verbatim}; The tag indicates which segment of memory the address points into.
; For example, at the Piton level, the tag PC means into the prog
; segment and the tag ADDR means into the data segment.  At lower levels
; there are other tags and other segments.  An object is an address
; pair if it and its associated segment satisfy the following relation

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{adpp} \\  
\=\+{\rm{adpp}}\,({\it{x\/}}, {\it{segment\/}})\index{adpp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{adp-offset}}\,({\it{x\/}})\index{adp-offset} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{adp-name}}\,({\it{x\/}})\index{adp-name}, {\it{segment\/}})\index{definedp} \\ 
$\wedge$$\;\;\;\;$({\rm{adp-offset}}\,({\it{x\/}})\index{adp-offset} $<$ {\rm{length}}\,({\rm{value}}\,({\rm{adp-name}}\,({\it{x\/}})\index{adp-name}, {\it{segment\/}})\index{value})\index{length}))\-\-
\end{tabbing}

\begin{verbatim}; Program counters are slightly different from addresses because
; the areas in the program segment are not (name . value) but
; (name formal-vars temps . program-body).

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{pcpp} \\  
\=\+{\rm{pcpp}}\,({\it{x\/}}, {\it{segment\/}})\index{pcpp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{adp-offset}}\,({\it{x\/}})\index{adp-offset} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{adp-name}}\,({\it{x\/}})\index{adp-name}, {\it{segment\/}})\index{definedp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{adp-offset}}\,({\it{x\/}})\index{adp-offset} \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{program-body}}\,({\rm{definition}}\,({\rm{adp-name}}\,({\it{x\/}})\index{adp-name}, {\it{segment\/}})\index{definition})\index{program-body})\index{length})\-)\-\-
\end{tabbing}

\begin{verbatim}; We nevertheless often manipulate them with the same functions we
; do adps.  For example, add1-adp, below, increments the offset of an
; adp by 1.  We will write (add1-adp pc) even though pc is a pcpp.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{add-adp} \\  
{\rm{add-adp}}\,({\it{adp\/}}, {\it{n\/}})\index{add-adp} $=$ {\rm{cons}}\,({\rm{adp-name}}\,({\it{adp\/}})\index{adp-name}, {\rm{adp-offset}}\,({\it{adp\/}})\index{adp-offset} $+$ {\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{add1-adp}$\;\;$
{\rm{add1-adp}}\,({\it{adp\/}})\index{add1-adp} $=$ {\rm{add-adp}}\,({\it{adp\/}}, {\tt{1}})\index{add-adp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{sub-adp} \\  
{\rm{sub-adp}}\,({\it{adp\/}}, {\it{n\/}})\index{sub-adp} $=$ {\rm{cons}}\,({\rm{adp-name}}\,({\it{adp\/}})\index{adp-name}, {\rm{adp-offset}}\,({\it{adp\/}})\index{adp-offset} $-$ {\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{sub1-adp}$\;\;$
{\rm{sub1-adp}}\,({\it{adp\/}})\index{sub1-adp} $=$ {\rm{sub-adp}}\,({\it{adp\/}}, {\tt{1}})\index{sub-adp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{get} \\  
\=\+{\rm{get}}\,({\it{n\/}}, {\it{lst\/}})\index{get} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{car}}\,({\it{lst\/}}) \\ 
{\bf else }{\rm{get}}\,({\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{lst\/}}))\index{get}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{put} \\  
\=\+{\rm{put}}\,({\it{val\/}}, {\it{n\/}}, {\it{lst\/}})\index{put} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$ \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{lst\/}})$\;\;${\bf then }{\rm{cons}}\,({\it{val\/}}, {\rm{cdr}}\,({\it{lst\/}})) \\ 
{\bf else }{\rm{list}}\,({\it{val\/}})$\;${\bf  endif}\- \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{lst\/}}), {\rm{put}}\,({\it{val\/}}, {\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{lst\/}}))\index{put})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{fetch-adp} \\  
\=\+{\rm{fetch-adp}}\,({\it{adp\/}}, {\it{segment\/}})\index{fetch-adp} \\ 
$=$$\;\;\;\;${\rm{get}}\,({\rm{adp-offset}}\,({\it{adp\/}})\index{adp-offset}, {\rm{value}}\,({\rm{adp-name}}\,({\it{adp\/}})\index{adp-name}, {\it{segment\/}})\index{value})\index{get}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{deposit-adp} \\  
\=\+{\rm{deposit-adp}}\,({\it{val\/}}, {\it{adp\/}}, {\it{segment\/}})\index{deposit-adp} \\ 
$=$$\;\;\;\;${\rm{put-value}}\,(\=\+{\rm{put}}\,({\it{val\/}}, {\rm{adp-offset}}\,({\it{adp\/}})\index{adp-offset}, {\rm{value}}\,({\rm{adp-name}}\,({\it{adp\/}})\index{adp-name}, {\it{segment\/}})\index{value})\index{put}, \\ 
{\rm{adp-name}}\,({\it{adp\/}})\index{adp-name}, \\ 
{\it{segment\/}})\-\index{put-value}\-
\end{tabbing}

\begin{verbatim}; While get enumerates the elements of lst from 0 starting at
; the left, we also need the function that enumerates the elements
; from 0 starting at the right.  This is used in the specification
; of the fetch-temp-stk instruction.  The name rget stands for "right get"
; or perhaps "reversed get":

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{rget}$\;\;$
{\rm{rget}}\,({\it{n\/}}, {\it{lst\/}})\index{rget} $=$ {\rm{get}}\,(({\rm{length}}\,({\it{lst\/}})\index{length} $-$ {\it{n\/}}) $-\;1$, {\it{lst\/}})\index{get}
\end{tabbing}

\begin{verbatim}; The corresponding put function:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{rput} \\  
{\rm{rput}}\,({\it{val\/}}, {\it{n\/}}, {\it{lst\/}})\index{rput} $=$ {\rm{put}}\,({\it{val\/}}, ({\rm{length}}\,({\it{lst\/}})\index{length} $-$ {\it{n\/}}) $-\;1$, {\it{lst\/}})\index{put}
\end{tabbing}





\begin{verbatim}; Tagged Objects

; We keep all Piton objects tagged.  The form we use is
; (tag obj) where tag is one of a fixed set of LITATOMs
; enumerated by the function p-objectp below.  The following
; three functions let us create a tagged object, access the
; tag field and access the contents field.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{tag}$\;\;$
{\rm{tag}}\,({\it{type\/}}, {\it{obj\/}})\index{tag} $=$ {\rm{list}}\,({\it{type\/}}, {\it{obj\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{type}$\;\;$
{\rm{type}}\,({\it{const\/}})\index{type} $=$ {\rm{car}}\,({\it{const\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{untag}$\;\;$
{\rm{untag}}\,({\it{const\/}})\index{untag} $=$ {\rm{cadr}}\,({\it{const\/}})
\end{tabbing}


\begin{verbatim}; Tagged Addresses

; We have a variety of objects in the system that are tagged address pairs.
; We call these things ``addresses'' and define primitives for recognizing
; and manipulating them.  At this level we do not care what the tags are,
; we just strip them off or duplicate them as necessary.  That is, to
; increment (tag (DELTA1 . 25)) we build (tag (DELTA1 . 26)) without
; inspecting tag.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{addressp}$\;\;$
{\rm{addressp}}\,({\it{x\/}}, {\it{segment\/}})\index{addressp} $=$ {\rm{adpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\it{segment\/}})\index{adpp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{area-name}$\;\;$
{\rm{area-name}}\,({\it{x\/}})\index{area-name} $=$ {\rm{adp-name}}\,({\rm{untag}}\,({\it{x\/}})\index{untag})\index{adp-name}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{offset}$\;\;$
{\rm{offset}}\,({\it{x\/}})\index{offset} $=$ {\rm{adp-offset}}\,({\rm{untag}}\,({\it{x\/}})\index{untag})\index{adp-offset}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{add-addr} \\  
{\rm{add-addr}}\,({\it{addr\/}}, {\it{n\/}})\index{add-addr} $=$ {\rm{tag}}\,({\rm{type}}\,({\it{addr\/}})\index{type}, {\rm{add-adp}}\,({\rm{untag}}\,({\it{addr\/}})\index{untag}, {\it{n\/}})\index{add-adp})\index{tag}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{add1-addr}$\;\;$
{\rm{add1-addr}}\,({\it{addr\/}})\index{add1-addr} $=$ {\rm{add-addr}}\,({\it{addr\/}}, {\tt{1}})\index{add-addr}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{sub-addr} \\  
{\rm{sub-addr}}\,({\it{addr\/}}, {\it{n\/}})\index{sub-addr} $=$ {\rm{tag}}\,({\rm{type}}\,({\it{addr\/}})\index{type}, {\rm{sub-adp}}\,({\rm{untag}}\,({\it{addr\/}})\index{untag}, {\it{n\/}})\index{sub-adp})\index{tag}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{sub1-addr}$\;\;$
{\rm{sub1-addr}}\,({\it{addr\/}})\index{sub1-addr} $=$ {\rm{sub-addr}}\,({\it{addr\/}}, {\tt{1}})\index{sub-addr}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{fetch} \\  
{\rm{fetch}}\,({\it{addr\/}}, {\it{segment\/}})\index{fetch} $=$ {\rm{fetch-adp}}\,({\rm{untag}}\,({\it{addr\/}})\index{untag}, {\it{segment\/}})\index{fetch-adp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{deposit} \\  
{\rm{deposit}}\,({\it{val\/}}, {\it{addr\/}}, {\it{segment\/}})\index{deposit} $=$ {\rm{deposit-adp}}\,({\it{val\/}}, {\rm{untag}}\,({\it{addr\/}})\index{untag}, {\it{segment\/}})\index{deposit-adp}
\end{tabbing}

\begin{verbatim}; Note:  Addresses are just one of many data types.  We could define
; tagged versions of all of our data manipulation functions.  E.g.,
; we could define (nat-plus x y) = (tag 'nat (plus (untag x) (untag y))).
; However we do not.  Instead we use tag and untag freely below.
; The reason we go to the trouble of defining tagged address functions
; is because we use those constructs so often -- not just to implement
; the semantics of the ADDR data type operations.  For example, fetching
; and depositing into memory, getting instructions, etc., all use
; tagged address manipulation.



\end{verbatim}
\newpage
\begin{verbatim}

; Booleans

; Unlike the logic, the PITON machine uses the LITATOM 'T for true and
; the LITATOM 'F for false.  This means we can't use the primitive
; AND, OR, and NOT functions of the logic to do AND-BOOL, OR-BOOL, and
; NOT-BOOL.  The reason I adopted this curious convention is so that T
; and F can be written inside of quoted list constants -- i.e., in
; PITON programs.  That is, if in the logic you write '(PUSH-CONSTANT
; (BOOL T)) that T is the litatom 'T, not (TRUE).

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{booleanp}$\;\;$
{\rm{booleanp}}\,({\it{x\/}})\index{booleanp} $=$ (({\it{x\/}} $=$ {\tt{'}}{\tt{t}}) $\vee$ ({\it{x\/}} $=$ {\tt{'}}{\tt{f}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bool} \\  
\=\+{\rm{bool}}\,({\it{x\/}})\index{bool} \\ 
$=$$\;\;\;\;${\rm{tag}}\,(\=\+{\tt{'}}{\tt{bool}}, \\ 
\=\+{\bf if }{\it{x\/}}$\;\;${\bf then }{\tt{'}}{\tt{t}} \\ 
{\bf else }{\tt{'}}{\tt{f}}$\;${\bf  endif}\-)\-\index{tag}\-
\end{tabbing}

\begin{verbatim}; Because we know we only apply the boolean operators to booleanps we
; can skimp on the tests.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{or-bool} \\  
\=\+{\rm{or-bool}}\,({\it{x\/}}, {\it{y\/}})\index{or-bool} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\it{y\/}} \\ 
{\bf else }{\tt{'}}{\tt{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{and-bool} \\  
\=\+{\rm{and-bool}}\,({\it{x\/}}, {\it{y\/}})\index{and-bool} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\tt{'}}{\tt{f}} \\ 
{\bf else }{\it{y\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{not-bool} \\  
\=\+{\rm{not-bool}}\,({\it{x\/}})\index{not-bool} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\tt{'}}{\tt{t}} \\ 
{\bf else }{\tt{'}}{\tt{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; *** 14-12-87/jsm:  The following defn was added during the proofs
; for i->m.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{xor-bool} \\  
\=\+{\rm{xor-bool}}\,({\it{x\/}}, {\it{y\/}})\index{xor-bool} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\it{y\/}} \\ 
{\bf elseif }{\it{y\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\tt{'}}{\tt{t}} \\ 
{\bf else }{\tt{'}}{\tt{f}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; Naturals

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{small-naturalp} \\  
{\rm{small-naturalp}}\,({\it{i\/}}, {\it{word-size\/}})\index{small-naturalp} $=$ (({\it{i\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{i\/}} $<$ {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}})\index{exp}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bool-to-nat} \\  
\=\+{\rm{bool-to-nat}}\,({\it{flg\/}})\index{bool-to-nat} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flg\/}} $=$ {\tt{'}}{\tt{f}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; *** 16-12-87/jsm:  "fix-small" was renamed "fix-small-natural" so that
; a parallel "fix-small-integer" could be defined.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{fix-small-natural} \\  
{\rm{fix-small-natural}}\,({\it{n\/}}, {\it{word-size\/}})\index{fix-small-natural} $=$ ({\it{n\/}} ${}${\bf{mod}}${}$ {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}})\index{exp})
\end{tabbing}



\begin{verbatim}; Integers

; The functions below are defined so that if given integerps they
; return integerps.  In particular, they never create (MINUS 0) though
; they might pass one through.

;; INTEGERP and ILESSP are defined in integers.events
;(defn integerp (i)
;  (or (numberp i)
;      (and (negativep i)
;	   (not (equal (negative-guts i) 0)))))

;(defn ilessp (i j)
;  (if (negativep i)
;      (if (negativep j)
;	  (lessp (negative-guts j)
;		 (negative-guts i))
;	  t)
;      (if (negativep j)
;	  f
;	  (lessp i j))))

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{small-integerp} \\  
\=\+{\rm{small-integerp}}\,({\it{i\/}}, {\it{word-size\/}})\index{small-integerp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{integerp}}\,({\it{i\/}})\index{integerp} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{ilessp}}\,({\it{i\/}}, $-$ {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}} $-\;1$)\index{exp})\index{ilessp}) \\ 
$\wedge$$\;\;\;\;${\rm{ilessp}}\,({\it{i\/}}, {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}} $-\;1$)\index{exp})\index{ilessp})\-\-
\end{tabbing}

\begin{verbatim};; IPLUS is defined in integers.events
;(defn iplus (i j)
;  (if (negativep i)
;      (if (negativep j)
;	  (minus
;	    (plus (negative-guts i)
;		  (negative-guts j)))
;	  (if (lessp j (negative-guts i))
;	      (minus (difference (negative-guts i) j))
;	      (difference j (negative-guts i))))
;      (if (negativep j)
;	  (if (lessp i (negative-guts j))
;	      (minus (difference (negative-guts j) i))
;	      (difference i (negative-guts j)))
;	  (plus i j))))

;; INEG is the same as INEGATE and is defined integer.events
;(defn inegate (i)
;  (if (negativep i)
;      (negative-guts i)
;      (if (zerop i)
;	  0
;	  (minus i))))

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{inegate}$\;\;$
{\rm{inegate}}\,({\it{i\/}})\index{inegate} $=$ {\rm{ineg}}\,({\it{i\/}})\index{ineg}
\end{tabbing}

\begin{verbatim};; IDIFFERENCE is defined in integers.events
;(defn idifference (i j)
;  (iplus i (inegate j)))

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{fix-small-integer} \\  
\=\+{\rm{fix-small-integer}}\,({\it{i\/}}, {\it{word-size\/}})\index{fix-small-integer} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{small-integerp}}\,({\it{i\/}}, {\it{word-size\/}})\index{small-integerp}$\;\;${\bf then }{\it{i\/}} \\ 
{\bf elseif }{\rm{negativep}}\,({\it{i\/}})$\;\;${\bf then }{\rm{iplus}}\,({\it{i\/}}, {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}})\index{exp})\index{iplus} \\ 
{\bf else }{\rm{iplus}}\,({\it{i\/}}, $-$ {\rm{exp}}\,({\tt{2}}, {\it{word-size\/}})\index{exp})\index{iplus}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; Bit vectors

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{bitp}$\;\;$
{\rm{bitp}}\,({\it{x\/}})\index{bitp} $=$ (({\it{x\/}} $=$ {\tt{0}}) $\vee$ ({\it{x\/}} $=$ {\tt{1}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bit-vectorp} \\  
\=\+{\rm{bit-vectorp}}\,({\it{x\/}}, {\it{n\/}})\index{bit-vectorp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }({\it{x\/}} $=$ {\bf{nil}}) $\wedge$ ({\it{n\/}} $\simeq {\tt{0}}$) \\ 
{\bf else }({\it{n\/}} $\not\simeq {\tt{0}}$) $\wedge$ {\rm{bitp}}\,({\rm{car}}\,({\it{x\/}}))\index{bitp} $\wedge$ {\rm{bit-vectorp}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{n\/}} $-\;1$)\index{bit-vectorp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{or-bit} \\  
\=\+{\rm{or-bit}}\,({\it{bit1\/}}, {\it{bit2\/}})\index{or-bit} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{bit1\/}} $=$ {\tt{0}} \\ 
{\bf then }\=\+{\bf if }{\it{bit2\/}} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\- \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

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

\begin{tabbing}{\sc Definition}:\index{and-bit} \\  
\=\+{\rm{and-bit}}\,({\it{bit1\/}}, {\it{bit2\/}})\index{and-bit} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{bit1\/}} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{bit2\/}} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{xor-bit} \\  
\=\+{\rm{xor-bit}}\,({\it{bit1\/}}, {\it{bit2\/}})\index{xor-bit} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{bit1\/}} $=$ {\tt{0}} \\ 
{\bf then }\=\+{\bf if }{\it{bit2\/}} $=$ {\tt{0}}$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }{\tt{1}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{bit2\/}} $=$ {\tt{0}}$\;\;${\bf then }{\tt{1}} \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{or-bitv} \\  
\=\+{\rm{or-bitv}}\,({\it{a\/}}, {\it{b\/}})\index{or-bitv} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{a\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{or-bit}}\,({\rm{car}}\,({\it{a\/}}), {\rm{car}}\,({\it{b\/}}))\index{or-bit}, {\rm{or-bitv}}\,({\rm{cdr}}\,({\it{a\/}}), {\rm{cdr}}\,({\it{b\/}}))\index{or-bitv})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{not-bitv} \\  
\=\+{\rm{not-bitv}}\,({\it{a\/}})\index{not-bitv} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{a\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{not-bit}}\,({\rm{car}}\,({\it{a\/}}))\index{not-bit}, {\rm{not-bitv}}\,({\rm{cdr}}\,({\it{a\/}}))\index{not-bitv})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{and-bitv} \\  
\=\+{\rm{and-bitv}}\,({\it{a\/}}, {\it{b\/}})\index{and-bitv} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{a\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{and-bit}}\,({\rm{car}}\,({\it{a\/}}), {\rm{car}}\,({\it{b\/}}))\index{and-bit}, {\rm{and-bitv}}\,({\rm{cdr}}\,({\it{a\/}}), {\rm{cdr}}\,({\it{b\/}}))\index{and-bitv})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{xor-bitv} \\  
\=\+{\rm{xor-bitv}}\,({\it{a\/}}, {\it{b\/}})\index{xor-bitv} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{a\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{xor-bit}}\,({\rm{car}}\,({\it{a\/}}), {\rm{car}}\,({\it{b\/}}))\index{xor-bit}, {\rm{xor-bitv}}\,({\rm{cdr}}\,({\it{a\/}}), {\rm{cdr}}\,({\it{b\/}}))\index{xor-bitv})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{all-but-last} \\  
\=\+{\rm{all-but-last}}\,({\it{a\/}})\index{all-but-last} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{a\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf elseif }{\rm{cdr}}\,({\it{a\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{a\/}}), {\rm{all-but-last}}\,({\rm{cdr}}\,({\it{a\/}}))\index{all-but-last})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{rsh-bitv}$\;\;$
{\rm{rsh-bitv}}\,({\it{a\/}})\index{rsh-bitv} $=$ {\rm{cons}}\,({\tt{0}}, {\rm{all-but-last}}\,({\it{a\/}})\index{all-but-last})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{lsh-bitv}$\;\;$
{\rm{lsh-bitv}}\,({\it{a\/}})\index{lsh-bitv} $=$ {\rm{append}}\,({\rm{cdr}}\,({\it{a\/}}), {\rm{list}}\,({\tt{0}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{all-zero-bitvp} \\  
\=\+{\rm{all-zero-bitvp}}\,({\it{a\/}})\index{all-zero-bitvp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{a\/}})$\;\;${\bf then }({\rm{car}}\,({\it{a\/}}) $=$ {\tt{0}}) $\wedge$ {\rm{all-zero-bitvp}}\,({\rm{cdr}}\,({\it{a\/}}))\index{all-zero-bitvp} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; Stacks

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{push}$\;\;$
{\rm{push}}\,({\it{x\/}}, {\it{stk\/}})\index{push} $=$ {\rm{cons}}\,({\it{x\/}}, {\it{stk\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{top}$\;\;$
{\rm{top}}\,({\it{stk\/}})\index{top} $=$ {\rm{car}}\,({\it{stk\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{pop}$\;\;$
{\rm{pop}}\,({\it{stk\/}})\index{pop} $=$ {\rm{cdr}}\,({\it{stk\/}})
\end{tabbing}

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

\begin{tabbing}{\sc Definition}:\index{top1}$\;\;$
{\rm{top1}}\,({\it{stk\/}})\index{top1} $=$ {\rm{top}}\,({\rm{pop}}\,({\it{stk\/}})\index{pop})\index{top}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{top2}$\;\;$
{\rm{top2}}\,({\it{stk\/}})\index{top2} $=$ {\rm{top}}\,({\rm{pop}}\,({\rm{pop}}\,({\it{stk\/}})\index{pop})\index{pop})\index{top}
\end{tabbing}




\begin{verbatim}; Labels

; In an earlier version of this I used the Lisp PROG convention for
; denoting labels:  a label is an atom in a list that otherwise
; contains non-atomic instructions.  The trouble with that convention
; is that the notions of the ``ith element'' and the ``length'' of
; such instruction lists have to be redefined to skip labels.  I
; anticipate much work going into the accessing of items at given
; addresses and wanted to use the same kind of fetch for program items
; as for data items.  Thus I have decided that each item in a list is
; an instruction and some are labelled.

; Here is a function which labels ins with lab:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{dl}$\;\;$
{\rm{dl}}\,({\it{lab\/}}, {\it{comment\/}}, {\it{ins\/}})\index{dl} $=$ {\rm{list}}\,({\tt{'}}{\tt{dl}}, {\it{lab\/}}, {\it{comment\/}}, {\it{ins\/}})
\end{tabbing}

\begin{verbatim}; The following function recognizes labelled items:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{labelledp}$\;\;$
{\rm{labelledp}}\,({\it{x\/}})\index{labelledp} $=$ ({\rm{car}}\,({\it{x\/}}) $=$ {\tt{'}}{\tt{dl}})
\end{tabbing}

\begin{verbatim}; This function extracts the instruction from the labelling.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{unlabel} \\  
\=\+{\rm{unlabel}}\,({\it{x\/}})\index{unlabel} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{labelledp}}\,({\it{x\/}})\index{labelledp}$\;\;${\bf then }{\rm{cadddr}}\,({\it{x\/}}) \\ 
{\bf else }{\it{x\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; I suspect we will never want to know whether something was labelled
; or not but rather deal with everything as though it weren't.  So I
; will disable the unlabel function.

\end{verbatim}
\noindent{\sc Event}:   Disable unlabel.

\addvspace{18pt}

\begin{verbatim}; The following function determines whether x is defined as a label
; in lst.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{find-labelp} \\  
\=\+{\rm{find-labelp}}\,({\it{x\/}}, {\it{lst\/}})\index{find-labelp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{labelledp}}\,({\rm{car}}\,({\it{lst\/}}))\index{labelledp} $\wedge$ ({\it{x\/}} $=$ {\rm{cadr}}\,({\rm{car}}\,({\it{lst\/}})))$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\rm{find-labelp}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{lst\/}}))\index{find-labelp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; This function counts the number of items in lst before the first
; one labelled x.
  
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{find-label} \\  
\=\+{\rm{find-label}}\,({\it{x\/}}, {\it{lst\/}})\index{find-label} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\rm{labelledp}}\,({\rm{car}}\,({\it{lst\/}}))\index{labelledp} $\wedge$ ({\it{x\/}} $=$ {\rm{cadr}}\,({\rm{car}}\,({\it{lst\/}})))$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ {\rm{find-label}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{lst\/}}))\index{find-label}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; Generally we convert labels into tagged PCs.  We use the following
; function:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{pc} \\  
\=\+{\rm{pc}}\,({\it{lab\/}}, {\it{program\/}})\index{pc} \\ 
$=$$\;\;\;\;${\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, {\rm{find-label}}\,({\it{lab\/}}, {\rm{program-body}}\,({\it{program\/}})\index{program-body})\index{find-label}))\index{tag}\-
\end{tabbing}

\begin{verbatim}; The following function is used by the JUMP-CASE instruction to
; check that a list of labels has been provided.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{all-find-labelp} \\  
\=\+{\rm{all-find-labelp}}\,({\it{lab-lst\/}}, {\it{lst\/}})\index{all-find-labelp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lab-lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }\=\+{\rm{find-labelp}}\,({\rm{car}}\,({\it{lab-lst\/}}), {\it{lst\/}})\index{find-labelp} \\ 
$\wedge$$\;\;\;\;${\rm{all-find-labelp}}\,({\rm{cdr}}\,({\it{lab-lst\/}}), {\it{lst\/}})\index{all-find-labelp}\-$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim};  P-Level Primitives


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-objectp} \\  
\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;$\=\+{\bf case on }{\rm{type}}\,({\it{x\/}})\index{type}: \\ 
{\bf case = }{\it{nat\/}} \\ 
{\bf then }{\rm{small-naturalp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp} \\ 
{\bf case = }{\it{int\/}} \\ 
{\bf $\;\;$then }{\rm{small-integerp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-integerp} \\ 
{\bf case = }{\it{bitv\/}} \\ 
{\bf $\;\;$then }{\rm{bit-vectorp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{bit-vectorp} \\ 
{\bf case = }{\it{bool\/}} \\ 
{\bf $\;\;$then }{\rm{booleanp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag})\index{booleanp} \\ 
{\bf case = }{\it{addr\/}} \\ 
{\bf $\;\;$then }{\rm{adpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{adpp} \\ 
{\bf case = }{\it{pc\/}} \\ 
{\bf $\;\;$then }{\rm{pcpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{pcpp} \\ 
{\bf case = }{\it{subr\/}} \\ 
{\bf $\;\;$then }{\rm{definedp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp} \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-objectp-type} \\  
{\rm{p-objectp-type}}\,({\it{type\/}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} $=$ (({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\it{type\/}}) $\wedge$ {\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{all-p-objectps} \\  
\=\+{\rm{all-p-objectps}}\,({\it{lst\/}}, {\it{p\/}})\index{all-p-objectps} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{lst\/}} $=$ {\bf{nil}} \\ 
{\bf else }{\rm{p-objectp}}\,({\rm{car}}\,({\it{lst\/}}), {\it{p\/}})\index{p-objectp} $\wedge$ {\rm{all-p-objectps}}\,({\rm{cdr}}\,({\it{lst\/}}), {\it{p\/}})\index{all-p-objectps}$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim}; The following function checks that it is ok to increment
; the pc by 1.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{add1-p-pc}$\;\;$
{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc} $=$ {\rm{add1-addr}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{add1-addr}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{add1-p-pcp} \\  
{\rm{add1-p-pcp}}\,({\it{p\/}})\index{add1-p-pcp} $=$ {\rm{pcpp}}\,({\rm{untag}}\,({\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{pcpp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-current-program} \\  
{\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program} $=$ {\rm{definition}}\,({\rm{area-name}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{area-name}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-current-instruction} \\  
\=\+{\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction} \\ 
$=$$\;\;\;\;${\rm{unlabel}}\,({\rm{get}}\,({\rm{offset}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{offset}, {\rm{program-body}}\,({\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{program-body})\index{get})\index{unlabel}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-frame}$\;\;$
{\rm{p-frame}}\,({\it{bindings\/}}, {\it{ret-pc\/}})\index{p-frame} $=$ {\rm{list}}\,({\it{bindings\/}}, {\it{ret-pc\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{bindings}$\;\;$
{\rm{bindings}}\,({\it{frame\/}})\index{bindings} $=$ {\rm{car}}\,({\it{frame\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{ret-pc}$\;\;$
{\rm{ret-pc}}\,({\it{frame\/}})\index{ret-pc} $=$ {\rm{cadr}}\,({\it{frame\/}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-frame-size} \\  
{\rm{p-frame-size}}\,({\it{frame\/}})\index{p-frame-size} $=$ ({\tt{2}} $+$ {\rm{length}}\,({\rm{bindings}}\,({\it{frame\/}})\index{bindings})\index{length})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-ctrl-stk-size} \\  
\=\+{\rm{p-ctrl-stk-size}}\,({\it{ctrl-stk\/}})\index{p-ctrl-stk-size} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{ctrl-stk\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }\=\+{\rm{p-frame-size}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{p-frame-size} \\ 
$+$$\;\;\;\;${\rm{p-ctrl-stk-size}}\,({\rm{cdr}}\,({\it{ctrl-stk\/}}))\index{p-ctrl-stk-size}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{local-varp} \\  
{\rm{local-varp}}\,({\it{var\/}}, {\it{ctrl-stk\/}})\index{local-varp} $=$ {\rm{definedp}}\,({\it{var\/}}, {\rm{bindings}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{bindings})\index{definedp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{local-var-value} \\  
{\rm{local-var-value}}\,({\it{var\/}}, {\it{ctrl-stk\/}})\index{local-var-value} $=$ {\rm{value}}\,({\it{var\/}}, {\rm{bindings}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{bindings})\index{value}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{set-local-var-value} \\  
\=\+{\rm{set-local-var-value}}\,({\it{val\/}}, {\it{var\/}}, {\it{ctrl-stk\/}})\index{set-local-var-value} \\ 
$=$$\;\;\;\;${\rm{push}}\,(\=\+{\rm{p-frame}}\,(\=\+{\rm{put-value}}\,({\it{val\/}}, {\it{var\/}}, {\rm{bindings}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{bindings})\index{put-value}, \\ 
{\rm{ret-pc}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{ret-pc})\-\index{p-frame}, \\ 
{\rm{pop}}\,({\it{ctrl-stk\/}})\index{pop})\-\index{push}\-
\end{tabbing}


\begin{verbatim};; REVERSE is defined in lists.events
;(defn reverse (x)
;  (if (nlistp x)
;      nil
;      (append (reverse (cdr x)) (list (car x)))))

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{first-n} \\  
\=\+{\rm{first-n}}\,({\it{n\/}}, {\it{x\/}})\index{first-n} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{x\/}}), {\rm{first-n}}\,({\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{x\/}}))\index{first-n})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{pair-formal-vars-with-actuals} \\  
\=\+{\rm{pair-formal-vars-with-actuals}}\,({\it{formal-vars\/}}, {\it{temp-stk\/}})\index{pair-formal-vars-with-actuals} \\ 
$=$$\;\;\;\;${\rm{pairlist}}\,({\it{formal-vars\/}}, {\rm{reverse}}\,({\rm{first-n}}\,({\rm{length}}\,({\it{formal-vars\/}})\index{length}, {\it{temp-stk\/}})\index{first-n})\index{reverse})\-
\end{tabbing}

\begin{verbatim}; Note:  I considered defining this function with:
;   (reverse (pairlist (reverse formal-vars) temp-stk))
; I am not sure which defn is the easiest to work with.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{pair-temps-with-initial-values} \\  
\=\+{\rm{pair-temps-with-initial-values}}\,({\it{temp-var-dcls\/}})\index{pair-temps-with-initial-values} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{temp-var-dcls\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,(\=\+{\rm{cons}}\,({\rm{caar}}\,({\it{temp-var-dcls\/}}), {\rm{cadar}}\,({\it{temp-var-dcls\/}})), \\ 
{\rm{pair-temps-with-initial-values}}\,({\rm{cdr}}\,({\it{temp-var-dcls\/}}))\index{pair-temps-with-initial-values})\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{make-p-call-frame} \\  
\=\+{\rm{make-p-call-frame}}\,({\it{formal-vars\/}}, {\it{temp-stk\/}}, {\it{temp-var-dcls\/}}, {\it{ret-pc\/}})\index{make-p-call-frame} \\ 
$=$$\;\;\;\;${\rm{p-frame}}\,(\=\+{\rm{append}}\,(\=\+{\rm{pair-formal-vars-with-actuals}}\,({\it{formal-vars\/}}, {\it{temp-stk\/}})\index{pair-formal-vars-with-actuals}, \\ 
{\rm{pair-temps-with-initial-values}}\,({\it{temp-var-dcls\/}})\index{pair-temps-with-initial-values})\-, \\ 
{\it{ret-pc\/}})\-\index{p-frame}\-
\end{tabbing}

\begin{verbatim}; If (FOO (X Y Z) ((A a) (B b) (C c)) ...) is a Piton program then
; the frame constructed when FOO is CALLed with temp-stk
; '(2 1 0 ...) looks like this:

; (((X . 0) (Y . 1) (Z . 2) (A . a) (B . b) (C . c))
;  ret-pc)

\end{verbatim}
\newpage
\begin{verbatim}

;-----------------------------------------------------------------------------
;  Individual Instructions.

;  I now begin defining the instruction set.  Suppose ins is an
;  instruction opcode.  Then I will define 3 functions, each with the
;  word ins in its name.  The three functions are:

;  p-ins-okp:  T or F according to whether the given instruction
;              is well-formed and legal to execute in a given state.

;  p-ins-step: the new state produced by the execution of a legal
;              well-formed instruction

;  icode-ins: the icode for this instruction.

\end{verbatim}
\newpage
\begin{verbatim}

;  (CALL subr)		Push a new frame onto the ctrl-stk binding the
;			formals and temps of the subroutine subr to their
;			actual values and saving the current return pc.
;			Transfer control to the beginning of subr.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-call-okp} \\  
\=\+{\rm{p-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-okp} \\ 
$=$$\;\;\;\;$(\=\+(\=\+{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} \\ 
$\not<$$\;\;\;\;${\rm{p-ctrl-stk-size}}\,({\rm{push}}\,(\=\+{\rm{make-p-call-frame}}\,(\=\+{\rm{formal-vars}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{formal-vars}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{temp-var-dcls}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{temp-var-dcls}, \\ 
{\rm{add1-addr}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{add1-addr})\-\index{make-p-call-frame}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{push})\index{p-ctrl-stk-size})\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} \\ 
$\not<$$\;\;\;\;${\rm{length}}\,({\rm{formal-vars}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{formal-vars})\index{length})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-call-step} \\  
\=\+{\rm{p-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{make-p-call-frame}}\,(\=\+{\rm{formal-vars}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{formal-vars}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{temp-var-dcls}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{temp-var-dcls}, \\ 
{\rm{add1-addr}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{add1-addr})\-\index{make-p-call-frame}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{push}, \\ 
{\rm{popn}}\,(\=\+{\rm{length}}\,({\rm{formal-vars}}\,({\rm{definition}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{formal-vars})\index{length}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{popn}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}
      
\begin{verbatim}; We now discuss how we compile a call instruction.  This means
; explaining a lot about the lower level machines and the structure of
; the compiler.

; Associated with every opcode, xxx, is a function named
; icode-xxx which generates the symbolic machine code
; for the opcode.  Code generated is called ``icode'' because it is
; the code executed by the I machine.

; Every icode-xxx function gets three arguments:

; ins          the Piton instruction being compiled
; pcn          the offset of the pc pointing to that Piton instruction
; program      the Piton program containing the instruction

; The pcn may be used as a unique seed for icode labels generated by the
; compiler.  It is guaranteed to be a NUMBERP.

; Icode contains labels.  What are these labels?  That is, what objects
; do we use for icode labels?  The answer is Piton PC-type objects.
; Icode labels are tagged so we can distinguish them from other things.
; The tag we use is 'PC!  At the icode level the initials PC should be
; thought of as standing for LABEL.

; Thus, in icode, (SUBR . 25) is a label!  It is tagged PC and thus
; a reference to it in the instruction stream would be denoted
; (PC (SUBR . 25)).  Remember that in icode PC stands for LABEL.

; To distinguish a reference from the defining occurrence, the defining
; occurrence is tagged exactly as in Piton code with DL.

; Thus, the defining occurrence of (SUBR . 25) would be in an instruction
; of the form
;     (DL (SUBR . 25) comment icode-ins)

; For each valid pc in a Piton program the icompiler defines that pc
; as a label at the beginning of the basic block of icode generated
; for the instruction at that pc.  Thus, the PC objects of Piton
; become the labels of icode programs and are given meaning.  In
; mapping the Piton PCs down to icode labels it is not necessary to do
; anything.  That is the beauty of our using the tag PC at the icode
; level.  Once upon a time I marked icode labels with the tag 'ILAB.
; But that means that when mapping the stacks or data memory down to
; the i level I had to go through and change all the PCs to ILABs.
; Now I don't.  The stacks at the r level are identical to the stacks
; at the i level!  (In the toy version, the r level stacks had pcs on
; them and they were transformed into i-level pcs.  That is no longer
; done.  The objects on the i-level stack become labels without any
; work.)

; User defined Piton labels, e.g., LOOP, are systematically eliminated
; by the icompiler into these pc type labels.  That is, when the
; defining occurrence of LOOP occurs at pcn 25 in a Piton program, it
; simply dropped in favor of the automatically generated pc-style
; label (DL (name . 25) & &).  When LOOP is used in a JUMP
; statement the corresponding pc-style label is computed and used
; instead.

; So far, we have established that all valid PC type objects in Piton
; are defined icode labels.  Furthermore, the label objects used in
; Piton are systematically eliminated in favor of pc-style labels.
; However, there are icode labels that are NOT valid Piton PC type
; objects!

; The problem arises because icode needs internal labels within basic
; blocks or to mark the prelude and postlude.  To generate distinct
; system-internal labels I exploit the fact that all valid Piton pc
; labels are of the form (name . number) where number is less than
; the length of the program body.   I generate labels of the
; form (name anything) and I also generate a single label of the form
; (name . length) where length is the length of the program body.
; I use labels of the first form to mark the PRELUDE for subroutine
; entry.  The label is (name PRELUDE).  I use the second label to
; mark the postlude.   Because these are icode labels they
; are tagged in the icode with either the PC tag, indicating a
; reference, e.g., (PC (name PRELUDE)), or the DL tag,
; indicating the defining occurrence (DL (name POSTLUDE) & &).
; Despite the fact that they are sometimes tagged PC they are not
; Piton PC.  Remember:  in icode PC stands for LABEL!

; Once upon a time I marked the postlude with (name POSTLUDE).  But
; that required that every program body end with a (RET) because
; many instructions assumed that the label marking the beginning of
; the block of instructions icompiled for the "next" Piton instruction
; was (name . n+1) where n is the position of the current instruction.
; (If the last instr is a (RET) then every other instr has a
; next one that is so labelled.)  I don't like enforcing the
; "last instr is a (RET)" convention, and it also makes the
; resulting implementation less efficient because often programs
; hit a (RET) which merely jumps to the instruction following the (RET)
; rather than just falling off the end.

; It is important that every icode label be structured enough to
; permit me to determine in which program it is defined.  All my
; labels have the name of the parent program as the car and then
; arbitrary stuff after.  I need to be able to find definitions since
; icode sometimes jumps to foreign labels (upon subroutine exit) and
; it must be possible to figure out the new pc from the supplied
; label.


; Historical Note and Commentary on Icode Labels:

; The presence in the icode of labels is rather unexpected to me.
; Originally labels were eliminated by the icompiler.  It is also odd
; that the high level language provides the notion of PC and the low
; level language uses labels!  Its a reversal of conceptual depth.
; The reason is that our pcs can be non-local.  That is, it is
; permitted in Piton for subroutine FOO to manipulate the non-local pc
; (BAR . 25) and to pass it to BAR and jumped to.

; If I were to map PCs in Piton down to pcs in the icode it would be
; necessary for the icompiler to compute icode pcs from Piton pcs.
; But that can't be done without an overall view of the system -- it
; cannot be done on a program by program basis.  So instead of using
; icode pcs below I use symbolic labels.  The fact that the labels I
; use are not atomic is irrelevant -- imagine icode labels were
; symbols if you wish.  The natural time to replace these symbols is
; at link time when we have absolute addresses.  An address like (BAR
; . 25) can be thought of as simply an alternative entry point into
; BAR and thus is like a subroutine in itself.

; Of course, I could make the icompiler have a second pass in which
; labels are eliminated in favor of icode-level pcs.  (That pass was
; called REMOVE-LABELS in HRIL.)  But the proof of the correctness of
; the icompiler is in the R->I transition and that is already the
; hardest of the three transitions to prove.  So in a way it is nice
; to eliminate a complexity from there.  Introducing the complexity in
; I->L is ok too both because that transition is the simplest and
; because it is already dealing with the idea that jumping to a
; symbolic subroutine address is the same as jumping to an absolute
; address where that subroutine is located.  So I don't think pushing
; label removal to the final transition is necessarily going to
; complicate the proof down there very much.



; Now, on with my icompiler!

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icode-call} \\  
\=\+{\rm{icode-call}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-call} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{cpush\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, $1\;+$ {\it{pcn\/}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{'}}{\tt{(}}{\tt{prelude}}{\tt{)}}))\index{tag})\-\-
\end{tabbing}

\begin{verbatim}; Notes:  See the "Guide to Decrypting I-level Opcodes" near the
; defn of link-instruction-alist for an explanation of the meaning
; of the i-level opcodes used in the icode- fns.

; Four observations come to mind about this piece of icode.
; First, while the tag function has heretofore been used only to
; produce Piton objects, I am here using it to produce icode objects,
; namely PCs.  Second, the return address pushed onto csp is an icode
; label not a pc.  Third, the return address label, (name . pcn+1) is
; not defined here.  That is because it is defined when I process the
; pcn+1st instruction.  In fact, icompile-program-body lays down the
; DLs implicit in the use of that label.  Fourth, the (name
; prelude) label is not defined here.  In fact, generate-prelude takes
; care of its defn.

; There is more to the compilation of a CALL instruction than merely
; the sequence of instructions generated for the CALL itself:  one
; must also consider the prelude that is part of every subroutine
; entry.  The prelude must be undone by the postlude.  I therefore
; include below the CALL code, the prelude, and the postlude.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{generate-prelude1} \\  
\=\+{\rm{generate-prelude1}}\,({\it{temp-var-dcls\/}})\index{generate-prelude1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{temp-var-dcls\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{cpush\_*}}{\tt{)}}, \\ 
{\rm{cons}}\,(\=\+{\rm{cadr}}\,({\rm{car}}\,({\it{temp-var-dcls\/}})), \\ 
{\rm{generate-prelude1}}\,({\rm{cdr}}\,({\it{temp-var-dcls\/}}))\index{generate-prelude1})\-)\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{generate-prelude2} \\  
\=\+{\rm{generate-prelude2}}\,({\it{formal-vars\/}})\index{generate-prelude2} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{formal-vars\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{cpush\_$<$tsp$>$+}}{\tt{)}}, \\ 
{\rm{generate-prelude2}}\,({\rm{cdr}}\,({\it{formal-vars\/}}))\index{generate-prelude2})\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{generate-prelude} \\  
\=\+{\rm{generate-prelude}}\,({\it{program\/}})\index{generate-prelude} \\ 
$=$$\;\;\;\;${\rm{append}}\,(\=\+{\rm{list}}\,(\=\+{\rm{dl}}\,(\=\+{\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, {\tt{'}}{\tt{(}}{\tt{prelude}}{\tt{)}}), \\ 
{\tt{'}}{\tt{(}}{\tt{prelude}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{cpush\_cfp}}{\tt{)}})\-\index{dl}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_cfp\_csp}}{\tt{)}})\-, \\ 
{\rm{append}}\,(\=\+{\rm{generate-prelude1}}\,({\rm{reverse}}\,({\rm{temp-var-dcls}}\,({\it{program\/}})\index{temp-var-dcls})\index{reverse})\index{generate-prelude1}, \\ 
{\rm{generate-prelude2}}\,({\rm{formal-vars}}\,({\it{program\/}})\index{formal-vars})\index{generate-prelude2})\-)\-\-
\end{tabbing}

\begin{verbatim};  Observe how the formals and temps are arranged on the stack.
;  Suppose that the header for the subroutine FOO is (FOO (X Y Z) ((A
;  a) (B b) (C c)) ...) where a, b, and c are constants.  At the
;  beginning of the execution of (CALL FOO) the temp-stk and ctrl-stk
;  look like this:

;     ...              ...
;      e1               c1  <- csp
;       x
;       y
;       z  <- tsp

;  Our stacks on the lower level grow downward.  For example, a
;  typical value for tsp might be '((TEMP-STK) . 25), which denotes
;  the 25th word from the base of the area named '(TEMP-STK).  The
;  contents of that word is the item on the top of the stack.  To push
;  something, tsp would become '((TEMP-STK) . 24).  To pop something,
;  tsp would become '((TEMP-STK) . 26).

;  Note that the base of the area named '(TEMP-STK) is not the
;  base of the stack!

;  After execution of (CALL FOO) the stacks are:

;     ...              ...    
;      e1  <- tsp       c1
;                   ret-pc
;                   old-fp  <- cfp
;                        c           +5
;                        b           +4
;                        a           +3
;                        z           +2
;                        y           +1        
;                        x  <- csp   +0

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{find-position-of-var} \\  
\=\+{\rm{find-position-of-var}}\,({\it{var\/}}, {\it{lst\/}})\index{find-position-of-var} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf elseif }{\it{var\/}} $=$ {\rm{car}}\,({\it{lst\/}})$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }$1\;+$ {\rm{find-position-of-var}}\,({\it{var\/}}, {\rm{cdr}}\,({\it{lst\/}}))\index{find-position-of-var}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{offset-from-csp} \\  
\=\+{\rm{offset-from-csp}}\,({\it{var\/}}, {\it{program\/}})\index{offset-from-csp} \\ 
$=$$\;\;\;\;${\rm{find-position-of-var}}\,({\it{var\/}}, {\rm{local-vars}}\,({\it{program\/}})\index{local-vars})\index{find-position-of-var}\-
\end{tabbing}


\begin{verbatim};  We now define

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{generate-postlude} \\  
\=\+{\rm{generate-postlude}}\,({\it{program\/}})\index{generate-postlude} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\rm{dl}}\,(\=\+{\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, {\rm{length}}\,({\rm{program-body}}\,({\it{program\/}})\index{program-body})\index{length}), \\ 
{\tt{'}}{\tt{(}}{\tt{postlude}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_csp\_cfp}}{\tt{)}})\-\index{dl}, \\ 
{\tt{'}}{\tt{(}}{\tt{cpop\_cfp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{cpop\_pc}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};  (RET)              Return from the current subroutine, leaving temp-stk
;                     untouched but restoring ctrl-stk.  We make a special
;                     case out of top-level RETs:  halt the machine with the
;                     distinguished, non-erroneous psw HALT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-ret-okp}$\;\;$
{\rm{p-ret-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-okp} $=$ {\bf{t}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-ret-step} \\  
\=\+{\rm{p-ret-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-step} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\rm{pop}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{pop}) \\ 
{\bf then }{\rm{p-state}}\,(\=\+{\rm{ret-pc}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{ret-pc}, \\ 
{\rm{pop}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{pop}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state} \\ 
{\bf else }{\rm{p-halt}}\,({\it{p\/}}, {\tt{'}}{\tt{halt}})\index{p-halt}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-ret} \\  
\=\+{\rm{icode-ret}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-ret} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, {\rm{length}}\,({\rm{program-body}}\,({\it{program\/}})\index{program-body})\index{length}))\index{tag})\-\-
\end{tabbing}


\begin{verbatim};  (LOCN var)           The argument var must be a local variable.  Suppose
;                       its value is i.  Then push onto temp-stk the value
;                       of the ith variable bound in the current frame.
;                       i must be less than the number of variables bound.
;                       We enumerate the variables from left to right.
;                       The enumeration is 0 based.  Thus, if a subroutine
;                       has formals X, Y, and Z, and declares temps
;                       A, B, and C, in that order, X is the 0th local,
;                       Y the 1st, Z the 2nd, A the 3rd, etc.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-locn-okp} \\  
\=\+{\rm{p-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{untag}}\,({\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value})\index{untag} \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{bindings}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{bindings})\index{length})\- \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}))\-\-
\end{tabbing}

\begin{verbatim}; Observe that LOCN enumerates the variables in the same order that
; they are offset from csp.  This is also the same order in which
; they are bound in the p-frame built for the subroutine.

; *** 14-12-87/jsm:  The definitions of keyn and var-name were once
; found here but have been deleted because they are no longer used.

; Here then is the step function for LOCN:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-locn-step} \\  
\=\+{\rm{p-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{cdr}}\,({\rm{get}}\,(\=\+{\rm{untag}}\,({\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value})\index{untag}, \\ 
{\rm{bindings}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{bindings})\-\index{get}), \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-locn} \\  
\=\+{\rm{icode-locn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-locn} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{offset-from-csp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{offset-from-csp})\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpush\_$<$x\{s\}$>$}}{\tt{)}})\-\-
\end{tabbing}	\begin{verbatim};push value of vari

\end{verbatim}
\newpage
\begin{verbatim}

;  (PUSH-CONSTANT c)    Push c onto temp-stk.  c is normally a tagged
;                       constant but we permit two abbreviations.
;                       If c is the atom 'pc, it denotes the pc
;                       of the instruction following this one.
;                       If c is a non-LISTP that is defined in
;                       the current program with a DL, it
;                       denotes the pc of that label.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-constant-okp} \\  
\=\+{\rm{p-push-constant-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-okp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})\-
\end{tabbing}

\begin{verbatim};  First I define the ``unabbreviate'' function.  Observe that the
;  abbreviation depends upon the current state, p, since it permits the 
;  abbreviation of the current p-pc.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{unabbreviate-constant} \\  
\=\+{\rm{unabbreviate-constant}}\,({\it{c\/}}, {\it{p\/}})\index{unabbreviate-constant} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{c\/}} $=$ {\tt{'}}{\tt{pc}}$\;\;${\bf then }{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc} \\ 
{\bf elseif }{\it{c\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{pc}}\,({\it{c\/}}, {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc} \\ 
{\bf else }{\it{c\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-constant-step} \\  
\=\+{\rm{p-push-constant-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{unabbreviate-constant}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{p\/}})\index{unabbreviate-constant}, {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-push-constant} \\  
\=\+{\rm{icode-push-constant}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-constant} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpush\_*}}{\tt{)}}, \\ 
\=\+{\bf if }{\rm{cadr}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pc}}$\;\;${\bf then }{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, $1\;+$ {\it{pcn\/}}))\index{tag} \\ 
{\bf elseif }{\rm{cadr}}\,({\it{ins\/}}) $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc} \\ 
{\bf else }{\rm{cadr}}\,({\it{ins\/}})$\;${\bf  endif}\-)\-\-
\end{tabbing}


\begin{verbatim};  (PUSH-LOCAL var)     Push the value of the local variable var onto
;                       the temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-local-okp} \\  
\=\+{\rm{p-push-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-okp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-local-step} \\  
\=\+{\rm{p-push-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value}, {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-push-local} \\  
\=\+{\rm{icode-push-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-local} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{offset-from-csp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{offset-from-csp})\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpush\_$<$x\{s\}$>$}}{\tt{)}})\-\-
\end{tabbing}	\begin{verbatim};push value of var onto tsp


\end{verbatim}
\newpage
\begin{verbatim}

;  (PUSH-GLOBAL var)    Push the value of the global variable var onto
;                       temp-stk.


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-global-okp} \\  
\=\+{\rm{p-push-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-okp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-global-step} \\  
\=\+{\rm{p-push-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{fetch}}\,({\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{fetch}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-push-global} \\  
\=\+{\rm{icode-push-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-global} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpush\_$<$x\{a\}$>$}}{\tt{)}})\-\-
\end{tabbing}


\begin{verbatim};  (PUSH-CTRL-STK-FREE-SIZE)
;                       Push onto temp-stk the size of the
;                       remaining free space in the control
;                       stack.  This is the number of pushes
;                       that can be done on the ctrl-stack
;                       without causing an error.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-ctrl-stk-free-size-okp} \\  
\=\+{\rm{p-push-ctrl-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-okp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-ctrl-stk-free-size-step} \\  
\=\+{\rm{p-push-ctrl-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{nat}}, \\ 
\=\+{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} \\ 
$-$$\;\;\;\;${\rm{p-ctrl-stk-size}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{p-ctrl-stk-size}\-)\-\index{tag}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-push-ctrl-stk-free-size} \\  
\=\+{\rm{icode-push-ctrl-stk-free-size}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-ctrl-stk-free-size} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{move\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{full-ctrl-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_csp}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_$<$tsp$>$\{s\}\_x\{s\}}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}



\begin{verbatim};  (PUSH-TEMP-STK-FREE-SIZE)
;                       Push onto temp-stk the size of the
;                       remaining free space in the temp
;                       stack.  This is the number of pushes
;                       that can be done on the temp-stack
;                       without causing an error -- assuming
;                       that the number pushed here has been
;                       popped off.  For example, if there
;                       is one slot left on the temp stack
;                       when this instruction is executed,
;                       (NAT 1) is pushed and the stack is
;                       then full.  When it is popped, we
;                       know 1 push can be done.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-temp-stk-free-size-okp} \\  
\=\+{\rm{p-push-temp-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-okp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-temp-stk-free-size-step} \\  
\=\+{\rm{p-push-temp-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{nat}}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $-$ {\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length})\-\index{tag}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-push-temp-stk-free-size} \\  
\=\+{\rm{icode-push-temp-stk-free-size}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-temp-stk-free-size} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{move\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{full-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_tsp}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_$<$tsp$>$\{s\}\_x\{s\}}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};  (PUSH-TEMP-STK-INDEX n)

;                       Push onto temp-stk the temp stk index of the
;                       slot n below the current top.  n must be a
;                       natural number less than the length of the
;                       stack.  The object pushed is a NAT.
;  		        Below is a picture of a temp-stk with
;                       of length 6, A being at the top:

;                       temp-stk:   (A B C D E F)    
;                       index:       5 4 3 2 1 0
;                       n:           0 1 2 3 4 5

;                       The index returned is suitable for use by
;                       FETCH-TEMP-STK and DEPOSIT-TEMP-STK.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-push-temp-stk-index-okp} \\  
\=\+{\rm{p-push-temp-stk-index-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-okp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $<$ {\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-push-temp-stk-index-step} \\  
\=\+{\rm{p-push-temp-stk-index-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{nat}}, ({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $-$ {\rm{cadr}}\,({\it{ins\/}})) $-\;1$)\index{tag}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{verbatim}; Note:  The assembly code below uses sub_<z>_x{s}_y{s} but is not actually
; sensitive to the z-flg.  I use that instruction simply because it
; was in the i machine already.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icode-push-temp-stk-index} \\  
\=\+{\rm{icode-push-temp-stk-index}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-push-temp-stk-index} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_y\_tsp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{empty-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sub\_$<$z$>$\_x\{s\}\_y\{s\}}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpush\_x}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, $1\;+$ {\rm{cadr}}\,({\it{ins\/}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{sub\_$<$tsp$>$\{n\}\_x\{n\}}}{\tt{)}})\-\-
\end{tabbing}


\begin{verbatim};  (JUMP-IF-TEMP-STK-FULL lab)
;                      If the temp-stk is full, jump to lab.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-jump-if-temp-stk-full-okp}$\;\;$
{\rm{p-jump-if-temp-stk-full-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-okp} $=$ {\bf{t}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-jump-if-temp-stk-full-step} \\  
\=\+{\rm{p-jump-if-temp-stk-full-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+\=\+{\bf if }{\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $=$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} \\ 
{\bf then }{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc} \\ 
{\bf else }{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}$\;${\bf  endif}\-, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-jump-if-temp-stk-full} \\  
\=\+{\rm{icode-jump-if-temp-stk-full}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-jump-if-temp-stk-full} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_tsp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_y\_*}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{full-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_y\_$<$y\{s\}$>$}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sub\_$<$z$>$\_x\{s\}\_y\{s\}}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\-\-
\end{tabbing}


\begin{verbatim};  (JUMP-IF-TEMP-STK-EMPTY lab)
;                      If the temp-stk is empty, jump to lab.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-jump-if-temp-stk-empty-okp}$\;\;$
{\rm{p-jump-if-temp-stk-empty-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-okp} $=$ {\bf{t}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-jump-if-temp-stk-empty-step} \\  
\=\+{\rm{p-jump-if-temp-stk-empty-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+\=\+{\bf if }{\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $\simeq {\tt{0}}$ \\ 
{\bf then }{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc} \\ 
{\bf else }{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}$\;${\bf  endif}\-, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-jump-if-temp-stk-empty} \\  
\=\+{\rm{icode-jump-if-temp-stk-empty}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-jump-if-temp-stk-empty} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_y\_tsp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{empty-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{sub\_$<$z$>$\_x\{s\}\_y\{s\}}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};  (POP)                Pop top of temp-stk and discard

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop-okp}$\;\;$
{\rm{p-pop-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-okp} $=$ {\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop-step} \\  
\=\+{\rm{p-pop-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop}$\;\;$
{\rm{icode-pop}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};  (POP* n)                Pop temp-stk n times.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop*-okp} \\  
{\rm{p-pop*-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-okp} $=$ ({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $\not<$ {\rm{cadr}}\,({\it{ins\/}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop*-step} \\  
\=\+{\rm{p-pop*-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{popn}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{popn}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop*} \\  
\=\+{\rm{icode-pop*}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop*} \\ 
$=$$\;\;\;\;${\rm{list}}\,({\tt{'}}{\tt{(}}{\tt{add\_tsp\_*\{n\}}}{\tt{)}}, {\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{cadr}}\,({\it{ins\/}}))\index{tag})\-
\end{tabbing}



\begin{verbatim};  (POPN)                Pop temp-stk once to obtain n,
;                        a NAT.  Then pop and discard n
;                        things from temp-stk.  n must be
;                        less than or equal to the length
;                        of the stack (after it is popped
;                        off).

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-popn-okp} \\  
\=\+{\rm{p-popn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $\not<$ ($1\;+$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-popn-step} \\  
\=\+{\rm{p-popn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{popn}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{popn}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-popn} \\  
{\rm{icode-popn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-popn} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_tsp\_x\{n\}}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};  (POP-LOCAL var)      Pop top of temp-stk and put the value into the local
;                       variable var.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop-local-okp}$\;\;$
{\rm{p-pop-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-okp} $=$ {\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop-local-step} \\  
\=\+{\rm{p-pop-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{set-local-var-value}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{set-local-var-value}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop-local} \\  
\=\+{\rm{icode-pop-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop-local} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{offset-from-csp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{offset-from-csp})\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpop\_$<$x\{s\}$>$}}{\tt{)}})\-\-
\end{tabbing}




\begin{verbatim};  (POP-GLOBAL var)     Pop top of temp-stk and put the value into the global
;                       variable var.


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop-global-okp}$\;\;$
{\rm{p-pop-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-okp} $=$ {\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop-global-step} \\  
\=\+{\rm{p-pop-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{deposit}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\-\index{deposit}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop-global} \\  
\=\+{\rm{icode-pop-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop-global} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpop\_$<$x\{a\}$>$}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};  (POP-LOCN var)       Pop top of temp-stk and put the value into the ith
;                       bound var in the current frame, where i is the value
;                       of the bound variable var.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop-locn-okp} \\  
\=\+{\rm{p-pop-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{untag}}\,({\rm{local-var-value}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{local-var-value})\index{untag} \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{bindings}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{bindings})\index{length})\- \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}))\-\-
\end{tabbing}

\begin{verbatim}; *** 14-12-87/mk:  In the original definition we set the value
; by going through the name of the ith variable.  Duplicate
; names caused problems.  We now set the value via position.
; Two new functions are defined.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{put-value-indirect} \\  
\=\+{\rm{put-value-indirect}}\,({\it{val\/}}, {\it{n\/}}, {\it{lst\/}})\index{put-value-indirect} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{lst\/}}) \\ 
{\bf then }\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{cons}}\,({\rm{cons}}\,({\rm{caar}}\,({\it{lst\/}}), {\it{val\/}}), {\rm{cdr}}\,({\it{lst\/}})) \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{lst\/}}), {\rm{put-value-indirect}}\,({\it{val\/}}, {\it{n\/}} $-\;1$, {\rm{cdr}}\,({\it{lst\/}}))\index{put-value-indirect})$\;${\bf  endif}\- \\ 
{\bf else }{\it{lst\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{set-local-var-indirect} \\  
\=\+{\rm{set-local-var-indirect}}\,({\it{val\/}}, {\it{index\/}}, {\it{ctrl-stk\/}})\index{set-local-var-indirect} \\ 
$=$$\;\;\;\;${\rm{push}}\,(\=\+{\rm{p-frame}}\,(\=\+{\rm{put-value-indirect}}\,({\it{val\/}}, {\it{index\/}}, {\rm{bindings}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{bindings})\index{put-value-indirect}, \\ 
{\rm{ret-pc}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{ret-pc})\-\index{p-frame}, \\ 
{\rm{pop}}\,({\it{ctrl-stk\/}})\index{pop})\-\index{push}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop-locn-step} \\  
\=\+{\rm{p-pop-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{set-local-var-indirect}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{untag}}\,({\rm{local-var-value}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{local-var-value})\index{untag}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{set-local-var-indirect}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop-locn} \\  
\=\+{\rm{icode-pop-locn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop-locn} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{offset-from-csp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{offset-from-csp})\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{tpop\_$<$x\{s\}$>$}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};  (POP-CALL)           Pop temp-stk to obtain a subroutine name and
;                       call that subroutine.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pop-call-okp} \\  
\=\+{\rm{p-pop-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{subr}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-call-okp}}\,(\=\+{\rm{list}}\,({\tt{'}}{\tt{call}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}), \\ 
{\rm{p-state}}\,(\=\+{\rm{p-pc}}\,({\it{p\/}})\index{p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state})\-\index{p-call-okp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-pop-call-step} \\  
\=\+{\rm{p-pop-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-step} \\ 
$=$$\;\;\;\;${\rm{p-call-step}}\,(\=\+{\rm{list}}\,({\tt{'}}{\tt{call}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}), \\ 
{\rm{p-state}}\,(\=\+{\rm{p-pc}}\,({\it{p\/}})\index{p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state})\-\index{p-call-step}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pop-call} \\  
\=\+{\rm{icode-pop-call}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pop-call} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{cpush\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, $1\;+$ {\it{pcn\/}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump\_x\{subr\}}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};   (FETCH-TEMP-STK)    Pop top of temp-stk.  The result must
;                       be an index into the temp-stk, that is,
;                       a NAT less than the length of temp-stk.
;                       Push onto the temp-stk the contents of
;                       the indexed cell of temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-fetch-temp-stk-okp} \\  
\=\+{\rm{p-fetch-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} $<$ {\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-fetch-temp-stk-step} \\  
\=\+{\rm{p-fetch-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{rget}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{rget}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-fetch-temp-stk} \\  
\=\+{\rm{icode-fetch-temp-stk}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-fetch-temp-stk} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{incr\_y\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{empty-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_x\{s\}\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_$<$x\{s\}$>$}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (DEPOSIT-TEMP-STK)  Pop top and top1 off of temp-stk.  top must be
;                       an index into temp-stk.  Deposit top1 into the indexed
;                       cell of temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-deposit-temp-stk-okp} \\  
\=\+{\rm{p-deposit-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{length})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-deposit-temp-stk-step} \\  
\=\+{\rm{p-deposit-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{rput}}\,(\=\+{\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{rput}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-deposit-temp-stk} \\  
\=\+{\rm{icode-deposit-temp-stk}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-deposit-temp-stk} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{incr\_y\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{sys-addr}}{\tt{ }}{\tt{(}}{\tt{empty-temp-stk-addr}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_$<$x\{s\}$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_x\{s\}\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpop\_$<$x\{s\}$>$}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};  (JUMP lab)           Jump to the location named by lab in the current 
;                       program.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-jump-okp}$\;\;$
{\rm{p-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-okp} $=$ {\bf{t}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-jump-step} \\  
\=\+{\rm{p-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{icode-jump} \\  
{\rm{icode-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-jump} $=$ {\rm{list}}\,({\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, {\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc})
\end{tabbing}


\begin{verbatim};   (JUMP-CASE lab0 lab1 ... labn)
;                       Pop top of temp-stk.  It must be a some nat, i.
;                       Jump to labi.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-jump-case-okp} \\  
\=\+{\rm{p-jump-case-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} $<$ {\rm{length}}\,({\rm{cdr}}\,({\it{ins\/}}))\index{length}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-jump-case-step} \\  
\=\+{\rm{p-jump-case-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{pc}}\,(\=\+{\rm{get}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\rm{cdr}}\,({\it{ins\/}}))\index{get}, \\ 
{\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\-\index{pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{jump\_*-lst} \\  
\=\+{\rm{jump\_*-lst}}\,({\it{lst\/}}, {\it{program\/}})\index{jump\_*-lst} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, \\ 
{\rm{cons}}\,(\=\+{\rm{pc}}\,({\rm{car}}\,({\it{lst\/}}), {\it{program\/}})\index{pc}, \\ 
{\rm{jump\_*-lst}}\,({\rm{cdr}}\,({\it{lst\/}}), {\it{program\/}})\index{jump\_*-lst})\-)\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-jump-case} \\  
\=\+{\rm{icode-jump-case}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-jump-case} \\ 
$=$$\;\;\;\;${\rm{append}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_x\_x\{n\}}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_pc\_x\{n\}}}{\tt{)}}{\tt{)}}, \\ 
{\rm{jump\_*-lst}}\,({\rm{cdr}}\,({\it{ins\/}}), {\it{program\/}})\index{jump\_*-lst})\-\-
\end{tabbing}
	

\begin{verbatim};  (PUSHJ lab)          Push onto temp-stk the pc of the next instruction
;                       and then jump to the location named by lab in the
;                       current program.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-pushj-okp} \\  
{\rm{p-pushj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-okp} $=$ ({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size})
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{p-pushj-step} \\  
\=\+{\rm{p-pushj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-pushj} \\  
\=\+{\rm{icode-pushj}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-pushj} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpush\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, $1\;+$ {\it{pcn\/}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc})\-\-
\end{tabbing}



\begin{verbatim};  (POPJ)               Pop the temp-stk to obtain a pc and jump to that
;                       location.  The location must be within the current
;                       program!

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-popj-okp} \\  
\=\+{\rm{p-popj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{pc}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{area-name}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{area-name} $=$ {\rm{area-name}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{area-name}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-popj-step} \\  
\=\+{\rm{p-popj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-popj}$\;\;$
{\rm{icode-popj}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-popj} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_pc}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};  (SET-LOCAL var)      Set the local variable var to the top of the temp-stk
;                       but do not pop the temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-set-local-okp}$\;\;$
{\rm{p-set-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-okp} $=$ {\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-set-local-step} \\  
\=\+{\rm{p-set-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{set-local-var-value}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\-\index{set-local-var-value}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-set-local} \\  
\=\+{\rm{icode-set-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-set-local} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{offset-from-csp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{program\/}})\index{offset-from-csp})\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{add\_x\{n\}\_csp}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_$<$x\{s\}$>$\_$<$tsp$>$}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim};  (SET-GLOBAL var)     Set the global variable var to the top of the temp-stk
;                       but do not pop the temp-stk.


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-set-global-okp}$\;\;$
{\rm{p-set-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-okp} $=$ {\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-set-global-step} \\  
\=\+{\rm{p-set-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{deposit}}\,(\=\+{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\-\index{deposit}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-set-global} \\  
\=\+{\rm{icode-set-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-set-global} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{addr}}, {\rm{cons}}\,({\rm{cadr}}\,({\it{ins\/}}), {\tt{0}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_$<$x\{a\}$>$\_$<$tsp$>$}}{\tt{)}})\-\-
\end{tabbing}



\begin{verbatim}; (TEST-type-AND-JUMP flg lab)
;                       Each instruction in this family pops one item, x, off
;                       temp-stk.  The item must be of the indicated type.
;                       The item is tested as indicated by the flg.  If the
;                       test is satisfied, we jump to the indicated label, lab.
;                       Otherwise, the next instruction is executed.  The 
;                       flags and tests available depend upon the type.
;                       We enumerate them in the documentation for each
;                       test-and-jump instruction.

;  For each member of the family I define p-test-xxx-and-jump-okp,
;  which approves the execution of the instruction.  Then I define
;  p-test-xxx-and-jump-step and
;  icode-test-xxx-and-jump.  Both the -okp and the
;  -step function are defined in terms of more general purpose functions.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-test-and-jump-okp} \\  
\=\+{\rm{p-test-and-jump-okp}}\,({\it{ins\/}}, {\it{type\/}}, {\it{test\/}}, {\it{p\/}})\index{p-test-and-jump-okp} \\ 
$=$$\;\;\;\;$({\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) $\wedge$ {\rm{p-objectp-type}}\,({\it{type\/}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-and-jump-step} \\  
\=\+{\rm{p-test-and-jump-step}}\,({\it{test\/}}, {\it{lab\/}}, {\it{p\/}})\index{p-test-and-jump-step} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{test\/}} \\ 
{\bf then }{\rm{p-state}}\,(\=\+{\rm{pc}}\,({\it{lab\/}}, {\rm{p-current-program}}\,({\it{p\/}})\index{p-current-program})\index{pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state} \\ 
{\bf else }{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endif}\-\-
\end{tabbing}



\begin{verbatim}; (TEST-NAT-AND-JUMP flg lab)

;                          flg                test

;                          ZERO          jump if x is 0
;                      NOT-ZERO          jump if x is not 0

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-test-natp} \\  
\=\+{\rm{p-test-natp}}\,({\it{flg\/}}, {\it{x\/}})\index{p-test-natp} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\it{flg\/}}: \\ 
{\bf case = }{\it{zero\/}} \\ 
{\bf then }{\it{x\/}} $=$ {\tt{0}} \\ 
{\bf otherwise }{\it{x\/}} $\not=$ {\tt{0}}$\;${\bf  endcase}\-\-
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{p-test-nat-and-jump-okp} \\  
\=\+{\rm{p-test-nat-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-okp} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-okp}}\,(\=\+{\it{ins\/}}, \\ 
{\tt{'}}{\tt{nat}}, \\ 
{\rm{p-test-natp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-natp}, \\ 
{\it{p\/}})\-\index{p-test-and-jump-okp}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-nat-and-jump-step} \\  
\=\+{\rm{p-test-nat-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-step} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-step}}\,(\=\+{\rm{p-test-natp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-natp}, \\ 
{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\it{p\/}})\-\index{p-test-and-jump-step}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-test-nat-and-jump} \\  
\=\+{\rm{icode-test-nat-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-test-nat-and-jump} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{cadr}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{zero\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{n\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{n\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-nz\_x}}{\tt{)}})\-$\;${\bf  endcase}\-\-
\end{tabbing}




\begin{verbatim}; (TEST-INT-AND-JUMP flg lab)
;                          flg                test
;                          ZERO          jump if x is 0
;                      NOT-ZERO          jump if x is not 0
;                          NEG           jump if x is negative
;                      NOT-NEG           jump if x is not negative
;                          POS           jump if x is positive
;                      NOT-POS           jump if x is not positive


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-test-intp} \\  
\=\+{\rm{p-test-intp}}\,({\it{flg\/}}, {\it{x\/}})\index{p-test-intp} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\it{flg\/}}: \\ 
{\bf case = }{\it{zero\/}} \\ 
{\bf then }{\it{x\/}} $=$ {\tt{0}} \\ 
{\bf case = }{\it{not-zero\/}} \\ 
{\bf $\;\;$then }{\it{x\/}} $\not=$ {\tt{0}} \\ 
{\bf case = }{\it{neg\/}} \\ 
{\bf $\;\;$then }{\rm{negativep}}\,({\it{x\/}}) \\ 
{\bf case = }{\it{not-neg\/}} \\ 
{\bf $\;\;$then }$\neg$ {\rm{negativep}}\,({\it{x\/}}) \\ 
{\bf case = }{\it{pos\/}} \\ 
{\bf $\;\;$then }({\it{x\/}} $\in\;${\bf{N}}${}$) $\wedge$ ({\it{x\/}} $\not=$ {\tt{0}}) \\ 
{\bf otherwise }({\it{x\/}} $=$ {\tt{0}}) $\vee$ {\rm{negativep}}\,({\it{x\/}})$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-int-and-jump-okp} \\  
\=\+{\rm{p-test-int-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-okp} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-okp}}\,(\=\+{\it{ins\/}}, \\ 
{\tt{'}}{\tt{int}}, \\ 
{\rm{p-test-intp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-intp}, \\ 
{\it{p\/}})\-\index{p-test-and-jump-okp}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-int-and-jump-step} \\  
\=\+{\rm{p-test-int-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-step} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-step}}\,(\=\+{\rm{p-test-intp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-intp}, \\ 
{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\it{p\/}})\-\index{p-test-and-jump-step}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-test-int-and-jump} \\  
\=\+{\rm{icode-test-int-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-test-int-and-jump} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{cadr}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{zero\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\- \\ 
{\bf case = }{\it{not-zero\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-nz\_x}}{\tt{)}})\- \\ 
{\bf case = }{\it{neg\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-n\_x}}{\tt{)}})\- \\ 
{\bf case = }{\it{not-neg\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-nn\_x}}{\tt{)}})\- \\ 
{\bf case = }{\it{pos\/}} \\ 
{\bf $\;\;$then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{tag}}\,({\tt{'}}{\tt{pc}}, {\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, $1\;+$ {\it{pcn\/}}))\index{tag}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-n\_x}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{i\}\_$<$zn$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-n\_x}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\-$\;${\bf  endcase}\-\-
\end{tabbing}

		    


\begin{verbatim}; (TEST-BOOL-AND-JUMP flg lab)
;                          flg                test
;                          T            jump if x is T
;                          F            jump if x is F

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-test-boolp} \\  
\=\+{\rm{p-test-boolp}}\,({\it{flg\/}}, {\it{x\/}})\index{p-test-boolp} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\it{flg\/}}: \\ 
{\bf case = }{\bf{t}} \\ 
{\bf then }{\it{x\/}} $=$ {\tt{'}}{\tt{t}} \\ 
{\bf otherwise }{\it{x\/}} $=$ {\tt{'}}{\tt{f}}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-bool-and-jump-okp} \\  
\=\+{\rm{p-test-bool-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-okp} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-okp}}\,(\=\+{\it{ins\/}}, \\ 
{\tt{'}}{\tt{bool}}, \\ 
{\rm{p-test-boolp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-boolp}, \\ 
{\it{p\/}})\-\index{p-test-and-jump-okp}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-bool-and-jump-step} \\  
\=\+{\rm{p-test-bool-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-step} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-step}}\,(\=\+{\rm{p-test-boolp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-boolp}, \\ 
{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\it{p\/}})\-\index{p-test-and-jump-step}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-test-bool-and-jump} \\  
\=\+{\rm{icode-test-bool-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-test-bool-and-jump} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{cadr}}\,({\it{ins\/}}): \\ 
{\bf case = }{\bf{t}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{b\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-nz\_x}}{\tt{)}})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{b\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\-$\;${\bf  endcase}\-\-
\end{tabbing}


\begin{verbatim}; (TEST-BITV-AND-JUMP flg lab)
;                          flg                test
;                          ALL-ZERO      jump if x contains all 0's
;                          NOT-ALL-ZERO  jump if x contains a 1

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-test-bitvp} \\  
\=\+{\rm{p-test-bitvp}}\,({\it{flg\/}}, {\it{x\/}})\index{p-test-bitvp} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\it{flg\/}}: \\ 
{\bf case = }{\it{all-zero\/}} \\ 
{\bf then }{\rm{all-zero-bitvp}}\,({\it{x\/}})\index{all-zero-bitvp} \\ 
{\bf otherwise }$\neg$ {\rm{all-zero-bitvp}}\,({\it{x\/}})\index{all-zero-bitvp}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-bitv-and-jump-okp} \\  
\=\+{\rm{p-test-bitv-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-okp} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-okp}}\,(\=\+{\it{ins\/}}, \\ 
{\tt{'}}{\tt{bitv}}, \\ 
{\rm{p-test-bitvp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-bitvp}, \\ 
{\it{p\/}})\-\index{p-test-and-jump-okp}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-test-bitv-and-jump-step} \\  
\=\+{\rm{p-test-bitv-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-step} \\ 
$=$$\;\;\;\;${\rm{p-test-and-jump-step}}\,(\=\+{\rm{p-test-bitvp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{p-test-bitvp}, \\ 
{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\it{p\/}})\-\index{p-test-and-jump-step}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-test-bitv-and-jump} \\  
\=\+{\rm{icode-test-bitv-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-test-bitv-and-jump} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{cadr}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{all-zero\/}} \\ 
{\bf then }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{v\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-z\_x}}{\tt{)}})\- \\ 
{\bf otherwise }{\rm{list}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{tpop\{v\}\_$<$z$>$\_y}}{\tt{)}}, \\ 
{\tt{'}}{\tt{(}}{\tt{move\_x\_*}}{\tt{)}}, \\ 
{\rm{pc}}\,({\rm{caddr}}\,({\it{ins\/}}), {\it{program\/}})\index{pc}, \\ 
{\tt{'}}{\tt{(}}{\tt{jump-nz\_x}}{\tt{)}})\-$\;${\bf  endcase}\-\-
\end{tabbing}



\begin{verbatim};   (NO-OP)             Do nothing.  Advance the pc to the next instruction.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-no-op-okp}$\;\;$
{\rm{p-no-op-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-okp} $=$ {\bf{t}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-no-op-step} \\  
\=\+{\rm{p-no-op-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-no-op} \\  
{\rm{icode-no-op}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-no-op} $=$ {\rm{list}}\,({\tt{'}}{\tt{(}}{\tt{move\_x\_x}}{\tt{)}})
\end{tabbing}

\begin{verbatim}; Note:  One might ask why no-ops generate any instructions at all.
; The reason is that it was the easiest way to guarantee that I kept
; proper track of high level pcs.  I have a guarantee that every pc
; at the high level corresponds to a label at the i level.  I have
; adopted the (DL pc & ins) hack to associate labels with instructions.
; I can't attach multiple labels to the same point.  So I see no alternative
; to generating a place holder instruction for the no-op and attaching
; a label to it.  Of course, I could change the DL conventions so that
; if no instruction was present we migrated the label down to the next
; DL and used (DL (pc1 pc2 ...) ins).  But even that loses
; if a no-op occurs as the last instruction.  This seems simplest.


\end{verbatim}
\newpage
\begin{verbatim}

;   (ADD-ADDR)		Pop top and top1 from temp-stk.  Top1 must
;                       be an addr, top must be a nat.  Increment
;                       the addr by nat and if that is a legal address
;                       push it onto temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add-addr-okp} \\  
\=\+{\rm{p-add-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,(\=\+{\tt{'}}{\tt{addr}}, \\ 
{\rm{add-addr}}\,(\=\+{\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{add-addr}, \\ 
{\it{p\/}})\-\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add-addr-step} \\  
\=\+{\rm{p-add-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{add-addr}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{add-addr}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add-addr} \\  
\=\+{\rm{icode-add-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add-addr} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_$<$tsp$>$\{a\}\_x\{n\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}
	

\begin{verbatim};   (SUB-ADDR)          Pop top and top1 off of temp-stk.
;                       Top must be a nat and top1 must be
;                       an addr.  Decrement the offset of the
;                       addr by nat and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub-addr-okp} \\  
\=\+{\rm{p-sub-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{offset}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{offset} $\not<$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub-addr-step} \\  
\=\+{\rm{p-sub-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{sub-addr}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{sub-addr}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub-addr} \\  
\=\+{\rm{icode-sub-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub-addr} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{sub\_$<$tsp$>$\{a\}\_x\{n\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}




\begin{verbatim};   (EQ)                Pop top and top1 off of temp-stk.  If they
;                       are both of the same type, push T or F according
;                       to whether they are equal.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-eq-okp} \\  
\=\+{\rm{p-eq-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;$({\rm{type}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{type} $=$ {\rm{type}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{type}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-eq-step} \\  
\=\+{\rm{p-eq-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} \\ 
$=$$\;\;\;\;${\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\-)\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-eq} \\  
\=\+{\rm{icode-eq}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-eq} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{xor\_$<$z$>$\_$<$tsp$>$\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{xor\_$<$tsp$>$\_$<$tsp$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-z\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}



\begin{verbatim};   (LT-ADDR)           Pop top and top1 off of temp-stk,
;                       and if both are addresses into the same area,
;                       push T if top1 < top and push F otherwise.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-lt-addr-okp} \\  
\=\+{\rm{p-lt-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{area-name}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{area-name} \\ 
$=$$\;\;\;\;${\rm{area-name}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{area-name})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-lt-addr-step} \\  
\=\+{\rm{p-lt-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,(\=\+{\rm{offset}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{offset} \\ 
$<$$\;\;\;\;${\rm{offset}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{offset}\-)\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{icode-lt-addr} \\  
\=\+{\rm{icode-lt-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-lt-addr} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_$<$c$>$\_$<$tsp$>$\{a\}\_x\{a\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{xor\_$<$tsp$>$\_$<$tsp$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}



\begin{verbatim};   (FETCH)             Pop top of temp-stk.  The result must
;                       be an address.  Push the contents of that
;                       address onto temp-stk.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-fetch-okp} \\  
\=\+{\rm{p-fetch-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-fetch-step} \\  
\=\+{\rm{p-fetch-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{fetch}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{fetch}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-fetch} \\  
{\rm{icode-fetch}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-fetch} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{tpush\_$<$x\{a\}$>$}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};   (DEPOSIT)           Pop top and top1 off of temp-stk.  top must be
;                       an address.  Deposit top1 into the address.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-deposit-okp} \\  
\=\+{\rm{p-deposit-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-deposit-step} \\  
\=\+{\rm{p-deposit-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{deposit}}\,(\=\+{\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, \\ 
{\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\-\index{deposit}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-deposit} \\  
{\rm{icode-deposit}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-deposit} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{tpop\_$<$x\{a\}$>$}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};   (ADD-INT)           Pop top and top1 off of temp-stk.  Both must
;                       be INTs.  Add them together and push the result,
;                       provided it is representable as an INT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add-int-okp} \\  
\=\+{\rm{p-add-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,(\=\+{\rm{iplus}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{iplus}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-integerp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add-int-step} \\  
\=\+{\rm{p-add-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{int}}, \\ 
{\rm{iplus}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{iplus})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add-int} \\  
\=\+{\rm{icode-add-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add-int} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_$<$tsp$>$\{i\}\_x\{i\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};   (ADD-INT-WITH-CARRY)
;                       Pop three things off temp stack, top, top1 and
;                       top2.  Top and top1 must be INTs.  Top2 must
;                       be Boolean.  Add top+top1+top2 -- coercing T to 1
;                       and F to 0.  Push two results.  First, a boolean
;                       indicating whether top+top1+top2 is not small.
;                       On top of that, push the corrected sum.  The corrected
;                       sum is the sum, if that is a small-integerp; the
;                       sum+2**word-size, if the sum is not small and is 
;                       negative; and the sum-2**word-size, if the sum is
;                       not small and not negative.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add-int-with-carry-okp} \\  
\=\+{\rm{p-add-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add-int-with-carry-step} \\  
\=\+{\rm{p-add-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{sum\/}}{\bf $\;$ be$\;\;$}{\rm{iplus}}\,(\=\+{\rm{bool-to-nat}}\,({\rm{untag}}\,({\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2})\index{untag})\index{bool-to-nat}, \\ 
{\rm{iplus}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{iplus})\-\index{iplus}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{int}}, {\rm{fix-small-integer}}\,({\it{sum\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{fix-small-integer})\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,($\neg$ {\rm{small-integerp}}\,({\it{sum\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-integerp})\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{pop})\-\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add-int-with-carry} \\  
\=\+{\rm{icode-add-int-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add-int-with-carry} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{asr\_$<$c$>$\_$<$tsp$>$\_$<$tsp$>$\{b\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{addc\_$<$v$>$\_x\{i\}\_y\{i\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-v\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (ADD1-INT)          Pop top of temp-stk.  The result must be an INT.
;                       Increment it by one and push the result, provided
;                       it is representable as an INT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add1-int-okp} \\  
\=\+{\rm{p-add1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,(\=\+{\rm{iplus}}\,({\tt{1}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{iplus}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-integerp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add1-int-step} \\  
\=\+{\rm{p-add1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{int}}, {\rm{iplus}}\,({\tt{1}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{iplus})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add1-int} \\  
{\rm{icode-add1-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add1-int} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{incr\_$<$tsp$>$\_$<$tsp$>$\{i\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (SUB-INT)           Pop top and top1 off of temp-stk.  Both must be
;                       INTs.  Subtract top from top1, i.e., form top1-top,
;                       and push the result provided it is representable
;                       as an INT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub-int-okp} \\  
\=\+{\rm{p-sub-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,(\=\+{\rm{idifference}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{idifference}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-integerp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub-int-step} \\  
\=\+{\rm{p-sub-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{int}}, \\ 
{\rm{idifference}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{idifference})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub-int} \\  
\=\+{\rm{icode-sub-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub-int} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{sub\_$<$tsp$>$\{i\}\_x\{i\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}


\begin{verbatim};   (SUB-INT-WITH-CARRY)
;                       Pop three things off temp stack, top, top1 and
;                       top2.  Top and top1 must be INTs.  Top2 must
;                       be Boolean.  Form top1-(top+top2) -- coercing T to 1
;                       and F to 0.  Push two results.  First, a boolean
;                       indicating whether top1-(top+top2) is not small.
;                       On top of that, push the corrected diff. The corrected
;                       diff is the diff, if that is a small-integerp; the
;                       diff+2**word-size, if the diff is not small and is 
;                       negative; and the diff-2**word-size, if the diff is
;                       not small and not negative.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub-int-with-carry-okp} \\  
\=\+{\rm{p-sub-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub-int-with-carry-step} \\  
\=\+{\rm{p-sub-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{diff\/}}{\bf $\;$ be$\;\;$}{\rm{idifference}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{iplus}}\,(\=\+{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, \\ 
{\rm{bool-to-nat}}\,({\rm{untag}}\,({\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2})\index{untag})\index{bool-to-nat})\-\index{iplus})\-\index{idifference}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{int}}, {\rm{fix-small-integer}}\,({\it{diff\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{fix-small-integer})\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,($\neg$ {\rm{small-integerp}}\,({\it{diff\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-integerp})\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{pop})\-\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub-int-with-carry} \\  
\=\+{\rm{icode-sub-int-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub-int-with-carry} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{asr\_$<$c$>$\_$<$tsp$>$\_$<$tsp$>$\{b\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{subb\_$<$v$>$\_x\{i\}\_y\{i\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-v\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (SUB1-INT)          Pop top of temp-stk.  It must be an INT.
;                       Decrement it by one and push the result,
;                       provided it is representable as an INT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub1-int-okp} \\  
\=\+{\rm{p-sub1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,(\=\+{\rm{idifference}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\tt{1}})\index{idifference}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-integerp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub1-int-step} \\  
\=\+{\rm{p-sub1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{int}}, {\rm{idifference}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\tt{1}})\index{idifference})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub1-int} \\  
{\rm{icode-sub1-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub1-int} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{decr\_$<$tsp$>$\_$<$tsp$>$\{i\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (NEG-INT)           Pop top of temp-stk.  It must be an INT.
;                       Negate it and push the result provided it is
;                       representable as an INT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-neg-int-okp} \\  
\=\+{\rm{p-neg-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,(\=\+{\rm{inegate}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{inegate}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-integerp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-neg-int-step} \\  
\=\+{\rm{p-neg-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{int}}, {\rm{inegate}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{inegate})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-neg-int} \\  
{\rm{icode-neg-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-neg-int} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{neg\_$<$tsp$>$\_$<$tsp$>$\{i\}}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};   (LT-INT)            Pop top and top1 off of temp-stk, and push T or F
;                       according to whether top1 < top.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-lt-int-okp} \\  
\=\+{\rm{p-lt-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-lt-int-step} \\  
\=\+{\rm{p-lt-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,({\rm{ilessp}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{ilessp})\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{verbatim}; Let n-flg and v-flg be the values of the n-flg and v-flg after computing x-y.
; It is a theorem that x<y iff (xor n-flg v-flg).

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icode-lt-int} \\  
\=\+{\rm{icode-lt-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-lt-int} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_$<$nv$>$\_$<$tsp$>$\{i\}\_x\{i\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{f}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-v\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{move\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{f}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-n\_x\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{xor\_$<$tsp$>$\{b\}\_x\{b\}}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}

\begin{verbatim}; The code above requires 7 clock ticks.  I have written one requiring
; 5 or 6 ticks, depending on whether n-flg was T or F.  But that code
; required an interior label and a move-n_pc_<pc+1> instruction where the
; label at pc+1 is one less than where I need to go (because the post
; increment adds to it).  The interior label would destroy the current
; r-i proof structure, but could probably be patched around.

\end{verbatim}
\newpage
\begin{verbatim}

;   (INT-TO-NAT)        Pop top off of temp-stk.  Top should
;                       be of type INT and be nonnegative.
;                       Push the NAT corresponding to top.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-int-to-nat-okp} \\  
\=\+{\rm{p-int-to-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{negativep}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-int-to-nat-step} \\  
\=\+{\rm{p-int-to-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{tag}, {\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-int-to-nat} \\  
{\rm{icode-int-to-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-int-to-nat} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{int-to-nat}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};   (ADD-NAT)           Pop top and top1 off of temp-stk.
;                       Both top and top1 must be NATs.  Push
;                       their NAT sum.

; *** 15-12-87/jsm:  This is actually a new Piton instruction with
; the same name as an old one.  The old ADD-NAT has been renamed
; ADD-NAT-WITH-CARRY.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add-nat-okp} \\  
\=\+{\rm{p-add-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-naturalp}}\,(\=\+\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} \\ 
$+$$\;\;\;\;${\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\-, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-naturalp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add-nat-step} \\  
\=\+{\rm{p-add-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{sum\/}}{\bf $\;$ be$\;\;$}\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} \\ 
$+$$\;\;\;\;${\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\-\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{sum\/}})\index{tag}, {\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add-nat} \\  
\=\+{\rm{icode-add-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add-nat} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{add\_$<$tsp$>$\{n\}\_x\{n\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}


\begin{verbatim};   (ADD-NAT-WITH-CARRY)
;			Pop top, top1 and top2 off of temp-stk.
;                       Both top and top1 must be NATs.  Top2 must be BOOL.
;                       Add all three together -- coercing T to 1 and F to 0.
;                       Let the result be sum.  Push T or F according to
;                       whether sum is not small.  Then push
;                       sum mod 2**word-size.

; *** 15-12-87/jsm:  This used to be called ADD-NAT.  I have renamed it
; so that the name ADD-NAT can be used for the simpler instruction
; that adds two naturals without input or output carry.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add-nat-with-carry-okp} \\  
\=\+{\rm{p-add-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add-nat-with-carry-step} \\  
\=\+{\rm{p-add-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{sum\/}}{\bf $\;$ be$\;\;$}\=\+{\rm{bool-to-nat}}\,({\rm{untag}}\,({\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2})\index{untag})\index{bool-to-nat} \\ 
$+$$\;\;\;\;${\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} \\ 
$+$$\;\;\;\;${\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\-\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{fix-small-natural}}\,({\it{sum\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{fix-small-natural})\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,($\neg$ {\rm{small-naturalp}}\,({\it{sum\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{pop})\-\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add-nat-with-carry} \\  
\=\+{\rm{icode-add-nat-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add-nat-with-carry} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{asr\_$<$c$>$\_$<$tsp$>$\_$<$tsp$>$\{b\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{addc\_$<$c$>$\_x\{n\}\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}			\begin{verbatim};push sum.


\end{verbatim}
\newpage
\begin{verbatim}

;   (ADD1-NAT)          Pop top off of temp-stk, add 1 to it
;                       and push the result.  The result must
;                       be representable.

; *** 16-12-87/jsm:  New instruction.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-add1-nat-okp} \\  
\=\+{\rm{p-add1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-naturalp}}\,($1\;+$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-add1-nat-step} \\  
\=\+{\rm{p-add1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{sum\/}}{\bf $\;$ be$\;\;$}$1\;+$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{sum\/}})\index{tag}, {\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-add1-nat} \\  
{\rm{icode-add1-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-add1-nat} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{incr\_$<$tsp$>$\_$<$tsp$>$\{n\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (SUB-NAT)           Pop top, top1 off of temp-stk.
;                       Both top and top1 must be NATs.
;                       If top1 >= top
;                          then push top1-top.
;                       Else, error.

; *** 15-12-87/jsm:  This is a new instruction with an old name.
; The instruction SUB-NAT-WITH-CARRY is now what used to be SUB-NAT.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub-nat-okp} \\  
\=\+{\rm{p-sub-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} $\not<$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub-nat-step} \\  
\=\+{\rm{p-sub-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{y\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, \\ 
{\it{x\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{x\/}} $-$ {\it{y\/}})\index{tag}, {\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub-nat} \\  
\=\+{\rm{icode-sub-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub-nat} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{sub\_$<$tsp$>$\{n\}\_x\{n\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};   (SUB-NAT-WITH-CARRY)
;			Pop top, top1 and top2 off of temp-stk.
;                       Both top and top1 must be NATs.  Top2 must be BOOL.
;                       If top1 >= top+top2 -- coercing T to 1 and F to 0 --
;                          then push F and top1-(top+top2).
;                       Else, push T and 2**word-size-((top+top2)-top1).

; *** 15-12-87/jsm:  This instruction was renamed from SUB-NAT to free
; that name for the new, simpler instruction.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub-nat-with-carry-okp} \\  
\=\+{\rm{p-sub-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub-nat-with-carry-step} \\  
\=\+{\rm{p-sub-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{y\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, \\ 
{\it{x\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\it{c\/}}{\bf $\;$ be$\;\;$}{\rm{bool-to-nat}}\,({\rm{untag}}\,({\rm{top2}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top2})\index{untag})\index{bool-to-nat}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{nat}}, \\ 
\=\+{\bf if }{\it{x\/}} $<$ ({\it{y\/}} $+$ {\it{c\/}}) \\ 
{\bf then }\=\+{\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp} \\ 
$-$$\;\;\;\;$(({\it{y\/}} $+$ {\it{c\/}}) $-$ {\it{x\/}})\- \\ 
{\bf else }{\it{x\/}} $-$ ({\it{y\/}} $+$ {\it{c\/}})$\;${\bf  endif}\-)\-\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,({\it{x\/}} $<$ ({\it{y\/}} $+$ {\it{c\/}}))\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\index{pop})\-\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub-nat-with-carry} \\  
\=\+{\rm{icode-sub-nat-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub-nat-with-carry} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_y}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{asr\_$<$c$>$\_$<$tsp$>$\_$<$tsp$>$\{b\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{subb\_$<$c$>$\_x\{n\}\_y\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (SUB1-NAT)          Pop top off of temp-stk.
;                       Top must be a NAT other than
;                       0.  Push top-1.

; *** 16-12-87/jsm:  This is a new instruction.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-sub1-nat-okp} \\  
\=\+{\rm{p-sub1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} $\not\simeq {\tt{0}}$))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-sub1-nat-step} \\  
\=\+{\rm{p-sub1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} $-\;1$)\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-sub1-nat} \\  
{\rm{icode-sub1-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-sub1-nat} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{decr\_$<$tsp$>$\_$<$tsp$>$\{n\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (LT-NAT)            Pop top and top1 off of temp-stk, and push T or F
;                       according to whether top1 < top.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-lt-nat-okp} \\  
\=\+{\rm{p-lt-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-lt-nat-step} \\  
\=\+{\rm{p-lt-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag} \\ 
$<$$\;\;\;\;${\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\-)\index{bool}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-lt-nat} \\  
\=\+{\rm{icode-lt-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-lt-nat} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub\_$<$c$>$\_$<$tsp$>$\{n\}\_x\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{xor\_$<$tsp$>$\_$<$tsp$>$}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (MULT2-NAT)         Pop top of temp-stk, multiply by 2 and push
;                       the result, which must be a small-naturalp.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-mult2-nat-okp} \\  
\=\+{\rm{p-mult2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{small-naturalp}}\,(\=\+{\tt{2}} $*$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-\index{small-naturalp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-mult2-nat-step} \\  
\=\+{\rm{p-mult2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{prod\/}}{\bf $\;$ be$\;\;$}{\tt{2}} $*$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{prod\/}})\index{tag}, {\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-mult2-nat} \\  
{\rm{icode-mult2-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-mult2-nat} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{add\_$<$tsp$>$\_$<$tsp$>$\{n\}}}{\tt{)}}{\tt{)}}
\end{tabbing}


\begin{verbatim};   (MULT2-NAT-WITH-CARRY-OUT)
;			Pop top of temp-stk, multiply by 2 and push
;                       two things:  whether the result is not smallp and
;                       the result mod 2**word-size.

; *** 15-12-87/jsm:  Renamed from MULT2.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-mult2-nat-with-carry-out-okp} \\  
\=\+{\rm{p-mult2-nat-with-carry-out-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-mult2-nat-with-carry-out-step} \\  
\=\+{\rm{p-mult2-nat-with-carry-out-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{prod\/}}{\bf $\;$ be$\;\;$}{\tt{2}} $*$ {\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\rm{fix-small-natural}}\,({\it{prod\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{fix-small-natural})\index{tag}, \\ 
{\rm{push}}\,(\=\+{\rm{bool}}\,($\neg$ {\rm{small-naturalp}}\,({\it{prod\/}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\index{bool}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-mult2-nat-with-carry-out} \\  
\=\+{\rm{icode-mult2-nat-with-carry-out}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-mult2-nat-with-carry-out} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{add\_$<$c$>$\_x\_x\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{f}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (DIV2-NAT)              Pop top of temp-stk, divide by 2 and push
;                       two things:  the quotient mod 2 and then
;                       the remainder mod 2.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-div2-nat-okp} \\  
\=\+{\rm{p-div2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length} $<$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-div2-nat-step} \\  
\=\+{\rm{p-div2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-step} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{quo\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} $\div$ {\tt{2}}, \\ 
{\it{rem\/}}{\bf $\;$ be$\;\;$}{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag} ${}${\bf{mod}}${}$ {\tt{2}}\- \\ 
{\bf in} \\ 
{\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{rem\/}})\index{tag}, \\ 
{\rm{push}}\,({\rm{tag}}\,({\tt{'}}{\tt{nat}}, {\it{quo\/}})\index{tag}, {\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{push})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-div2-nat} \\  
\=\+{\rm{icode-div2-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-div2-nat} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{tpop\_$<$c$>$\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{lsr\_$<$c$>$\_x\_x\{n\}}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_x}}{\tt{)}} \\ 
{\tt{(}}{\tt{tpush\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{nat}}{\tt{ }}{\tt{0}}{\tt{)}} \\ 
{\tt{(}}{\tt{move-c\_$<$tsp$>$\_*}}{\tt{)}} \\ 
{\tt{(}}{\tt{nat}}{\tt{ }}{\tt{1}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}


\begin{verbatim};   (OR-BITV)           Pop top and top1 off of temp-stk, or them together
;                       and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-or-bitv-okp} \\  
\=\+{\rm{p-or-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-or-bitv-step} \\  
\=\+{\rm{p-or-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{bitv}}, \\ 
{\rm{or-bitv}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{or-bitv})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-or-bitv} \\  
{\rm{icode-or-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-or-bitv} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{or\_$<$tsp$>$\{v\}\_x\{v\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (AND-BITV)          Pop top and top1 off of temp-stk, and them together
;                       and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-and-bitv-okp} \\  
\=\+{\rm{p-and-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-and-bitv-step} \\  
\=\+{\rm{p-and-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{bitv}}, \\ 
{\rm{and-bitv}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{and-bitv})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-and-bitv} \\  
\=\+{\rm{icode-and-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-and-bitv} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{and\_$<$tsp$>$\{v\}\_x\{v\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};   (NOT-BITV)          Pop top of temp-stk, not it, and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-not-bitv-okp} \\  
\=\+{\rm{p-not-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-not-bitv-step} \\  
\=\+{\rm{p-not-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{bitv}}, {\rm{not-bitv}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{not-bitv})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-not-bitv} \\  
{\rm{icode-not-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-not-bitv} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{not\_$<$tsp$>$\_$<$tsp$>$\{v\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (XOR-BITV)          Pop top and top1 off of temp-stk, xor them,
;                       and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-xor-bitv-okp} \\  
\=\+{\rm{p-xor-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-xor-bitv-step} \\  
\=\+{\rm{p-xor-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{bitv}}, \\ 
{\rm{xor-bitv}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{xor-bitv})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-xor-bitv} \\  
\=\+{\rm{icode-xor-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-xor-bitv} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{xor\_$<$tsp$>$\{v\}\_x\{v\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};   (RSH-BITV)          Pop top of temp-stk, shift it right 1, bringing
;                       a 0 in at the top, and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-rsh-bitv-okp} \\  
\=\+{\rm{p-rsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-rsh-bitv-step} \\  
\=\+{\rm{p-rsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{bitv}}, {\rm{rsh-bitv}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{rsh-bitv})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-rsh-bitv} \\  
{\rm{icode-rsh-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-rsh-bitv} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{lsr\_$<$tsp$>$\_$<$tsp$>$\{v\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (LSH-BITV)          Pop top of temp-stk, shift it left 1, bringing
;                       a 0 in at the btm, and push the result.


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-lsh-bitv-okp} \\  
\=\+{\rm{p-lsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-lsh-bitv-step} \\  
\=\+{\rm{p-lsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{bitv}}, {\rm{lsh-bitv}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{lsh-bitv})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-lsh-bitv} \\  
{\rm{icode-lsh-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-lsh-bitv} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{add\_$<$tsp$>$\_$<$tsp$>$\{v\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (OR-BOOL)           Pop top and top1 off of temp-stk, or them together
;                       and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-or-bool-okp} \\  
\=\+{\rm{p-or-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-or-bool-step} \\  
\=\+{\rm{p-or-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{bool}}, \\ 
{\rm{or-bool}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{or-bool})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-or-bool} \\  
{\rm{icode-or-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-or-bool} $=$ {\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{or\_$<$tsp$>$\{b\}\_x\{b\}}}{\tt{)}}{\tt{)}}
\end{tabbing}



\begin{verbatim};   (AND-BOOL)          Pop top and top1 off of temp-stk, and them together
;                       and push the result.
;                       

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-and-bool-okp} \\  
\=\+{\rm{p-and-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-and-bool-step} \\  
\=\+{\rm{p-and-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,(\=\+{\tt{'}}{\tt{bool}}, \\ 
{\rm{and-bool}}\,(\=\+{\rm{untag}}\,({\rm{top1}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top1})\index{untag}, \\ 
{\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\-\index{and-bool})\-\index{tag}, \\ 
{\rm{pop}}\,({\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-and-bool} \\  
\=\+{\rm{icode-and-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-and-bool} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{tpop\_x}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{and\_$<$tsp$>$\{b\}\_x\{b\}}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};   (NOT-BOOL)          Pop top of temp-stk, not it, and push the result.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-not-bool-okp} \\  
\=\+{\rm{p-not-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-okp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-not-bool-step} \\  
\=\+{\rm{p-not-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-step} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{add1-p-pc}}\,({\it{p\/}})\index{add1-p-pc}, \\ 
{\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}, \\ 
{\rm{push}}\,(\=\+{\rm{tag}}\,({\tt{'}}{\tt{bool}}, {\rm{not-bool}}\,({\rm{untag}}\,({\rm{top}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{top})\index{untag})\index{not-bool})\index{tag}, \\ 
{\rm{pop}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{pop})\-\index{push}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode-not-bool} \\  
\=\+{\rm{icode-not-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode-not-bool} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{(}}{\tt{xor\_$<$tsp$>$\{b\}\_*\{b\}}}{\tt{)}}{\tt{ }}{\tt{(}}{\tt{bool}}{\tt{ }}{\tt{t}}{\tt{)}}{\tt{)}}\-
\end{tabbing}



\begin{verbatim};---------------------------------------------------------------------------------
;  The P Machine  

; The complete list of PITON opcodes is given below.  To add a new
; instruction, xxx, to the PITON machine it is necessary to

; (a) define the function (p-xxx-okp ins p), which returns T or F
; according to whether it is legal to execute ins in state p, where
; ins is an instance of the new instruction xxx.

; (b) define the function (p-xxx-step ins p), which returns the state
; produced by stepping forward from state p by the instruction ins.
; Ins is known to be p-xxx-okp.

; (c) add xxx to the list below.

; The prescription above does NOT address how you implement the new
; instruction via the icompiler, etc.


\end{verbatim}\begin{tabbing}{\sc Definition}:\index{piton-opcodes} \\  
\=\+{\sc{piton-opcodes}}\index{piton-opcodes} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{call}}{\tt{ }}{\tt{ret}}{\tt{ }}{\tt{locn}}{\tt{ }}{\tt{push-constant}}{\tt{ }}{\tt{push-local}}{\tt{ }}{\tt{push-global}} \\ 
{\tt{push-ctrl-stk-free-size}}{\tt{ }}{\tt{push-temp-stk-free-size}} \\ 
{\tt{push-temp-stk-index}}{\tt{ }}{\tt{jump-if-temp-stk-full}} \\ 
{\tt{jump-if-temp-stk-empty}}{\tt{ }}{\tt{pop}}{\tt{ }}{\tt{pop*}}{\tt{ }}{\tt{popn}}{\tt{ }}{\tt{pop-local}} \\ 
{\tt{pop-global}}{\tt{ }}{\tt{pop-locn}}{\tt{ }}{\tt{pop-call}}{\tt{ }}{\tt{fetch-temp-stk}} \\ 
{\tt{deposit-temp-stk}}{\tt{ }}{\tt{jump}}{\tt{ }}{\tt{jump-case}}{\tt{ }}{\tt{pushj}}{\tt{ }}{\tt{popj}}{\tt{ }}{\tt{set-local}} \\ 
{\tt{set-global}}{\tt{ }}{\tt{test-nat-and-jump}}{\tt{ }}{\tt{test-int-and-jump}} \\ 
{\tt{test-bool-and-jump}}{\tt{ }}{\tt{test-bitv-and-jump}}{\tt{ }}{\tt{no-op}}{\tt{ }}{\tt{add-addr}} \\ 
{\tt{sub-addr}}{\tt{ }}{\tt{eq}}{\tt{ }}{\tt{lt-addr}}{\tt{ }}{\tt{fetch}}{\tt{ }}{\tt{deposit}}{\tt{ }}{\tt{add-int}} \\ 
{\tt{add-int-with-carry}}{\tt{ }}{\tt{add1-int}}{\tt{ }}{\tt{sub-int}}{\tt{ }}{\tt{sub-int-with-carry}} \\ 
{\tt{sub1-int}}{\tt{ }}{\tt{neg-int}}{\tt{ }}{\tt{lt-int}}{\tt{ }}{\tt{int-to-nat}}{\tt{ }}{\tt{add-nat}} \\ 
{\tt{add-nat-with-carry}}{\tt{ }}{\tt{add1-nat}}{\tt{ }}{\tt{sub-nat}}{\tt{ }}{\tt{sub-nat-with-carry}} \\ 
{\tt{sub1-nat}}{\tt{ }}{\tt{lt-nat}}{\tt{ }}{\tt{mult2-nat}}{\tt{ }}{\tt{mult2-nat-with-carry-out}} \\ 
{\tt{div2-nat}}{\tt{ }}{\tt{or-bitv}}{\tt{ }}{\tt{and-bitv}}{\tt{ }}{\tt{not-bitv}}{\tt{ }}{\tt{xor-bitv}}{\tt{ }}{\tt{rsh-bitv}} \\ 
{\tt{lsh-bitv}}{\tt{ }}{\tt{or-bool}}{\tt{ }}{\tt{and-bool}}{\tt{ }}{\tt{not-bool}}{\tt{)}}\-\-
\end{tabbing}

\begin{verbatim}; The following function generates the name of the error
; message produced when an illegal instruction is hit.  The
; first argument is the ``level'' name, e.g., 'P or 'R.
; the (cdr (unpack 'g-instruction)) is used instead of
; (unpack '-instruction) only because '-instruction is an
; illegal evg in the logic, since it does not start with an
; alphabetic character.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{x-y-error-msg} \\  
\=\+{\rm{x-y-error-msg}}\,({\it{x\/}}, {\it{y\/}})\index{x-y-error-msg} \\ 
$=$$\;\;\;\;${\rm{pack}}\,({\rm{append}}\,(\=\+{\rm{unpack}}\,({\tt{'}}{\tt{illegal-}}), \\ 
{\rm{append}}\,({\rm{unpack}}\,({\it{y\/}}), {\rm{cdr}}\,({\rm{unpack}}\,({\tt{'}}{\tt{g-instruction}}))))\-)\-
\end{tabbing}

\begin{verbatim}; The function checks that it is legal to execute ins in state
; p:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-ins-okp} \\  
\=\+{\rm{p-ins-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{p-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-okp} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{p-ret-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-okp} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-okp} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-constant-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-okp} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-okp} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-okp} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-ctrl-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-okp} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-okp} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-index-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-okp} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-full-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-okp} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-empty-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-okp} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-okp} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop*-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-okp} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{p-popn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-okp} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-okp} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-okp} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-okp} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-okp} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-okp} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-okp} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-okp} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-case-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-okp} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{p-pushj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-okp} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{p-popj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-okp} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-okp} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-okp} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-nat-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-okp} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-int-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-okp} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bool-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-okp} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bitv-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-okp} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{p-no-op-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-okp} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-okp} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-okp} \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf $\;\;$then }{\rm{p-eq-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-okp} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-okp} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-okp} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-okp} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-okp} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-okp} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-okp} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-okp} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-okp} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-okp} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-neg-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-okp} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-okp} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-int-to-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-okp} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-okp} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-okp} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-okp} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-okp} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-okp} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-okp} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-okp} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-okp} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-with-carry-out-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-okp} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-div2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-okp} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-okp} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-okp} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-okp} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-xor-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-okp} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-rsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-okp} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-lsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-okp} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-okp} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-okp} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-okp} \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{verbatim}; Note: Initially I used an APPLY$ to define this function but
; that suffers because we don't track the dependency between
; p-ins-okp and p-not-bool-okp, say.  Thus, if the -okp
; function for some instruction is undone and changed,
; theorems about the top-level -okp remain in the data-base,
; inconsistently.  So I have abandoned the APPLY$ and define
; the function with a CASE statement.

; If ins is legal, the following function steps the state forward one.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-ins-step} \\  
\=\+{\rm{p-ins-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{p-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-step} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{p-ret-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-step} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-step} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-constant-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-step} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-step} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-step} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-ctrl-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-step} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-step} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-index-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-step} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-full-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-step} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-empty-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-step} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-step} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop*-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-step} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{p-popn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-step} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-step} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-step} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-step} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-step} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-step} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-step} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-step} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-case-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-step} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{p-pushj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-step} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{p-popj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-step} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-step} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-step} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-nat-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-step} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-int-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-step} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bool-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-step} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bitv-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-step} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{p-no-op-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-step} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-step} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-step} \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf $\;\;$then }{\rm{p-eq-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-step} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-step} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-step} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-step} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-step} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-step} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-step} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-step} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-step} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-step} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-neg-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-step} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-step} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-int-to-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-step} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-step} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-step} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-step} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-step} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-step} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-step} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-step} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-step} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-with-carry-out-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-step} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-div2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-step} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-step} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-step} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-step} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-xor-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-step} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-rsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-step} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-lsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-step} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-step} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-step} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-step} \\ 
{\bf otherwise }{\rm{p-halt}}\,({\it{p\/}}, {\tt{'}}{\tt{run}})\index{p-halt}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{verbatim}; We now package these up into a single function that takes an
; instruction and a state and returns the result of executing the
; given instruction in the state or causing an error.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-step1} \\  
\=\+{\rm{p-step1}}\,({\it{ins\/}}, {\it{p\/}})\index{p-step1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{p-ins-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp}$\;\;${\bf then }{\rm{p-ins-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step} \\ 
{\bf else }{\rm{p-halt}}\,({\it{p\/}}, {\rm{x-y-error-msg}}\,({\tt{'}}{\tt{p}}, {\rm{car}}\,({\it{ins\/}}))\index{x-y-error-msg})\index{p-halt}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; Of course, we are only interested in executing the current
; instruction of a state.  That is what we call stepping the state.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-step} \\  
\=\+{\rm{p-step}}\,({\it{p\/}})\index{p-step} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}$\;\;${\bf then }{\rm{p-step1}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-step1} \\ 
{\bf else }{\it{p\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; Note that p-step is a no-op if the psw is anything besides RUN.

; And given the ability to step a state, here is how you step it n
; times.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p} \\  
\=\+{\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\it{p\/}} \\ 
{\bf else }{\rm{p}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step}, {\it{n\/}} $-\;1$)\index{p}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; The function p, above, is the PITON machine.

; Note:  In the toy version of the system I set the final psw to
; TIMED-OUT if n exhausted before an error or HALT occurred.  I
; think the above defn is better because it gives us
; (p p (plus i j)) = (p (p p i) j).  Consider the psw of (p p n).
; If it is 'RUN then everything worked normally and n was exhausted.
; If it is 'HALT then a top-level return occurred.
; If it is anything else, an error halted the machine.
; Note that a final psw of RUN is equivalent in this world to a
; final psw of 'TIMED-OUT in the toy one.

; The initial Piton state.  We will in general be mapping down
; arbitrary Piton states.  But it is convenient to have a function
; that produces an initial state.  Here it is:

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p0} \\  
\=\+{\rm{p0}}\,({\it{temp-stk\/}}, {\it{prog-segment\/}}, {\it{data-segment\/}})\index{p0} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\tt{'}}{\tt{(}}{\tt{pc}}{\tt{ }}{\tt{(}}{\tt{main}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}}, \\ 
{\rm{push}}\,(\=\+{\rm{make-p-call-frame}}\,(\=\+{\rm{formal-vars}}\,({\rm{definition}}\,(\=\+{\tt{'}}{\tt{main}}, \\ 
{\it{prog-segment\/}})\-\index{definition})\index{formal-vars}, \\ 
{\it{temp-stk\/}}, \\ 
{\rm{temp-var-dcls}}\,({\rm{definition}}\,(\=\+{\tt{'}}{\tt{main}}, \\ 
{\it{prog-segment\/}})\-\index{definition})\index{temp-var-dcls}, \\ 
{\tt{'}}{\tt{(}}{\tt{pc}}{\tt{ }}{\tt{(}}{\tt{main}}{\tt{ .\ }}{\tt{0}}{\tt{)}}{\tt{)}})\-\index{make-p-call-frame}, \\ 
{\bf{nil}})\-\index{push}, \\ 
{\bf{nil}}, \\ 
{\it{prog-segment\/}}, \\ 
{\it{data-segment\/}}, \\ 
{\tt{20}}, \\ 
{\tt{20}}, \\ 
{\tt{32}}, \\ 
{\tt{'}}{\tt{run}})\-\index{p-state}\-
\end{tabbing}


\begin{verbatim}; The Icompiler

; Most of the icompiler has been defined already, in the
; icode-ins functions among the definitions of
; the P machine instruction steppers.

; With them we can generate the assembly code for a given instruction
; ins located at offset pcn in a given program.  Note that we here
; include a DL that labels the basic block of icode generated
; for the instruction.  The comment we ``generate'' is just the high
; level instruction being icompiled, complete with its label, if any.
; We completely ignore the Piton labels here, stripping them off with
; unlabel in every dealing with ins.  We get away with this because
; every reference to a Piton label, as in a JUMP statement, is converted
; to a reference to the PC instead and we generate a label for every
; PC.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icode1} \\  
\=\+{\rm{icode1}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode1} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{icode-call}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-call} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{icode-ret}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-ret} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{icode-locn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-locn} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-constant}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-constant} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-local} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-global} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-ctrl-stk-free-size}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-ctrl-stk-free-size} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-temp-stk-free-size}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-temp-stk-free-size} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{icode-push-temp-stk-index}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-push-temp-stk-index} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{icode-jump-if-temp-stk-full}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-jump-if-temp-stk-full} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{icode-jump-if-temp-stk-empty}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-jump-if-temp-stk-empty} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop*}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop*} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{icode-popn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-popn} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop-local} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop-global} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop-locn}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop-locn} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pop-call}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pop-call} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{icode-fetch-temp-stk}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-fetch-temp-stk} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{icode-deposit-temp-stk}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-deposit-temp-stk} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{icode-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-jump} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{icode-jump-case}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-jump-case} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{icode-pushj}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-pushj} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{icode-popj}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-popj} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{icode-set-local}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-set-local} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{icode-set-global}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-set-global} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{icode-test-nat-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-test-nat-and-jump} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{icode-test-int-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-test-int-and-jump} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{icode-test-bool-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-test-bool-and-jump} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{icode-test-bitv-and-jump}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-test-bitv-and-jump} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{icode-no-op}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-no-op} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add-addr} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub-addr} \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf $\;\;$then }{\rm{icode-eq}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-eq} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{icode-lt-addr}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-lt-addr} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{icode-fetch}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-fetch} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{icode-deposit}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-deposit} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add-int} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add-int-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add-int-with-carry} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add1-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add1-int} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub-int} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub-int-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub-int-with-carry} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub1-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub1-int} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-neg-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-neg-int} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{icode-lt-int}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-lt-int} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-int-to-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-int-to-nat} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add-nat} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add-nat-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add-nat-with-carry} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-add1-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-add1-nat} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub-nat} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub-nat-with-carry}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub-nat-with-carry} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-sub1-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-sub1-nat} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-lt-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-lt-nat} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-mult2-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-mult2-nat} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{icode-mult2-nat-with-carry-out}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-mult2-nat-with-carry-out} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{icode-div2-nat}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-div2-nat} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-or-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-or-bitv} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-and-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-and-bitv} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-not-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-not-bitv} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-xor-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-xor-bitv} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-rsh-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-rsh-bitv} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{icode-lsh-bitv}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-lsh-bitv} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{icode-or-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-or-bool} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{icode-and-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-and-bool} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{icode-not-bool}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{prog\/}})\index{icode-not-bool} \\ 
{\bf otherwise }{\tt{'}}{\tt{(}}{\tt{(}}{\tt{error}}{\tt{)}}{\tt{)}}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{verbatim}; Note that if the opcode of ins is unrecognized we lay down an erroneous
; opcode, error.  The I-level machine halts with psw 'error on
; this instruction.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{dl-block} \\  
{\rm{dl-block}}\,({\it{lab\/}}, {\it{comment\/}}, {\it{block\/}})\index{dl-block} $=$ {\rm{cons}}\,({\rm{dl}}\,({\it{lab\/}}, {\it{comment\/}}, {\rm{car}}\,({\it{block\/}}))\index{dl}, {\rm{cdr}}\,({\it{block\/}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{icode} \\  
\=\+{\rm{icode}}\,({\it{ins\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icode} \\ 
$=$$\;\;\;\;${\rm{dl-block}}\,({\rm{cons}}\,({\rm{name}}\,({\it{program\/}})\index{name}, {\it{pcn\/}}), {\it{ins\/}}, {\rm{icode1}}\,({\rm{unlabel}}\,({\it{ins\/}})\index{unlabel}, {\it{pcn\/}}, {\it{program\/}})\index{icode1})\index{dl-block}\-
\end{tabbing}

\begin{verbatim}; To icompile the body of a procedure we walk through the list of
; instructions in it, appending together the result of assembling
; each.  We increment the pcn on each step.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icompile-program-body} \\  
\=\+{\rm{icompile-program-body}}\,({\it{lst\/}}, {\it{pcn\/}}, {\it{program\/}})\index{icompile-program-body} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{append}}\,(\=\+{\rm{icode}}\,({\rm{car}}\,({\it{lst\/}}), {\it{pcn\/}}, {\it{program\/}})\index{icode}, \\ 
{\rm{icompile-program-body}}\,({\rm{cdr}}\,({\it{lst\/}}), $1\;+$ {\it{pcn\/}}, {\it{program\/}})\index{icompile-program-body})\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; To icompile a program we sandwich the icompiled body between the prelude
; and postlude.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icompile-program} \\  
\=\+{\rm{icompile-program}}\,({\it{program\/}})\index{icompile-program} \\ 
$=$$\;\;\;\;${\rm{cons}}\,(\=\+{\rm{name}}\,({\it{program\/}})\index{name}, \\ 
{\rm{append}}\,(\=\+{\rm{generate-prelude}}\,({\it{program\/}})\index{generate-prelude}, \\ 
{\rm{append}}\,(\=\+{\rm{icompile-program-body}}\,(\=\+{\rm{program-body}}\,({\it{program\/}})\index{program-body}, \\ 
{\tt{0}}, \\ 
{\it{program\/}})\-\index{icompile-program-body}, \\ 
{\rm{generate-postlude}}\,({\it{program\/}})\index{generate-postlude})\-)\-)\-\-
\end{tabbing}

\begin{verbatim}; The assembling of a system of programs is done by assembling each
; program in isolation.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{icompile} \\  
\=\+{\rm{icompile}}\,({\it{programs\/}})\index{icompile} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{programs\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{nil}} \\ 
{\bf else }{\rm{cons}}\,(\=\+{\rm{icompile-program}}\,({\rm{car}}\,({\it{programs\/}}))\index{icompile-program}, \\ 
{\rm{icompile}}\,({\rm{cdr}}\,({\it{programs\/}}))\index{icompile})\-$\;${\bf  endif}\-\-
\end{tabbing}



\begin{verbatim}; Proper P states

; I begin by defining what a proper piton program is, by defining
; what a proper piton instruction is, for each type of instruction.

; In the definitions below, ins is an instruction that occurs in
; the program named name in the p-state p.  Despite the fact that
; this notion of proper takes a p-state, I shall prove that it is
; invariant under execution.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{proper-p-call-instructionp} \\  
\=\+{\rm{proper-p-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-call-instructionp} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{definedp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp})\-
\end{tabbing}
       
\begin{tabbing}{\sc Definition}:\index{proper-p-ret-instructionp} \\  
{\rm{proper-p-ret-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-ret-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-locn-instructionp} \\  
\=\+{\rm{proper-p-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-locn-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $\in$ {\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-constant-instructi!onp} \\  
\=\+{\rm{proper-p-push-constant-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-constant-instructi!onp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\it{p\/}})\index{p-objectp} \\ 
$\vee$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pc}}) \\ 
$\vee$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,(\=\+{\it{name\/}}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{program-body})\-\index{find-labelp})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-local-instructionp} \\  
\=\+{\rm{proper-p-push-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-local-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $\in$ {\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-global-instructio!np} \\  
\=\+{\rm{proper-p-push-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-global-instructio!np} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{definedp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{definedp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-ctrl-stk-free-size!-instructionp} \\  
\=\+{\rm{proper-p-push-ctrl-stk-free-size-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-ctrl-stk-free-size!-instructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-temp-stk-free-size!-instructionp} \\  
\=\+{\rm{proper-p-push-temp-stk-free-size-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-temp-stk-free-size!-instructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-push-temp-stk-index-in!structionp} \\  
\=\+{\rm{proper-p-push-temp-stk-index-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-temp-stk-index-in!structionp} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{small-naturalp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-jump-if-temp-stk-full-i!nstructionp} \\  
\=\+{\rm{proper-p-jump-if-temp-stk-full-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-if-temp-stk-full-i!nstructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-jump-if-temp-stk-empty!-instructionp} \\  
\=\+{\rm{proper-p-jump-if-temp-stk-empty-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-if-temp-stk-empty!-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop-instructionp} \\  
{\rm{proper-p-pop-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop*-instructionp} \\  
\=\+{\rm{proper-p-pop*-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop*-instructionp} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{small-naturalp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-popn-instructionp} \\  
{\rm{proper-p-popn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popn-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop-local-instructionp} \\  
\=\+{\rm{proper-p-pop-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-local-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $\in$ {\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop-global-instructionp} \\  
\=\+{\rm{proper-p-pop-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-global-instructionp} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{definedp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{definedp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop-locn-instructionp} \\  
\=\+{\rm{proper-p-pop-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-locn-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $\in$ {\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pop-call-instructionp} \\  
{\rm{proper-p-pop-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-call-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-fetch-temp-stk-instructi!onp} \\  
{\rm{proper-p-fetch-temp-stk-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-fetch-temp-stk-instructi!onp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-deposit-temp-stk-instr!uctionp} \\  
{\rm{proper-p-deposit-temp-stk-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-deposit-temp-stk-instr!uctionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-jump-instructionp} \\  
\=\+{\rm{proper-p-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-jump-case-instructionp} \\  
\=\+{\rm{proper-p-jump-case-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-case-instructionp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\rm{cdr}}\,({\it{ins\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{all-find-labelp}}\,(\=\+{\rm{cdr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,(\=\+{\it{name\/}}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definition})\index{program-body})\-\index{all-find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-pushj-instructionp} \\  
\=\+{\rm{proper-p-pushj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pushj-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{cadr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-popj-instructionp} \\  
{\rm{proper-p-popj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popj-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-set-local-instructionp} \\  
\=\+{\rm{proper-p-set-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-local-instructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\it{ins\/}}) $\in$ {\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-set-global-instructionp} \\  
\=\+{\rm{proper-p-set-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-global-instructionp} \\ 
$=$$\;\;\;\;$(({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{2}}) $\wedge$ {\rm{definedp}}\,({\rm{cadr}}\,({\it{ins\/}}), {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{definedp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-test-nat-and-jump-inst!ructionp} \\  
\=\+{\rm{proper-p-test-nat-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-nat-and-jump-inst!ructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{3}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-test-int-and-jump-inst!ructionp} \\  
\=\+{\rm{proper-p-test-int-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-int-and-jump-inst!ructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{3}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-test-bool-and-jump-inst!ructionp} \\  
\=\+{\rm{proper-p-test-bool-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-bool-and-jump-inst!ructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{3}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-test-bitv-and-jump-inst!ructionp} \\  
\=\+{\rm{proper-p-test-bitv-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-bitv-and-jump-inst!ructionp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{3}}) \\ 
$\wedge$$\;\;\;\;${\rm{find-labelp}}\,(\=\+{\rm{caddr}}\,({\it{ins\/}}), \\ 
{\rm{program-body}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{program-body})\-\index{find-labelp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-no-op-instructionp} \\  
{\rm{proper-p-no-op-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-no-op-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add-addr-instructionp} \\  
{\rm{proper-p-add-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-addr-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub-addr-instructionp} \\  
{\rm{proper-p-sub-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-addr-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-eq-instructionp} \\  
{\rm{proper-p-eq-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-eq-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-lt-addr-instructionp} \\  
{\rm{proper-p-lt-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-addr-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-fetch-instructionp} \\  
{\rm{proper-p-fetch-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-fetch-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-deposit-instructionp} \\  
{\rm{proper-p-deposit-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-deposit-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add-int-instructionp} \\  
{\rm{proper-p-add-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add-int-with-carry-inst!ructionp} \\  
\=\+{\rm{proper-p-add-int-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-int-with-carry-inst!ructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add1-int-instructionp} \\  
{\rm{proper-p-add1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub-int-instructionp} \\  
{\rm{proper-p-sub-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub-int-with-carry-inst!ructionp} \\  
\=\+{\rm{proper-p-sub-int-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-int-with-carry-inst!ructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub1-int-instructionp} \\  
{\rm{proper-p-sub1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-neg-int-instructionp} \\  
{\rm{proper-p-neg-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-neg-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-lt-int-instructionp} \\  
{\rm{proper-p-lt-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-int-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-int-to-nat-instructionp} \\  
{\rm{proper-p-int-to-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-int-to-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add-nat-instructionp} \\  
{\rm{proper-p-add-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add-nat-with-carry-inst!ructionp} \\  
\=\+{\rm{proper-p-add-nat-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-nat-with-carry-inst!ructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-add1-nat-instructionp} \\  
{\rm{proper-p-add1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub-nat-instructionp} \\  
{\rm{proper-p-sub-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub-nat-with-carry-inst!ructionp} \\  
\=\+{\rm{proper-p-sub-nat-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-nat-with-carry-inst!ructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-sub1-nat-instructionp} \\  
{\rm{proper-p-sub1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-lt-nat-instructionp} \\  
{\rm{proper-p-lt-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-mult2-nat-instructionp} \\  
{\rm{proper-p-mult2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-mult2-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-mult2-nat-with-carry-o!ut-instructionp} \\  
\=\+{\rm{proper-p-mult2-nat-with-carry-out-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-mult2-nat-with-carry-o!ut-instructionp} \\ 
$=$$\;\;\;\;$({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-div2-nat-instructionp} \\  
{\rm{proper-p-div2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-div2-nat-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-or-bitv-instructionp} \\  
{\rm{proper-p-or-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-and-bitv-instructionp} \\  
{\rm{proper-p-and-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-not-bitv-instructionp} \\  
{\rm{proper-p-not-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-xor-bitv-instructionp} \\  
{\rm{proper-p-xor-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-xor-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-rsh-bitv-instructionp} \\  
{\rm{proper-p-rsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-rsh-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-lsh-bitv-instructionp} \\  
{\rm{proper-p-lsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lsh-bitv-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-or-bool-instructionp} \\  
{\rm{proper-p-or-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bool-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-and-bool-instructionp} \\  
{\rm{proper-p-and-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bool-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-not-bool-instructionp} \\  
{\rm{proper-p-not-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bool-instructionp} $=$ ({\rm{length}}\,({\it{ins\/}})\index{length} $=$ {\tt{1}})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-instructionp} \\  
\=\+{\rm{proper-p-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-instructionp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{plistp}}\,({\it{ins\/}})\index{plistp} \\ 
$\wedge$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{proper-p-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-call-instructionp} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-ret-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-ret-instructionp} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-locn-instructionp} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-constant-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-constant-instructi!onp} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-local-instructionp} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-global-instructio!np} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-ctrl-stk-free-size-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-push-ctrl-stk-free-size!-instructionp} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-temp-stk-free-size-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-push-temp-stk-free-size!-instructionp} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-temp-stk-index-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-temp-stk-index-in!structionp} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-if-temp-stk-full-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-if-temp-stk-full-i!nstructionp} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-if-temp-stk-empty-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-jump-if-temp-stk-empty!-instructionp} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-instructionp} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop*-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop*-instructionp} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-popn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popn-instructionp} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-local-instructionp} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-global-instructionp} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-locn-instructionp} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-call-instructionp} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-fetch-temp-stk-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-fetch-temp-stk-instructi!onp} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-deposit-temp-stk-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-deposit-temp-stk-instr!uctionp} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-instructionp} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-case-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-case-instructionp} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pushj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pushj-instructionp} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-popj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popj-instructionp} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-set-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-local-instructionp} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-set-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-global-instructionp} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-nat-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-nat-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-int-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-int-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-bool-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-bool-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-bitv-and-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-test-bitv-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-no-op-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-no-op-instructionp} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-addr-instructionp} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-addr-instructionp} \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-eq-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-eq-instructionp} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-addr-instructionp} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-fetch-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-fetch-instructionp} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-deposit-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-deposit-instructionp} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-int-instructionp} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-int-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-int-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-int-instructionp} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-int-instructionp} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-int-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-int-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-int-instructionp} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-neg-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-neg-int-instructionp} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-int-instructionp} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-int-to-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-int-to-nat-instructionp} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-nat-instructionp} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-nat-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-nat-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-nat-instructionp} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-nat-instructionp} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-nat-with-carry-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-nat-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-nat-instructionp} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-nat-instructionp} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-mult2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-mult2-nat-instructionp} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-mult2-nat-with-carry-out-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-mult2-nat-with-carry-o!ut-instructionp} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-div2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-div2-nat-instructionp} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-or-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bitv-instructionp} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-and-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bitv-instructionp} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-not-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bitv-instructionp} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-xor-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-xor-bitv-instructionp} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-rsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-rsh-bitv-instructionp} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lsh-bitv-instructionp} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-or-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bool-instructionp} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-and-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bool-instructionp} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-not-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bool-instructionp} \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{legal-labelp} \\  
{\rm{legal-labelp}}\,({\it{ins\/}})\index{legal-labelp} $=$ ({\rm{labelledp}}\,({\it{ins\/}})\index{labelledp} $\rightarrow$ {\rm{litatom}}\,({\rm{cadr}}\,({\it{ins\/}})))
\end{tabbing}

\begin{verbatim}; The following predicate recognizes lists of properly labeled
; proper instructions.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{proper-labeled-p-instructionsp} \\  
\=\+{\rm{proper-labeled-p-instructionsp}}\,({\it{lst\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-labeled-p-instructionsp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{lst\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{legal-labelp}}\,({\rm{car}}\,({\it{lst\/}}))\index{legal-labelp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-instructionp}}\,({\rm{unlabel}}\,({\rm{car}}\,({\it{lst\/}}))\index{unlabel}, {\it{name\/}}, {\it{p\/}})\index{proper-p-instructionp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-labeled-p-instructionsp}}\,({\rm{cdr}}\,({\it{lst\/}}), {\it{name\/}}, {\it{p\/}})\index{proper-labeled-p-instructionsp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; A list is fall-off proof if it is not possible for execution to
; fall off the end.  We shall prove that if a list is fall-off proof
; and you are at an instruction other than one of those listed below,
; then add1-p-pcp is ok.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{fall-off-proofp} \\  
\=\+{\rm{fall-off-proofp}}\,({\it{lst\/}})\index{fall-off-proofp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{car}}\,({\rm{unlabel}}\,({\rm{get}}\,({\rm{length}}\,({\it{lst\/}})\index{length} $-\;1$, {\it{lst\/}})\index{get})\index{unlabel}) \\ 
$\in$$\;\;\;\;${\tt{'}}{\tt{(}}{\tt{ret}}{\tt{ }}{\tt{jump}}{\tt{ }}{\tt{jump-case}}{\tt{ }}{\tt{popj}}{\tt{)}})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-program-bodyp} \\  
\=\+{\rm{proper-p-program-bodyp}}\,({\it{lst\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-program-bodyp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\it{lst\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-labeled-p-instructionsp}}\,({\it{lst\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-labeled-p-instructionsp} \\ 
$\wedge$$\;\;\;\;${\rm{fall-off-proofp}}\,({\it{lst\/}})\index{fall-off-proofp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{all-litatoms} \\  
\=\+{\rm{all-litatoms}}\,({\it{lst\/}})\index{all-litatoms} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{lst\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{lst\/}} $=$ {\bf{nil}} \\ 
{\bf else }{\rm{litatom}}\,({\rm{car}}\,({\it{lst\/}})) $\wedge$ {\rm{all-litatoms}}\,({\rm{cdr}}\,({\it{lst\/}}))\index{all-litatoms}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-temp-var-dclsp} \\  
\=\+{\rm{proper-p-temp-var-dclsp}}\,({\it{temp-var-dcls\/}}, {\it{p\/}})\index{proper-p-temp-var-dclsp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{temp-var-dcls\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }\=\+{\rm{litatom}}\,({\rm{car}}\,({\rm{car}}\,({\it{temp-var-dcls\/}}))) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp}}\,({\rm{cadr}}\,({\rm{car}}\,({\it{temp-var-dcls\/}})), {\it{p\/}})\index{p-objectp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-var-dclsp}}\,({\rm{cdr}}\,({\it{temp-var-dcls\/}}), {\it{p\/}})\index{proper-p-temp-var-dclsp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-programp} \\  
\=\+{\rm{proper-p-programp}}\,({\it{prog\/}}, {\it{p\/}})\index{proper-p-programp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{litatom}}\,({\rm{name}}\,({\it{prog\/}})\index{name}) \\ 
$\wedge$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{formal-vars}}\,({\it{prog\/}})\index{formal-vars})\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-var-dclsp}}\,({\rm{temp-var-dcls}}\,({\it{prog\/}})\index{temp-var-dcls}, {\it{p\/}})\index{proper-p-temp-var-dclsp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-program-bodyp}}\,({\rm{program-body}}\,({\it{prog\/}})\index{program-body}, {\rm{name}}\,({\it{prog\/}})\index{name}, {\it{p\/}})\index{proper-p-program-bodyp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-prog-segmentp} \\  
\=\+{\rm{proper-p-prog-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{segment\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{segment\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{proper-p-programp}}\,({\rm{car}}\,({\it{segment\/}}), {\it{p\/}})\index{proper-p-programp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-prog-segmentp}}\,({\rm{cdr}}\,({\it{segment\/}}), {\it{p\/}})\index{proper-p-prog-segmentp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-alistp} \\  
\=\+{\rm{proper-p-alistp}}\,({\it{alist\/}}, {\it{p\/}})\index{proper-p-alistp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{alist\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{alist\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{listp}}\,({\rm{car}}\,({\it{alist\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{caar}}\,({\it{alist\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp}}\,({\rm{cdr}}\,({\rm{car}}\,({\it{alist\/}})), {\it{p\/}})\index{p-objectp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{cdr}}\,({\it{alist\/}}), {\it{p\/}})\index{proper-p-alistp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-framep} \\  
\=\+{\rm{proper-p-framep}}\,({\it{frame\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-framep} \\ 
$=$$\;\;\;\;$(\=\+{\rm{listp}}\,({\it{frame\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\it{frame\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{frame\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{bindings}}\,({\it{frame\/}})\index{bindings}, {\it{p\/}})\index{proper-p-alistp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{strip-cars}}\,({\rm{bindings}}\,({\it{frame\/}})\index{bindings}) \\ 
$=$$\;\;\;\;${\rm{local-vars}}\,({\rm{definition}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definition})\index{local-vars})\- \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{pc}}, {\rm{ret-pc}}\,({\it{frame\/}})\index{ret-pc}, {\it{p\/}})\index{p-objectp-type})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-ctrl-stkp} \\  
\=\+{\rm{proper-p-ctrl-stkp}}\,({\it{ctrl-stk\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-ctrl-stkp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{ctrl-stk\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{ctrl-stk\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{proper-p-framep}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top}, {\it{name\/}}, {\it{p\/}})\index{proper-p-framep} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-ctrl-stkp}}\,(\=\+{\rm{pop}}\,({\it{ctrl-stk\/}})\index{pop}, \\ 
{\rm{area-name}}\,({\rm{ret-pc}}\,({\rm{top}}\,({\it{ctrl-stk\/}})\index{top})\index{ret-pc})\index{area-name}, \\ 
{\it{p\/}})\-\index{proper-p-ctrl-stkp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-temp-stkp} \\  
\=\+{\rm{proper-p-temp-stkp}}\,({\it{temp-stk\/}}, {\it{p\/}})\index{proper-p-temp-stkp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{temp-stk\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{temp-stk\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{p-objectp}}\,({\rm{top}}\,({\it{temp-stk\/}})\index{top}, {\it{p\/}})\index{p-objectp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-stkp}}\,({\rm{pop}}\,({\it{temp-stk\/}})\index{pop}, {\it{p\/}})\index{proper-p-temp-stkp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-area} \\  
\=\+{\rm{proper-p-area}}\,({\it{area\/}}, {\it{p\/}})\index{proper-p-area} \\ 
$=$$\;\;\;\;$(\=\+{\rm{litatom}}\,({\rm{car}}\,({\it{area\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\it{area\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{all-p-objectps}}\,({\rm{cdr}}\,({\it{area\/}}), {\it{p\/}})\index{all-p-objectps})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{proper-p-data-segmentp} \\  
\=\+{\rm{proper-p-data-segmentp}}\,({\it{data-segment\/}}, {\it{p\/}})\index{proper-p-data-segmentp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{data-segment\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{data-segment\/}} $=$ {\bf{nil}} \\ 
{\bf else }\=\+{\rm{proper-p-area}}\,({\rm{car}}\,({\it{data-segment\/}}), {\it{p\/}})\index{proper-p-area} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{definedp}}\,({\rm{caar}}\,({\it{data-segment\/}}), {\rm{cdr}}\,({\it{data-segment\/}}))\index{definedp}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-data-segmentp}}\,({\rm{cdr}}\,({\it{data-segment\/}}), {\it{p\/}})\index{proper-p-data-segmentp}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim}; Below is the definition of proper P state.  Intuitively,
; a proper p state has the following properties:

; (1) it is a p-state shell;
; (2) the pc is a legal address into the program segment;
; (3) the ctrl stack is non-empty;
; (4) the top frame of the ctrl stack is appropriate for
;     the current pc, which means the locals of that program
;     are bound to legal objects and the ret-pc is legal;
; (5) the rest of the ctrl stack is properly structured;
; (6) the ctrl stack isn't too large;
; (7) the temp stack contains legal objects;
; (8) the temp stack isn't too large;
; (9) the prog segment contains programs of the form
;     (name formal-vars temp-var-dcls . body) -- see proper-prog-segment;
;(10) the data segment contains non-empty areas consisting
;     of legal objects;
;(11) the resource limitations are all numeric;
;(12) the stack sizes are less than 2**word-size -- this insures that
;     the stack free sizes and indices are all representable
;(13) the word size is not 0.  This insures that lsh and other bitv
;     operations are well-defined (bitv's are non-empty).

; It is supposed to be the case that if p is proper and stepping p to
; p' does not produce an error then p' is proper.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{proper-p-statep} \\  
\=\+{\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$=$$\;\;\;\;$(\=\+{\rm{p-statep}}\,({\it{p\/}})\index{p-statep} \\ 
$\wedge$$\;\;\;\;${\rm{p-objectp-type}}\,({\tt{'}}{\tt{pc}}, {\rm{p-pc}}\,({\it{p\/}})\index{p-pc}, {\it{p\/}})\index{p-objectp-type} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-framep}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top}, {\rm{area-name}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{area-name}, {\it{p\/}})\index{proper-p-framep} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-ctrl-stkp}}\,(\=\+{\rm{pop}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{pop}, \\ 
{\rm{area-name}}\,({\rm{ret-pc}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{ret-pc})\index{area-name}, \\ 
{\it{p\/}})\-\index{proper-p-ctrl-stkp} \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $\not<$ {\rm{p-ctrl-stk-size}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{p-ctrl-stk-size}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-stkp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, {\it{p\/}})\index{proper-p-temp-stkp} \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $\not<$ {\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-prog-segmentp}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-data-segmentp}}\,({\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, {\it{p\/}})\index{proper-p-data-segmentp} \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $<$ {\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $<$ {\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp}) \\ 
$\wedge$$\;\;\;\;$({\tt{0}} $<$ {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}))\-\-
\end{tabbing}

\begin{verbatim}; We also define the predicate that checks that a state is loadable on
; FM8502.  This is not technically part of the Piton definition but
; rather concerned with the implementation.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{segment-length} \\  
\=\+{\rm{segment-length}}\,({\it{segment\/}})\index{segment-length} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{segment\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\tt{0}} \\ 
{\bf else }\=\+{\rm{length}}\,({\rm{cdr}}\,({\rm{car}}\,({\it{segment\/}})))\index{length} \\ 
$+$$\;\;\;\;${\rm{segment-length}}\,({\rm{cdr}}\,({\it{segment\/}}))\index{segment-length}\-$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{total-p-system-size} \\  
\=\+{\rm{total-p-system-size}}\,({\it{p\/}})\index{total-p-system-size} \\ 
$=$$\;\;\;\;$(\=\+{\rm{segment-length}}\,({\rm{icompile}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{icompile})\index{segment-length} \\ 
$+$$\;\;\;\;${\rm{segment-length}}\,({\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{segment-length} \\ 
$+$$\;\;\;\;$($1\;+$ {\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}) \\ 
$+$$\;\;\;\;$($1\;+$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}) \\ 
$+$$\;\;\;\;${\tt{3}})\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-loadablep} \\  
{\rm{p-loadablep}}\,({\it{p\/}})\index{p-loadablep} $=$ ({\rm{total-p-system-size}}\,({\it{p\/}})\index{total-p-system-size} $<$ {\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp})
\end{tabbing}



\begin{verbatim}; Examples of P and the Icompiler

; We are now ready to test the foregoing definitions.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{display-p-state} \\  
\=\+{\rm{display-p-state}}\,({\it{p\/}})\index{display-p-state} \\ 
$=$$\;\;\;\;${\rm{list}}\,(\=\+{\tt{'}}{\tt{p-state}}, \\ 
{\rm{p-pc}}\,({\it{p\/}})\index{p-pc}, \\ 
{\rm{list}}\,({\tt{'}}{\tt{nxt-inst}}, {\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{bindings}}, {\rm{bindings}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{bindings}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{temp-stk}}, {\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{data-seg}}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{psw}}, {\rm{p-psw}}\,({\it{p\/}})\index{p-psw}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{ret-pc}}, {\rm{ret-pc}}\,({\rm{top}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{top})\index{ret-pc}), \\ 
{\rm{list}}\,({\tt{'}}{\tt{pop-ctrl-stk}}, {\rm{pop}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{pop}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{augment-displayed-p-state} \\  
\=\+{\rm{augment-displayed-p-state}}\,({\it{p\/}}, {\it{p0\/}})\index{augment-displayed-p-state} \\ 
$=$$\;\;\;\;${\rm{p-state}}\,(\=\+{\rm{assoc}}\,({\tt{'}}{\tt{pc}}, {\rm{cdr}}\,({\it{p\/}})), \\ 
{\rm{push}}\,(\=\+{\rm{p-frame}}\,(\=\+{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{bindings}}, {\rm{cdr}}\,({\it{p\/}}))), \\ 
{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{ret-pc}}, {\rm{cdr}}\,({\it{p\/}}))))\-\index{p-frame}, \\ 
{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{pop-ctrl-stk}}, {\rm{cdr}}\,({\it{p\/}}))))\-\index{push}, \\ 
{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{temp-stk}}, {\rm{cdr}}\,({\it{p\/}}))), \\ 
{\rm{p-prog-segment}}\,({\it{p0\/}})\index{p-prog-segment}, \\ 
{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{data-seg}}, {\rm{cdr}}\,({\it{p\/}}))), \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p0\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p0\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p0\/}})\index{p-word-size}, \\ 
{\rm{cadr}}\,({\rm{assoc}}\,({\tt{'}}{\tt{psw}}, {\rm{cdr}}\,({\it{p\/}}))))\-\index{p-state}\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{ps} \\  
{\rm{ps}}\,({\it{p\/}}, {\it{n\/}}, {\it{p0\/}})\index{ps} $=$ {\rm{display-p-state}}\,({\rm{p}}\,({\rm{augment-displayed-p-state}}\,({\it{p\/}}, {\it{p0\/}})\index{augment-displayed-p-state}, {\it{n\/}})\index{p})\index{display-p-state}
\end{tabbing}

\begin{verbatim}; display-p-state abbreviates the given p state, showing just those
; components that change and showing them in the order I find convenient.
; augment-displayed-p-state takes a displayed state and ``the'' original
; one and constructs a new state whose display is the given state.
; Really it just takes the dynamic information in the displayed state
; and merges it with the static information in the original state.

; The effect of the foregoing defns is that we can use r-loop conveniently
; to step through p computations.  In particular, in r-loop

; (setq p0 (p-state ...))

; (setq p (display-p-state p0))

; then repeatedly type

; (setq p (ps p 1 p0))

; to single step from p0 and see each state in its displayed form.
; Here is a p state.  We call this p0 in our subsequent examples.

#|
(quote 
(p-state '(pc (main . 0))
	 '( ( nil (pc (main . 0))) )
	 nil
	 '((main nil nil (call test) (ret))
	   (test nil nil
		 (push-constant (addr (ar1 . 0)))
		 (push-constant (nat 4))
		 (call clear)
		 (ret))
	   (clear (array max-index) ((ptr (nat 0)))
		  (push-local array)
		  (push-local max-index)
		  (add-addr)
		  (pop-local ptr)
		  
            (dl loop                       (this is the top level loop
                                            we deposit 0 into ptr 
                                            test to see if ptr is array
                                            and if not decrement ptr and
                                            repeat)
   	          (push-constant (nat 0)))
		  (push-local ptr)
		  (deposit)
		  
		  (push-local ptr)
		  (push-local array)
		  (eq)
		  (test-bool-and-jump t end)
	
		  (push-local ptr)
		  (push-constant (nat 1))
		  (sub-addr)
		  (pop-local ptr)
		  (jump loop)
	   (dl end                          (we get here when ptr is array)
                  (ret))))

	 '((ar1 (nat 10)
		(nat 11)
		(nat 12)
		(nat 13)
		(nat 14)))
	 
	 12
	 7
	 8
	 'run))

|#

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{signature}$\;\;$
{\rm{signature}}\,({\it{area\/}})\index{signature} $=$ {\rm{cons}}\,({\rm{car}}\,({\it{area\/}}), {\rm{length}}\,({\it{area\/}})\index{length})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{same-signature} \\  
\=\+{\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{segment1\/}}) \\ 
{\bf then }\=\+{\rm{listp}}\,({\it{segment2\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{signature}}\,({\rm{car}}\,({\it{segment1\/}}))\index{signature} $=$ {\rm{signature}}\,({\rm{car}}\,({\it{segment2\/}}))\index{signature}) \\ 
$\wedge$$\;\;\;\;${\rm{same-signature}}\,({\rm{cdr}}\,({\it{segment1\/}}), {\rm{cdr}}\,({\it{segment2\/}}))\index{same-signature}\- \\ 
{\bf else }{\it{segment2\/}} $\simeq\;${{\bf{nil}}}${}$$\;${\bf  endif}\-\-
\end{tabbing}


\begin{verbatim};; ***** End stuff from defs.events *****

;; Now some other lemmas from Piton.  The ones that are easy to prove (i.e.
;; do not depend on other lemmas) we prove, the rest are added as axioms.

;; The following is from p-r.events

; I will disable type, tag and untag for sanity's sake,
; but prove the obvious relationships first.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  type-tag \\ \index{type-tag}
{\rm{type}}\,({\rm{tag}}\,({\it{x\/}}, {\it{y\/}})\index{tag})\index{type} $=$ {\it{x\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  untag-tag \\ \index{untag-tag}
{\rm{untag}}\,({\rm{tag}}\,({\it{x\/}}, {\it{y\/}})\index{tag})\index{untag} $=$ {\it{y\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  equal-tags \\ \index{equal-tags}
({\rm{tag}}\,({\it{type\/}}, {\it{x\/}})\index{tag} $=$ {\rm{tag}}\,({\it{type\/}}, {\it{y\/}})\index{tag}) $=$ ({\it{x\/}} $=$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cddr-tag \\ \index{cddr-tag}
{\rm{cddr}}\,({\rm{tag}}\,({\it{type\/}}, {\it{obj\/}})\index{tag}) $=$ {\bf{nil}}
\end{tabbing}


\noindent{\sc Event}:   Disable type.

\addvspace{18pt}

\noindent{\sc Event}:   Disable tag.

\addvspace{18pt}

\noindent{\sc Event}:   Disable untag.

\addvspace{18pt}

\begin{verbatim}; Error messages are irrelevant as long as they are not 'run or 'halt.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  not-equal-x-y-error-msg-run \\ \index{not-equal-x-y-error-msg-run}
{\rm{x-y-error-msg}}\,({\it{x\/}}, {\it{y\/}})\index{x-y-error-msg} $\not=$ {\tt{'}}{\tt{run}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-equal-x-y-error-msg-halt \\ \index{not-equal-x-y-error-msg-halt}
{\rm{x-y-error-msg}}\,({\it{x\/}}, {\it{y\/}})\index{x-y-error-msg} $\not=$ {\tt{'}}{\tt{halt}}
\end{tabbing}


\noindent{\sc Event}:   Disable x-y-error-msg.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-objectp-opener \\ \index{p-objectp-opener}
\=\+(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{nat}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{small-naturalp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\-)\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{int}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-integerp})\-)\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{bitv}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{bit-vectorp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{bit-vectorp})\-)\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{bool}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) $\wedge$ {\rm{booleanp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag})\index{booleanp}))\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{addr}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{adpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{adpp})\-)\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{pcpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{pcpp})\-)\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{subr}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-objectp}}\,({\it{x\/}}, {\it{p\/}})\index{p-objectp} \\ 
$=$$\;\;\;\;$(\=\+({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp})\-)\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-objectp.

\addvspace{18pt}



\noindent{\sc Event}:   Disable name.

\addvspace{18pt}

\noindent{\sc Event}:   Disable formal-vars.

\addvspace{18pt}

\noindent{\sc Event}:   Disable temp-var-dcls.

\addvspace{18pt}

\noindent{\sc Event}:   Disable program-body.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  bindings-p-frame \\ \index{bindings-p-frame}
{\rm{bindings}}\,({\rm{p-frame}}\,({\it{alist\/}}, {\it{pc\/}})\index{p-frame})\index{bindings} $=$ {\it{alist\/}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ret-pc-p-frame \\ \index{ret-pc-p-frame}
{\rm{ret-pc}}\,({\rm{p-frame}}\,({\it{alist\/}}, {\it{pc\/}})\index{p-frame})\index{ret-pc} $=$ {\it{pc\/}}
\end{tabbing}


\noindent{\sc Event}:   Disable bindings.

\addvspace{18pt}

\noindent{\sc Event}:   Disable ret-pc.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-frame.

\addvspace{18pt}


\noindent{\sc Event}:   Disable proper-p-instructionp.

\addvspace{18pt}


\noindent{\sc Event}:   Disable legal-labelp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  proper-labeled-p-instructionsp-implies-labelp-and-instructionp \\ \index{proper-labeled-p-instructionsp-i!mplies-labelp-and-instructionp}
\=\+({\rm{proper-labeled-p-instructionsp}}\,({\it{lst\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-labeled-p-instructionsp} $\wedge$ ({\it{x\/}} $\in$ {\it{lst\/}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{legal-labelp}}\,({\it{x\/}})\index{legal-labelp} $\wedge$ {\rm{proper-p-instructionp}}\,({\rm{unlabel}}\,({\it{x\/}})\index{unlabel}, {\it{name\/}}, {\it{p\/}})\index{proper-p-instructionp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  proper-p-prog-segmentp-implies-proper-p-programp \\ \index{proper-p-prog-segmentp-implies-p!roper-p-programp}
\=\+({\rm{proper-p-prog-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-prog-segmentp} $\wedge$ ({\it{prog\/}} $\in$ {\it{segment\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-programp}}\,({\it{prog\/}}, {\it{p\/}})\index{proper-p-programp}\-
\end{tabbing}	\begin{verbatim}; Added disable to speed up proof, AF

\end{verbatim}\begin{tabbing}{\sc Theorem}:  member-assoc \\ \index{member-assoc}
{\rm{definedp}}\,({\it{name\/}}, {\it{alist\/}})\index{definedp} $\rightarrow$ ({\rm{assoc}}\,({\it{name\/}}, {\it{alist\/}}) $\in$ {\it{alist\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  name-assoc \\ \index{name-assoc}
{\rm{definedp}}\,({\it{name\/}}, {\it{alist\/}})\index{definedp} $\rightarrow$ ({\rm{name}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{alist\/}}))\index{name} $=$ {\it{name\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-get \\ \index{member-get}
({\it{n\/}} $<$ {\rm{length}}\,({\it{lst\/}})\index{length}) $\rightarrow$ ({\rm{get}}\,({\it{n\/}}, {\it{lst\/}})\index{get} $\in$ {\it{lst\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  proper-p-statep-implies-proper-p-instructionp \\ \index{proper-p-statep-implies-proper-p!-instructionp}
\=\+(\=\+{\rm{proper-p-prog-segmentp}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}) \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{program-body}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{program-body})\index{length})\-)\- \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-instructionp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), {\it{p\/}})\index{proper-p-instructionp}\-
\end{tabbing}


	 
\begin{verbatim}; Now I restructure proper-p-statep into two parts, those that
; have to do with arithmetic and those that do not.  The parts
; that do not are arithmetic, I confine to proper-p-statep1,
; which I keep closed and backchain into as needed.  The other
; parts I keep out in the open.  In addition, I throw in the
; proper-p-instructionp proved above, essentially forward
; chaining through the lemma.

\end{verbatim}
\noindent{\sc Event}:   Disable p-loadablep.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{proper-p-statep1} \\  
\=\+{\rm{proper-p-statep1}}\,({\it{p\/}})\index{proper-p-statep1} \\ 
$=$$\;\;\;\;$(\=\+{\rm{p-statep}}\,({\it{p\/}})\index{p-statep} \\ 
$\wedge$$\;\;\;\;$({\rm{type}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{bindings}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{bindings}, {\it{p\/}})\index{proper-p-alistp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{strip-cars}}\,({\rm{bindings}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{bindings}) \\ 
$=$$\;\;\;\;${\rm{append}}\,(\=\+{\rm{formal-vars}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{formal-vars}, \\ 
{\rm{strip-cars}}\,({\rm{temp-var-dcls}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{temp-var-dcls}))\-)\- \\ 
$\wedge$$\;\;\;\;$({\rm{type}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-ctrl-stkp}}\,(\=\+{\rm{cdr}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}), \\ 
{\rm{car}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}), \\ 
{\it{p\/}})\-\index{proper-p-ctrl-stkp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-stkp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, {\it{p\/}})\index{proper-p-temp-stkp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-prog-segmentp}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-data-segmentp}}\,({\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, {\it{p\/}})\index{proper-p-data-segmentp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  proper-p-statep-restructuring \\ \index{proper-p-statep-restructuring}
\=\+{\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$=$$\;\;\;\;$(\=\+{\rm{proper-p-statep1}}\,({\it{p\/}})\index{proper-p-statep1} \\ 
$\wedge$$\;\;\;\;$({\rm{cdr}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}) $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}) \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{program-body}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{program-body})\index{length})\- \\ 
$\wedge$$\;\;\;\;$({\rm{cdr}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}) $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}) \\ 
$<$$\;\;\;\;${\rm{length}}\,({\rm{program-body}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{program-body})\index{length})\- \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $\not<$ {\rm{p-ctrl-stk-size}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})\index{p-ctrl-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $\not<$ {\rm{length}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk})\index{length}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size} $\in\;${\bf{N}}${}$) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size} $<$ {\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size} $<$ {\rm{exp}}\,({\tt{2}}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{exp}) \\ 
$\wedge$$\;\;\;\;$({\tt{0}} $<$ {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-instructionp}}\,(\=\+{\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, \\ 
{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\it{p\/}})\-\index{proper-p-instructionp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  proper-p-statep1-properties \\ \index{proper-p-statep1-properties}
\=\+{\rm{proper-p-statep1}}\,({\it{p\/}})\index{proper-p-statep1} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{p-statep}}\,({\it{p\/}})\index{p-statep} \\ 
$\wedge$$\;\;\;\;$({\rm{type}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk})) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{bindings}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{bindings}, {\it{p\/}})\index{proper-p-alistp} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{strip-cars}}\,({\rm{bindings}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{bindings}) \\ 
$=$$\;\;\;\;${\rm{append}}\,(\=\+{\rm{formal-vars}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{formal-vars}, \\ 
{\rm{strip-cars}}\,({\rm{temp-var-dcls}}\,({\rm{assoc}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-)\index{temp-var-dcls}))\-)\- \\ 
$\wedge$$\;\;\;\;$({\rm{type}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,(\=\+{\rm{car}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}), \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\-\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-ctrl-stkp}}\,(\=\+{\rm{cdr}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}), \\ 
{\rm{car}}\,({\rm{untag}}\,({\rm{ret-pc}}\,({\rm{car}}\,({\rm{p-ctrl-stk}}\,({\it{p\/}})\index{p-ctrl-stk}))\index{ret-pc})\index{untag}), \\ 
{\it{p\/}})\-\index{proper-p-ctrl-stkp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-temp-stkp}}\,({\rm{p-temp-stk}}\,({\it{p\/}})\index{p-temp-stk}, {\it{p\/}})\index{proper-p-temp-stkp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-prog-segmentp}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-data-segmentp}}\,({\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment}, {\it{p\/}})\index{proper-p-data-segmentp})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable proper-p-statep.

\addvspace{18pt}

\noindent{\sc Event}:   Disable proper-p-statep1.

\addvspace{18pt}


\noindent{\sc Event}:   Disable p-current-instruction.

\addvspace{18pt}

\begin{verbatim}; Now I provide a simple delayed opener for proper-p-instructionp:

\end{verbatim}\begin{tabbing}{\sc Theorem}:  proper-p-instructionp-opener \\ \index{proper-p-instructionp-opener}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\rm{pack}}\,({\it{xxx\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{proper-p-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-instructionp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{plistp}}\,({\it{ins\/}})\index{plistp} \\ 
$\wedge$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{proper-p-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-call-instructionp} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-ret-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-ret-instructionp} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-locn-instructionp} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-constant-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-constant-instructi!onp} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-local-instructionp} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-push-global-instructio!np} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-ctrl-stk-free-size-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-push-ctrl-stk-free-size!-instructionp} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-temp-stk-free-size-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-push-temp-stk-free-size!-instructionp} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-push-temp-stk-index-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-push-temp-stk-index-in!structionp} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-if-temp-stk-full-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-jump-if-temp-stk-full-i!nstructionp} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-if-temp-stk-empty-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-jump-if-temp-stk-empty!-instructionp} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-instructionp} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop*-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop*-instructionp} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-popn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popn-instructionp} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-local-instructionp} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-global-instructionp} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-locn-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-locn-instructionp} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pop-call-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pop-call-instructionp} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-fetch-temp-stk-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-fetch-temp-stk-instructi!onp} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-deposit-temp-stk-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-deposit-temp-stk-instr!uctionp} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-instructionp} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-jump-case-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-jump-case-instructionp} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-pushj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-pushj-instructionp} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-popj-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-popj-instructionp} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-set-local-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-local-instructionp} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-set-global-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-set-global-instructionp} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-nat-and-jump-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-test-nat-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-int-and-jump-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-test-int-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-bool-and-jump-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-test-bool-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-test-bitv-and-jump-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-test-bitv-and-jump-inst!ructionp} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-no-op-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-no-op-instructionp} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-addr-instructionp} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-addr-instructionp} \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-eq-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-eq-instructionp} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-addr-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-addr-instructionp} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-fetch-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-fetch-instructionp} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-deposit-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-deposit-instructionp} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-int-instructionp} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-int-with-carry-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-add-int-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-int-instructionp} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-int-instructionp} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-int-with-carry-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-sub-int-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub1-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-int-instructionp} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-neg-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-neg-int-instructionp} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-int-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-int-instructionp} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-int-to-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-int-to-nat-instructionp} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add-nat-instructionp} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add-nat-with-carry-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-add-nat-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-add1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-add1-nat-instructionp} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub-nat-instructionp} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub-nat-with-carry-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-sub-nat-with-carry-inst!ructionp} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-sub1-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-sub1-nat-instructionp} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lt-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lt-nat-instructionp} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-mult2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-mult2-nat-instructionp} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-mult2-nat-with-carry-out-instructionp}}\,(\=\+{\it{ins\/}}, \\ 
{\it{name\/}}, \\ 
{\it{p\/}})\-\index{proper-p-mult2-nat-with-carry-o!ut-instructionp} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-div2-nat-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-div2-nat-instructionp} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-or-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bitv-instructionp} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-and-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bitv-instructionp} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-not-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bitv-instructionp} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-xor-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-xor-bitv-instructionp} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-rsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-rsh-bitv-instructionp} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-lsh-bitv-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-lsh-bitv-instructionp} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-or-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-or-bool-instructionp} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-and-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-and-bool-instructionp} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{proper-p-not-bool-instructionp}}\,({\it{ins\/}}, {\it{name\/}}, {\it{p\/}})\index{proper-p-not-bool-instructionp} \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\-)\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  length-put-assoc \\ \index{length-put-assoc}
{\rm{length}}\,({\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{alist\/}})\index{put-assoc})\index{length} $=$ {\rm{length}}\,({\it{alist\/}})\index{length}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  assoc-put-assoc-1 \\ \index{assoc-put-assoc-1}
\=\+({\it{name1\/}} $\not=$ {\it{name2\/}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{assoc}}\,({\it{name1\/}}, {\rm{put-assoc}}\,({\it{val\/}}, {\it{name2\/}}, {\it{alist\/}})\index{put-assoc}) $=$ {\rm{assoc}}\,({\it{name1\/}}, {\it{alist\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  assoc-put-assoc-2 \\ \index{assoc-put-assoc-2}
\=\+{\rm{definedp}}\,({\it{name\/}}, {\it{alist\/}})\index{definedp} \\ 
$\rightarrow$$\;\;\;\;$({\rm{assoc}}\,({\it{name\/}}, {\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{alist\/}})\index{put-assoc}) $=$ {\rm{cons}}\,({\it{name\/}}, {\it{val\/}}))\-
\end{tabbing}

\begin{verbatim};; The original lemma SAME-SIGNATURE-PUT-ASSOC-1 had the DEFINEDP
;; term below in it.  It is not necessary so I commented it out.  -- AF
\end{verbatim}\begin{tabbing}{\sc Theorem}:  same-signature-put-assoc-1 \\ \index{same-signature-put-assoc-1}
\=\+({\rm{litatom}}\,({\it{name\/}}) $\wedge$ ({\rm{length}}\,({\it{val\/}})\index{length} $=$ {\rm{length}}\,({\rm{value}}\,({\it{name\/}}, {\it{segment1\/}})\index{value})\index{length})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{same-signature}}\,({\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{segment1\/}})\index{put-assoc}, {\it{segment2\/}})\index{same-signature} \\ 
$=$$\;\;\;\;${\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature})\-\-
\end{tabbing}

\begin{verbatim};; The original lemma SAME-SIGNATURE-PUT-ASSOC-2 had the DEFINEDP
;; term below in it.  It is not necessary so I commented it out.  -- AF
\end{verbatim}\begin{tabbing}{\sc Theorem}:  same-signature-put-assoc-2 \\ \index{same-signature-put-assoc-2}
\=\+({\rm{litatom}}\,({\it{name\/}}) $\wedge$ ({\rm{length}}\,({\it{val\/}})\index{length} $=$ {\rm{length}}\,({\rm{value}}\,({\it{name\/}}, {\it{segment2\/}})\index{value})\index{length})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{same-signature}}\,({\it{segment1\/}}, {\rm{put-assoc}}\,({\it{val\/}}, {\it{name\/}}, {\it{segment2\/}})\index{put-assoc})\index{same-signature} \\ 
$=$$\;\;\;\;${\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature})\-\-
\end{tabbing}



\noindent{\sc Event}:   Disable same-signature.

\addvspace{18pt}


\begin{verbatim}; Now I want to disable get and put so that they are only manipulated by
; the lemmas we have proved.

\end{verbatim}
\noindent{\sc Event}:   Disable get.

\addvspace{18pt}


\noindent{\sc Event}:   Disable put.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  length-first-n \\ \index{length-first-n}
{\rm{length}}\,({\rm{first-n}}\,({\it{n\/}}, {\it{x\/}})\index{first-n})\index{length} $=$ {\rm{fix}}\,({\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  same-signature-implies-equal-lengths \\ \index{same-signature-implies-equal-le!ngths}
\=\+{\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{length}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{segment1\/}})))\index{length} \\ 
$=$$\;\;\;\;${\rm{length}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{segment2\/}})))\index{length})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  same-signature-implies-equal-definedp \\ \index{same-signature-implies-equal-de!finedp}
\=\+{\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature} \\ 
$\rightarrow$$\;\;\;\;$({\rm{definedp}}\,({\it{name\/}}, {\it{segment1\/}})\index{definedp} $=$ {\rm{definedp}}\,({\it{name\/}}, {\it{segment2\/}})\index{definedp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  same-signature-reflexive-generalized \\ \index{same-signature-reflexive-genera!lized}
{\rm{same-signature}}\,({\it{segment\/}}, {\it{segment\/}})\index{same-signature}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  definedp-put-assoc \\ \index{definedp-put-assoc}
{\rm{definedp}}\,({\it{name1\/}}, {\rm{put-assoc}}\,({\it{val\/}}, {\it{name2\/}}, {\it{alist\/}})\index{put-assoc})\index{definedp} $=$ {\rm{definedp}}\,({\it{name1\/}}, {\it{alist\/}})\index{definedp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-objectp-type-opener \\ \index{p-objectp-type-opener}
\=\+(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{nat}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{small-naturalp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-naturalp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{int}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{small-integerp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{small-integerp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{bitv}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{bit-vectorp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\index{bit-vectorp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{bool}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{bool}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{booleanp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag})\index{booleanp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{addr}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{addr}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{adpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{adpp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{pc}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{pc}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{pcpp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{pcpp})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p-objectp-type}}\,({\tt{'}}{\tt{subr}}, {\it{x\/}}, {\it{p\/}})\index{p-objectp-type} \\ 
$=$$\;\;\;\;$(\=\+({\rm{type}}\,({\it{x\/}})\index{type} $=$ {\tt{'}}{\tt{subr}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cddr}}\,({\it{x\/}}) $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\rm{untag}}\,({\it{x\/}})\index{untag}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp})\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-objectp-type.

\addvspace{18pt}

\begin{verbatim};; This is from Piton but with PROPERP instead of PLISTP
\end{verbatim}\begin{tabbing}{\sc Theorem}:  proper-p-alistp-append \\ \index{proper-p-alistp-append}
\=\+{\rm{plistp}}\,({\it{a\/}})\index{plistp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{proper-p-alistp}}\,({\rm{append}}\,({\it{a\/}}, {\it{b\/}}), {\it{p\/}})\index{proper-p-alistp} \\ 
$=$$\;\;\;\;$({\rm{proper-p-alistp}}\,({\it{a\/}}, {\it{p\/}})\index{proper-p-alistp} $\wedge$ {\rm{proper-p-alistp}}\,({\it{b\/}}, {\it{p\/}})\index{proper-p-alistp}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  strip-cars-put-assoc \\ \index{strip-cars-put-assoc}
{\rm{strip-cars}}\,({\rm{put-assoc}}\,({\it{val\/}}, {\it{var\/}}, {\it{alist\/}})\index{put-assoc}) $=$ {\rm{strip-cars}}\,({\it{alist\/}})
\end{tabbing}

\begin{verbatim}; So after the rule is applied, we have to prove two proper-p-alistps.
; The first is for the pairlist of the formals to the actuals.
; The second is for the initialization of the temp vars.

; The first is handled by:

\end{verbatim}\begin{tabbing}{\sc Theorem}:  proper-p-alistp-pairlist \\ \index{proper-p-alistp-pairlist}
\=\+(\=\+{\rm{all-litatoms}}\,({\it{formals\/}})\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{all-p-objectps}}\,({\it{actuals\/}}, {\it{p\/}})\index{all-p-objectps} \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\it{formals\/}})\index{length} $=$ {\rm{length}}\,({\it{actuals\/}})\index{length}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{pairlist}}\,({\it{formals\/}}, {\it{actuals\/}}), {\it{p\/}})\index{proper-p-alistp}\-
\end{tabbing}

\begin{verbatim}; where the hypotheses above are relieved as follows.  The all-litatoms
; of the formals is derived from proper-p-prog-segmentp:

\end{verbatim}\begin{tabbing}{\sc Theorem}:  all-litatoms-formal-vars-generalized \\ \index{all-litatoms-formal-vars-genera!lized}
\=\+({\rm{proper-p-prog-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-prog-segmentp} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\it{segment\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{formal-vars}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{segment\/}}))\index{formal-vars})\index{all-litatoms}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  all-litatoms-formal-vars \\ \index{all-litatoms-formal-vars}
\=\+(\=\+{\rm{proper-p-prog-segmentp}}\,({\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, {\it{p\/}})\index{proper-p-prog-segmentp} \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment})\index{definedp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{formal-vars}}\,({\rm{assoc}}\,({\it{name\/}}, {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}))\index{formal-vars})\index{all-litatoms}\-
\end{tabbing}

\begin{verbatim}; The third hypothesis of the pairlist lemma above is that the lengths of
; the formals and actuals are the same.  That follows from what we've
; already proved.

; Now we move to the second proper-p-alistp task, namely, for the
; initialization of the temp vars.  That is handled by:

\end{verbatim}\begin{tabbing}{\sc Theorem}:  proper-p-prog-segmentp-implies-proper-p-temp-var-dclsp \\ \index{proper-p-prog-segmentp-implies-p!roper-p-temp-var-dclsp}
\=\+({\rm{proper-p-prog-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-prog-segmentp} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\it{segment\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-temp-var-dclsp}}\,({\rm{temp-var-dcls}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{segment\/}}))\index{temp-var-dcls}, {\it{p\/}})\index{proper-p-temp-var-dclsp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  proper-p-alistp-pair-temps-with-initial-values \\ \index{proper-p-alistp-pair-temps-with!-initial-values}
\=\+{\rm{proper-p-temp-var-dclsp}}\,({\it{var-dcls\/}}, {\it{p\/}})\index{proper-p-temp-var-dclsp} \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-alistp}}\,({\rm{pair-temps-with-initial-values}}\,({\it{var-dcls\/}})\index{pair-temps-with-initial-values}, {\it{p\/}})\index{proper-p-alistp}\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-call-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-call-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-ret-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-ret-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-locn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-locn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-constant-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-constant-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-ctrl-stk-free-size-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-ctrl-stk-free-size-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-temp-stk-free-size-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-temp-stk-free-size-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-temp-stk-index-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-push-temp-stk-index-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-if-temp-stk-full-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-if-temp-stk-full-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-if-temp-stk-empty-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-if-temp-stk-empty-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop*-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop*-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-popn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-popn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-locn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-locn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-call-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pop-call-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-fetch-temp-stk-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-fetch-temp-stk-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-deposit-temp-stk-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-deposit-temp-stk-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-case-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-jump-case-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pushj-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-pushj-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-popj-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-popj-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-set-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-set-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-set-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-set-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-nat-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-nat-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-int-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-int-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-bool-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-bool-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-bitv-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-test-bitv-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-no-op-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-no-op-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-eq-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-eq-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-fetch-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-fetch-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-deposit-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-deposit-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-int-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-int-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add1-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add1-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-int-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-int-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub1-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub1-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-neg-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-neg-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-int-to-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-int-to-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-nat-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add-nat-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add1-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-add1-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-nat-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub-nat-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub1-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-sub1-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lt-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-mult2-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-mult2-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-mult2-nat-with-carry-out-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-mult2-nat-with-carry-out-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-div2-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-div2-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-or-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-or-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-and-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-and-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-not-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-not-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-xor-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-xor-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-rsh-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-rsh-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lsh-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-lsh-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-or-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-or-bool-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-and-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-and-bool-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-not-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-not-bool-step.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{p-ins-okp2} \\  
\=\+{\rm{p-ins-okp2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp2} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf then }{\rm{p-eq-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-okp} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-okp} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-okp} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-okp} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-okp} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-okp} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-okp} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-okp} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-okp} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-okp} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-neg-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-okp} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-okp} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-int-to-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-okp} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-okp} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-okp} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-okp} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-okp} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-okp} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-okp} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-okp} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-okp} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-with-carry-out-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-okp} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-div2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-okp} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-okp} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-okp} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-okp} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-xor-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-okp} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-rsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-okp} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-lsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-okp} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-okp} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-okp} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-okp} \\ 
{\bf otherwise }{\bf{f}}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-ins-okp1} \\  
\=\+{\rm{p-ins-okp1}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp1} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{p-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-okp} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{p-ret-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-okp} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-okp} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-constant-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-okp} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-okp} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-okp} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-ctrl-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-okp} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-okp} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-index-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-okp} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-full-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-okp} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-empty-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-okp} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-okp} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop*-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-okp} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{p-popn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-okp} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-okp} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-okp} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-okp} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-okp} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-okp} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-okp} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-okp} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-case-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-okp} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{p-pushj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-okp} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{p-popj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-okp} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-okp} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-okp} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-nat-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-okp} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-int-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-okp} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bool-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-okp} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bitv-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-okp} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{p-no-op-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-okp} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-okp} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-okp} \\ 
{\bf otherwise }{\rm{p-ins-okp2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp2}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-okp-is-p-ins-okp1 \\ \index{p-ins-okp-is-p-ins-okp1}
{\rm{p-ins-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp} $=$ {\rm{p-ins-okp1}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp1}
\end{tabbing}


\noindent{\sc Event}:   Disable p-ins-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-ins-okp-is-p-ins-okp1.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{p-ins-step2} \\  
\=\+{\rm{p-ins-step2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step2} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{eq\/}} \\ 
{\bf then }{\rm{p-eq-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-step} \\ 
{\bf case = }{\it{lt-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-step} \\ 
{\bf case = }{\it{fetch\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-step} \\ 
{\bf case = }{\it{deposit\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-step} \\ 
{\bf case = }{\it{add-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-step} \\ 
{\bf case = }{\it{add-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-step} \\ 
{\bf case = }{\it{add1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-step} \\ 
{\bf case = }{\it{sub-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-step} \\ 
{\bf case = }{\it{sub-int-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-step} \\ 
{\bf case = }{\it{sub1-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-step} \\ 
{\bf case = }{\it{neg-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-neg-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-step} \\ 
{\bf case = }{\it{lt-int\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-step} \\ 
{\bf case = }{\it{int-to-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-int-to-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-step} \\ 
{\bf case = }{\it{add-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-step} \\ 
{\bf case = }{\it{add-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-step} \\ 
{\bf case = }{\it{add1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-add1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-step} \\ 
{\bf case = }{\it{sub-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-step} \\ 
{\bf case = }{\it{sub-nat-with-carry\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-step} \\ 
{\bf case = }{\it{sub1-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-step} \\ 
{\bf case = }{\it{lt-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-lt-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-step} \\ 
{\bf case = }{\it{mult2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-step} \\ 
{\bf case = }{\it{mult2-nat-with-carry-out\/}} \\ 
{\bf $\;\;$then }{\rm{p-mult2-nat-with-carry-out-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-step} \\ 
{\bf case = }{\it{div2-nat\/}} \\ 
{\bf $\;\;$then }{\rm{p-div2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-step} \\ 
{\bf case = }{\it{or-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-step} \\ 
{\bf case = }{\it{and-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-step} \\ 
{\bf case = }{\it{not-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-step} \\ 
{\bf case = }{\it{xor-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-xor-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-step} \\ 
{\bf case = }{\it{rsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-rsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-step} \\ 
{\bf case = }{\it{lsh-bitv\/}} \\ 
{\bf $\;\;$then }{\rm{p-lsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-step} \\ 
{\bf case = }{\it{or-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-or-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-step} \\ 
{\bf case = }{\it{and-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-and-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-step} \\ 
{\bf case = }{\it{not-bool\/}} \\ 
{\bf $\;\;$then }{\rm{p-not-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-step} \\ 
{\bf otherwise }{\rm{p-halt}}\,({\it{p\/}}, {\tt{'}}{\tt{run}})\index{p-halt}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-ins-step1} \\  
\=\+{\rm{p-ins-step1}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step1} \\ 
$=$$\;\;\;\;$\=\+{\bf case on }{\rm{car}}\,({\it{ins\/}}): \\ 
{\bf case = }{\it{call\/}} \\ 
{\bf then }{\rm{p-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-step} \\ 
{\bf case = }{\it{ret\/}} \\ 
{\bf $\;\;$then }{\rm{p-ret-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-step} \\ 
{\bf case = }{\it{locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-step} \\ 
{\bf case = }{\it{push-constant\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-constant-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-step} \\ 
{\bf case = }{\it{push-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-step} \\ 
{\bf case = }{\it{push-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-step} \\ 
{\bf case = }{\it{push-ctrl-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-ctrl-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-step} \\ 
{\bf case = }{\it{push-temp-stk-free-size\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-step} \\ 
{\bf case = }{\it{push-temp-stk-index\/}} \\ 
{\bf $\;\;$then }{\rm{p-push-temp-stk-index-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-step} \\ 
{\bf case = }{\it{jump-if-temp-stk-full\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-full-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-step} \\ 
{\bf case = }{\it{jump-if-temp-stk-empty\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-if-temp-stk-empty-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-step} \\ 
{\bf case = }{\it{pop\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-step} \\ 
{\bf case = }{\it{pop*\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop*-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-step} \\ 
{\bf case = }{\it{popn\/}} \\ 
{\bf $\;\;$then }{\rm{p-popn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-step} \\ 
{\bf case = }{\it{pop-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-step} \\ 
{\bf case = }{\it{pop-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-step} \\ 
{\bf case = }{\it{pop-locn\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-step} \\ 
{\bf case = }{\it{pop-call\/}} \\ 
{\bf $\;\;$then }{\rm{p-pop-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-step} \\ 
{\bf case = }{\it{fetch-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-fetch-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-step} \\ 
{\bf case = }{\it{deposit-temp-stk\/}} \\ 
{\bf $\;\;$then }{\rm{p-deposit-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-step} \\ 
{\bf case = }{\it{jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-step} \\ 
{\bf case = }{\it{jump-case\/}} \\ 
{\bf $\;\;$then }{\rm{p-jump-case-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-step} \\ 
{\bf case = }{\it{pushj\/}} \\ 
{\bf $\;\;$then }{\rm{p-pushj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-step} \\ 
{\bf case = }{\it{popj\/}} \\ 
{\bf $\;\;$then }{\rm{p-popj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-step} \\ 
{\bf case = }{\it{set-local\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-step} \\ 
{\bf case = }{\it{set-global\/}} \\ 
{\bf $\;\;$then }{\rm{p-set-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-step} \\ 
{\bf case = }{\it{test-nat-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-nat-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-step} \\ 
{\bf case = }{\it{test-int-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-int-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-step} \\ 
{\bf case = }{\it{test-bool-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bool-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-step} \\ 
{\bf case = }{\it{test-bitv-and-jump\/}} \\ 
{\bf $\;\;$then }{\rm{p-test-bitv-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-step} \\ 
{\bf case = }{\it{no-op\/}} \\ 
{\bf $\;\;$then }{\rm{p-no-op-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-step} \\ 
{\bf case = }{\it{add-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-add-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-step} \\ 
{\bf case = }{\it{sub-addr\/}} \\ 
{\bf $\;\;$then }{\rm{p-sub-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-step} \\ 
{\bf otherwise }{\rm{p-ins-step2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step2}$\;${\bf  endcase}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-step-is-p-ins-step1 \\ \index{p-ins-step-is-p-ins-step1}
{\rm{p-ins-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step} $=$ {\rm{p-ins-step1}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step1}
\end{tabbing}


\noindent{\sc Event}:   Disable p-ins-step.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-ins-step-is-p-ins-step1.

\addvspace{18pt}

\begin{verbatim}; We disable p-ins-okp because the main owc theorem involves p-ins-okp
; and p-ins-step, and opening either is sufficient to drive the case
; analysis.  If both open, then we get cross-multiplied cases and
; there is a lot of silly propositional work to do.  So we arbitrarily
; choose to keep p-ins-okp disabled.  Now we could choose to rewrite
; it to p-xxx-okp when the car of ins is 'xxx, analogously to what we
; did for r-ins-okp above.  But the proof of the owc should be faster
; if we do this: keep p-ins-okp disabled and show that p-xxx-okp holds
; if the car of ins is 'xxx.  The reason is that when we fire the
; xxx-one-way-correspondence-p-r lemma we will want to get p-xxx-okp
; and we'll be governed by a p-ins-okp and a hyp about car ins.  But
; the hyp about car ins won't have been raised all the way to the top
; and so won't yet be available to tell the p-ins-okp which way to go.
; This is the same strategy used for r-ins-okp in the r-i level proof.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  p-ins-okp2-backchainer \\ \index{p-ins-okp2-backchainer}
\=\+{\rm{p-ins-okp2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp2} \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{eq}}) $\rightarrow$ {\rm{p-eq-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-addr}}) $\rightarrow$ {\rm{p-lt-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{fetch}}) $\rightarrow$ {\rm{p-fetch-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{deposit}}) $\rightarrow$ {\rm{p-deposit-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-int}}) $\rightarrow$ {\rm{p-add-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-int-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-add-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add1-int}}) $\rightarrow$ {\rm{p-add1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-int}}) $\rightarrow$ {\rm{p-sub-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-int-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-sub-int-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub1-int}}) $\rightarrow$ {\rm{p-sub1-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{neg-int}}) $\rightarrow$ {\rm{p-neg-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-int}}) $\rightarrow$ {\rm{p-lt-int-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{int-to-nat}}) $\rightarrow$ {\rm{p-int-to-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-nat}}) $\rightarrow$ {\rm{p-add-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-nat-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-add-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add1-nat}}) $\rightarrow$ {\rm{p-add1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-nat}}) $\rightarrow$ {\rm{p-sub-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-nat-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-sub-nat-with-carry-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub1-nat}}) $\rightarrow$ {\rm{p-sub1-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-nat}}) $\rightarrow$ {\rm{p-lt-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{mult2-nat}}) $\rightarrow$ {\rm{p-mult2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{mult2-nat-with-carry-out}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-mult2-nat-with-carry-out-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{div2-nat}}) $\rightarrow$ {\rm{p-div2-nat-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{or-bitv}}) $\rightarrow$ {\rm{p-or-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{and-bitv}}) $\rightarrow$ {\rm{p-and-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{not-bitv}}) $\rightarrow$ {\rm{p-not-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{xor-bitv}}) $\rightarrow$ {\rm{p-xor-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{rsh-bitv}}) $\rightarrow$ {\rm{p-rsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lsh-bitv}}) $\rightarrow$ {\rm{p-lsh-bitv-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{or-bool}}) $\rightarrow$ {\rm{p-or-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{and-bool}}) $\rightarrow$ {\rm{p-and-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{not-bool}}) $\rightarrow$ {\rm{p-not-bool-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-okp}))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-ins-okp2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-ins-okp-backchainer \\ \index{p-ins-okp-backchainer}
\=\+{\rm{p-ins-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{call}}) $\rightarrow$ {\rm{p-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{ret}}) $\rightarrow$ {\rm{p-ret-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{locn}}) $\rightarrow$ {\rm{p-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-constant}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-push-constant-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-local}}) $\rightarrow$ {\rm{p-push-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-global}}) $\rightarrow$ {\rm{p-push-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-ctrl-stk-free-size}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-push-ctrl-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-temp-stk-free-size}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-push-temp-stk-free-size-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-temp-stk-index}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-push-temp-stk-index-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-if-temp-stk-full}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-jump-if-temp-stk-full-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-if-temp-stk-empty}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-jump-if-temp-stk-empty-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop}}) $\rightarrow$ {\rm{p-pop-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop*}}) $\rightarrow$ {\rm{p-pop*-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{popn}}) $\rightarrow$ {\rm{p-popn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-local}}) $\rightarrow$ {\rm{p-pop-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-global}}) $\rightarrow$ {\rm{p-pop-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-locn}}) $\rightarrow$ {\rm{p-pop-locn-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-call}}) $\rightarrow$ {\rm{p-pop-call-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{fetch-temp-stk}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-fetch-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{deposit-temp-stk}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-deposit-temp-stk-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump}}) $\rightarrow$ {\rm{p-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-case}}) $\rightarrow$ {\rm{p-jump-case-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pushj}}) $\rightarrow$ {\rm{p-pushj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{popj}}) $\rightarrow$ {\rm{p-popj-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{set-local}}) $\rightarrow$ {\rm{p-set-local-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{set-global}}) $\rightarrow$ {\rm{p-set-global-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-okp}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-nat-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-test-nat-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-int-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-test-int-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-bool-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-test-bool-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-okp})\- \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-bitv-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-test-bitv-and-jump-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-okp})\- \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{no-op}}) $\rightarrow$ {\rm{p-no-op-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-addr}}) $\rightarrow$ {\rm{p-add-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-okp}) \\ 
$\wedge$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-addr}}) $\rightarrow$ {\rm{p-sub-addr-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-okp}))\-\-
\end{tabbing}

\begin{verbatim}; The only problem with these backchainers is that we don't know that the
; above cases are exhaustive.  That is, suppose the current instruction
; is none of the above.  Then p-ins-okp is false.  We need to know that.
; The most natural expression of this fact is that if the instruction
; is not call and not ret and, etc., then p-ins-okp is false.  But that
; is an inefficient way to hang it, because every time we see p-ins-okp
; we'll try to show the instruction is none of the above and most of the time
; it will be one of the ones listed half-way through the list.  So we'll
; hang it on one of the instructions!  It reads: if p-ins-okp is true
; and the instruction is not call, not ret, etc., then the instruction
; is 'not-bool, except we split it into two lemmas.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  p-ins-okp-exhausted \\ \index{p-ins-okp-exhausted}
\=\+(\=\+{\rm{p-ins-okp}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp} \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{call}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{ret}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{locn}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-constant}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-local}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-global}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-ctrl-stk-free-size}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-temp-stk-free-size}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{push-temp-stk-index}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{jump-if-temp-stk-full}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{jump-if-temp-stk-empty}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop*}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{popn}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop-local}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop-global}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop-locn}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pop-call}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{fetch-temp-stk}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{deposit-temp-stk}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{jump}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{jump-case}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{pushj}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{popj}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{set-local}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{set-global}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{test-nat-and-jump}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{test-int-and-jump}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{test-bool-and-jump}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{test-bitv-and-jump}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{no-op}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add-addr}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub-addr}}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{p-ins-okp2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp2}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-okp2-exhausted \\ \index{p-ins-okp2-exhausted}
\=\+(\=\+{\rm{p-ins-okp2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-okp2} \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{eq}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{lt-addr}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{fetch}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{deposit}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add-int-with-carry}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add1-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub-int-with-carry}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub1-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{neg-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{lt-int}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{int-to-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add-nat-with-carry}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{add1-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub-nat-with-carry}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{sub1-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{lt-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{mult2-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{mult2-nat-with-carry-out}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{div2-nat}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{or-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{and-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{not-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{xor-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{rsh-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{lsh-bitv}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{or-bool}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{ins\/}}) $\not=$ {\tt{'}}{\tt{and-bool}}))\- \\ 
$\rightarrow$$\;\;\;\;$(({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{not-bool}}) $=$ {\bf{t}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-ins-step2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  transitivity-of-same-signature \\ \index{transitivity-of-same-signature}
\=\+({\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment2\/}})\index{same-signature} $\wedge$ {\rm{same-signature}}\,({\it{segment2\/}}, {\it{segment3\/}})\index{same-signature}) \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\it{segment1\/}}, {\it{segment3\/}})\index{same-signature}\-
\end{tabbing}

\begin{verbatim};; ***** End stuff from p-r.events *****

;; The next two lemmas are from big-add.events by J Moore.
\end{verbatim}\begin{tabbing}{\sc Theorem}:  p-opener \\ \index{p-opener}
\=\+({\rm{p}}\,({\it{s\/}}, {\tt{0}})\index{p} $=$ {\it{s\/}}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{p}}\,(\=\+{\rm{p-state}}\,({\it{pc\/}}, {\it{ctrl\/}}, {\it{temp\/}}, {\it{prog\/}}, {\it{data\/}}, {\it{max-ctrl\/}}, {\it{max-temp\/}}, {\it{word-size\/}}, {\it{psw\/}})\index{p-state}, \\ 
$1\;+$ {\it{n\/}})\-\index{p} \\ 
$=$$\;\;\;\;${\rm{p}}\,(\=\+{\rm{p-step}}\,({\rm{p-state}}\,(\=\+{\it{pc\/}}, \\ 
{\it{ctrl\/}}, \\ 
{\it{temp\/}}, \\ 
{\it{prog\/}}, \\ 
{\it{data\/}}, \\ 
{\it{max-ctrl\/}}, \\ 
{\it{max-temp\/}}, \\ 
{\it{word-size\/}}, \\ 
{\it{psw\/}})\-\index{p-state})\index{p-step}, \\ 
{\it{n\/}})\-\index{p})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-opener.

\addvspace{18pt}


\noindent{\sc Event}:   Disable p.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-step1-opener \\ \index{p-step1-opener}
\=\+{\rm{p-step1}}\,({\rm{cons}}\,({\it{opcode\/}}, {\it{operands\/}}), {\it{p\/}})\index{p-step1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{p-ins-okp}}\,({\rm{cons}}\,({\it{opcode\/}}, {\it{operands\/}}), {\it{p\/}})\index{p-ins-okp} \\ 
{\bf then }{\rm{p-ins-step}}\,({\rm{cons}}\,({\it{opcode\/}}, {\it{operands\/}}), {\it{p\/}})\index{p-ins-step} \\ 
{\bf else }{\rm{p-halt}}\,({\it{p\/}}, {\rm{x-y-error-msg}}\,({\tt{'}}{\tt{p}}, {\it{opcode\/}})\index{x-y-error-msg})\index{p-halt}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-step1-opener.

\addvspace{18pt}


\noindent{\sc Event}:   Disable p-step1.

\addvspace{18pt}

\begin{verbatim};; ***** End stuff from big-add.events *****

\end{verbatim}
\noindent{\sc Event}:   Disable same-signature-implies-equal-lengths.

\addvspace{18pt}

\noindent{\sc Event}:   Disable same-signature-implies-equal-definedp.

\addvspace{18pt}

\noindent{\sc Event}:   Disable transitivity-of-same-signature.

\addvspace{18pt}

\begin{verbatim};; The following axioms are proven in Piton (in p-r).


\end{verbatim}\begin{tabbing}{\sc Axiom}:  p-step-preserves-proper-p-statep \\ \index{p-step-preserves-proper-p-statep}
\=\+({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step})\index{p-psw})\index{errorp})) \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-statep}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step})\index{proper-p-statep}\-
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  once-errorp-always-errorp-step \\ \index{once-errorp-always-errorp-step}
($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step})\index{p-psw})\index{errorp}) $\rightarrow$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\it{p\/}})\index{p-psw})\index{errorp})
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  once-errorp-always-errorp \\ \index{once-errorp-always-errorp}
($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-psw})\index{errorp}) $\rightarrow$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\it{p\/}})\index{p-psw})\index{errorp})
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  p-preserves-proper-p-statep \\ \index{p-preserves-proper-p-statep}
\=\+({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-psw})\index{errorp})) \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-statep}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{proper-p-statep}\-
\end{tabbing}

\begin{verbatim};; ***** End axioms proven in p-r.events *****


;; The following lemmas are NOT proven in Piton.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{p-invariant1} \\  
\=\+{\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1} \\ 
$=$$\;\;\;\;$(\=\+({\rm{p-prog-segment}}\,({\it{p0\/}})\index{p-prog-segment} $=$ {\rm{p-prog-segment}}\,({\it{p1\/}})\index{p-prog-segment}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\it{p0\/}})\index{p-max-ctrl-stk-size} $=$ {\rm{p-max-ctrl-stk-size}}\,({\it{p1\/}})\index{p-max-ctrl-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\it{p0\/}})\index{p-max-temp-stk-size} $=$ {\rm{p-max-temp-stk-size}}\,({\it{p1\/}})\index{p-max-temp-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-word-size}}\,({\it{p0\/}})\index{p-word-size} $=$ {\rm{p-word-size}}\,({\it{p1\/}})\index{p-word-size}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{p-invariant} \\  
\=\+{\rm{p-invariant}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant} \\ 
$=$$\;\;\;\;$(\=\+{\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{p0\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p1\/}})\index{p-data-segment})\index{same-signature} \\ 
$\wedge$$\;\;\;\;${\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-invariant-opener \\ \index{p-invariant-opener}
\=\+{\rm{p-invariant}}\,(\=\+{\rm{p-state}}\,(\=\+{\it{pc\/}}, \\ 
{\it{ctrl-stk\/}}, \\ 
{\it{temp-stk\/}}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\it{data-seg\/}}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\it{psw\/}})\-\index{p-state}, \\ 
{\it{p\/}})\-\index{p-invariant} \\ 
$=$$\;\;\;\;${\rm{same-signature}}\,({\it{data-seg\/}}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-invariant1-opener \\ \index{p-invariant1-opener}
{\rm{p-invariant1}}\,(\=\+{\rm{p-state}}\,(\=\+{\it{pc\/}}, \\ 
{\it{ctrl-stk\/}}, \\ 
{\it{temp-stk\/}}, \\ 
{\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}, \\ 
{\it{data-seg\/}}, \\ 
{\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}, \\ 
{\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}, \\ 
{\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size}, \\ 
{\it{psw\/}})\-\index{p-state}, \\ 
{\it{p\/}})\-\index{p-invariant1}
\end{tabbing}


\noindent{\sc Event}:   Disable p-invariant.

\addvspace{18pt}

\noindent{\sc Event}:   Disable p-invariant1.

\addvspace{18pt}

\begin{verbatim};; It will be easier later to no that the p-prog-segment and the 3 resource
;; limitations p-max-ctrl-stk-size, p-max-temp-stk-size and p-word-size
;; never change.  It is nice to not have to check the run flag.  We could
;; probably prove that if we have a PROPER-P-STATEP that these are invariant
;; but we get nicer rewrite rules later (at the lr level anyway) if we
;; do not have to assume that.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  no-op-preserves-p-invariant \\ \index{no-op-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{no-op}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-no-op-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-no-op-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-global-preserves-p-invariant \\ \index{push-global-preserves-p-invaria!nt}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-global}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-push-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-global-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{verbatim};; The following is inspired by the lemma length-put of Piton.
\end{verbatim}\begin{tabbing}{\sc Theorem}:  my-length-put \\ \index{my-length-put}
\=\+{\rm{length}}\,({\rm{put}}\,({\it{val\/}}, {\it{n\/}}, {\it{lst\/}})\index{put})\index{length} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{n\/}} $<$ {\rm{length}}\,({\it{lst\/}})\index{length}$\;\;${\bf then }{\rm{length}}\,({\it{lst\/}})\index{length} \\ 
{\bf else }$1\;+$ {\it{n\/}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable my-length-put.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  proper-p-statep-proper-implies-proper-p-instructionp \\ \index{proper-p-statep-proper-implies-p!roper-p-instructionp}
\=\+{\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$\rightarrow$$\;\;\;\;${\rm{proper-p-instructionp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\rm{car}}\,({\rm{untag}}\,({\rm{p-pc}}\,({\it{p\/}})\index{p-pc})\index{untag}), {\it{p\/}})\index{proper-p-instructionp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  definedp-p-data-segment-implies-listp-generalized \\ \index{definedp-p-data-segment-implies!-listp-generalized}
\=\+({\rm{proper-p-data-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-data-segmentp} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\it{segment\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{name\/}}, {\it{segment\/}})))\-
\end{tabbing}

\begin{verbatim};; The lemma definedp-p-data-segment-implies-listp in p-r was definedp with
;; proper-p-statep1, which we don't use, so and a '-1' [so there are not
;; name conflicts] to the name and use proper-p-statep.  AF
\end{verbatim}\begin{tabbing}{\sc Theorem}:  definedp-p-data-segment-implies-listp-1 \\ \index{definedp-p-data-segment-implies!-listp-1}
\=\+({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{listp}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{name\/}}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})))\-
\end{tabbing}


\noindent{\sc Event}:   Disable definedp-p-data-segment-implies-listp-1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  definedp-p-data-segment-implies-litatom-generalized \\ \index{definedp-p-data-segment-implies!-litatom-generalized}
\=\+({\rm{proper-p-data-segmentp}}\,({\it{segment\/}}, {\it{p\/}})\index{proper-p-data-segmentp} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\it{segment\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{litatom}}\,({\it{name\/}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  definedp-p-data-segment-implies-litatom \\ \index{definedp-p-data-segment-implies!-litatom}
({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{definedp}) $\rightarrow$ {\rm{litatom}}\,({\it{name\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-global-preserves-p-invariant1 \\ \index{pop-global-preserves-p-invariant!1}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-global}}) $\rightarrow$ {\rm{p-invariant1}}\,({\rm{p-pop-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-global-step}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-global-preserves-p-same-signature-data-segment \\ \index{pop-global-preserves-p-same-sig!nature-data-segment}
\=\+{\bf let }\=\+{\it{new-p\/}}{\bf $\;$ be$\;\;$}{\rm{p-pop-global-step}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-pop-global-step}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}) $=$ {\tt{'}}{\tt{pop-global}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$\wedge$$\;\;\;\;${\rm{p-pop-global-okp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-pop-global-okp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{new-p\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-local-preserves-p-invariant \\ \index{push-local-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-local}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-push-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-local-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-local-preserves-p-invariant \\ \index{pop-local-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-local}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pop-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-local-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  deposit-preserves-p-invariant1 \\ \index{deposit-preserves-p-invariant1}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{deposit}}) $\rightarrow$ {\rm{p-invariant1}}\,({\rm{p-deposit-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-step}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  deposit-preserves-same-signature-data-segment \\ \index{deposit-preserves-same-signature!-data-segment}
\=\+{\bf let }\=\+{\it{new-p\/}}{\bf $\;$ be$\;\;$}{\rm{p-deposit-step}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-deposit-step}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}) $=$ {\tt{'}}{\tt{deposit}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$\wedge$$\;\;\;\;${\rm{p-deposit-okp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-deposit-okp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{new-p\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add1-nat-preserves-p-invariant \\ \index{add1-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add1-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-add1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add-addr-preserves-p-invariant \\ \index{add-addr-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-addr}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-add-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-addr-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add-nat-with-carry-preserves-p-invariant \\ \index{add-nat-with-carry-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-nat-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-add-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-with-carry-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  mult2-nat-with-carry-out-preserves-p-invariant \\ \index{mult2-nat-with-carry-out-preserve!s-p-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{mult2-nat-with-carry-out}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-mult2-nat-with-carry-out-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-with-carry-out-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fetch-temp-stk-preserves-p-invariant \\ \index{fetch-temp-stk-preserves-p-inva!riant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{fetch-temp-stk}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-fetch-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-temp-stk-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  deposit-temp-stk-preserves-p-invariant \\ \index{deposit-temp-stk-preserves-p-inv!ariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{deposit-temp-stk}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-deposit-temp-stk-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-deposit-temp-stk-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop*-preserves-p-invariant \\ \index{pop*-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop*}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pop*-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop*-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  popn-preserves-p-invariant \\ \index{popn-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{popn}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-popn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popn-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}


\begin{verbatim}; For what it's worth, this concludes the so-called "test section"
; of instructions identified as interesting in the case of the
; one-way-correspondence proof.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  set-local-preserves-p-invariant \\ \index{set-local-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{set-local}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-set-local-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-local-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  set-global-preserves-p-invariant1 \\ \index{set-global-preserves-p-invariant!1}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{set-global}}) $\rightarrow$ {\rm{p-invariant1}}\,({\rm{p-set-global-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-set-global-step}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  set-global-preserves-same-signature-data-segment \\ \index{set-global-preserves-same-signat!ure-data-segment}
\=\+{\bf let }\=\+{\it{new-p\/}}{\bf $\;$ be$\;\;$}{\rm{p-set-global-step}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-set-global-step}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}) $=$ {\tt{'}}{\tt{set-global}}) \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} \\ 
$\wedge$$\;\;\;\;${\rm{p-set-global-okp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-set-global-okp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{new-p\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-constant-preserves-p-invariant \\ \index{push-constant-preserves-p-invari!ant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-constant}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-push-constant-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-constant-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-ctrl-stk-free-size-preserves-p-invariant \\ \index{push-ctrl-stk-free-size-preserve!s-p-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-ctrl-stk-free-size}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-push-ctrl-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-ctrl-stk-free-size-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-temp-stk-free-size-preserves-p-invariant \\ \index{push-temp-stk-free-size-preserve!s-p-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-temp-stk-free-size}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-push-temp-stk-free-size-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-free-size-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  push-temp-stk-index-preserves-p-invariant \\ \index{push-temp-stk-index-preserves-p!-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{push-temp-stk-index}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-push-temp-stk-index-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-push-temp-stk-index-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-preserves-p-invariant \\ \index{pop-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pop-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  jump-preserves-p-invariant \\ \index{jump-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pushj-preserves-p-invariant \\ \index{pushj-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pushj}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pushj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pushj-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  popj-preserves-p-invariant \\ \index{popj-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{popj}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-popj-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-popj-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub-addr-preserves-p-invariant \\ \index{sub-addr-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-addr}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-sub-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-addr-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  eq-preserves-p-invariant \\ \index{eq-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{eq}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-eq-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-eq-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lt-addr-preserves-p-invariant \\ \index{lt-addr-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-addr}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-lt-addr-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-addr-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  fetch-preserves-p-invariant \\ \index{fetch-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{fetch}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-fetch-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-fetch-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add-int-preserves-p-invariant \\ \index{add-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-add-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add-int-with-carry-preserves-p-invariant \\ \index{add-int-with-carry-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-int-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-add-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-int-with-carry-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add1-int-preserves-p-invariant \\ \index{add1-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add1-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-add1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add1-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub-int-preserves-p-invariant \\ \index{sub-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-sub-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub-int-with-carry-preserves-p-invariant \\ \index{sub-int-with-carry-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-int-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-sub-int-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-int-with-carry-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub1-int-preserves-p-invariant \\ \index{sub1-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub1-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-sub1-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  neg-int-preserves-p-invariant \\ \index{neg-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{neg-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-neg-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-neg-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lt-int-preserves-p-invariant \\ \index{lt-int-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-int}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-lt-int-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-int-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  int-to-nat-preserves-p-invariant \\ \index{int-to-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{int-to-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-int-to-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-int-to-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  add-nat-preserves-p-invariant \\ \index{add-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{add-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-add-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-add-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub-nat-preserves-p-invariant \\ \index{sub-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-sub-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub-nat-with-carry-preserves-p-invariant \\ \index{sub-nat-with-carry-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub-nat-with-carry}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-sub-nat-with-carry-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub-nat-with-carry-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sub1-nat-preserves-p-invariant \\ \index{sub1-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{sub1-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-sub1-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-sub1-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lt-nat-preserves-p-invariant \\ \index{lt-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lt-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-lt-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lt-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  mult2-nat-preserves-p-invariant \\ \index{mult2-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{mult2-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-mult2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-mult2-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  div2-nat-preserves-p-invariant \\ \index{div2-nat-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{div2-nat}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-div2-nat-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-div2-nat-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  or-bitv-preserves-p-invariant \\ \index{or-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{or-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-or-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  and-bitv-preserves-p-invariant \\ \index{and-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{and-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-and-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-bitv-preserves-p-invariant \\ \index{not-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{not-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-not-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  xor-bitv-preserves-p-invariant \\ \index{xor-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{xor-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-xor-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-xor-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  rsh-bitv-preserves-p-invariant \\ \index{rsh-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{rsh-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-rsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-rsh-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lsh-bitv-preserves-p-invariant \\ \index{lsh-bitv-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{lsh-bitv}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-lsh-bitv-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-lsh-bitv-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  or-bool-preserves-p-invariant \\ \index{or-bool-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{or-bool}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-or-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-or-bool-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  and-bool-preserves-p-invariant \\ \index{and-bool-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{and-bool}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-and-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-and-bool-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-bool-preserves-p-invariant \\ \index{not-bool-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{not-bool}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-not-bool-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-not-bool-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  jump-if-temp-stk-full-preserves-p-invariant \\ \index{jump-if-temp-stk-full-preserves!-p-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-if-temp-stk-full}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-jump-if-temp-stk-full-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-full-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  jump-if-temp-stk-empty-preserves-p-invariant \\ \index{jump-if-temp-stk-empty-preserve!s-p-invariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-if-temp-stk-empty}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-jump-if-temp-stk-empty-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-if-temp-stk-empty-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  test-nat-and-jump-preserves-p-invariant \\ \index{test-nat-and-jump-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-nat-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-test-nat-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-nat-and-jump-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  test-int-and-jump-preserves-p-invariant \\ \index{test-int-and-jump-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-int-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-test-int-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-int-and-jump-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  test-bool-and-jump-preserves-p-invariant \\ \index{test-bool-and-jump-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-bool-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-test-bool-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bool-and-jump-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  test-bitv-and-jump-preserves-p-invariant \\ \index{test-bitv-and-jump-preserves-p-i!nvariant}
\=\+({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{test-bitv-and-jump}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{p-invariant}}\,({\rm{p-test-bitv-and-jump-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-test-bitv-and-jump-step}, {\it{p\/}})\index{p-invariant}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-locn-preserves-p-invariant \\ \index{pop-locn-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-locn}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pop-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-locn-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  locn-preserves-p-invariant \\ \index{locn-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{locn}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-locn-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-locn-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  jump-case-preserves-p-invariant \\ \index{jump-case-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{jump-case}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-jump-case-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-jump-case-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  call-preserves-p-invariant \\ \index{call-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{call}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-call-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  pop-call-preserves-p-invariant \\ \index{pop-call-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{pop-call}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-pop-call-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-pop-call-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  ret-preserves-p-invariant \\ \index{ret-preserves-p-invariant}
({\rm{car}}\,({\it{ins\/}}) $=$ {\tt{'}}{\tt{ret}}) $\rightarrow$ {\rm{p-invariant}}\,({\rm{p-ret-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ret-step}, {\it{p\/}})\index{p-invariant}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-invariant-p-invariant1 \\ \index{p-invariant-p-invariant1}
{\rm{p-invariant}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant} $\rightarrow$ {\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-step2-preserves-p-invariant1 \\ \index{p-ins-step2-preserves-p-invaria!nt1}
{\rm{p-invariant1}}\,({\rm{p-ins-step2}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step2}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-step-preserves-p-invariant1 \\ \index{p-ins-step-preserves-p-invariant!1}
{\rm{p-invariant1}}\,({\rm{p-ins-step}}\,({\it{ins\/}}, {\it{p\/}})\index{p-ins-step}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}


\noindent{\sc Event}:   Disable p-invariant-p-invariant1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-invariant1-reflexive \\ \index{p-invariant1-reflexive}
{\rm{p-invariant1}}\,({\it{p\/}}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-invariant1-p-halt \\ \index{p-invariant1-p-halt}
\=\+({\rm{p-invariant1}}\,({\it{p0\/}}, {\rm{p-halt}}\,({\it{p1\/}}, {\it{error-message\/}})\index{p-halt})\index{p-invariant1} $=$ {\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-invariant1}}\,({\rm{p-halt}}\,({\it{p0\/}}, {\it{error-message\/}})\index{p-halt}, {\it{p1\/}})\index{p-invariant1} $=$ {\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-step-preserves-p-invariant1 \\ \index{p-step-preserves-p-invariant1}
{\rm{p-invariant1}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  transitivity-of-p-invariant1 \\ \index{transitivity-of-p-invariant1}
({\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant1} $\wedge$ {\rm{p-invariant1}}\,({\it{p1\/}}, {\it{p2\/}})\index{p-invariant1}) $\rightarrow$ {\rm{p-invariant1}}\,({\it{p0\/}}, {\it{p2\/}})\index{p-invariant1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-preserves-p-invariant1 \\ \index{p-preserves-p-invariant1}
{\rm{p-invariant1}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p}, {\it{p\/}})\index{p-invariant1}
\end{tabbing}


\noindent{\sc Event}:   Disable transitivity-of-p-invariant1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-preserves-p-resources \\ \index{p-preserves-p-resources}
\=\+({\rm{p-prog-segment}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-prog-segment} $=$ {\rm{p-prog-segment}}\,({\it{p\/}})\index{p-prog-segment}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-ctrl-stk-size}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-max-ctrl-stk-size} $=$ {\rm{p-max-ctrl-stk-size}}\,({\it{p\/}})\index{p-max-ctrl-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-max-temp-stk-size}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-max-temp-stk-size} $=$ {\rm{p-max-temp-stk-size}}\,({\it{p\/}})\index{p-max-temp-stk-size}) \\ 
$\wedge$$\;\;\;\;$({\rm{p-word-size}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-word-size} $=$ {\rm{p-word-size}}\,({\it{p\/}})\index{p-word-size})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-invariant-same-signature-data-segments \\ \index{p-invariant-same-signature-data!-segments}
\=\+{\rm{p-invariant}}\,({\it{p0\/}}, {\it{p1\/}})\index{p-invariant} \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{p0\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p1\/}})\index{p-data-segment})\index{same-signature}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-step2-preserves-same-signature-data-segment \\ \index{p-ins-step2-preserves-same-sign!ature-data-segment}
\=\+{\bf let }\=\+{\it{new-p\/}}{\bf $\;$ be$\;\;$}{\rm{p-ins-step2}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-ins-step2}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{p-ins-okp2}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-ins-okp2} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\it{new-p\/}})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-ins-step-preserves-same-signature-data-segment \\ \index{p-ins-step-preserves-same-signat!ure-data-segment}
\=\+(\=\+({\rm{p-psw}}\,({\it{p\/}})\index{p-psw} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{p-ins-okp}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-ins-okp} \\ 
$\wedge$$\;\;\;\;${\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,(\=\+{\rm{p-data-segment}}\,({\rm{p-ins-step}}\,({\rm{p-current-instruction}}\,({\it{p\/}})\index{p-current-instruction}, {\it{p\/}})\index{p-ins-step})\index{p-data-segment}, \\ 
{\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\-\index{same-signature}\-
\end{tabbing}


\noindent{\sc Event}:   Disable p-invariant-same-signature-data-segments.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  p-step-preserves-same-signature-data-segment \\ \index{p-step-preserves-same-signature!-data-segment}
\=\+({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step})\index{p-psw})\index{errorp})) \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\rm{p-step}}\,({\it{p\/}})\index{p-step})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  p-preserves-same-signature-data-segment \\ \index{p-preserves-same-signature-data!-segment}
\=\+({\rm{proper-p-statep}}\,({\it{p\/}})\index{proper-p-statep} $\wedge$ ($\neg$ {\rm{errorp}}\,({\rm{p-psw}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-psw})\index{errorp})) \\ 
$\rightarrow$$\;\;\;\;${\rm{same-signature}}\,({\rm{p-data-segment}}\,({\rm{p}}\,({\it{p\/}}, {\it{n\/}})\index{p})\index{p-data-segment}, {\rm{p-data-segment}}\,({\it{p\/}})\index{p-data-segment})\index{same-signature}\-
\end{tabbing}

\begin{verbatim};; Finally enable the Piton -okp and -step functions, we want them for later.
\end{verbatim}
\noindent{\sc Event}:   Enable p-call-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-call-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-ret-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-ret-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-locn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-locn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-constant-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-constant-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-ctrl-stk-free-size-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-ctrl-stk-free-size-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-temp-stk-free-size-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-temp-stk-free-size-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-temp-stk-index-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-push-temp-stk-index-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-if-temp-stk-full-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-if-temp-stk-full-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-if-temp-stk-empty-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-if-temp-stk-empty-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop*-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop*-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-popn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-popn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-locn-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-locn-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-call-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pop-call-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-fetch-temp-stk-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-fetch-temp-stk-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-deposit-temp-stk-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-deposit-temp-stk-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-case-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-jump-case-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pushj-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-pushj-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-popj-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-popj-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-set-local-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-set-local-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-set-global-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-set-global-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-nat-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-nat-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-int-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-int-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-bool-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-bool-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-bitv-and-jump-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-test-bitv-and-jump-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-no-op-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-no-op-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-eq-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-eq-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-addr-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-addr-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-fetch-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-fetch-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-deposit-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-deposit-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-int-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-int-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add1-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add1-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-int-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-int-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub1-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub1-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-neg-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-neg-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-int-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-int-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-int-to-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-int-to-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-nat-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add-nat-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add1-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-add1-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-nat-with-carry-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub-nat-with-carry-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub1-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-sub1-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lt-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-mult2-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-mult2-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-mult2-nat-with-carry-out-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-mult2-nat-with-carry-out-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-div2-nat-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-div2-nat-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-or-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-or-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-and-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-and-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-not-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-not-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-xor-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-xor-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-rsh-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-rsh-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lsh-bitv-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-lsh-bitv-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-or-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-or-bool-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-and-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-and-bool-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-not-bool-okp.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-not-bool-step.

\addvspace{18pt}


\noindent{\sc Event}:   Enable p-ins-step.

\addvspace{18pt}

\noindent{\sc Event}:   Enable p-ins-okp.

\addvspace{18pt}

\begin{verbatim}; ------------------------------------------------------------
; was l-.events
; ------------------------------------------------------------

;;; This is a prototype compiler for the Logic.  Right now we only include
;;; CONS, CAR, CDR, LISTP and TRUE and TRUEP.  (Also Quote).

;; Functions to test compiler:
;; -------------------------------------------------------------------------
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{app} \\  
\=\+{\rm{app}}\,({\it{x\/}}, {\it{y\/}})\index{app} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{cons}}\,({\rm{car}}\,({\it{x\/}}), {\rm{app}}\,({\rm{cdr}}\,({\it{x\/}}), {\it{y\/}})\index{app}) \\ 
{\bf else }{\it{y\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{rev} \\  
\=\+{\rm{rev}}\,({\it{x\/}})\index{rev} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{app}}\,({\rm{rev}}\,({\rm{cdr}}\,({\it{x\/}}))\index{rev}, {\rm{list}}\,({\rm{car}}\,({\it{x\/}})))\index{app} \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{frev} \\  
\=\+{\rm{frev}}\,({\it{x\/}}, {\it{y\/}})\index{frev} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }{\rm{frev}}\,({\rm{cdr}}\,({\it{x\/}}), {\rm{cons}}\,({\rm{car}}\,({\it{x\/}}), {\it{y\/}}))\index{frev} \\ 
{\bf else }{\it{y\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; -------------------------------------------------------------------------
;; End functions for testing

;; Returns a list containing the value or F.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{l-eval} \\  
\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clk\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{car}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval}, \\ 
{\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{clk\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{litatom}}\,({\it{expr\/}})$\;\;${\bf then }{\rm{list}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{expr\/}}, {\it{alist\/}}))) \\ 
{\bf elseif }{\it{expr\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{list}}\,({\it{expr\/}}) \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\rm{list}}\,({\rm{cadr}}\,({\it{expr\/}})) \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{l-eval}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\it{test\/}} \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\it{test\/}})$\;\;${\bf then }{\rm{l-eval}}\,({\bf{t}}, {\rm{caddr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval} \\ 
{\bf else }{\rm{l-eval}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }{\bf{f}} $\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval}$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{subrp}}\,({\rm{car}}\,({\it{expr\/}})) \\ 
{\bf then }{\rm{list}}\,({\rm{apply-subr}}\,(\=\+{\rm{car}}\,({\it{expr\/}}), \\ 
{\rm{strip-cars}}\,({\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clk\/}})\index{l-eval}))\-) \\ 
{\bf else }{\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{body}}\,({\rm{car}}\,({\it{expr\/}})), \\ 
{\rm{pairlist}}\,(\=\+{\rm{formals}}\,({\rm{car}}\,({\it{expr\/}})), \\ 
{\rm{strip-cars}}\,({\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{expr\/}}), \\ 
{\it{alist\/}}, \\ 
{\it{clk\/}})\-\index{l-eval}))\-, \\ 
{\it{clk\/}} $-\;1$)\-\index{l-eval}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{remove-costs} \\  
\=\+{\rm{remove-costs}}\,({\it{list\/}})\index{remove-costs} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{list\/}})$\;\;${\bf then }{\rm{cons}}\,({\rm{list}}\,({\rm{caar}}\,({\it{list\/}})), {\rm{remove-costs}}\,({\rm{cdr}}\,({\it{list\/}}))\index{remove-costs}) \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  strip-cars-remove-costs \\ \index{strip-cars-remove-costs}
{\rm{strip-cars}}\,({\rm{remove-costs}}\,({\it{l\/}})\index{remove-costs}) $=$ {\rm{strip-cars}}\,({\it{l\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-strip-cars-definedp \\ \index{member-strip-cars-definedp}
({\it{x\/}} $\in$ {\rm{strip-cars}}\,({\it{y\/}})) $=$ {\rm{definedp}}\,({\it{x\/}}, {\it{y\/}})\index{definedp}
\end{tabbing}


\noindent{\sc Event}:   Disable member-strip-cars-definedp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  member-plist \\ \index{member-plist}
({\it{x\/}} $\in$ {\rm{plist}}\,({\it{y\/}})\index{plist}) $=$ ({\it{x\/}} $\in$ {\it{y\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  car-assoc \\ \index{car-assoc}
{\rm{definedp}}\,({\it{x\/}}, {\it{y\/}})\index{definedp} $\rightarrow$ ({\rm{car}}\,({\rm{assoc}}\,({\it{x\/}}, {\it{y\/}})) $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  v\&c\$-l-eval-equivalence \\ \index{v\&c\$-l-eval-equivalence}
\=\+(\=\+(({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\bf{f}} $\not\in$ {\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval})) \\ 
$\vee$$\;\;\;\;$(({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval} $\not=$ {\bf{f}})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}}$\;\;${\bf then }{\rm{remove-costs}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))\index{remove-costs} \\ 
{\bf else }{\rm{list}}\,({\rm{car}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})))$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\bf{f}} $\not\in$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))) \\ 
$\vee$$\;\;\;\;$(({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}) $\not=$ {\bf{f}})))\-)\-\-
\end{tabbing}


\begin{tabbing}{\sc Theorem}:  cdr-v\&c\$-lessp-if-cadr \\ \index{cdr-v\&c\$-lessp-if-cadr}
\=\+{\rm{v\&c-apply\$}}\,({\tt{'}}{\tt{if}}, {\rm{cons}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}})) \\ 
$<$$\;\;\;\;${\rm{cdr}}\,({\rm{v\&c-apply\$}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{cons}}\,(\=\+{\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), \\ 
{\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))\-)\-))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cdr-v\&c\$-lessp-if-caddr \\ \index{cdr-v\&c\$-lessp-if-caddr}
\=\+(\=\+{\rm{v\&c-apply\$}}\,({\tt{'}}{\tt{if}}, {\rm{cons}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))) \\ 
$\wedge$$\;\;\;\;${\rm{car}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\rm{car}}\,({\it{branches\/}}), {\it{alist\/}})) \\ 
$<$$\;\;\;\;${\rm{cdr}}\,({\rm{v\&c-apply\$}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{cons}}\,(\=\+{\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), \\ 
{\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))\-)\-))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cdr-v\&c\$-lessp-if-cadddr \\ \index{cdr-v\&c\$-lessp-if-cadddr}
\=\+(\=\+{\rm{v\&c-apply\$}}\,({\tt{'}}{\tt{if}}, {\rm{cons}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{car}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}))))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{branches\/}}), {\it{alist\/}})) \\ 
$<$$\;\;\;\;${\rm{cdr}}\,({\rm{v\&c-apply\$}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{cons}}\,(\=\+{\rm{v\&c\$}}\,({\bf{t}}, {\it{test\/}}, {\it{alist\/}}), \\ 
{\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{branches\/}}, {\it{alist\/}}))\-)\-))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  v\&c\$-f-l-eval-f-if-helper-1 \\ \index{v\&c\$-f-l-eval-f-if-helper-1}
\=\+(\=\+({\it{clock\/}} $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{expr\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;${\rm{l-eval}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{v\&c-apply\$}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{cons}}\,(\=\+{\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}), \\ 
{\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\rm{cddr}}\,({\it{expr\/}}), {\it{alist\/}}))\-)\-) \\ 
$\wedge$$\;\;\;\;${\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval}) \\ 
$\wedge$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\rm{caddr}}\,({\it{expr\/}}), {\it{alist\/}}))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{l-eval}}\,({\bf{t}}, {\rm{caddr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval})\-
\end{tabbing}


\noindent{\sc Event}:   Disable v\&c\$-f-l-eval-f-if-helper-1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  v\&c\$-f-l-eval-f-if-helper-2 \\ \index{v\&c\$-f-l-eval-f-if-helper-2}
\=\+(\=\+({\it{clock\/}} $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{expr\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;${\rm{l-eval}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{v\&c-apply\$}}\,(\=\+{\tt{'}}{\tt{if}}, \\ 
{\rm{cons}}\,(\=\+{\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}), \\ 
{\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\rm{cddr}}\,({\it{expr\/}}), {\it{alist\/}}))\-)\-) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval})) \\ 
$\wedge$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{expr\/}}), {\it{alist\/}}))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{l-eval}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{expr\/}}), {\it{alist\/}}, {\it{clock\/}})\index{l-eval})\-
\end{tabbing}


\noindent{\sc Event}:   Disable v\&c\$-f-l-eval-f-if-helper-2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  v\&c\$-f-l-eval-flag-list \\ \index{v\&c\$-f-l-eval-flag-list}
\=\+({\bf{f}} $\not\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{strip-cars}}\,({\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}})) \\ 
$=$$\;\;\;\;${\rm{strip-cars}}\,({\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval}))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable v\&c\$-f-l-eval-flag-list.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  v\&c\$-f-l-eval-f \\ \index{v\&c\$-f-l-eval-f}
\=\+(\=\+(({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\bf{f}} $\in$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))) \\ 
$\vee$$\;\;\;\;$(({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}) $=$ {\bf{f}})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\bf{f}} $\in$ {\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval})) \\ 
$\vee$$\;\;\;\;$(({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval} $=$ {\bf{f}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-v\&c\$-flag-not-list \\ \index{l-eval-v\&c\$-flag-not-list}
\=\+(($\neg$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})) $\wedge$ ({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval} $=$ {\bf{f}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable l-eval-v\&c\$-flag-not-list.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  l-eval-v\&c\$-flag-list \\ \index{l-eval-v\&c\$-flag-list}
\=\+({\bf{f}} $\in$ {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}})) \\ 
$\rightarrow$$\;\;\;\;$({\bf{f}} $\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  v\&c\$-l-eval-flag-list \\ \index{v\&c\$-l-eval-flag-list}
\=\+({\bf{f}} $\not\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval}) \\ 
$\rightarrow$$\;\;\;\;$({\bf{f}} $\not\in$ {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{alist\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-f-v\&c\$-fact-1 \\ \index{member-f-v\&c\$-fact-1}
\=\+(\=\+{\rm{listp}}\,({\it{expr\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\bf{f}} $\in$ {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}), {\it{alist\/}})) \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  sum-cdrs-v\&c\$-list-fact-1 \\ \index{sum-cdrs-v\&c\$-list-fact-1}
\=\+(\=\+{\rm{v\&c-apply\$}}\,({\it{fun\/}}, {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{arg-list\/}}, {\it{alist\/}})) \\ 
$\wedge$$\;\;\;\;$({\it{fun\/}} $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$({\it{fun\/}} $\not=$ {\tt{'}}{\tt{if}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{sum-cdrs}}\,({\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{arg-list\/}}, {\it{alist\/}})) \\ 
$<$$\;\;\;\;${\rm{cdr}}\,({\rm{v\&c-apply\$}}\,({\it{fun\/}}, {\rm{v\&c\$}}\,({\tt{'}}{\tt{list}}, {\it{arg-list\/}}, {\it{alist\/}}))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subrp-expr-v\&c-apply\$ \\ \index{subrp-expr-v\&c-apply\$}
\=\+({\rm{subrp}}\,({\it{x\/}}) $\wedge$ ({\it{x\/}} $\not=$ {\tt{'}}{\tt{if}}) $\wedge$ ({\bf{f}} $\not\in$ {\it{args\/}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{car}}\,({\rm{v\&c-apply\$}}\,({\it{x\/}}, {\it{args\/}})) $=$ {\rm{apply-subr}}\,({\it{x\/}}, {\rm{strip-cars}}\,({\it{args\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-subrp-expr-v\&c-apply\$ \\ \index{not-subrp-expr-v\&c-apply\$}
\=\+(($\neg$ {\rm{subrp}}\,({\it{x\/}})) $\wedge$ ({\bf{f}} $\not\in$ {\it{args\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{car}}\,({\rm{v\&c-apply\$}}\,({\it{x\/}}, {\it{args\/}})) \\ 
$=$$\;\;\;\;${\rm{car}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\rm{body}}\,({\it{x\/}}), {\rm{pairlist}}\,({\rm{formals}}\,({\it{x\/}}), {\rm{strip-cars}}\,({\it{args\/}})))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  v\&c\$-body-lessp-fact-1 \\ \index{v\&c\$-body-lessp-fact-1}
\=\+(($\neg$ {\rm{subrp}}\,({\it{fun\/}})) $\wedge$ {\rm{v\&c-apply\$}}\,({\it{fun\/}}, {\it{args\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{cdr}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\rm{body}}\,({\it{fun\/}}), {\rm{pairlist}}\,({\rm{formals}}\,({\it{fun\/}}), {\rm{strip-cars}}\,({\it{args\/}})))) \\ 
$<$$\;\;\;\;${\rm{cdr}}\,({\rm{v\&c-apply\$}}\,({\it{fun\/}}, {\it{args\/}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  v\&c\$-not-subrp-expand-1 \\ \index{v\&c\$-not-subrp-expand-1}
\=\+({\rm{v\&c-apply\$}}\,({\it{fun\/}}, {\it{args\/}}) $\wedge$ ($\neg$ {\rm{subrp}}\,({\it{fun\/}}))) \\ 
$\rightarrow$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\rm{body}}\,({\it{fun\/}}), {\rm{pairlist}}\,({\rm{formals}}\,({\it{fun\/}}), {\rm{strip-cars}}\,({\it{args\/}})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-member-remove-costs \\ \index{not-member-remove-costs}
($\neg$ {\rm{listp}}\,({\it{x\/}})) $\rightarrow$ ({\it{x\/}} $\not\in$ {\rm{remove-costs}}\,({\it{list\/}})\index{remove-costs})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-not-f-v\&c\$-equivalence \\ \index{l-eval-not-f-v\&c\$-equivalence}
\=\+(\=\+(\=\+({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) \\ 
$\wedge$$\;\;\;\;$({\bf{f}} $\not\in$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{sum-cdrs}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})) $<$ {\it{clock\/}}))\- \\ 
$\vee$$\;\;\;\;$(\=\+({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) \\ 
$\wedge$$\;\;\;\;$({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}) $\not=$ {\bf{f}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cdr}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})) $<$ {\it{clock\/}}))\-)\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}}$\;\;${\bf then }{\rm{remove-costs}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))\index{remove-costs} \\ 
{\bf else }{\rm{list}}\,({\rm{car}}\,({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}})))$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+(({\it{flag\/}} $=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\bf{f}} $\not\in$ {\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}))) \\ 
$\vee$$\;\;\;\;$(({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\rm{v\&c\$}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{alist\/}}) $\not=$ {\bf{f}})))\-)\-\-
\end{tabbing}


\begin{verbatim}; ------------------------------------------------------------
; was s-eval1.events
; ------------------------------------------------------------

\end{verbatim}
\noindent{\sc Event}:   Disable pack-equal.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{number-cons} \\  
\=\+{\rm{number-cons}}\,({\it{x\/}})\index{number-cons} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }$1\;+$ ({\rm{number-cons}}\,({\rm{car}}\,({\it{x\/}}))\index{number-cons} $+$ {\rm{number-cons}}\,({\rm{cdr}}\,({\it{x\/}}))\index{number-cons}) \\ 
{\bf else }{\tt{0}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  number-cons-car \\ \index{number-cons-car}
{\rm{listp}}\,({\it{x\/}}) $\rightarrow$ ({\rm{number-cons}}\,({\rm{car}}\,({\it{x\/}}))\index{number-cons} $<$ {\rm{number-cons}}\,({\it{x\/}})\index{number-cons})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  number-cons-cdr \\ \index{number-cons-cdr}
{\rm{listp}}\,({\it{x\/}}) $\rightarrow$ ({\rm{number-cons}}\,({\rm{cdr}}\,({\it{x\/}}))\index{number-cons} $<$ {\rm{number-cons}}\,({\it{x\/}})\index{number-cons})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  number-cons-cadr-caddr-cadddr \\ \index{number-cons-cadr-caddr-cadddr}
\=\+{\rm{listp}}\,({\it{x\/}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{number-cons}}\,({\rm{cadr}}\,({\it{x\/}}))\index{number-cons} $<$ {\rm{number-cons}}\,({\it{x\/}})\index{number-cons}) \\ 
$\wedge$$\;\;\;\;$({\rm{number-cons}}\,({\rm{caddr}}\,({\it{x\/}}))\index{number-cons} $<$ {\rm{number-cons}}\,({\it{x\/}})\index{number-cons}) \\ 
$\wedge$$\;\;\;\;$({\rm{number-cons}}\,({\rm{cadddr}}\,({\it{x\/}}))\index{number-cons} $<$ {\rm{number-cons}}\,({\it{x\/}})\index{number-cons}))\-\-
\end{tabbing}

\begin{verbatim};; ***** The S-level (S for Subexpression).  *****
;; This level is somewhat similar to the logic.  Quoted constants are now
;; looked up in a global alist.
;; An S-STATE has eight components.
;; S-PNAME:  the name of the program currently being executed
;; S-POS:    the "position" of the expression currently being evaluated.
;; S-ANS:    the answer
;; S-PARAMS: an alist with entries of form (<parameter name> . <value>)
;; S-TEMPS:  an alist with entries of form (<expr> <flag> <value>)
;; S-PROGS: an alist with entires of form
;;          (<program name> <formals> <temps> <body>)
;; S-ERR-FLAG: A flag that should be 'RUN, otherwise it means we terminated
;;             with an error.
;; S-PNAME names the current program, S-POS denotes the position.
;; The position is a list of integers that uniquely determines the
;; current sub-expression.
;; An example in the list:
;;   (a b (c d (f g) (h (i j) k l m)))
;; the position (2 2) denotes the list (f g).
;; 
;; The expression and the bodies of the programs (S-PROGS) are
;; slightly different from the logic.
;; Parameters (entries in S-PARAMS) appear as LITATOMs (i.e. they
;; are not changed).
;; Entries in S-TEMPS are triples, the CAR is the expression,
;; the CADR is a boolean flag, if T it means that the CADDR is the value
;; of the expression, otherwise the CADDR is undefined.
;; There are 3 forms that effect or are effected by S-TEMPS.  The CAR of
;; each of these forms is a singleton list, with one of the values:
;; TEMP-EVAL, TEMP-FETCH, or TEMP-TEST.
;; All these forms should have an expression as the only argument
;; (called EXP below).

;; TEMP-EVAL:  if the flag corresoponding to EXP in S-TEMPS is not F,
;;             set S-ERR-FLAG to an error and return, otherwise evaluate
;;             EXP and put it and the value into S-TEMPS and set the flag.
;; TEMP-FETCH: if the flag corresponding to EXP in S-TEMPS is set returns
;;             the value associated with EXP, otherwise sets S-ERR-FLAG
;;             to an error.
;; TEMP-TEST:  if the flag corresponding to EXP in S-TEMPS is set
;;             returns the value associated with EXP, otherwise evaluate
;;             EXP and put it and the value into S-TEMPS, setting the flag.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{s-temp-eval}$\;\;$
{\sc{s-temp-eval}}\index{s-temp-eval} $=$ {\tt{'}}{\tt{(}}{\tt{temp-eval}}{\tt{)}}
\end{tabbing}
\begin{tabbing}{\sc Definition}:\index{s-temp-fetch}$\;\;$
{\sc{s-temp-fetch}}\index{s-temp-fetch} $=$ {\tt{'}}{\tt{(}}{\tt{temp-fetch}}{\tt{)}}
\end{tabbing}
\begin{tabbing}{\sc Definition}:\index{s-temp-test}$\;\;$
{\sc{s-temp-test}}\index{s-temp-test} $=$ {\tt{'}}{\tt{(}}{\tt{temp-test}}{\tt{)}}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-temp-setp}$\;\;$
{\rm{s-temp-setp}}\,({\it{expr\/}}, {\it{temps\/}})\index{s-temp-setp} $=$ {\rm{cadr}}\,({\rm{assoc}}\,({\it{expr\/}}, {\it{temps\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable s-temp-setp.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-temp-value}$\;\;$
{\rm{s-temp-value}}\,({\it{expr\/}}, {\it{temps\/}})\index{s-temp-value} $=$ {\rm{caddr}}\,({\rm{assoc}}\,({\it{expr\/}}, {\it{temps\/}}))
\end{tabbing}


\noindent{\sc Event}:   Add the shell {\it{s-state\/}}\index{s-state}, with recognizer function symbol {\it{s-statep\/}} and 7 accessors: {\it{s-pname\/}}, with type restriction (none-of) and default value zero; {\it{s-pos\/}}, with type restriction (none-of) and default value zero; {\it{s-ans\/}}, with type restriction (none-of) and default value zero; {\it{s-params\/}}, with type restriction (none-of) and default value zero; {\it{s-temps\/}}, with type restriction (none-of) and default value zero; {\it{s-progs\/}}, with type restriction (none-of) and default value zero; {\it{s-err-flag\/}}, with type restriction (none-of) and default value zero.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{cur-expr} \\  
\=\+{\rm{cur-expr}}\,({\it{position\/}}, {\it{expr\/}})\index{cur-expr} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{position\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{expr\/}} \\ 
{\bf else }{\rm{cur-expr}}\,({\rm{cdr}}\,({\it{position\/}}), {\rm{get}}\,({\rm{car}}\,({\it{position\/}}), {\it{expr\/}})\index{get})\index{cur-expr}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{butlast}$\;\;$
{\rm{butlast}}\,({\it{list\/}})\index{butlast} $=$ {\rm{firstn}}\,({\rm{length}}\,({\it{list\/}})\index{length} $-\;1$, {\it{list\/}})\index{firstn}
\end{tabbing}


\noindent{\sc Event}:   Disable butlast.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{last} \\  
\=\+{\rm{last}}\,({\it{l\/}})\index{last} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{l\/}}))$\;\;${\bf then }{\rm{last}}\,({\rm{cdr}}\,({\it{l\/}}))\index{last} \\ 
{\bf else }{\it{l\/}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{dv}$\;\;$
{\rm{dv}}\,({\it{pos\/}}, {\it{increment\/}})\index{dv} $=$ {\rm{append}}\,({\it{pos\/}}, {\rm{list}}\,({\it{increment\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable dv.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{nx} \\  
{\rm{nx}}\,({\it{pos\/}})\index{nx} $=$ {\rm{append}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\rm{list}}\,($1\;+$ {\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last})))
\end{tabbing}


\noindent{\sc Event}:   Disable nx.

\addvspace{18pt}

\begin{verbatim};; We prepend all user names with U-.  This is to avoid name conflicts.
;; We used to just make sure the main program was not one of the names
;; specified to LOGIC->S (by using GENSYM).  However we needed to know that
;; it was not a SUBRP.  This made the correctness theorem almost useless,
;; because it had an hypothesis of the form:
;;   (not (subrp (car (gensym (unpack 'main) nil pnames))))
;; This could not in general be reduced.  Also we will probably need to have
;; our own functions.  The names of these functions should start with I-.
;; U- is for User, I- for Internal.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{user-fname-prefix} \\  
{\sc{user-fname-prefix}}\index{user-fname-prefix} $=$ {\rm{list}}\,({\rm{car}}\,({\rm{unpack}}\,({\tt{'}}{\tt{u-}})), {\rm{cadr}}\,({\rm{unpack}}\,({\tt{'}}{\tt{u-}})))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{user-fname} \\  
{\rm{user-fname}}\,({\it{name\/}})\index{user-fname} $=$ {\rm{pack}}\,({\rm{append}}\,({\sc{user-fname-prefix}}\index{user-fname-prefix}, {\rm{unpack}}\,({\it{name\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable user-fname.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{user-fnamep} \\  
\=\+{\rm{user-fnamep}}\,({\it{name\/}})\index{user-fnamep} \\ 
$=$$\;\;\;\;$(\=\+{\rm{litatom}}\,({\it{name\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{unpack}}\,({\it{name\/}})) $=$ {\rm{car}}\,({\sc{user-fname-prefix}}\index{user-fname-prefix})) \\ 
$\wedge$$\;\;\;\;$({\rm{cadr}}\,({\rm{unpack}}\,({\it{name\/}})) $=$ {\rm{cadr}}\,({\sc{user-fname-prefix}}\index{user-fname-prefix})))\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable user-fnamep.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{logic-fname}$\;\;$
{\rm{logic-fname}}\,({\it{name\/}})\index{logic-fname} $=$ {\rm{pack}}\,({\rm{cddr}}\,({\rm{unpack}}\,({\it{name\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable logic-fname.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-formals}$\;\;$
{\rm{s-formals}}\,({\it{s-program\/}})\index{s-formals} $=$ {\rm{cadr}}\,({\it{s-program\/}})
\end{tabbing}

\noindent{\sc Event}:   Disable s-formals.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-temp-list}$\;\;$
{\rm{s-temp-list}}\,({\it{s-program\/}})\index{s-temp-list} $=$ {\rm{caddr}}\,({\it{s-program\/}})
\end{tabbing}

\noindent{\sc Event}:   Disable s-temp-list.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-body}$\;\;$
{\rm{s-body}}\,({\it{s-program\/}})\index{s-body} $=$ {\rm{cadddr}}\,({\it{s-program\/}})
\end{tabbing}

\noindent{\sc Event}:   Disable s-body.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-prog}$\;\;$
{\rm{s-prog}}\,({\it{s\/}})\index{s-prog} $=$ {\rm{definition}}\,({\rm{s-pname}}\,({\it{s\/}})\index{s-pname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{definition}
\end{tabbing}


\noindent{\sc Event}:   Disable s-prog.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-expr}$\;\;$
{\rm{s-expr}}\,({\it{s\/}})\index{s-expr} $=$ {\rm{cur-expr}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{cur-expr}
\end{tabbing}


\noindent{\sc Event}:   Disable s-expr.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-expr-list} \\  
\=\+{\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list} \\ 
$=$$\;\;\;\;${\rm{restn}}\,(\=\+{\rm{car}}\,({\rm{last}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{last}), \\ 
{\rm{cur-expr}}\,({\rm{butlast}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{butlast}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{cur-expr})\-\index{restn}\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-expr-list.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  get-anything-nil \\ \index{get-anything-nil}
($\neg$ {\rm{listp}}\,({\it{lst\/}})) $\rightarrow$ ({\rm{get}}\,({\it{anything\/}}, {\it{lst\/}})\index{get} $=$ {\tt{0}})
\end{tabbing}


\noindent{\sc Event}:   Disable get-anything-nil.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  get-cons \\ \index{get-cons}
({\it{k\/}} $\not\simeq {\tt{0}}$) $\rightarrow$ ({\rm{get}}\,({\it{k\/}}, {\rm{cons}}\,({\it{anything\/}}, {\it{list\/}}))\index{get} $=$ {\rm{get}}\,({\it{k\/}} $-\;1$, {\it{list\/}})\index{get})
\end{tabbing}


\noindent{\sc Event}:   Disable get-cons.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  get-large-index \\ \index{get-large-index}
({\it{n\/}} $\not<$ {\rm{length}}\,({\it{list\/}})\index{length}) $\rightarrow$ ({\rm{get}}\,({\it{n\/}}, {\it{list\/}})\index{get} $=$ {\tt{0}})
\end{tabbing}


\noindent{\sc Event}:   Disable get-large-index.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  get-zerop \\ \index{get-zerop}
({\it{n\/}} $\simeq {\tt{0}}$) $\rightarrow$ ({\rm{get}}\,({\it{n\/}}, {\it{list\/}})\index{get} $=$ {\rm{car}}\,({\it{list\/}}))
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-set-pos} \\  
\=\+{\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{s-pname}}\,({\it{s\/}})\index{s-pname}, \\ 
{\it{pos\/}}, \\ 
{\rm{s-ans}}\,({\it{s\/}})\index{s-ans}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\rm{s-temps}}\,({\it{s\/}})\index{s-temps}, \\ 
{\rm{s-progs}}\,({\it{s\/}})\index{s-progs}, \\ 
{\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-set-pos \\ \index{s-accessors-s-set-pos}
\=\+({\rm{s-pname}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{s\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-pos} $=$ {\it{pos\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{s\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-params} $=$ {\rm{s-params}}\,({\it{s\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-temps} $=$ {\rm{s-temps}}\,({\it{s\/}})\index{s-temps}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-err-flag} $=$ {\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-set-pos.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-set-temps} \\  
\=\+{\rm{s-set-temps}}\,({\it{state\/}}, {\it{new-temps\/}})\index{s-set-temps} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{s-pname}}\,({\it{state\/}})\index{s-pname}, \\ 
{\rm{s-pos}}\,({\it{state\/}})\index{s-pos}, \\ 
{\rm{s-ans}}\,({\it{state\/}})\index{s-ans}, \\ 
{\rm{s-params}}\,({\it{state\/}})\index{s-params}, \\ 
{\it{new-temps\/}}, \\ 
{\rm{s-progs}}\,({\it{state\/}})\index{s-progs}, \\ 
{\rm{s-err-flag}}\,({\it{state\/}})\index{s-err-flag})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-set-temps \\ \index{s-accessors-s-set-temps}
\=\+({\rm{s-pname}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{state\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-pos} $=$ {\rm{s-pos}}\,({\it{state\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{state\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-temps} $=$ {\it{temps\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-params} $=$ {\rm{s-params}}\,({\it{state\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{state\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-set-temps}}\,({\it{state\/}}, {\it{temps\/}})\index{s-set-temps})\index{s-err-flag} $=$ {\rm{s-err-flag}}\,({\it{state\/}})\index{s-err-flag})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-set-temps.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-set-error} \\  
\=\+{\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{s-pname}}\,({\it{state\/}})\index{s-pname}, \\ 
{\rm{s-pos}}\,({\it{state\/}})\index{s-pos}, \\ 
{\rm{s-ans}}\,({\it{state\/}})\index{s-ans}, \\ 
{\rm{s-params}}\,({\it{state\/}})\index{s-params}, \\ 
{\rm{s-temps}}\,({\it{state\/}})\index{s-temps}, \\ 
{\rm{s-progs}}\,({\it{state\/}})\index{s-progs}, \\ 
{\it{flag\/}})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-set-error \\ \index{s-accessors-s-set-error}
\=\+({\rm{s-pname}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{state\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-pos} $=$ {\rm{s-pos}}\,({\it{state\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{state\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-temps} $=$ {\rm{s-temps}}\,({\it{state\/}})\index{s-temps}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-params} $=$ {\rm{s-params}}\,({\it{state\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{state\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-set-error}}\,({\it{state\/}}, {\it{flag\/}})\index{s-set-error})\index{s-err-flag} $=$ {\it{flag\/}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-set-error.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-change-temp} \\  
\=\+{\rm{s-change-temp}}\,({\it{s\/}}, {\it{expr\/}}, {\it{value\/}})\index{s-change-temp} \\ 
$=$$\;\;\;\;${\rm{s-set-temps}}\,({\it{s\/}}, {\rm{put-assoc}}\,({\rm{list}}\,({\bf{t}}, {\it{value\/}}), {\it{expr\/}}, {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{put-assoc})\index{s-set-temps}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-change-temp \\ \index{s-accessors-s-change-temp}
\=\+({\rm{s-pname}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{s\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-pos} $=$ {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{s\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-params} $=$ {\rm{s-params}}\,({\it{s\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-change-temp}}\,({\it{s\/}}, {\it{e\/}}, {\it{v\/}})\index{s-change-temp})\index{s-err-flag} $=$ {\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-change-temp.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-set-ans} \\  
\=\+{\rm{s-set-ans}}\,({\it{state\/}}, {\it{ans\/}})\index{s-set-ans} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{s-pname}}\,({\it{state\/}})\index{s-pname}, \\ 
{\rm{s-pos}}\,({\it{state\/}})\index{s-pos}, \\ 
{\it{ans\/}}, \\ 
{\rm{s-params}}\,({\it{state\/}})\index{s-params}, \\ 
{\rm{s-temps}}\,({\it{state\/}})\index{s-temps}, \\ 
{\rm{s-progs}}\,({\it{state\/}})\index{s-progs}, \\ 
{\rm{s-err-flag}}\,({\it{state\/}})\index{s-err-flag})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-set-ans \\ \index{s-accessors-s-set-ans}
\=\+({\rm{s-pname}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{s\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-pos} $=$ {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-ans} $=$ {\it{ans\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-params} $=$ {\rm{s-params}}\,({\it{s\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-temps} $=$ {\rm{s-temps}}\,({\it{s\/}})\index{s-temps}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-err-flag} $=$ {\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-set-ans.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-eval-do-temp-fetch} \\  
\=\+{\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-setp} \\ 
{\bf then }{\rm{s-set-ans}}\,({\it{state\/}}, {\rm{s-temp-value}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-value})\index{s-set-ans} \\ 
{\bf else }{\rm{s-set-error}}\,({\it{state\/}}, {\tt{'}}{\tt{temp-fetch-not-set}})\index{s-set-error}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-eval-do-temp-fetch \\ \index{s-accessors-s-eval-do-temp-fetc!h}
\=\+({\rm{s-pname}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{state\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-pos} $=$ {\rm{s-pos}}\,({\it{state\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-ans} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-setp} \\ 
{\bf then }{\rm{s-temp-value}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-value} \\ 
{\bf else }{\rm{s-ans}}\,({\it{state\/}})\index{s-ans}$\;${\bf  endif}\-)\- \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-params} $=$ {\rm{s-params}}\,({\it{state\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-temps} $=$ {\rm{s-temps}}\,({\it{state\/}})\index{s-temps}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{state\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-err-flag}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-err-flag} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-setp} \\ 
{\bf then }{\rm{s-err-flag}}\,({\it{state\/}})\index{s-err-flag} \\ 
{\bf else }{\tt{'}}{\tt{temp-fetch-not-set}}$\;${\bf  endif}\-)\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-eval-do-temp-fetch.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{make-temps-entries} \\  
\=\+{\rm{make-temps-entries}}\,({\it{list\/}})\index{make-temps-entries} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{list\/}}) \\ 
{\bf then }{\rm{cons}}\,({\rm{list}}\,({\rm{car}}\,({\it{list\/}}), {\bf{f}}, {\bf{nil}}), {\rm{make-temps-entries}}\,({\rm{cdr}}\,({\it{list\/}}))\index{make-temps-entries}) \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-fun-call-state} \\  
\=\+{\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}, \\ 
{\bf{nil}}, \\ 
{\rm{s-ans}}\,({\it{s\/}})\index{s-ans}, \\ 
{\rm{pairlist}}\,(\=\+{\rm{s-formals}}\,({\rm{assoc}}\,({\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{s-formals}, \\ 
{\rm{s-ans}}\,({\it{s\/}})\index{s-ans})\-, \\ 
{\rm{make-temps-entries}}\,({\rm{s-temp-list}}\,({\rm{assoc}}\,(\=\+{\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}, \\ 
{\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\-)\index{s-temp-list})\index{make-temps-entries}, \\ 
{\rm{s-progs}}\,({\it{s\/}})\index{s-progs}, \\ 
{\tt{'}}{\tt{run}})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-fun-call-state \\ \index{s-accessors-s-fun-call-state}
\=\+({\rm{s-pname}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-pname} $=$ {\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-pos} $=$ {\bf{nil}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{s\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-params}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-params} \\ 
$=$$\;\;\;\;${\rm{pairlist}}\,(\=\+{\rm{s-formals}}\,({\rm{assoc}}\,({\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{s-formals}, \\ 
{\rm{s-ans}}\,({\it{s\/}})\index{s-ans})\-)\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-temps}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-temps} \\ 
$=$$\;\;\;\;${\rm{make-temps-entries}}\,({\rm{s-temp-list}}\,({\rm{assoc}}\,(\=\+{\rm{user-fname}}\,({\it{pname\/}})\index{user-fname}, \\ 
{\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\-)\index{s-temp-list})\index{make-temps-entries})\- \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-fun-call-state}}\,({\it{s\/}}, {\it{pname\/}})\index{s-fun-call-state})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-fun-call-state.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-set-expr} \\  
\=\+{\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\rm{s-pname}}\,({\it{s2\/}})\index{s-pname}, \\ 
{\it{pos\/}}, \\ 
{\rm{s-ans}}\,({\it{s1\/}})\index{s-ans}, \\ 
{\rm{s-params}}\,({\it{s1\/}})\index{s-params}, \\ 
{\rm{s-temps}}\,({\it{s1\/}})\index{s-temps}, \\ 
{\rm{s-progs}}\,({\it{s2\/}})\index{s-progs}, \\ 
{\rm{s-err-flag}}\,({\it{s1\/}})\index{s-err-flag})\-\index{s-state}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-accessors-s-set-expr \\ \index{s-accessors-s-set-expr}
\=\+({\rm{s-pname}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{s2\/}})\index{s-pname}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-pos}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-pos} $=$ {\it{pos\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-ans}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-ans} $=$ {\rm{s-ans}}\,({\it{s1\/}})\index{s-ans}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-params} $=$ {\rm{s-params}}\,({\it{s1\/}})\index{s-params}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-temps}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-temps} $=$ {\rm{s-temps}}\,({\it{s1\/}})\index{s-temps}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s2\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-err-flag} $=$ {\rm{s-err-flag}}\,({\it{s1\/}})\index{s-err-flag})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-set-expr.

\addvspace{18pt}	    

\begin{tabbing}{\sc Theorem}:  lessp-number-cons-restn-get \\ \index{lessp-number-cons-restn-get}
({\it{n\/}} $<$ {\rm{length}}\,({\it{x\/}})\index{length}) $\rightarrow$ ({\rm{number-cons}}\,({\rm{get}}\,({\it{n\/}}, {\it{x\/}})\index{get})\index{number-cons} $<$ {\rm{number-cons}}\,({\rm{restn}}\,({\it{n\/}}, {\it{x\/}})\index{restn})\index{number-cons})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  get-add1-opener \\ \index{get-add1-opener}
{\rm{get}}\,($1\;+$ {\it{x\/}}, {\it{list\/}})\index{get} $=$ {\rm{get}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{list\/}}))\index{get}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-add1-opener \\ \index{restn-add1-opener}
{\rm{listp}}\,({\it{list\/}}) $\rightarrow$ ({\rm{restn}}\,($1\;+$ {\it{x\/}}, {\it{list\/}})\index{restn} $=$ {\rm{restn}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{list\/}}))\index{restn})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-cdr \\ \index{restn-cdr}
({\it{n\/}} $<$ {\rm{length}}\,({\it{x\/}})\index{length}) $\rightarrow$ ({\rm{restn}}\,({\it{n\/}}, {\rm{cdr}}\,({\it{x\/}}))\index{restn} $=$ {\rm{cdr}}\,({\rm{restn}}\,({\it{n\/}}, {\it{x\/}})\index{restn}))
\end{tabbing}


\noindent{\sc Event}:   Disable restn-cdr.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  car-restn-get \\ \index{car-restn-get}
{\rm{car}}\,({\rm{restn}}\,({\it{n\/}}, {\it{list\/}})\index{restn}) $=$ {\rm{get}}\,({\it{n\/}}, {\it{list\/}})\index{get}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-set-expr \\ \index{s-prog-s-set-expr}
{\rm{s-prog}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s2\/}})\index{s-prog}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-set-pos \\ \index{s-prog-s-set-pos}
{\rm{s-prog}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s\/}})\index{s-prog}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cur-expr-append \\ \index{cur-expr-append}
{\rm{cur-expr}}\,({\rm{append}}\,({\it{pos1\/}}, {\it{pos2\/}}), {\it{body\/}})\index{cur-expr} $=$ {\rm{cur-expr}}\,({\it{pos2\/}}, {\rm{cur-expr}}\,({\it{pos1\/}}, {\it{body\/}})\index{cur-expr})\index{cur-expr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-expr-s-set-expr \\ \index{s-expr-s-set-expr}
{\rm{s-expr}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s2\/}})\index{s-pos}, {\it{n\/}})\index{dv})\index{s-set-expr})\index{s-expr} $=$ {\rm{get}}\,({\it{n\/}}, {\rm{s-expr}}\,({\it{s2\/}})\index{s-expr})\index{get}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-expr-s-set-pos-t \\ \index{s-expr-s-set-pos-t}
{\rm{s-expr}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\it{n\/}})\index{dv})\index{s-set-pos})\index{s-expr} $=$ {\rm{get}}\,({\it{n\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{get}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  butlast-append \\ \index{butlast-append}
{\rm{listp}}\,({\it{l2\/}}) $\rightarrow$ ({\rm{butlast}}\,({\rm{append}}\,({\it{l1\/}}, {\it{l2\/}}))\index{butlast} $=$ {\rm{append}}\,({\it{l1\/}}, {\rm{butlast}}\,({\it{l2\/}})\index{butlast}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  restn-sub1-length-last \\ \index{restn-sub1-length-last}
(({\it{n\/}} $=$ ({\rm{length}}\,({\it{l\/}})\index{length} $-\;1$)) $\wedge$ {\rm{listp}}\,({\it{l\/}})) $\rightarrow$ ({\rm{restn}}\,({\it{n\/}}, {\it{l\/}})\index{restn} $=$ {\rm{last}}\,({\it{l\/}})\index{last})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  append-butlast-lastcdr \\ \index{append-butlast-lastcdr}
{\rm{listp}}\,({\it{x\/}}) $\rightarrow$ ({\rm{append}}\,({\rm{butlast}}\,({\it{x\/}})\index{butlast}, {\rm{last}}\,({\it{x\/}})\index{last}) $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-listp-cdr-last \\ \index{not-listp-cdr-last}
{\rm{listp}}\,({\rm{cdr}}\,({\rm{last}}\,({\it{x\/}})\index{last})) $=$ {\bf{f}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-last-listp \\ \index{listp-last-listp}
{\rm{listp}}\,({\rm{last}}\,({\it{x\/}})\index{last}) $=$ {\rm{listp}}\,({\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cur-expr-last \\ \index{cur-expr-last}
\=\+({\rm{listp}}\,({\it{pos\/}}) $\wedge$ ({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}) $<$ {\rm{length}}\,({\it{body\/}})\index{length})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{cur-expr}}\,({\rm{last}}\,({\it{pos\/}})\index{last}, {\it{body\/}})\index{cur-expr} $=$ {\rm{get}}\,({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}), {\it{body\/}})\index{get})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  number-cons-cur-expr \\ \index{number-cons-cur-expr}
\=\+(({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}) $<$ {\rm{length}}\,({\rm{cur-expr}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{body\/}})\index{cur-expr})\index{length}) $\wedge$ {\rm{listp}}\,({\it{pos\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{number-cons}}\,({\rm{cur-expr}}\,({\it{pos\/}}, {\it{body\/}})\index{cur-expr})\index{number-cons} \\ 
$<$$\;\;\;\;${\rm{number-cons}}\,({\rm{restn}}\,({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}), {\rm{cur-expr}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{body\/}})\index{cur-expr})\index{restn})\index{number-cons})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  last-append \\ \index{last-append}
{\rm{listp}}\,({\it{y\/}}) $\rightarrow$ ({\rm{last}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{last} $=$ {\rm{last}}\,({\it{y\/}})\index{last})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  butlast-singleton-list \\ \index{butlast-singleton-list}
{\rm{butlast}}\,({\rm{list}}\,({\it{x\/}}))\index{butlast} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  last-nx \\ \index{last-nx}
{\rm{listp}}\,({\it{pos\/}}) $\rightarrow$ ({\rm{last}}\,({\rm{nx}}\,({\it{pos\/}})\index{nx})\index{last} $=$ {\rm{list}}\,($1\;+$ {\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last})))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  butlast-nx \\ \index{butlast-nx}
{\rm{listp}}\,({\it{pos\/}}) $\rightarrow$ ({\rm{butlast}}\,({\rm{nx}}\,({\it{pos\/}})\index{nx})\index{butlast} $=$ {\rm{butlast}}\,({\it{pos\/}})\index{butlast})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cur-expr-plist \\ \index{cur-expr-plist}
{\rm{cur-expr}}\,({\rm{plist}}\,({\it{pos\/}})\index{plist}, {\it{body\/}})\index{cur-expr} $=$ {\rm{cur-expr}}\,({\it{pos\/}}, {\it{body\/}})\index{cur-expr}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  last-dv \\ \index{last-dv}
{\rm{last}}\,({\rm{dv}}\,({\it{pos\/}}, {\it{n\/}})\index{dv})\index{last} $=$ {\rm{list}}\,({\it{n\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  butlast-dv \\ \index{butlast-dv}
{\rm{butlast}}\,({\rm{dv}}\,({\it{pos\/}}, {\it{n\/}})\index{dv})\index{butlast} $=$ {\rm{plist}}\,({\it{pos\/}})\index{plist}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-expr-list-s-s-set-expr-nx \\ \index{s-expr-list-s-s-set-expr-nx}
\=\+({\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) $\wedge$ {\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-expr-list}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s\/}}, {\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\index{s-set-expr})\index{s-expr-list} $=$ {\rm{cdr}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  lessp-number-cons-s-expr-s-expr-list \\ \index{lessp-number-cons-s-expr-s-expr!-list}
\=\+({\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) $\wedge$ {\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{number-cons}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{number-cons} $<$ {\rm{number-cons}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})\index{number-cons})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-expr-list-s-set-pos-dv \\ \index{s-expr-list-s-set-pos-dv}
{\rm{s-expr-list}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\it{n\/}})\index{dv})\index{s-set-pos})\index{s-expr-list} $=$ {\rm{restn}}\,({\it{n\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{restn}
\end{tabbing}

\begin{verbatim};; if flag is 'list then state contains a list of expressions,
;; otherwise it is just one.
;; Returns a s-state.  If flag is LIST the S-ANS of the s-state is
;; a list results.  Otherwise S-ANS of the result is the answer.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{s-eval} \\  
\=\+{\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag} $\not=$ {\tt{'}}{\tt{run}}$\;\;${\bf then }{\it{s\/}} \\ 
{\bf elseif }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{s-pos}}\,({\it{s\/}})\index{s-pos} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{s-set-error}}\,({\it{s\/}}, {\tt{'}}{\tt{bad-list-position}})\index{s-set-error} \\ 
{\bf elseif }{\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) \\ 
{\bf then }\=\+{\bf let }\=\+{\it{car-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{cdr-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\it{car-s\/}}, \\ 
{\it{s\/}}, \\ 
{\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\-\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval}\- \\ 
{\bf in} \\ 
{\rm{s-set-ans}}\,(\=\+{\it{cdr-s\/}}, \\ 
{\rm{cons}}\,({\rm{s-ans}}\,({\it{car-s\/}})\index{s-ans}, {\rm{s-ans}}\,({\it{cdr-s\/}})\index{s-ans}))\-\index{s-set-ans}$\;${\bf  endlet}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\rm{s-set-ans}}\,({\it{s\/}}, {\bf{nil}})\index{s-set-ans}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{c\/}} $\simeq {\tt{0}}$$\;\;${\bf then }{\rm{s-set-error}}\,({\it{s\/}}, {\tt{'}}{\tt{out-of-time}})\index{s-set-error} \\ 
{\bf elseif }{\rm{litatom}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
{\bf then }{\rm{s-set-ans}}\,({\it{s\/}}, {\rm{value}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}, {\rm{s-params}}\,({\it{s\/}})\index{s-params})\index{value})\index{s-set-ans} \\ 
{\bf elseif }{\rm{s-expr}}\,({\it{s\/}})\index{s-expr} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\rm{s-set-error}}\,({\it{s\/}}, {\tt{'}}{\tt{bad-expression}})\index{s-set-error} \\ 
{\bf elseif }{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{s-err-flag}}\,({\it{test\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}} \\ 
{\bf then }\=\+{\bf if }{\rm{s-ans}}\,({\it{test\/}})\index{s-ans} \\ 
{\bf then }{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-expr}}\,({\it{test\/}}, {\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{2}})\index{dv})\index{s-set-expr}, {\it{c\/}})\index{s-eval} \\ 
{\bf else }{\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-expr}}\,({\it{test\/}}, {\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{3}})\index{dv})\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval}$\;${\bf  endif}\- \\ 
{\bf else }{\it{test\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{new-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
{\rm{s-change-temp}}\,({\it{new-s\/}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-ans}}\,({\it{new-s\/}})\index{s-ans})\index{s-change-temp}$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test} \\ 
{\bf then }\=\+{\bf if }{\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-temp-setp} \\ 
{\bf then }{\rm{s-eval-do-temp-fetch}}\,({\it{s\/}})\index{s-eval-do-temp-fetch} \\ 
{\bf else }\=\+{\bf let }\=\+{\it{new-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, \\ 
{\it{c\/}})\-\index{s-eval}\- \\ 
{\bf in} \\ 
{\rm{s-change-temp}}\,(\=\+{\it{new-s\/}}, \\ 
{\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), \\ 
{\rm{s-ans}}\,({\it{new-s\/}})\index{s-ans})\-\index{s-change-temp}$\;${\bf  endlet}\-$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}$\;\;${\bf then }{\rm{s-eval-do-temp-fetch}}\,({\it{s\/}})\index{s-eval-do-temp-fetch} \\ 
{\bf elseif }{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\rm{s-set-ans}}\,({\it{s\/}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-set-ans} \\ 
{\bf elseif }\=\+{\rm{s-err-flag}}\,({\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval})\index{s-err-flag} \\ 
$\not=$$\;\;\;\;${\tt{'}}{\tt{run}}\- \\ 
{\bf then }{\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval} \\ 
{\bf elseif }{\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
{\bf then }\=\+{\bf let }\=\+{\it{arg-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
{\rm{s-set-ans}}\,({\it{arg-s\/}}, {\rm{apply-subr}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-ans}}\,({\it{arg-s\/}})\index{s-ans}))\index{s-set-ans}$\;${\bf  endlet}\- \\ 
{\bf elseif }{\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
{\bf then }\=\+{\bf let }\=\+{\it{arg-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{new-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-fun-call-state}}\,(\=\+{\it{arg-s\/}}, \\ 
{\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\-\index{s-fun-call-state}, \\ 
{\it{c\/}} $-\;1$)\-\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf if }{\rm{s-err-flag}}\,({\it{new-s\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}} \\ 
{\bf then }{\rm{s-set-expr}}\,(\=\+{\rm{s-set-ans}}\,({\it{arg-s\/}}, {\rm{s-ans}}\,({\it{new-s\/}})\index{s-ans})\index{s-set-ans}, \\ 
{\it{s\/}}, \\ 
{\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\-\index{s-set-expr} \\ 
{\bf else }{\it{new-s\/}}$\;${\bf  endif}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\rm{s-set-error}}\,({\it{s\/}}, {\tt{'}}{\tt{bad-instruction}})\index{s-set-error}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-progs-s-eval \\ \index{s-progs-s-eval}
{\rm{s-progs}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{state\/}})\index{s-progs}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-params-s-eval \\ \index{s-params-s-eval}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-params}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-params} $=$ {\rm{s-params}}\,({\it{state\/}})\index{s-params})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-pname-s-eval \\ \index{s-pname-s-eval}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-pname}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-pname} $=$ {\rm{s-pname}}\,({\it{state\/}})\index{s-pname})\-
\end{tabbing}

\begin{verbatim};; Takes body and expands away temporary variables.
;; BODY is a S-STATE expression.
;; Returns the expanded body
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{s-expand-temps} \\  
\=\+{\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{body\/}})\index{s-expand-temps} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{body\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{car}}\,({\it{body\/}}))\index{s-expand-temps}, \\ 
{\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{body\/}}))\index{s-expand-temps})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\it{body\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{body\/}} \\ 
{\bf elseif }\=\+({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test})\- \\ 
{\bf then }{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{body\/}}))\index{s-expand-temps} \\ 
{\bf elseif }{\rm{car}}\,({\it{body\/}}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\it{body\/}} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{body\/}}), {\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{body\/}}))\index{s-expand-temps})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{subr-arity-alist} \\  
\=\+{\sc{subr-arity-alist}}\index{subr-arity-alist} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{(}}\=\+{\tt{(}}{\tt{add1}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{add-to-set}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{and}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{append}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{apply-subr}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{apply\$}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{assoc}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{body}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{car}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{cdr}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{cons}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{count}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{difference}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{equal}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{eval\$}}{\tt{ }}{\tt{3}}{\tt{)}} \\ 
{\tt{(}}{\tt{false}}{\tt{ }}{\tt{0}}{\tt{)}} \\ 
{\tt{(}}{\tt{falsep}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{fix}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{fix-cost}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{for}}{\tt{ }}{\tt{6}}{\tt{)}} \\ 
{\tt{(}}{\tt{formals}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{geq}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{greaterp}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{if}}{\tt{ }}{\tt{3}}{\tt{)}} \\ 
{\tt{(}}{\tt{iff}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{implies}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{leq}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{lessp}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{listp}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{litatom}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{max}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{member}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{minus}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{negativep}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{negative-guts}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{nlistp}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{not}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{numberp}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{or}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{ordinalp}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{ord-lessp}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{pack}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{pairlist}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{plus}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{quantifier-initial-value}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{quantifier-operation}}{\tt{ }}{\tt{3}}{\tt{)}} \\ 
{\tt{(}}{\tt{quotient}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{remainder}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{strip-cars}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{sub1}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{subrp}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{sum-cdrs}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{times}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{true}}{\tt{ }}{\tt{0}}{\tt{)}} \\ 
{\tt{(}}{\tt{truep}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{union}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{unpack}}{\tt{ }}{\tt{1}}{\tt{)}} \\ 
{\tt{(}}{\tt{v\&c\$}}{\tt{ }}{\tt{3}}{\tt{)}} \\ 
{\tt{(}}{\tt{v\&c-apply\$}}{\tt{ }}{\tt{2}}{\tt{)}} \\ 
{\tt{(}}{\tt{zero}}{\tt{ }}{\tt{0}}{\tt{)}} \\ 
{\tt{(}}{\tt{zerop}}{\tt{ }}{\tt{1}}{\tt{)}}{\tt{)}}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{arity} \\  
\=\+{\rm{arity}}\,({\it{function\/}})\index{arity} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{subrp}}\,({\it{function\/}})$\;\;${\bf then }{\rm{cadr}}\,({\rm{assoc}}\,({\it{function\/}}, {\sc{subr-arity-alist}}\index{subr-arity-alist})) \\ 
{\bf elseif }{\it{function\/}} $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\tt{1}} \\ 
{\bf else }{\rm{length}}\,({\rm{formals}}\,({\it{function\/}}))\index{length}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable arity.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-proper-exprp} \\  
\=\+{\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }\=\+{\rm{s-proper-exprp}}\,({\bf{t}}, {\rm{car}}\,({\it{expr\/}}), {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{expr\/}}), \\ 
{\it{p-names\/}}, \\ 
{\it{formals\/}}, \\ 
{\it{temp-list\/}})\-\index{s-proper-exprp}\- \\ 
{\bf else }{\it{expr\/}} $=$ {\bf{nil}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }\=\+{\bf if }$\neg$ {\rm{plistp}}\,({\it{expr\/}})\index{plistp}$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }\=\+({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test})\- \\ 
{\bf then }\=\+({\rm{cadr}}\,({\it{expr\/}}) $\in$ {\it{temp-list\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{length}}\,({\it{expr\/}})\index{length} $=$ {\tt{2}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{cadr}}\,({\it{expr\/}}), \\ 
{\it{p-names\/}}, \\ 
{\it{formals\/}}, \\ 
{\it{temp-list\/}})\-\index{s-proper-exprp}\- \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}} \\ 
{\bf then }{\rm{length}}\,({\rm{cdr}}\,({\it{expr\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{expr\/}}))\index{arity} \\ 
{\bf elseif }{\rm{subrp}}\,({\rm{car}}\,({\it{expr\/}})) \\ 
{\bf then }\=\+({\rm{length}}\,({\rm{cdr}}\,({\it{expr\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{expr\/}}))\index{arity}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not\in$ {\it{p-names\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{expr\/}}), \\ 
{\it{p-names\/}}, \\ 
{\it{formals\/}}, \\ 
{\it{temp-list\/}})\-\index{s-proper-exprp}\- \\ 
{\bf elseif }{\rm{body}}\,({\rm{car}}\,({\it{expr\/}})) \\ 
{\bf then }\=\+({\rm{length}}\,({\rm{cdr}}\,({\it{expr\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{expr\/}}))\index{arity}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\in$ {\it{p-names\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{expr\/}}), \\ 
{\it{p-names\/}}, \\ 
{\it{formals\/}}, \\ 
{\it{temp-list\/}})\-\index{s-proper-exprp}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{litatom}}\,({\it{expr\/}})$\;\;${\bf then }{\it{expr\/}} $\in$ {\it{formals\/}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-programs-properp} \\  
\=\+{\rm{s-programs-properp}}\,({\it{programs\/}}, {\it{program-names\/}})\index{s-programs-properp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{programs\/}}) \\ 
{\bf then }\=\+{\rm{all-litatoms}}\,({\rm{s-formals}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-formals})\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-body}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-body}, \\ 
{\it{program-names\/}}, \\ 
{\rm{s-formals}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-formals}, \\ 
{\rm{s-temp-list}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-temp-list})\-\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{s-programs-properp}}\,({\rm{cdr}}\,({\it{programs\/}}), {\it{program-names\/}})\index{s-programs-properp}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-programs-okp} \\  
\=\+{\rm{s-programs-okp}}\,({\it{programs\/}})\index{s-programs-okp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{programs\/}}) \\ 
{\bf then }\=\+({\rm{s-formals}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-formals} $\not=$ {\bf{f}}) \\ 
$\wedge$$\;\;\;\;${\rm{user-fnamep}}\,({\rm{car}}\,({\rm{car}}\,({\it{programs\/}})))\index{user-fnamep} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-formals}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-formals} \\ 
$=$$\;\;\;\;${\rm{formals}}\,({\rm{logic-fname}}\,({\rm{car}}\,({\rm{car}}\,({\it{programs\/}})))\index{logic-fname}))\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{s-body}}\,({\rm{car}}\,({\it{programs\/}}))\index{s-body})\index{s-expand-temps} \\ 
$=$$\;\;\;\;${\rm{body}}\,({\rm{logic-fname}}\,({\rm{car}}\,({\rm{car}}\,({\it{programs\/}})))\index{logic-fname}))\- \\ 
$\wedge$$\;\;\;\;${\rm{s-programs-okp}}\,({\rm{cdr}}\,({\it{programs\/}}))\index{s-programs-okp}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{temps-okp} \\  
\=\+{\rm{temps-okp}}\,({\it{temps\/}}, {\it{params\/}}, {\it{c\/}})\index{temps-okp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{temps\/}}) \\ 
{\bf then }\=\+(\=\+($\neg$ {\rm{cadr}}\,({\rm{car}}\,({\it{temps\/}}))) \\ 
$\vee$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{car}}\,({\rm{car}}\,({\it{temps\/}})))\index{s-expand-temps}, {\it{params\/}}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{car}}\,({\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{car}}\,({\rm{car}}\,({\it{temps\/}})))\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{c\/}})\-\index{l-eval}) \\ 
$=$$\;\;\;\;${\rm{caddr}}\,({\rm{car}}\,({\it{temps\/}})))\-)\-)\- \\ 
$\wedge$$\;\;\;\;${\rm{temps-okp}}\,({\rm{cdr}}\,({\it{temps\/}}), {\it{params\/}}, {\it{c\/}})\index{temps-okp}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{good-posp1} \\  
\=\+{\rm{good-posp1}}\,({\it{pos\/}}, {\it{expr\/}})\index{good-posp1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{pos\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{t}} \\ 
{\bf elseif }{\it{expr\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) $\vee$ ({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
{\bf then }({\rm{car}}\,({\it{pos\/}}) $=$ {\tt{1}}) $\wedge$ {\rm{good-posp1}}\,({\rm{cdr}}\,({\it{pos\/}}), {\rm{cadr}}\,({\it{expr\/}}))\index{good-posp1} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\bf{f}} \\ 
{\bf else }\=\+({\rm{car}}\,({\it{pos\/}}) $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{pos\/}}) $<$ {\rm{length}}\,({\it{expr\/}})\index{length}) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{cdr}}\,({\it{pos\/}}), {\rm{get}}\,({\rm{car}}\,({\it{pos\/}}), {\it{expr\/}})\index{get})\index{good-posp1}\-$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable good-posp1.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{good-posp-list} \\  
\=\+{\rm{good-posp-list}}\,({\it{n\/}}, {\it{expr\/}})\index{good-posp-list} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{expr\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }\=\+({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}})\-$\;\;${\bf then }{\bf{f}} \\ 
{\bf else }({\it{n\/}} $\not\simeq {\tt{0}}$) $\wedge$ ({\rm{length}}\,({\it{expr\/}})\index{length} $\not<$ {\it{n\/}})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{good-posp} \\  
\=\+{\rm{good-posp}}\,({\it{flag\/}}, {\it{pos\/}}, {\it{expr\/}})\index{good-posp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\rm{good-posp-list}}\,({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}), {\rm{cur-expr}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{expr\/}})\index{cur-expr})\index{good-posp-list} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{expr\/}})\index{good-posp1}\- \\ 
{\bf else }{\rm{good-posp1}}\,({\it{pos\/}}, {\it{expr\/}})\index{good-posp1}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable good-posp.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{all-user-fnamesp} \\  
\=\+{\rm{all-user-fnamesp}}\,({\it{list\/}})\index{all-user-fnamesp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{list\/}}) \\ 
{\bf then }{\rm{user-fnamep}}\,({\rm{car}}\,({\it{list\/}}))\index{user-fnamep} $\wedge$ {\rm{all-user-fnamesp}}\,({\rm{cdr}}\,({\it{list\/}}))\index{all-user-fnamesp} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{strip-logic-fnames} \\  
\=\+{\rm{strip-logic-fnames}}\,({\it{list\/}})\index{strip-logic-fnames} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{list\/}}) \\ 
{\bf then }{\rm{cons}}\,({\rm{logic-fname}}\,({\rm{caar}}\,({\it{list\/}}))\index{logic-fname}, {\rm{strip-logic-fnames}}\,({\rm{cdr}}\,({\it{list\/}}))\index{strip-logic-fnames}) \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; This is a bit bogus.  We check S-PROGRAMS-OKP of the CDR of S-PROGS.  This
;; is because S-PROGRAMS-OKP checks that BODY and FORMALS are defined on
;; the names of the PROGRAMS.  Therefore it is NECESSARY that the expression
;; given to the compiler be the first program in S-PROGS.
;; Note that all functions calls must be defined, but can not be the
;; first program.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{s-good-statep} \\  
\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$=$$\;\;\;\;$(\=\+{\rm{definedp}}\,({\rm{s-pname}}\,({\it{s\/}})\index{s-pname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{definedp} \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{car}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs})) $=$ {\tt{'}}{\tt{main}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-programs-properp}}\,(\=\+{\rm{s-progs}}\,({\it{s\/}})\index{s-progs}, \\ 
{\rm{strip-logic-fnames}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{strip-logic-fnames})\-\index{s-programs-properp} \\ 
$\wedge$$\;\;\;\;${\rm{s-programs-okp}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{s-programs-okp} \\ 
$\wedge$$\;\;\;\;$({\rm{strip-cars}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps}) $=$ {\rm{plist}}\,({\rm{s-temp-list}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-temp-list})\index{plist}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{temps-okp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{temps-okp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-1 \\ \index{s-good-statep-backchainer-1}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ {\rm{definedp}}\,({\rm{s-pname}}\,({\it{s\/}})\index{s-pname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{definedp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-user-fnamep-not-definedp-s-programs-okp \\ \index{not-user-fnamep-not-definedp-s-p!rograms-okp}
\=\+(($\neg$ {\rm{user-fnamep}}\,({\it{name\/}})\index{user-fnamep}) $\wedge$ {\rm{definedp}}\,({\it{name\/}}, {\it{progs\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{s-programs-okp}}\,({\it{progs\/}})\index{s-programs-okp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-2 \\ \index{s-good-statep-backchainer-2}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ ($\neg$ {\rm{definedp}}\,({\tt{'}}{\tt{main}}, {\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{definedp})
\end{tabbing}


\noindent{\sc Event}:   Disable s-good-statep-backchainer-2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-2-5 \\ \index{s-good-statep-backchainer-2-5}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ ({\rm{caar}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) $=$ {\tt{'}}{\tt{main}})
\end{tabbing}


\noindent{\sc Event}:   Disable s-good-statep-backchainer-2-5.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-3 \\ \index{s-good-statep-backchainer-3}
\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-programs-properp}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}, {\rm{strip-logic-fnames}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{strip-logic-fnames})\index{s-programs-properp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-4 \\ \index{s-good-statep-backchainer-4}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ {\rm{s-programs-okp}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{s-programs-okp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-5 \\ \index{s-good-statep-backchainer-5}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ {\rm{temps-okp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{temps-okp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-backchainer-6 \\ \index{s-good-statep-backchainer-6}
{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\rightarrow$ ({\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-strip-cars-temps \\ \index{s-good-statep-strip-cars-temps}
\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\rightarrow$$\;\;\;\;$({\rm{strip-cars}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps}) $=$ {\rm{plist}}\,({\rm{s-temp-list}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-temp-list})\index{plist})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-set-pos \\ \index{s-good-statep-s-set-pos}
{\rm{s-good-statep}}\,({\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos}, {\it{c\/}})\index{s-good-statep} $=$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temps-okp-put-assoc \\ \index{temps-okp-put-assoc}
\=\+({\rm{temps-okp}}\,({\it{temps\/}}, {\it{params\/}}, {\it{c\/}})\index{temps-okp} $\wedge$ {\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{c\/}})\index{l-eval}) \\ 
$\rightarrow$$\;\;\;\;${\rm{temps-okp}}\,(\=\+{\rm{put-assoc}}\,(\=\+{\rm{list}}\,(\=\+{\bf{t}}, \\ 
{\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{c\/}})\index{l-eval}))\-, \\ 
{\it{expr\/}}, \\ 
{\it{temps\/}})\-\index{put-assoc}, \\ 
{\it{params\/}}, \\ 
{\it{c\/}})\-\index{temps-okp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-set-temps \\ \index{s-prog-s-set-temps}
{\rm{s-prog}}\,({\rm{s-set-temps}}\,({\it{s\/}}, {\it{new-temps\/}})\index{s-set-temps})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s\/}})\index{s-prog}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-change-temp \\ \index{s-good-statep-s-change-temp}
\=\+{\bf let }\=\+{\it{expr\/}}{\bf $\;$ be$\;\;$}{\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), \\ 
{\it{s1\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$({\it{x\/}} $=$ {\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval})))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,({\rm{s-change-temp}}\,({\it{s1\/}}, {\it{expr\/}}, {\it{x\/}})\index{s-change-temp}, {\it{c\/}})\index{s-good-statep}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-set-ans \\ \index{s-prog-s-set-ans}
{\rm{s-prog}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s\/}})\index{s-prog}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-set-ans \\ \index{s-good-statep-s-set-ans}
{\rm{s-good-statep}}\,({\rm{s-set-ans}}\,({\it{s\/}}, {\it{ans\/}})\index{s-set-ans}, {\it{c\/}})\index{s-good-statep} $=$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-set-expr \\ \index{s-good-statep-s-set-expr}
\=\+({\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} $\wedge$ {\rm{s-good-statep}}\,({\it{s2\/}}, {\it{c\/}})\index{s-good-statep} $\wedge$ ({\rm{s-prog}}\,({\it{s1\/}})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s2\/}})\index{s-prog})) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,({\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{pos\/}})\index{s-set-expr}, {\it{c\/}})\index{s-good-statep}\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-good-statep-strip-cars-temps.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-programs-properp-s-proper-exprp \\ \index{s-programs-properp-s-proper-exp!rp}
\=\+({\rm{s-programs-properp}}\,({\it{progs\/}}, {\it{program-names\/}})\index{s-programs-properp} $\wedge$ ({\it{prog\/}} $\in$ {\it{progs\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-body}}\,({\it{prog\/}})\index{s-body}, \\ 
{\it{program-names\/}}, \\ 
{\rm{s-formals}}\,({\it{prog\/}})\index{s-formals}, \\ 
{\rm{s-temp-list}}\,({\it{prog\/}})\index{s-temp-list})\-\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-proper-exprp \\ \index{s-good-statep-s-proper-exprp}
\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body}, \\ 
{\rm{strip-logic-fnames}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{strip-logic-fnames}, \\ 
{\rm{s-formals}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-formals}, \\ 
{\rm{s-temp-list}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-temp-list})\-\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-temp-list \\ \index{s-good-statep-s-temp-list}
\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\rightarrow$$\;\;\;\;$(({\it{x\/}} $\in$ {\rm{s-temp-list}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-temp-list}) $=$ {\rm{definedp}}\,({\it{x\/}}, {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{definedp})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-good-statep.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-list-s-proper-get-t \\ \index{s-proper-exprp-list-s-proper-get!-t}
\=\+(\=\+({\it{n\/}} $<$ {\rm{length}}\,({\it{expr\/}})\index{length}) \\ 
$\wedge$$\;\;\;\;${\rm{plistp}}\,({\it{expr\/}})\index{plistp} \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,({\tt{'}}{\tt{list}}, {\it{expr\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,({\bf{t}}, {\rm{get}}\,({\it{n\/}}, {\it{expr\/}})\index{get}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-t-s-proper-get-t \\ \index{s-proper-exprp-t-s-proper-get-t}
\=\+(\=\+({\rm{car}}\,({\it{expr\/}}) $\not=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-proper-exprp}}\,({\bf{t}}, {\it{expr\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;$({\it{n\/}} $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;$({\it{n\/}} $<$ {\rm{length}}\,({\it{expr\/}})\index{length}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,({\bf{t}}, {\rm{get}}\,({\it{n\/}}, {\it{expr\/}})\index{get}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-proper-exprp-list-s-proper-get-t.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-s-proper-exprp-cur-expr \\ \index{s-proper-exprp-s-proper-exprp-c!ur-expr}
\=\+({\rm{s-proper-exprp}}\,({\bf{t}}, {\it{body\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} $\wedge$ {\rm{good-posp1}}\,({\it{pos\/}}, {\it{body\/}})\index{good-posp1}) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,({\bf{t}}, {\rm{cur-expr}}\,({\it{pos\/}}, {\it{body\/}})\index{cur-expr}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-proper-exprp-cur-expr \\ \index{s-good-statep-s-proper-exprp-cu!r-expr}
\=\+({\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\wedge$ {\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1}) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-expr}}\,({\it{s\/}})\index{s-expr}, \\ 
{\rm{strip-logic-fnames}}\,({\rm{cdr}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{strip-logic-fnames}, \\ 
{\rm{s-formals}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-formals}, \\ 
{\rm{s-temp-list}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-temp-list})\-\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-definedp \\ \index{s-proper-exprp-definedp}
\=\+(\=\+{\rm{s-proper-exprp}}\,({\bf{t}}, {\it{body\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\-)\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{cadr}}\,({\it{body\/}}) $\in$ {\it{temp-list\/}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-definedp-temps \\ \index{s-good-statep-definedp-temps}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\-)\- \\ 
$\rightarrow$$\;\;\;\;${\rm{definedp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{definedp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  strip-cars-s-temps-s-eval \\ \index{strip-cars-s-temps-s-eval}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{strip-cars}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{state\/}}, {\it{clock\/}})\index{s-eval})\index{s-temps}) \\ 
$=$$\;\;\;\;${\rm{strip-cars}}\,({\rm{s-temps}}\,({\it{state\/}})\index{s-temps}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temps-okp-make-temps-entries \\ \index{temps-okp-make-temps-entries}
{\rm{temps-okp}}\,({\rm{make-temps-entries}}\,({\it{x\/}})\index{make-temps-entries}, {\it{params\/}}, {\it{c\/}})\index{temps-okp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-flag-not-list \\ \index{l-eval-flag-not-list}
\=\+({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} $=$ {\rm{l-eval}}\,({\bf{t}}, {\it{expr\/}}, {\it{params\/}}, {\it{clock\/}})\index{l-eval})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  strip-cars-make-temps-entries \\ \index{strip-cars-make-temps-entries}
{\rm{strip-cars}}\,({\rm{make-temps-entries}}\,({\it{x\/}})\index{make-temps-entries}) $=$ {\rm{plist}}\,({\it{x\/}})\index{plist}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-err-flag-s-eval-flag-list-flag-t \\ \index{s-err-flag-s-eval-flag-list-fla!g-t}
\=\+(\=\+(\=\+{\rm{s-err-flag}}\,({\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-expr}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, {\it{s\/}}, {\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\index{s-set-expr}, {\it{c\/}})\index{s-eval})\index{s-err-flag} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{run}})\- \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-append \\ \index{good-posp1-append}
\=\+{\rm{good-posp1}}\,({\rm{append}}\,({\it{pos1\/}}, {\it{pos2\/}}), {\it{body\/}})\index{good-posp1} \\ 
$=$$\;\;\;\;$({\rm{good-posp1}}\,({\it{pos1\/}}, {\it{body\/}})\index{good-posp1} $\wedge$ {\rm{good-posp1}}\,({\it{pos2\/}}, {\rm{cur-expr}}\,({\it{pos1\/}}, {\it{body\/}})\index{cur-expr})\index{good-posp1})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  cur-expr-nlistp \\ \index{cur-expr-nlistp}
({\it{expr\/}} $\simeq\;${{\bf{nil}}}${}$) $\rightarrow$ ({\rm{listp}}\,({\rm{cur-expr}}\,({\it{pos\/}}, {\it{expr\/}})\index{cur-expr}) $=$ {\bf{f}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-nlistp \\ \index{good-posp1-nlistp}
($\neg$ {\rm{listp}}\,({\it{pos\/}})) $\rightarrow$ {\rm{good-posp1}}\,({\it{pos\/}}, {\it{body\/}})\index{good-posp1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-list-good-posp-list-t \\ \index{good-posp1-list-good-posp-list-t}
\=\+(\=\+{\rm{good-posp1}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{body\/}})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp-list}}\,({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}), {\rm{cur-expr}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{body\/}})\index{cur-expr})\index{good-posp-list} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{restn}}\,({\rm{car}}\,({\rm{last}}\,({\it{pos\/}})\index{last}), {\rm{cur-expr}}\,({\rm{butlast}}\,({\it{pos\/}})\index{butlast}, {\it{body\/}})\index{cur-expr})\index{restn}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{pos\/}}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{good-posp1}}\,({\it{pos\/}}, {\it{body\/}})\index{good-posp1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp-flag-not-list-good-posp1 \\ \index{good-posp-flag-not-list-good-po!sp1}
({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\rightarrow$ ({\rm{good-posp}}\,({\it{flag\/}}, {\it{pos\/}}, {\it{body\/}})\index{good-posp} $=$ {\rm{good-posp1}}\,({\it{pos\/}}, {\it{body\/}})\index{good-posp1})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp-list-t \\ \index{good-posp-list-t}
\=\+(\=\+{\rm{good-posp}}\,({\tt{'}}{\tt{list}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-eval-do-s-temp-fetch \\ \index{s-prog-s-eval-do-s-temp-fetch}
{\rm{s-prog}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{state\/}})\index{s-eval-do-temp-fetch})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{state\/}})\index{s-prog}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-prog-s-eval \\ \index{s-prog-s-eval}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-prog}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-prog} $=$ {\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp-list-nx \\ \index{good-posp-list-nx}
\=\+(\=\+{\rm{good-posp}}\,({\tt{'}}{\tt{list}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{good-posp}}\,({\tt{'}}{\tt{list}}, {\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  car-s-expr-list-s-expr \\ \index{car-s-expr-list-s-expr}
\=\+({\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) $\wedge$ {\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) $=$ {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-s-expand-temps-flag-list-fact-1 \\ \index{l-eval-s-expand-temps-flag-list!-fact-1}
\=\+{\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\it{body\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{body\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{car}}\,({\it{body\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval}, \\ 
{\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{body\/}}))\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; The rewrite rule l-eval-s-expand-temps-flag-list-fact-1 had body
;; in place of (restn (car (last (s-pos s))) (s-expr s)), but this cause
;; infinite rewriting, so I changed it to block rewriting after doing
;; it once.
\end{verbatim}\begin{tabbing}{\sc Theorem}:  l-eval-s-expand-temps-flag-list-s-expr-fact-1 \\ \index{l-eval-s-expand-temps-flag-list!-s-expr-fact-1}
\=\+{\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{car}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval}, \\ 
{\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-s-expand-temps-litatom-fact-1 \\ \index{l-eval-s-expand-temps-litatom-f!act-1}
\=\+(({\it{clock\/}} $\not\simeq {\tt{0}}$) $\wedge$ {\rm{litatom}}\,({\it{body\/}}) $\wedge$ ({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{body\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;${\rm{list}}\,({\rm{cdr}}\,({\rm{assoc}}\,({\it{body\/}}, {\it{params\/}}))))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-length-cur-expr \\ \index{s-proper-exprp-length-cur-expr}
\=\+(\=\+{\rm{s-proper-exprp}}\,({\bf{t}}, {\it{expr\/}}, {\it{p-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{expr\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{subrp}}\,({\rm{car}}\,({\it{expr\/}})) $\vee$ {\rm{body}}\,({\rm{car}}\,({\it{expr\/}}))) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $\not=$ {\tt{'}}{\tt{quote}}))\- \\ 
$\rightarrow$$\;\;\;\;$({\rm{length}}\,({\it{expr\/}})\index{length} $=$ ($1\;+$ {\rm{arity}}\,({\rm{car}}\,({\it{expr\/}}))\index{arity}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-cons-lessp-4-if \\ \index{good-posp1-cons-lessp-4-if}
\=\+(({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}}) $\wedge$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+(\=\+{\rm{good-posp1}}\,({\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$=$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{good-posp1}}\,({\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{2}})\index{dv}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$=$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{good-posp1}}\,({\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{3}})\index{dv}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$=$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-if-fact-1 \\ \index{l-eval-if-fact-1}
\=\+(({\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}}) $\wedge$ ({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
{\bf then }\=\+{\bf if }{\rm{car}}\,({\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval}) \\ 
{\bf then }{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{caddr}}\,({\it{expr\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
{\bf else }{\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{expr\/}}))\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-eval-do-temp-fetch \\ \index{s-good-statep-s-eval-do-temp-fet!ch}
\=\+({\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} $\wedge$ {\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-temp-setp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{s\/}})\index{s-eval-do-temp-fetch}, {\it{c\/}})\index{s-good-statep}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-dv-1-temps \\ \index{good-posp1-dv-1-temps}
\=\+(\=\+(({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) $\vee$ ({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test})) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{good-posp1}}\,({\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-s-temps \\ \index{s-eval-l-eval-s-temps}
\=\+(\=\+({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\-)\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;${\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-quote-fact-1 \\ \index{l-eval-quote-fact-1}
\=\+(({\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}}) $\wedge$ ({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) $\wedge$ ({\it{clock\/}} $\not\simeq {\tt{0}}$)) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;${\rm{list}}\,({\rm{cadr}}\,({\it{expr\/}})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-not-lessp-length-1 \\ \index{listp-not-lessp-length-1}
{\rm{listp}}\,({\it{x\/}}) $\rightarrow$ (({\rm{length}}\,({\it{x\/}})\index{length} $<$ {\tt{1}}) $=$ {\bf{f}})
\end{tabbing}


\noindent{\sc Event}:   Disable listp-not-lessp-length-1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  good-posp1-plist \\ \index{good-posp1-plist}
{\rm{good-posp1}}\,({\rm{plist}}\,({\it{pos\/}})\index{plist}, {\it{body\/}})\index{good-posp1} $=$ {\rm{good-posp1}}\,({\it{pos\/}}, {\it{body\/}})\index{good-posp1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp-dv-1-funcall \\ \index{good-posp-dv-1-funcall}
\=\+(\=\+{\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{good-posp}}\,({\tt{'}}{\tt{list}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-s-expand-temps-subrp-fact-1 \\ \index{l-eval-s-expand-temps-subrp-fact!-1}
\=\+(\=\+{\rm{subrp}}\,({\rm{car}}\,({\it{e\/}})) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{e\/}}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\it{clock\/}} $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;$({\bf{f}} $\not\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{e\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval}) \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{e\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;${\rm{list}}\,({\rm{apply-subr}}\,(\=\+{\rm{car}}\,({\it{e\/}}), \\ 
{\rm{strip-cars}}\,({\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-expand-temps}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{e\/}}))\-\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval}))\-))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  logic-fname-user-fname-identity \\ \index{logic-fname-user-fname-identity}
{\rm{litatom}}\,({\it{x\/}}) $\rightarrow$ ({\rm{logic-fname}}\,({\rm{user-fname}}\,({\it{x\/}})\index{user-fname})\index{logic-fname} $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  user-fname-logic-fname-identity \\ \index{user-fname-logic-fname-identity}
{\rm{user-fnamep}}\,({\it{x\/}})\index{user-fnamep} $\rightarrow$ ({\rm{user-fname}}\,({\rm{logic-fname}}\,({\it{x\/}})\index{logic-fname})\index{user-fname} $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-strip-logic-fnames-definedp \\ \index{member-strip-logic-fnames-define!dp}
\=\+({\rm{all-user-fnamesp}}\,({\rm{strip-cars}}\,({\it{y\/}}))\index{all-user-fnamesp} $\wedge$ {\rm{litatom}}\,({\it{x\/}})) \\ 
$\rightarrow$$\;\;\;\;$(({\it{x\/}} $\in$ {\rm{strip-logic-fnames}}\,({\it{y\/}})\index{strip-logic-fnames}) $=$ {\rm{definedp}}\,({\rm{user-fname}}\,({\it{x\/}})\index{user-fname}, {\it{y\/}})\index{definedp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-programs-okp-all-user-fnamesp-strip-cars \\ \index{s-programs-okp-all-user-fnamesp!-strip-cars}
{\rm{s-programs-okp}}\,({\it{programs\/}})\index{s-programs-okp} $\rightarrow$ {\rm{all-user-fnamesp}}\,({\rm{strip-cars}}\,({\it{programs\/}}))\index{all-user-fnamesp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-definedp-programs \\ \index{s-proper-exprp-definedp-program!s}
\=\+(\=\+{\rm{s-proper-exprp}}\,({\bf{t}}, {\it{body\/}}, {\rm{strip-logic-fnames}}\,({\it{programs\/}})\index{strip-logic-fnames}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{body\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-programs-okp}}\,({\it{programs\/}})\index{s-programs-okp} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\it{body\/}}))) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\it{body\/}})))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{definedp}}\,({\rm{user-fname}}\,({\rm{car}}\,({\it{body\/}}))\index{user-fname}, {\it{programs\/}})\index{definedp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-s-fun-call-state \\ \index{s-good-statep-s-fun-call-state}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s2\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s1\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s1\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\it{s1\/}})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s2\/}})\index{s-progs}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,({\rm{s-fun-call-state}}\,({\it{s2\/}}, {\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))\index{s-fun-call-state}, {\it{c\/}} $-\;1$)\index{s-good-statep}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-posp1-flag-not-list-nil \\ \index{good-posp1-flag-not-list-nil}
{\rm{good-posp1}}\,({\bf{nil}}, {\it{body\/}})\index{good-posp1}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-s-expand-temps-not-subrp-fact-1 \\ \index{l-eval-s-expand-temps-not-subrp!-fact-1}
\=\+(\=\+($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\it{e\/}}))) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{e\/}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{listp}}\,({\rm{car}}\,({\it{e\/}}))) \\ 
$\wedge$$\;\;\;\;$({\it{clock\/}} $\not\simeq {\tt{0}}$) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{e\/}}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$({\bf{f}} $\not\in$ {\rm{l-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{e\/}}))\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval}) \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{e\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} \\ 
$=$$\;\;\;\;${\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{body}}\,({\rm{car}}\,({\it{e\/}})), \\ 
{\rm{pairlist}}\,(\=\+{\rm{formals}}\,({\rm{car}}\,({\it{e\/}})), \\ 
{\rm{strip-cars}}\,({\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-expand-temps}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{e\/}}))\-\index{s-expand-temps}, \\ 
{\it{params\/}}, \\ 
{\it{clock\/}})\-\index{l-eval}))\-, \\ 
{\it{clock\/}} $-\;1$)\-\index{l-eval})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-programs-okp-formals-body \\ \index{s-programs-okp-formals-body}
\=\+({\rm{s-programs-okp}}\,({\it{progs\/}})\index{s-programs-okp} $\wedge$ ({\it{prog\/}} $\in$ {\it{progs\/}})) \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{s-formals}}\,({\it{prog\/}})\index{s-formals} $=$ {\rm{formals}}\,({\rm{logic-fname}}\,({\rm{car}}\,({\it{prog\/}}))\index{logic-fname})) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{s-body}}\,({\it{prog\/}})\index{s-body})\index{s-expand-temps} \\ 
$=$$\;\;\;\;${\rm{body}}\,({\rm{logic-fname}}\,({\rm{car}}\,({\it{prog\/}}))\index{logic-fname}))\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-not-car-s-expr-caar-s-progs \\ \index{s-good-statep-not-car-s-expr-ca!ar-s-progs}
\=\+(\=\+{\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs}) \\ 
$\wedge$$\;\;\;\;$({\rm{user-fname}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{user-fname} $=$ {\rm{caar}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs})))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep})\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-good-statep-not-car-s-expr-caar-s-progs.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-expand-temps-s-expr-s-fun-call-state \\ \index{s-expand-temps-s-expr-s-fun-cal!l-state}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s2\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s1\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s1\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\it{s1\/}})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s2\/}})\index{s-progs}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\rm{s-fun-call-state}}\,({\it{s2\/}}, {\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))\index{s-fun-call-state})\index{s-expr})\index{s-expand-temps} \\ 
$=$$\;\;\;\;${\rm{body}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-formals \\ \index{s-good-statep-formals}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{s-formals}}\,({\rm{assoc}}\,({\rm{user-fname}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{user-fname}, {\rm{s-progs}}\,({\it{s\/}})\index{s-progs}))\index{s-formals} \\ 
$=$$\;\;\;\;${\rm{formals}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  definedp-temps-okp \\ \index{definedp-temps-okp}
\=\+(\=\+{\rm{temps-okp}}\,({\it{temps\/}}, {\it{params\/}}, {\it{c\/}})\index{temps-okp} \\ 
$\wedge$$\;\;\;\;${\rm{definedp}}\,({\it{expr\/}}, {\it{temps\/}})\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{s-temp-setp}}\,({\it{expr\/}}, {\it{temps\/}})\index{s-temp-setp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-expand-temps}, {\it{params\/}}, {\it{c\/}})\index{l-eval}) \\ 
$=$$\;\;\;\;${\rm{s-temp-value}}\,({\it{expr\/}}, {\it{temps\/}})\index{s-temp-value})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-s-eval-do-temp-fetch-fact-1 \\ \index{l-eval-s-eval-do-temp-fetch-fact!-1}
\=\+(\=\+{\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\- \\ 
$\wedge$$\;\;\;\;${\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-temp-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval}) \\ 
$=$$\;\;\;\;${\rm{s-ans}}\,({\rm{s-eval-do-temp-fetch}}\,({\it{s\/}})\index{s-eval-do-temp-fetch})\index{s-ans})\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-equivalence \\ \index{s-eval-l-eval-equivalence}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp}}\,({\it{flag\/}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{s-good-statep}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+({\bf{f}} $\not\in$ {\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-ans} \\ 
$=$$\;\;\;\;${\rm{strip-cars}}\,({\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})\-\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval}))\-\- \\ 
{\bf else }\=\+{\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-ans} \\ 
$=$$\;\;\;\;${\rm{car}}\,({\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\-\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval}))\-\-$\;${\bf  endif}\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-s-good-statep \\ \index{s-eval-s-good-statep}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp}}\,({\it{flag\/}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, {\it{c\/}})\index{s-good-statep}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-t \\ \index{s-eval-l-eval-flag-t}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{l-eval}}\,({\bf{t}}, {\rm{s-expand-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-ans} \\ 
$=$$\;\;\;\;${\rm{car}}\,({\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-expand-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval}))\-)\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-collect-all-temps} \\  
\=\+{\rm{s-collect-all-temps}}\,({\it{flag\/}}, {\it{expr\/}})\index{s-collect-all-temps} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }{\rm{append}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{car}}\,({\it{expr\/}}))\index{s-collect-all-temps}, \\ 
{\rm{s-collect-all-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}))\index{s-collect-all-temps})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }\=\+{\bf if }({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) $\vee$ ({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
{\bf then }{\rm{cons}}\,({\rm{cadr}}\,({\it{expr\/}}), {\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-collect-all-temps}) \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch} \\ 
{\bf then }{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-collect-all-temps} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\bf{nil}} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}} \\ 
{\bf then }{\rm{append}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}))\index{s-collect-all-temps}, \\ 
{\rm{bagint}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{caddr}}\,({\it{expr\/}}))\index{s-collect-all-temps}, \\ 
{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadddr}}\,({\it{expr\/}}))\index{s-collect-all-temps})\-\index{bagint})\- \\ 
{\bf else }{\rm{s-collect-all-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}))\index{s-collect-all-temps}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; This takes an expression (appropriate for s-eval) and makes sure
;; that all the temp-fetch forms will have the setp flag set.
;; temp-set is a set of expressions that can be assumed to have been evaluated
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{s-all-temps-setp} \\  
\=\+{\rm{s-all-temps-setp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{temp-set\/}})\index{s-all-temps-setp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }\=\+{\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{car}}\,({\it{expr\/}}), {\it{temp-set\/}})\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{expr\/}}), \\ 
{\rm{append}}\,(\=\+{\rm{s-collect-all-temps}}\,(\=\+{\bf{t}}, \\ 
{\rm{car}}\,({\it{expr\/}}))\-\index{s-collect-all-temps}, \\ 
{\it{temp-set\/}})\-)\-\index{s-all-temps-setp}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\it{expr\/}}) \\ 
{\bf then }\=\+{\bf if }({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) $\vee$ ({\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
{\bf then }{\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{temp-set\/}})\index{s-all-temps-setp} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}$\;\;${\bf then }{\rm{cadr}}\,({\it{expr\/}}) $\in$ {\it{temp-set\/}} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{quote}}$\;\;${\bf then }{\bf{t}} \\ 
{\bf elseif }{\rm{car}}\,({\it{expr\/}}) $=$ {\tt{'}}{\tt{if}} \\ 
{\bf then }\=\+{\bf if }{\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{cadr}}\,({\it{expr\/}}), {\it{temp-set\/}})\index{s-all-temps-setp} \\ 
{\bf then }\=\+{\bf let }\=\+{\it{test-temp-set\/}}{\bf $\;$ be$\;\;$}{\rm{s-collect-all-temps}}\,(\=\+{\bf{t}}, \\ 
{\rm{cadr}}\,({\it{expr\/}}))\-\index{s-collect-all-temps}\- \\ 
{\bf in} \\ 
\=\+{\rm{s-all-temps-setp}}\,(\=\+{\bf{t}}, \\ 
{\rm{caddr}}\,({\it{expr\/}}), \\ 
{\rm{append}}\,({\it{test-temp-set\/}}, {\it{temp-set\/}}))\-\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,(\=\+{\bf{t}}, \\ 
{\rm{cadddr}}\,({\it{expr\/}}), \\ 
{\rm{append}}\,(\=\+{\it{test-temp-set\/}}, \\ 
{\it{temp-set\/}})\-)\-\index{s-all-temps-setp}\-$\;${\bf  endlet}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\rm{s-all-temps-setp}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\it{expr\/}}), {\it{temp-set\/}})\index{s-all-temps-setp}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{temp-alist-to-set-1} \\  
\=\+{\rm{temp-alist-to-set-1}}\,({\it{alist\/}}, {\it{acc\/}})\index{temp-alist-to-set-1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{alist\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{car}}\,({\it{alist\/}})) $\wedge$ {\rm{cadar}}\,({\it{alist\/}}) $\wedge$ ({\rm{caar}}\,({\it{alist\/}}) $\not\in$ {\it{acc\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{caar}}\,({\it{alist\/}}), \\ 
{\rm{temp-alist-to-set-1}}\,({\rm{cdr}}\,({\it{alist\/}}), {\rm{cons}}\,({\rm{caar}}\,({\it{alist\/}}), {\it{acc\/}}))\index{temp-alist-to-set-1})\- \\ 
{\bf else }{\rm{temp-alist-to-set-1}}\,({\rm{cdr}}\,({\it{alist\/}}), {\rm{cons}}\,({\rm{caar}}\,({\it{alist\/}}), {\it{acc\/}}))\index{temp-alist-to-set-1}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-1-gives-members \\ \index{temp-alist-to-set-1-gives-membe!rs}
\=\+({\it{x\/}} $\in$ {\rm{temp-alist-to-set-1}}\,({\it{alist\/}}, {\it{acc\/}})\index{temp-alist-to-set-1}) \\ 
$=$$\;\;\;\;$({\rm{listp}}\,({\rm{assoc}}\,({\it{x\/}}, {\it{alist\/}})) $\wedge$ {\rm{s-temp-setp}}\,({\it{x\/}}, {\it{alist\/}})\index{s-temp-setp} $\wedge$ ({\it{x\/}} $\not\in$ {\it{acc\/}}))\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{temp-alist-to-set} \\  
{\rm{temp-alist-to-set}}\,({\it{alist\/}})\index{temp-alist-to-set} $=$ {\rm{temp-alist-to-set-1}}\,({\it{alist\/}}, {\bf{nil}})\index{temp-alist-to-set-1}
\end{tabbing}


\noindent{\sc Event}:   Disable temp-alist-to-set.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-gives-members \\ \index{temp-alist-to-set-gives-members}
\=\+({\it{x\/}} $\in$ {\rm{temp-alist-to-set}}\,({\it{alist\/}})\index{temp-alist-to-set}) \\ 
$=$$\;\;\;\;$({\rm{listp}}\,({\rm{assoc}}\,({\it{x\/}}, {\it{alist\/}})) $\wedge$ {\rm{s-temp-setp}}\,({\it{x\/}}, {\it{alist\/}})\index{s-temp-setp})\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-check-temps-setp-1} \\  
\=\+{\rm{s-check-temps-setp-1}}\,({\it{exprs\/}}, {\it{temp-set\/}})\index{s-check-temps-setp-1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{exprs\/}}) \\ 
{\bf then }\=\+(\=\+({\rm{car}}\,({\it{exprs\/}}) $\not\in$ {\it{temp-set\/}}) \\ 
$\vee$$\;\;\;\;${\rm{subsetp}}\,({\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{car}}\,({\it{exprs\/}}))\index{s-collect-all-temps}, {\it{temp-set\/}})\index{subsetp})\- \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,({\rm{cdr}}\,({\it{exprs\/}}), {\it{temp-set\/}})\index{s-check-temps-setp-1}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{good-alistp} \\  
\=\+{\rm{good-alistp}}\,({\it{alist\/}})\index{good-alistp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{alist\/}})$\;\;${\bf then }{\rm{listp}}\,({\rm{car}}\,({\it{alist\/}})) $\wedge$ {\rm{good-alistp}}\,({\rm{cdr}}\,({\it{alist\/}}))\index{good-alistp} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  good-alistp-listp-assoc \\ \index{good-alistp-listp-assoc}
{\rm{good-alistp}}\,({\it{alist\/}})\index{good-alistp} $\rightarrow$ ({\rm{definedp}}\,({\it{expr\/}}, {\it{alist\/}})\index{definedp} $\leftrightarrow$ {\rm{listp}}\,({\rm{assoc}}\,({\it{expr\/}}, {\it{alist\/}})))
\end{tabbing}


\noindent{\sc Event}:   Disable good-alistp-listp-assoc.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  good-alistp-put-assoc \\ \index{good-alistp-put-assoc}
{\rm{good-alistp}}\,({\it{alist\/}})\index{good-alistp} $\rightarrow$ {\rm{good-alistp}}\,({\rm{put-assoc}}\,({\it{val\/}}, {\it{expr\/}}, {\it{alist\/}})\index{put-assoc})\index{good-alistp}
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{s-check-temps-setp} \\  
\=\+{\rm{s-check-temps-setp}}\,({\it{temp-alist\/}})\index{s-check-temps-setp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{good-alistp}}\,({\it{temp-alist\/}})\index{good-alistp} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,(\=\+{\rm{strip-cars}}\,({\it{temp-alist\/}}), \\ 
{\rm{temp-alist-to-set}}\,({\it{temp-alist\/}})\index{temp-alist-to-set})\-\index{s-check-temps-setp-1})\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-check-temps-setp.

\addvspace{18pt}

\begin{tabbing}{\sc Definition}:\index{s-all-progs-temps-setp} \\  
\=\+{\rm{s-all-progs-temps-setp}}\,({\it{progs\/}})\index{s-all-progs-temps-setp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{progs\/}}) \\ 
{\bf then }\=\+{\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{s-body}}\,({\rm{car}}\,({\it{progs\/}}))\index{s-body}, {\bf{nil}})\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{make-temps-entries}}\,({\rm{s-temp-list}}\,({\rm{car}}\,({\it{progs\/}}))\index{s-temp-list})\index{make-temps-entries})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-progs-temps-setp}}\,({\rm{cdr}}\,({\it{progs\/}}))\index{s-all-progs-temps-setp}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-all-progs-temps-setp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  subsetp-member \\ \index{subsetp-member}
({\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp} $\wedge$ ({\it{x\/}} $\in$ {\it{set1\/}})) $\rightarrow$ ({\it{x\/}} $\in$ {\it{set2\/}})
\end{tabbing}


\noindent{\sc Event}:   Disable subsetp-member.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  subsetp-append-1 \\ \index{subsetp-append-1}
\=\+{\rm{subsetp}}\,({\rm{append}}\,({\it{set1\/}}, {\it{set2\/}}), {\it{set3\/}})\index{subsetp} \\ 
$=$$\;\;\;\;$({\rm{subsetp}}\,({\it{set1\/}}, {\it{set3\/}})\index{subsetp} $\wedge$ {\rm{subsetp}}\,({\it{set2\/}}, {\it{set3\/}})\index{subsetp})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-cons \\ \index{subsetp-cons}
{\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp} $\rightarrow$ {\rm{subsetp}}\,({\it{set1\/}}, {\rm{cons}}\,({\it{x\/}}, {\it{set2\/}}))\index{subsetp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-reflexive \\ \index{subsetp-reflexive}
{\rm{subsetp}}\,({\it{set\/}}, {\it{set\/}})\index{subsetp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-append-2 \\ \index{subsetp-append-2}
\=\+({\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp} $\vee$ {\rm{subsetp}}\,({\it{set1\/}}, {\it{set3\/}})\index{subsetp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,({\it{set1\/}}, {\rm{append}}\,({\it{set2\/}}, {\it{set3\/}}))\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-1-subsetp \\ \index{temp-alist-to-set-1-subsetp}
\=\+{\rm{subsetp}}\,({\it{acc1\/}}, {\it{acc2\/}})\index{subsetp} \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{temp-alist-to-set-1}}\,({\it{temp-alist\/}}, {\it{acc2\/}})\index{temp-alist-to-set-1}, \\ 
{\rm{temp-alist-to-set-1}}\,({\it{temp-alist\/}}, {\it{acc1\/}})\index{temp-alist-to-set-1})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-1-nlistp \\ \index{temp-alist-to-set-1-nlistp}
\=\+($\neg$ {\rm{listp}}\,({\rm{temp-alist-to-set-1}}\,({\it{alist\/}}, {\it{acc\/}})\index{temp-alist-to-set-1})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{temp-alist-to-set-1}}\,({\it{alist\/}}, {\it{acc\/}})\index{temp-alist-to-set-1} $=$ {\bf{nil}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-1-cons-nil \\ \index{temp-alist-to-set-1-cons-nil}
\=\+({\rm{temp-alist-to-set-1}}\,({\it{temp-alist\/}}, {\it{acc\/}})\index{temp-alist-to-set-1} $=$ {\bf{nil}}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{temp-alist-to-set-1}}\,({\it{temp-alist\/}}, {\rm{cons}}\,({\it{x\/}}, {\it{acc\/}}))\index{temp-alist-to-set-1} $=$ {\bf{nil}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-1-make-temp-entries \\ \index{temp-alist-to-set-1-make-temp-e!ntries}
{\rm{temp-alist-to-set-1}}\,({\rm{make-temps-entries}}\,({\it{temp-alist\/}})\index{make-temps-entries}, {\it{acc\/}})\index{temp-alist-to-set-1} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  temp-alist-to-set-make-temp-entries \\ \index{temp-alist-to-set-make-temp-ent!ries}
{\rm{temp-alist-to-set}}\,({\rm{make-temps-entries}}\,({\it{temp-alist\/}})\index{make-temps-entries})\index{temp-alist-to-set} $=$ {\bf{nil}}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-subsetp \\ \index{s-all-temps-setp-subsetp}
\=\+({\rm{subsetp}}\,({\it{temp-set1\/}}, {\it{temp-set2\/}})\index{subsetp} $\wedge$ {\rm{s-all-temps-setp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{temp-set1\/}})\index{s-all-temps-setp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{temp-set2\/}})\index{s-all-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-transistive \\ \index{subsetp-transistive}
({\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp} $\wedge$ {\rm{subsetp}}\,({\it{set2\/}}, {\it{set3\/}})\index{subsetp}) $\rightarrow$ {\rm{subsetp}}\,({\it{set1\/}}, {\it{set3\/}})\index{subsetp}
\end{tabbing}


\noindent{\sc Event}:   Disable subsetp-transistive.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-temp-setp-put-assoc-1 \\ \index{s-temp-setp-put-assoc-1}
\=\+{\rm{s-temp-setp}}\,({\it{expr1\/}}, {\rm{put-assoc}}\,({\rm{cons}}\,({\bf{t}}, {\it{anything\/}}), {\it{expr2\/}}, {\it{temp-alist\/}})\index{put-assoc})\index{s-temp-setp} \\ 
$\leftrightarrow$$\;\;\;\;$\=\+{\bf if }{\it{expr1\/}} $=$ {\it{expr2\/}}$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\rm{s-temp-setp}}\,({\it{expr1\/}}, {\it{temp-alist\/}})\index{s-temp-setp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-assoc-fact-1 \\ \index{listp-assoc-fact-1}
\=\+{\rm{listp}}\,({\rm{assoc}}\,({\it{expr1\/}}, {\it{temp-alist\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{listp}}\,({\rm{assoc}}\,({\it{expr1\/}}, {\rm{put-assoc}}\,({\rm{cons}}\,({\it{x\/}}, {\it{y\/}}), {\it{expr2\/}}, {\it{temp-alist\/}})\index{put-assoc}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-temp-alist-to-set-put-assoc-1 \\ \index{subsetp-temp-alist-to-set-put-a!ssoc-1}
\=\+{\rm{definedp}}\,({\it{expr\/}}, {\it{temp-alist\/}})\index{definedp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{subsetp}}\,(\=\+{\it{set1\/}}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{put-assoc}}\,({\rm{cons}}\,({\bf{t}}, {\it{anything\/}}), {\it{expr\/}}, {\it{temp-alist\/}})\index{put-assoc})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$=$$\;\;\;\;${\rm{subsetp}}\,({\it{set1\/}}, {\rm{cons}}\,({\it{expr\/}}, {\rm{temp-alist-to-set}}\,({\it{temp-alist\/}})\index{temp-alist-to-set}))\index{subsetp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-temp-alist-to-set-s-change-temp \\ \index{subsetp-temp-alist-to-set-s-cha!nge-temp}
\=\+{\rm{definedp}}\,({\it{expr\/}}, {\rm{s-temps}}\,({\it{st\/}})\index{s-temps})\index{definedp} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{subsetp}}\,({\it{set1\/}}, {\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-change-temp}}\,({\it{st\/}}, {\it{expr\/}}, {\it{val\/}})\index{s-change-temp})\index{s-temps})\index{temp-alist-to-set})\index{subsetp} \\ 
$=$$\;\;\;\;${\rm{subsetp}}\,({\it{set1\/}}, {\rm{cons}}\,({\it{expr\/}}, {\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{st\/}})\index{s-temps})\index{temp-alist-to-set}))\index{subsetp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-definedp-put-assoc \\ \index{not-definedp-put-assoc}
\=\+($\neg$ {\rm{definedp}}\,({\it{expr\/}}, {\it{temp-alist\/}})\index{definedp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{put-assoc}}\,({\it{anything\/}}, {\it{expr\/}}, {\it{temp-alist\/}})\index{put-assoc} $=$ {\it{temp-alist\/}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-trans-fact-2 \\ \index{subsetp-trans-fact-2}
\=\+{\rm{subsetp}}\,({\it{set\/}}, {\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{st\/}})\index{s-temps})\index{temp-alist-to-set})\index{subsetp} \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,({\it{set\/}}, {\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-change-temp}}\,({\it{st\/}}, {\it{expr\/}}, {\it{value\/}})\index{s-change-temp})\index{s-temps})\index{temp-alist-to-set})\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-temps-subsetp \\ \index{s-eval-temps-subsetp}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-delete \\ \index{subsetp-delete}
{\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp} $\rightarrow$ {\rm{subsetp}}\,({\rm{delete}}\,({\it{x\/}}, {\it{set1\/}})\index{delete}, {\it{set2\/}})\index{subsetp}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  subsetp-bagint \\ \index{subsetp-bagint}
\=\+({\rm{subsetp}}\,({\it{set1\/}}, {\it{set3\/}})\index{subsetp} $\vee$ {\rm{subsetp}}\,({\it{set2\/}}, {\it{set3\/}})\index{subsetp}) \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,({\rm{bagint}}\,({\it{set1\/}}, {\it{set2\/}})\index{bagint}, {\it{set3\/}})\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-eval-zerop-clock \\ \index{l-eval-zerop-clock}
\=\+(({\it{clock\/}} $\simeq {\tt{0}}$) $\wedge$ ({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{l-eval}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{params\/}}, {\it{clock\/}})\index{l-eval} $=$ {\bf{f}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-temps-subsetp-s-set-pos \\ \index{s-eval-temps-subsetp-s-set-pos}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\it{pos\/}})\index{s-set-pos}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-subsetp-if-caddr \\ \index{s-all-temps-setp-subsetp-if-cad!dr}
\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{set1\/}}{\bf $\;$ be$\;\;$}{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\it{set2\/}}{\bf $\;$ be$\;\;$}{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{test\/}})\index{s-temps})\index{temp-alist-to-set}, \\ 
{\it{set3\/}}{\bf $\;$ be$\;\;$}{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{s-err-flag}}\,({\it{test\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{caddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{append}}\,({\it{set1\/}}, {\it{set3\/}}))\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,({\it{set1\/}}, {\it{set2\/}})\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{caddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\it{set2\/}})\index{s-all-temps-setp}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-subsetp-if-cadddr \\ \index{s-all-temps-setp-subsetp-if-cad!ddr}
\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+{\bf let }\=\+{\it{set1\/}}{\bf $\;$ be$\;\;$}{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\it{set2\/}}{\bf $\;$ be$\;\;$}{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{test\/}})\index{s-temps})\index{temp-alist-to-set}, \\ 
{\it{set3\/}}{\bf $\;$ be$\;\;$}{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{s-err-flag}}\,({\it{test\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{cadddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{append}}\,({\it{set1\/}}, {\it{set3\/}}))\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,({\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, {\it{set2\/}})\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{cadddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\it{set2\/}})\index{s-all-temps-setp}\-$\;${\bf  endlet}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-temps-subsetp-s-set-expr \\ \index{s-eval-temps-subsetp-s-set-expr}
\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{e\/}})\index{s-set-expr}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s1\/}})\index{s-temps})\index{temp-alist-to-set}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-expr}}\,({\it{s1\/}}, {\it{s2\/}}, {\it{e\/}})\index{s-set-expr}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-1 \\ \index{s-eval-l-eval-flag-run-helper-1}
\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\it{test\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-expr}}\,({\it{test\/}}, {\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{2}})\index{dv})\index{s-set-expr}, {\it{c\/}})\index{s-eval})\index{s-err-flag} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{run}})\- \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{caddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\it{test\/}}, \\ 
{\it{s\/}}, \\ 
{\rm{dv}}\,(\=\+{\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, \\ 
{\tt{2}})\-\index{dv})\-\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{test\/}})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\it{test\/}}, \\ 
{\it{s\/}}, \\ 
{\rm{dv}}\,(\=\+{\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, \\ 
{\tt{2}})\-\index{dv})\-\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-$\;${\bf  endlet}\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-eval-l-eval-flag-run-helper-1.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-2 \\ \index{s-eval-l-eval-flag-run-helper-2}
\=\+{\bf let }\=\+{\it{test\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+(\=\+({\rm{s-err-flag}}\,({\it{s\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\it{test\/}})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;$(\=\+{\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-expr}}\,({\it{test\/}}, {\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{3}})\index{dv})\index{s-set-expr}, {\it{clock\/}})\index{s-eval})\index{s-err-flag} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{run}})\- \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadddr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\it{test\/}}, \\ 
{\it{s\/}}, \\ 
{\rm{dv}}\,(\=\+{\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, \\ 
{\tt{3}})\-\index{dv})\-\index{s-set-expr}, \\ 
{\it{clock\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{test\/}})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\it{test\/}}, \\ 
{\it{s\/}}, \\ 
{\rm{dv}}\,(\=\+{\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, \\ 
{\tt{3}})\-\index{dv})\-\index{s-set-expr}, \\ 
{\it{clock\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-$\;${\bf  endlet}\-
\end{tabbing}


\noindent{\sc Event}:   Disable s-eval-l-eval-flag-run-helper-2.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-temp-setp-s-change-temp \\ \index{s-temp-setp-s-change-temp}
\=\+{\rm{s-temp-setp}}\,({\it{expr1\/}}, {\rm{s-temps}}\,({\rm{s-change-temp}}\,({\it{state\/}}, {\it{expr2\/}}, {\it{value\/}})\index{s-change-temp})\index{s-temps})\index{s-temp-setp} \\ 
$\leftrightarrow$$\;\;\;\;$\=\+{\bf if }{\it{expr1\/}} $=$ {\it{expr2\/}}$\;\;${\bf then }{\bf{t}} \\ 
{\bf else }{\rm{s-temp-setp}}\,({\it{expr1\/}}, {\rm{s-temps}}\,({\it{state\/}})\index{s-temps})\index{s-temp-setp}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-statep-listp-assoc-temps \\ \index{s-good-statep-listp-assoc-temps}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\- \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{listp}}\,({\rm{assoc}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  listp-assoc-s-change-temp \\ \index{listp-assoc-s-change-temp}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}))\- \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s1\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s1\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{strip-cars}}\,({\rm{s-temps}}\,({\it{s1\/}})\index{s-temps}) $=$ {\rm{strip-cars}}\,({\rm{s-temps}}\,({\it{s2\/}})\index{s-temps})))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{listp}}\,({\rm{assoc}}\,(\=\+{\rm{cadr}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}), \\ 
{\rm{s-temps}}\,({\rm{s-change-temp}}\,({\it{s2\/}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}), {\it{value\/}})\index{s-change-temp})\index{s-temps})\-)\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-1-cons-non-member \\ \index{s-check-temps-setp-1-cons-non-me!mber}
\=\+({\rm{s-check-temps-setp-1}}\,({\it{temp-list\/}}, {\it{temp-set\/}})\index{s-check-temps-setp-1} $\wedge$ ({\it{expr\/}} $\not\in$ {\it{temp-list\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,({\it{temp-list\/}}, {\rm{cons}}\,({\it{expr\/}}, {\it{temp-set\/}}))\index{s-check-temps-setp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-1-cons-member \\ \index{s-check-temps-setp-1-cons-membe!r}
\=\+(\=\+{\rm{s-check-temps-setp-1}}\,({\it{temp-list\/}}, {\it{temp-set\/}})\index{s-check-temps-setp-1} \\ 
$\wedge$$\;\;\;\;$({\it{expr\/}} $\in$ {\it{temp-list\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,({\rm{s-collect-all-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-collect-all-temps}, {\it{temp-set\/}})\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,({\it{temp-list\/}}, {\rm{cons}}\,({\it{expr\/}}, {\it{temp-set\/}}))\index{s-check-temps-setp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-1-put-assoc \\ \index{s-check-temps-setp-1-put-assoc}
\=\+(\=\+{\rm{definedp}}\,({\it{expr\/}}, {\it{temp-alist\/}})\index{definedp} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,(\=\+{\it{temp-list\/}}, \\ 
{\rm{cons}}\,({\it{expr\/}}, {\rm{temp-alist-to-set}}\,({\it{temp-alist\/}})\index{temp-alist-to-set}))\-\index{s-check-temps-setp-1})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp-1}}\,(\=\+{\it{temp-list\/}}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{put-assoc}}\,(\=\+{\rm{cons}}\,({\bf{t}}, {\it{any\/}}), \\ 
{\it{expr\/}}, \\ 
{\it{temp-alist\/}})\-\index{put-assoc})\index{temp-alist-to-set})\-\index{s-check-temps-setp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-put-assoc \\ \index{s-check-temps-setp-put-assoc}
\=\+{\bf let }\=\+{\it{cadr-s\/}}{\bf $\;$ be$\;\;$}{\rm{s-eval}}\,({\bf{t}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval}\- \\ 
{\bf in} \\ 
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\it{cadr-s\/}})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{cadr-s\/}})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-eval}}\index{s-temp-eval}))\-)\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\rm{s-change-temp}}\,(\=\+{\it{cadr-s\/}}, \\ 
{\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), \\ 
{\it{value\/}})\-\index{s-change-temp})\index{s-temps})\index{s-check-temps-setp}\-$\;${\bf  endlet}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-check-s-temp-setp-1-subsetp \\ \index{member-check-s-temp-setp-1-subsetp}
\=\+(\=\+{\rm{s-check-temps-setp-1}}\,({\it{temp-list\/}}, {\it{set\/}})\index{s-check-temps-setp-1} \\ 
$\wedge$$\;\;\;\;$({\it{expr\/}} $\in$ {\it{set\/}}) \\ 
$\wedge$$\;\;\;\;$({\it{expr\/}} $\in$ {\it{temp-list\/}}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,({\rm{s-collect-all-temps}}\,({\bf{t}}, {\it{expr\/}})\index{s-collect-all-temps}, {\it{set\/}})\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-3 \\ \index{s-eval-l-eval-flag-run-helper-3}
\=\+(\=\+{\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-temp-setp}}\,({\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}), {\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-temp-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$(\=\+({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\vee$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}))\-)\- \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{cadr}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-5 \\ \index{s-eval-l-eval-flag-run-helper-5}
\=\+(\=\+({\bf{f}} $\in$ {\rm{l-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-expand-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}))\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{state\/}})\index{s-params}, \\ 
{\it{clock\/}})\-\index{l-eval}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) $\not=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) $\not=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{state\/}})\index{s-expr}) $\not=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{state\/}})\index{s-expr})\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{state\/}})\index{s-params}, \\ 
{\it{clock\/}})\-\index{l-eval})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-member-progs \\ \index{s-check-temps-setp-member-progs}
\=\+({\rm{s-all-progs-temps-setp}}\,({\it{progs\/}})\index{s-all-progs-temps-setp} $\wedge$ ({\it{x\/}} $\in$ {\it{progs\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{make-temps-entries}}\,({\rm{s-temp-list}}\,({\it{x\/}})\index{s-temp-list})\index{make-temps-entries})\index{s-check-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-member-progs \\ \index{s-all-temps-setp-member-progs}
\=\+({\rm{s-all-progs-temps-setp}}\,({\it{progs\/}})\index{s-all-progs-temps-setp} $\wedge$ ({\it{x\/}} $\in$ {\it{progs\/}})) \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{s-body}}\,({\it{x\/}})\index{s-body}, {\bf{nil}})\index{s-all-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-check-temps-setp-s-all-progs-temps-setp \\ \index{s-check-temps-setp-s-all-progs-te!mps-setp}
\=\+(\=\+{\rm{s-all-progs-temps-setp}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{s-all-progs-temps-setp} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{make-temps-entries}}\,({\rm{s-temp-list}}\,({\rm{assoc}}\,(\=\+{\rm{user-fname}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))\index{user-fname}, \\ 
{\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\-)\index{s-temp-list})\index{make-temps-entries})\index{s-check-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-6 \\ \index{s-eval-l-eval-flag-run-helper-6}
\=\+(\=\+{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{l-eval}}\,(\=\+{\bf{t}}, \\ 
{\rm{body}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})), \\ 
{\rm{pairlist}}\,(\=\+{\rm{formals}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})), \\ 
{\rm{s-ans}}\,({\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-pos}}\,({\it{s\/}}, {\rm{dv}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\tt{1}})\index{dv})\index{s-set-pos}, {\it{c\/}})\index{s-eval})\index{s-ans})\-, \\ 
{\it{c\/}} $-\;1$)\-\index{l-eval}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-s-all-progs-temps-setp \\ \index{s-all-temps-setp-s-all-progs-te!mps-setp}
\=\+(\=\+{\rm{s-all-progs-temps-setp}}\,({\rm{s-progs}}\,({\it{s1\/}})\index{s-progs})\index{s-all-progs-temps-setp} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{subrp}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-good-statep}}\,({\it{s1\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s1\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s1\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$({\rm{s-progs}}\,({\it{s1\/}})\index{s-progs} $=$ {\rm{s-progs}}\,({\it{s2\/}})\index{s-progs}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\bf{t}}, {\rm{s-expr}}\,({\rm{s-fun-call-state}}\,({\it{s2\/}}, {\rm{car}}\,({\rm{s-expr}}\,({\it{s1\/}})\index{s-expr}))\index{s-fun-call-state})\index{s-expr}, {\bf{nil}})\index{s-all-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-fact-2 \\ \index{s-proper-exprp-fact-2}
\=\+(\=\+{\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{litatom}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr})))\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-all-temps-setp-subsetp-flag-list \\ \index{s-all-temps-setp-subsetp-flag-li!st}
\=\+(\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}), \\ 
{\rm{append}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set})\-)\-\index{s-all-temps-setp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}), \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{s-all-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-s-good-statep-bad-car-expr \\ \index{not-s-good-statep-bad-car-expr}
\=\+(\=\+{\rm{listp}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{if}}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-eval}}\index{s-temp-eval}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-test}}\index{s-temp-test}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\sc{s-temp-fetch}}\index{s-temp-fetch}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}) $\not=$ {\tt{'}}{\tt{quote}}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{litatom}}\,({\rm{car}}\,({\rm{s-expr}}\,({\it{s\/}})\index{s-expr}))) \\ 
$\wedge$$\;\;\;\;${\rm{good-posp1}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp1})\- \\ 
$\rightarrow$$\;\;\;\;$($\neg$ {\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-helper-7 \\ \index{s-eval-l-eval-flag-run-helper-7}
\=\+(\=\+(\=\+{\rm{s-err-flag}}\,({\rm{s-eval}}\,({\tt{'}}{\tt{list}}, {\rm{s-set-expr}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, {\it{s\/}}, {\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\index{s-set-expr}, {\it{c\/}})\index{s-eval})\index{s-err-flag} \\ 
$=$$\;\;\;\;${\tt{'}}{\tt{run}})\- \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos}) \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\tt{'}}{\tt{list}}, {\rm{cdr}}\,({\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list}))\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, \\ 
{\it{s\/}}, \\ 
{\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\-\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\bf{t}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{s-set-expr}}\,(\=\+{\rm{s-eval}}\,({\bf{t}}, {\it{s\/}}, {\it{c\/}})\index{s-eval}, \\ 
{\it{s\/}}, \\ 
{\rm{nx}}\,({\rm{s-pos}}\,({\it{s\/}})\index{s-pos})\index{nx})\-\index{s-set-expr}, \\ 
{\it{c\/}})\-\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  not-listp-pos-not-good-posp \\ \index{not-listp-pos-not-good-posp}
($\neg$ {\rm{listp}}\,({\it{pos\/}})) $\rightarrow$ ($\neg$ {\rm{good-posp}}\,({\tt{'}}{\tt{list}}, {\it{pos\/}}, {\it{body\/}})\index{good-posp})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run \\ \index{s-eval-l-eval-flag-run}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp}}\,({\it{flag\/}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,(\=\+{\it{flag\/}}, \\ 
\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}}$\;\;${\bf then }{\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list} \\ 
{\bf else }{\rm{s-expr}}\,({\it{s\/}})\index{s-expr}$\;${\bf  endif}\-, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set})\-\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-progs-temps-setp}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{s-all-progs-temps-setp} \\ 
$\wedge$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }{\bf{f}} $\not\in$ {\rm{l-eval}}\,(\=\+{\it{flag\/}}, \\ 
{\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list})\index{s-expand-temps}, \\ 
{\rm{s-params}}\,({\it{s\/}})\index{s-params}, \\ 
{\it{c\/}})\-\index{l-eval} \\ 
{\bf else }{\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval}$\;${\bf  endif}\- \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-check-temps-setp})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,(\=\+{\it{flag\/}}, \\ 
\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }{\rm{s-expr-list}}\,({\it{s\/}})\index{s-expr-list} \\ 
{\bf else }{\rm{s-expr}}\,({\it{s\/}})\index{s-expr}$\;${\bf  endif}\-)\-\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp})\-\-
\end{tabbing}


\begin{tabbing}{\sc Definition}:\index{s-construct-programs} \\  
\=\+{\rm{s-construct-programs}}\,({\it{fun-list\/}})\index{s-construct-programs} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{fun-list\/}}) \\ 
{\bf then }{\rm{cons}}\,(\=\+{\rm{list}}\,(\=\+{\rm{user-fname}}\,({\rm{car}}\,({\it{fun-list\/}}))\index{user-fname}, \\ 
{\rm{formals}}\,({\rm{car}}\,({\it{fun-list\/}})), \\ 
{\bf{nil}}, \\ 
{\rm{body}}\,({\rm{car}}\,({\it{fun-list\/}})))\-, \\ 
{\rm{s-construct-programs}}\,({\rm{cdr}}\,({\it{fun-list\/}}))\index{s-construct-programs})\- \\ 
{\bf else }{\bf{nil}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{delete-all} \\  
\=\+{\rm{delete-all}}\,({\it{x\/}}, {\it{l\/}})\index{delete-all} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }\=\+{\bf if }{\it{x\/}} $=$ {\rm{car}}\,({\it{l\/}})$\;\;${\bf then }{\rm{delete-all}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{l\/}}))\index{delete-all} \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{l\/}}), {\rm{delete-all}}\,({\it{x\/}}, {\rm{cdr}}\,({\it{l\/}}))\index{delete-all})$\;${\bf  endif}\- \\ 
{\bf else }{\it{l\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  delete-all-non-decreasing-count \\ \index{delete-all-non-decreasing-count}
{\rm{count}}\,({\it{l\/}}) $\not<$ {\rm{count}}\,({\rm{delete-all}}\,({\it{x\/}}, {\it{l\/}})\index{delete-all})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{remove-duplicates} \\  
\=\+{\rm{remove-duplicates}}\,({\it{l\/}})\index{remove-duplicates} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{l\/}}) \\ 
{\bf then }{\rm{cons}}\,({\rm{car}}\,({\it{l\/}}), {\rm{remove-duplicates}}\,({\rm{delete-all}}\,({\rm{car}}\,({\it{l\/}}), {\rm{cdr}}\,({\it{l\/}}))\index{delete-all})\index{remove-duplicates}) \\ 
{\bf else }{\it{l\/}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{logic-$>$s} \\  
\=\+{\rm{logic-$>$s}}\,({\it{expr\/}}, {\it{alist\/}}, {\it{fun-names\/}})\index{logic-$>$s} \\ 
$=$$\;\;\;\;${\rm{s-state}}\,(\=\+{\tt{'}}{\tt{main}}, \\ 
{\bf{nil}}, \\ 
{\bf{nil}}, \\ 
{\it{alist\/}}, \\ 
{\bf{nil}}, \\ 
{\rm{cons}}\,(\=\+{\rm{list}}\,({\tt{'}}{\tt{main}}, {\rm{strip-cars}}\,({\it{alist\/}}), {\bf{nil}}, {\it{expr\/}}), \\ 
{\rm{s-construct-programs}}\,({\rm{remove-duplicates}}\,({\it{fun-names\/}})\index{remove-duplicates})\index{s-construct-programs})\-, \\ 
{\tt{'}}{\tt{run}})\-\index{s-state}\-
\end{tabbing}

\begin{verbatim}; (setq st (logic->s '(plus (length (app '(a) x)) '2)
; 		      '((x . (b c)))
; 		       '(app length)))

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{l-proper-exprp} \\  
\=\+{\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{body\/}}, {\it{program-names\/}}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{flag\/}} $=$ {\tt{'}}{\tt{list}} \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\it{body\/}}) \\ 
{\bf then }\=\+{\rm{l-proper-exprp}}\,({\bf{t}}, {\rm{car}}\,({\it{body\/}}), {\it{program-names\/}}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{body\/}}), \\ 
{\it{program-names\/}}, \\ 
{\it{formals\/}})\-\index{l-proper-exprp}\- \\ 
{\bf else }{\it{body\/}} $=$ {\bf{nil}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{listp}}\,({\it{body\/}}) \\ 
{\bf then }\=\+{\bf if }$\neg$ {\rm{plistp}}\,({\it{body\/}})\index{plistp}$\;\;${\bf then }{\bf{f}} \\ 
{\bf elseif }{\rm{car}}\,({\it{body\/}}) $=$ {\tt{'}}{\tt{quote}} \\ 
{\bf then }{\rm{length}}\,({\rm{cdr}}\,({\it{body\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{body\/}}))\index{arity} \\ 
{\bf elseif }{\rm{subrp}}\,({\rm{car}}\,({\it{body\/}})) \\ 
{\bf then }\=\+({\rm{length}}\,({\rm{cdr}}\,({\it{body\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{body\/}}))\index{arity}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $\not\in$ {\it{program-names\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{body\/}}), \\ 
{\it{program-names\/}}, \\ 
{\it{formals\/}})\-\index{l-proper-exprp}\- \\ 
{\bf elseif }{\rm{body}}\,({\rm{car}}\,({\it{body\/}})) \\ 
{\bf then }\=\+({\rm{length}}\,({\rm{cdr}}\,({\it{body\/}}))\index{length} $=$ {\rm{arity}}\,({\rm{car}}\,({\it{body\/}}))\index{arity}) \\ 
$\wedge$$\;\;\;\;$({\rm{car}}\,({\it{body\/}}) $\in$ {\it{program-names\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-exprp}}\,(\=\+{\tt{'}}{\tt{list}}, \\ 
{\rm{cdr}}\,({\it{body\/}}), \\ 
{\it{program-names\/}}, \\ 
{\it{formals\/}})\-\index{l-proper-exprp}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{litatom}}\,({\it{body\/}})$\;\;${\bf then }{\it{body\/}} $\in$ {\it{formals\/}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{l-proper-programsp-1} \\  
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{program-names\/}}) \\ 
{\bf then }\=\+{\rm{formals}}\,({\rm{car}}\,({\it{program-names\/}})) \\ 
$\wedge$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{formals}}\,({\rm{car}}\,({\it{program-names\/}})))\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-exprp}}\,(\=\+{\bf{t}}, \\ 
{\rm{body}}\,({\rm{car}}\,({\it{program-names\/}})), \\ 
{\it{all-program-names\/}}, \\ 
{\rm{formals}}\,({\rm{car}}\,({\it{program-names\/}})))\-\index{l-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-programsp-1}}\,({\rm{cdr}}\,({\it{program-names\/}}), {\it{all-program-names\/}})\index{l-proper-programsp-1}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{l-proper-programsp} \\  
\=\+{\rm{l-proper-programsp}}\,({\it{program-names\/}})\index{l-proper-programsp} \\ 
$=$$\;\;\;\;${\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{program-names\/}})\index{l-proper-programsp-1}\-
\end{tabbing}


\noindent{\sc Event}:   Disable l-proper-programsp.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  definedp-assoc-fact-1 \\ \index{definedp-assoc-fact-1}
($\neg$ {\rm{definedp}}\,({\it{expr\/}}, {\it{alist\/}})\index{definedp}) $\rightarrow$ ($\neg$ {\rm{assoc}}\,({\it{expr\/}}, {\it{alist\/}}))
\end{tabbing}


\noindent{\sc Event}:   Disable definedp-assoc-fact-1.

\addvspace{18pt}  

\begin{tabbing}{\sc Definition}:\index{all-litatoms-not-plist} \\  
\=\+{\rm{all-litatoms-not-plist}}\,({\it{list\/}})\index{all-litatoms-not-plist} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{list\/}}) \\ 
{\bf then }{\rm{litatom}}\,({\rm{car}}\,({\it{list\/}})) $\wedge$ {\rm{all-litatoms-not-plist}}\,({\rm{cdr}}\,({\it{list\/}}))\index{all-litatoms-not-plist} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  strip-logic-fnames-s-construct-programs \\ \index{strip-logic-fnames-s-construct-p!rograms}
\=\+{\rm{all-litatoms-not-plist}}\,({\it{program-names\/}})\index{all-litatoms-not-plist} \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{strip-logic-fnames}}\,({\rm{s-construct-programs}}\,({\it{program-names\/}})\index{s-construct-programs})\index{strip-logic-fnames} \\ 
$=$$\;\;\;\;${\rm{plist}}\,({\it{program-names\/}})\index{plist})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-expr-functions-definedp-s-proper-expr \\ \index{l-proper-expr-functions-definedp!-s-proper-expr}
\=\+{\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{prog\/}}, {\it{all-program-names\/}}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{prog\/}}, {\it{all-program-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-programs-properp-s-construct-programs \\ \index{s-programs-properp-s-construct-p!rograms}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-programs-properp}}\,(\=\+{\rm{s-construct-programs}}\,({\it{program-names\/}})\index{s-construct-programs}, \\ 
{\it{all-program-names\/}})\-\index{s-programs-properp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-plist \\ \index{s-proper-exprp-plist}
\=\+{\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\rm{plist}}\,({\it{program-names\/}})\index{plist}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$=$$\;\;\;\;${\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{program-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-programsp-plist \\ \index{s-proper-programsp-plist}
\=\+{\rm{s-programs-properp}}\,({\it{programs\/}}, {\rm{plist}}\,({\it{program-names\/}})\index{plist})\index{s-programs-properp} \\ 
$=$$\;\;\;\;${\rm{s-programs-properp}}\,({\it{programs\/}}, {\it{program-names\/}})\index{s-programs-properp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-expand-temps-body-equal-body \\ \index{s-expand-temps-body-equal-body}
\=\+{\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{all-program-names\/}}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$\rightarrow$$\;\;\;\;$({\rm{s-expand-temps}}\,({\it{flag\/}}, {\it{expr\/}})\index{s-expand-temps} $=$ {\it{expr\/}})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programsp-1-delete-all \\ \index{l-proper-programsp-1-delete-all}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{l-proper-programsp-1}}\,({\rm{delete-all}}\,({\it{name\/}}, {\it{program-names\/}})\index{delete-all}, {\it{all-program-names\/}})\index{l-proper-programsp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  user-fnamep-user-fname \\ \index{user-fnamep-user-fname}
{\rm{user-fnamep}}\,({\rm{user-fname}}\,({\it{x\/}})\index{user-fname})\index{user-fnamep}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  logic-fname-user-fname-identity-formals \\ \index{logic-fname-user-fname-identity!-formals}
{\rm{formals}}\,({\it{x\/}}) $\rightarrow$ ({\rm{logic-fname}}\,({\rm{user-fname}}\,({\it{x\/}})\index{user-fname})\index{logic-fname} $=$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-programs-okp-s-construct-programs \\ \index{s-programs-okp-s-construct-prog!rams}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-programs-okp}}\,({\rm{s-construct-programs}}\,({\rm{remove-duplicates}}\,({\it{program-names\/}})\index{remove-duplicates})\index{s-construct-programs})\index{s-programs-okp}\-
\end{tabbing}


\noindent{\sc Event}:   Disable logic-fname-user-fname-identity-formals.

\addvspace{18pt}

\begin{tabbing}{\sc Theorem}:  s-eval-l-eval-flag-run-flag-t \\ \index{s-eval-l-eval-flag-run-flag-t}
\=\+(\=\+{\rm{s-good-statep}}\,({\it{s\/}}, {\it{c\/}})\index{s-good-statep} \\ 
$\wedge$$\;\;\;\;${\rm{good-posp}}\,({\it{flag\/}}, {\rm{s-pos}}\,({\it{s\/}})\index{s-pos}, {\rm{s-body}}\,({\rm{s-prog}}\,({\it{s\/}})\index{s-prog})\index{s-body})\index{good-posp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr}, {\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{temp-alist-to-set})\index{s-all-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{s-all-progs-temps-setp}}\,({\rm{s-progs}}\,({\it{s\/}})\index{s-progs})\index{s-all-progs-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{l-eval}}\,({\it{flag\/}}, {\rm{s-expand-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-expand-temps}, {\rm{s-params}}\,({\it{s\/}})\index{s-params}, {\it{c\/}})\index{l-eval} \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\it{s\/}})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;$({\it{flag\/}} $\not=$ {\tt{'}}{\tt{list}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+({\rm{s-err-flag}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-err-flag} $=$ {\tt{'}}{\tt{run}}) \\ 
$\wedge$$\;\;\;\;${\rm{s-check-temps-setp}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{s-check-temps-setp} \\ 
$\wedge$$\;\;\;\;${\rm{subsetp}}\,(\=\+{\rm{s-collect-all-temps}}\,({\it{flag\/}}, {\rm{s-expr}}\,({\it{s\/}})\index{s-expr})\index{s-collect-all-temps}, \\ 
{\rm{temp-alist-to-set}}\,({\rm{s-temps}}\,({\rm{s-eval}}\,({\it{flag\/}}, {\it{s\/}}, {\it{c\/}})\index{s-eval})\index{s-temps})\index{temp-alist-to-set})\-\index{subsetp})\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-expr-s-all-temps-setp \\ \index{l-proper-expr-s-all-temps-setp}
\=\+{\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{prog-names\/}}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-temps-setp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{temp-set\/}})\index{s-all-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programsp-1-s-all-progs-temps-setp \\ \index{l-proper-programsp-1-s-all-prog!s-temps-setp}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-progs-temps-setp}}\,({\rm{s-construct-programs}}\,({\it{program-names\/}})\index{s-construct-programs})\index{s-all-progs-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programsp-s-all-progs-temps-setp \\ \index{l-proper-programsp-s-all-progs-te!mps-setp}
\=\+{\rm{l-proper-programsp}}\,({\it{program-names\/}})\index{l-proper-programsp} \\ 
$\rightarrow$$\;\;\;\;${\rm{s-all-progs-temps-setp}}\,({\rm{s-construct-programs}}\,({\it{program-names\/}})\index{s-construct-programs})\index{s-all-progs-temps-setp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-delete-all \\ \index{member-delete-all}
\=\+({\it{x\/}} $\in$ {\rm{delete-all}}\,({\it{y\/}}, {\it{l\/}})\index{delete-all}) \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{x\/}} $\in$ {\it{l\/}}$\;\;${\bf then }{\it{x\/}} $\not=$ {\it{y\/}} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  member-remove-duplicates \\ \index{member-remove-duplicates}
({\it{e\/}} $\in$ {\rm{remove-duplicates}}\,({\it{x\/}})\index{remove-duplicates}) $=$ ({\it{e\/}} $\in$ {\it{x\/}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-proper-exprp-remove-duplicates \\ \index{s-proper-exprp-remove-duplicate!s}
\=\+{\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\rm{remove-duplicates}}\,({\it{prog-names\/}})\index{remove-duplicates}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp} \\ 
$=$$\;\;\;\;${\rm{s-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{prog-names\/}}, {\it{formals\/}}, {\it{temp-list\/}})\index{s-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-exprp-remove-duplicates \\ \index{l-proper-exprp-remove-duplicate!s}
\=\+{\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\rm{remove-duplicates}}\,({\it{prog-names\/}})\index{remove-duplicates}, {\it{formals\/}})\index{l-proper-exprp} \\ 
$=$$\;\;\;\;${\rm{l-proper-exprp}}\,({\it{flag\/}}, {\it{expr\/}}, {\it{prog-names\/}}, {\it{formals\/}})\index{l-proper-exprp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programs-remove-duplicates-arg2 \\ \index{l-proper-programs-remove-duplic!ates-arg2}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\rm{remove-duplicates}}\,({\it{all-program-names\/}})\index{remove-duplicates})\index{l-proper-programsp-1} \\ 
$=$$\;\;\;\;${\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programs-remove-duplicates-arg1 \\ \index{l-proper-programs-remove-duplic!ates-arg1}
\=\+{\rm{l-proper-programsp-1}}\,({\it{program-names\/}}, {\it{all-program-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{l-proper-programsp-1}}\,(\=\+{\rm{remove-duplicates}}\,({\it{program-names\/}})\index{remove-duplicates}, \\ 
{\it{all-program-names\/}})\-\index{l-proper-programsp-1}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  all-litatoms-not-plist-delete-all \\ \index{all-litatoms-not-plist-delete-a!ll}
{\rm{all-litatoms-not-plist}}\,({\it{list\/}})\index{all-litatoms-not-plist} $\rightarrow$ {\rm{all-litatoms-not-plist}}\,({\rm{delete-all}}\,({\it{x\/}}, {\it{list\/}})\index{delete-all})\index{all-litatoms-not-plist}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  all-litatoms-not-plist-remove-duplicates \\ \index{all-litatoms-not-plist-remove-d!uplicates}
\=\+{\rm{all-litatoms-not-plist}}\,({\it{list\/}})\index{all-litatoms-not-plist} \\ 
$\rightarrow$$\;\;\;\;${\rm{all-litatoms-not-plist}}\,({\rm{remove-duplicates}}\,({\it{list\/}})\index{remove-duplicates})\index{all-litatoms-not-plist}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  all-litatoms-not-plist-lr-proper-programsp-1 \\ \index{all-litatoms-not-plist-lr-prope!r-programsp-1}
\=\+{\rm{l-proper-programsp-1}}\,({\it{prog-names\/}}, {\it{all-prog-names\/}})\index{l-proper-programsp-1} \\ 
$\rightarrow$$\;\;\;\;${\rm{all-litatoms-not-plist}}\,({\it{prog-names\/}})\index{all-litatoms-not-plist}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  s-good-state-s-construct-programs \\ \index{s-good-state-s-construct-progra!ms}
\=\+(\=\+{\rm{l-proper-programsp}}\,({\it{prog-names\/}})\index{l-proper-programsp} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-exprp}}\,({\bf{t}}, {\it{expr\/}}, {\it{prog-names\/}}, {\rm{strip-cars}}\,({\it{alist\/}}))\index{l-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{strip-cars}}\,({\it{alist\/}}))\index{all-litatoms})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{s-good-statep}}\,(\=\+{\rm{s-state}}\,(\=\+{\tt{'}}{\tt{main}}, \\ 
{\bf{nil}}, \\ 
{\bf{nil}}, \\ 
{\it{alist\/}}, \\ 
{\bf{nil}}, \\ 
{\rm{cons}}\,(\=\+{\rm{list}}\,({\tt{'}}{\tt{main}}, {\rm{strip-cars}}\,({\it{alist\/}}), {\bf{nil}}, {\it{expr\/}}), \\ 
{\rm{s-construct-programs}}\,({\rm{remove-duplicates}}\,({\it{prog-names\/}})\index{remove-duplicates})\index{s-construct-programs})\-, \\ 
{\tt{'}}{\tt{run}})\-\index{s-state}, \\ 
{\it{c\/}})\-\index{s-good-statep}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  l-proper-programsp-remove-duplicates \\ \index{l-proper-programsp-remove-dupli!cates}
\=\+{\rm{l-proper-programsp}}\,({\it{program-names\/}})\index{l-proper-programsp} \\ 
$\rightarrow$$\;\;\;\;${\rm{l-proper-programsp}}\,({\rm{remove-duplicates}}\,({\it{program-names\/}})\index{remove-duplicates})\index{l-proper-programsp}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  logic-$>$s-ok \\ \index{logic-$>$s-ok}
\=\+(\=\+{\rm{l-proper-exprp}}\,({\bf{t}}, {\it{expr\/}}, {\it{program-names\/}}, {\rm{strip-cars}}\,({\it{alist\/}}))\index{l-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-programsp}}\,({\it{program-names\/}})\index{l-proper-programsp} \\ 
$\wedge$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{strip-cars}}\,({\it{alist\/}}))\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{l-eval}}\,({\bf{t}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{logic-$>$s}}\,({\it{expr\/}}, {\it{alist\/}}, {\it{program-names\/}})\index{logic-$>$s}, {\it{clock\/}})\index{s-eval})\index{s-ans} \\ 
$=$$\;\;\;\;${\rm{car}}\,({\rm{l-eval}}\,({\bf{t}}, {\it{expr\/}}, {\it{alist\/}}, {\it{clock\/}})\index{l-eval}))\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  logic-$>$s-ok-really \\ \index{logic-$>$s-ok-really}
\=\+(\=\+{\rm{l-proper-exprp}}\,({\bf{t}}, {\it{expr\/}}, {\it{program-names\/}}, {\rm{strip-cars}}\,({\it{alist\/}}))\index{l-proper-exprp} \\ 
$\wedge$$\;\;\;\;${\rm{l-proper-programsp}}\,({\it{program-names\/}})\index{l-proper-programsp} \\ 
$\wedge$$\;\;\;\;${\rm{all-litatoms}}\,({\rm{strip-cars}}\,({\it{alist\/}}))\index{all-litatoms} \\ 
$\wedge$$\;\;\;\;${\rm{v\&c\$}}\,({\bf{t}}, {\it{expr\/}}, {\it{alist\/}}) \\ 
$\wedge$$\;\;\;\;$({\rm{cdr}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{expr\/}}, {\it{alist\/}})) $<$ {\it{clock\/}}))\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{s-ans}}\,({\rm{s-eval}}\,({\bf{t}}, {\rm{logic-$>$s}}\,({\it{expr\/}}, {\it{alist\/}}, {\it{program-names\/}})\index{logic-$>$s}, {\it{clock\/}})\index{s-eval})\index{s-ans} \\ 
$=$$\;\;\;\;${\rm{car}}\,({\rm{v\&c\$}}\,({\bf{t}}, {\it{expr\/}}, {\it{alist\/}})))\-\-
\end{tabbing}

\noindent{\sc Event}:   Make the library {\tt{"app-c-d-e"}} and compile it.

\addvspace{18pt}


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