\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.
|#

;; A solution to the Gilbreath card trick challenge.
;; Matt Kaufmann, 10/92.

;; The proof splits into two halves.  The lemma main-1 handles the
;; case in which we do not make the final adjustment of rotating one
;; card.  The lemma main-2 handles the other case.  We glue these
;; together in the final theorem, main.

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

\addvspace{18pt}

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

\begin{verbatim};; The following definition takes an arbitrary `oracle', which says
;; whether the next card in the shuffle comes from the left pile or
;; the right pile.  See below for the definition of shuffle-top,
;; which makes the `move one card' adjustment when necessary.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{shuffle} \\  
\=\+{\rm{shuffle}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\it{left\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{right\/}} \\ 
{\bf elseif }{\it{right\/}} $\simeq\;${{\bf{nil}}}${}$$\;\;${\bf then }{\it{left\/}} \\ 
{\bf elseif }{\rm{car}}\,({\it{oracle\/}}) \\ 
{\bf then }{\rm{cons}}\,({\rm{car}}\,({\it{left\/}}), {\rm{shuffle}}\,({\rm{cdr}}\,({\it{left\/}}), {\it{right\/}}, {\rm{cdr}}\,({\it{oracle\/}}))\index{shuffle}) \\ 
{\bf else }{\rm{cons}}\,({\rm{car}}\,({\it{right\/}}), {\rm{shuffle}}\,({\it{left\/}}, {\rm{cdr}}\,({\it{right\/}}), {\rm{cdr}}\,({\it{oracle\/}}))\index{shuffle})$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; To be really arbitrary, we postulate a color function that takes
;; two values (which might as well be booleans), using the
;; conservative CONSTRAIN principle to make this postulation.

\end{verbatim}\begin{tabbing}{\sc Conservative Axiom}:  color-intro \\ \index{color-intro}
{\rm{truep}}\,({\rm{color}}\,({\it{x\/}})\index{color}) $\vee$ {\rm{falsep}}\,({\rm{color}}\,({\it{x\/}})\index{color})
\end{tabbing}\noindent Simultaneously, we introduce the new function symbol {\it color\/}.

\begin{tabbing}{\sc Definition}:\index{same-color}$\;\;$
{\rm{same-color}}\,({\it{x\/}}, {\it{y\/}})\index{same-color} $=$ ({\rm{color}}\,({\it{x\/}})\index{color} $\leftrightarrow$ {\rm{color}}\,({\it{y\/}})\index{color})
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{altp} \\  
\=\+{\rm{altp}}\,({\it{pile\/}})\index{altp} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{pile\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{pile\/}})) \\ 
{\bf then }\=\+{\bf if }{\rm{same-color}}\,({\rm{car}}\,({\it{pile\/}}), {\rm{cadr}}\,({\it{pile\/}}))\index{same-color}$\;\;${\bf then }{\bf{f}} \\ 
{\bf else }{\rm{altp}}\,({\rm{cdr}}\,({\it{pile\/}}))\index{altp}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

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

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

\begin{tabbing}{\sc Definition}:\index{shuffle-top} \\  
\=\+{\rm{shuffle-top}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle-top} \\ 
$=$$\;\;\;\;$\=\+{\bf let }\=\+{\it{shuf\/}}{\bf $\;$ be$\;\;$}{\rm{shuffle}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle}\- \\ 
{\bf in} \\ 
\=\+{\bf if }$\neg$ {\rm{same-color}}\,({\rm{last}}\,({\it{left\/}})\index{last}, {\rm{last}}\,({\it{right\/}})\index{last})\index{same-color}$\;\;${\bf then }{\it{shuf\/}} \\ 
{\bf else }{\rm{cons}}\,({\rm{last}}\,({\it{shuf\/}})\index{last}, {\rm{butlast}}\,({\it{shuf\/}})\index{butlast})$\;${\bf  endif}\-$\;${\bf  endlet}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{even-length-p-rec} \\  
\=\+{\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}})$\;\;${\bf then }$\neg$ {\rm{even-length-p-rec}}\,({\rm{cdr}}\,({\it{x\/}}))\index{even-length-p-rec} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  even-length-p-rec-rewrite \\ \index{even-length-p-rec-rewrite}
\=\+({\rm{listp}}\,({\it{x\/}}) $\wedge$ {\rm{altp}}\,({\it{x\/}})\index{altp}) \\ 
$\rightarrow$$\;\;\;\;$({\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec} $=$ ($\neg$ {\rm{same-color}}\,({\rm{car}}\,({\it{x\/}}), {\rm{last}}\,({\it{x\/}})\index{last})\index{same-color}))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  even-length-p-rec-append \\ \index{even-length-p-rec-append}
\=\+{\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{even-length-p-rec} \\ 
$=$$\;\;\;\;$({\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec} $\leftrightarrow$ {\rm{even-length-p-rec}}\,({\it{y\/}})\index{even-length-p-rec})\-
\end{tabbing}

\begin{verbatim};; A conditional rewrite rule with hypothesis
;; (and (listp x) (listp y)) would probably suffice for most of the
;; proof, but I believe that this version is needed somewhere late in
;; the proof.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  altp-append \\ \index{altp-append}
\=\+{\rm{altp}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{altp} \\ 
$=$$\;\;\;\;$(\=\+{\rm{altp}}\,({\it{x\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{y\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;$(({\rm{listp}}\,({\it{x\/}}) $\wedge$ {\rm{listp}}\,({\it{y\/}})) $\rightarrow$ ($\neg$ {\rm{same-color}}\,({\rm{last}}\,({\it{x\/}})\index{last}, {\rm{car}}\,({\it{y\/}}))\index{same-color})))\-\-
\end{tabbing}

\begin{verbatim};; Probably the following lemma isn't needed till the end, but let's
;; make sure that we can prove it.  Once we know this to be true,
;; we'll use it implicitly by adding in the hypothesis
;; (not (same-color (car left) (car right))) to main-1 (and similarly
;; for main-2).

\end{verbatim}\begin{tabbing}{\sc Theorem}:  last-same-color-iff-first-same-color \\ \index{last-same-color-iff-first-same-!color}
\=\+(\=\+{\rm{listp}}\,({\it{left\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{right\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{even-length-p-rec})\- \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{same-color}}\,({\rm{last}}\,({\it{left\/}})\index{last}, {\rm{last}}\,({\it{right\/}})\index{last})\index{same-color} \\ 
$\leftrightarrow$$\;\;\;\;${\rm{same-color}}\,({\rm{car}}\,({\it{left\/}}), {\rm{car}}\,({\it{right\/}}))\index{same-color})\-\-
\end{tabbing}

\begin{verbatim};; Here is the induction scheme we use for main-1, and in fact also
;; for main-2 (actually main-2-lemma).

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{main-1-induction} \\  
\=\+{\rm{main-1-induction}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{main-1-induction} \\ 
$=$$\;\;\;\;$\=\+{\bf if }({\it{left\/}} $\simeq\;${{\bf{nil}}}${}$) $\vee$ ({\it{right\/}} $\simeq\;${{\bf{nil}}}${}$)$\;\;${\bf then }{\bf{t}} \\ 
{\bf elseif }{\rm{car}}\,({\it{oracle\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{cadr}}\,({\it{oracle\/}}) \\ 
{\bf then }{\rm{main-1-induction}}\,({\rm{cddr}}\,({\it{left\/}}), {\it{right\/}}, {\rm{cddr}}\,({\it{oracle\/}}))\index{main-1-induction} \\ 
{\bf else }{\rm{main-1-induction}}\,({\rm{cdr}}\,({\it{left\/}}), {\rm{cdr}}\,({\it{right\/}}), {\rm{cddr}}\,({\it{oracle\/}}))\index{main-1-induction}$\;${\bf  endif}\- \\ 
{\bf elseif }{\rm{cadr}}\,({\it{oracle\/}}) \\ 
{\bf then }{\rm{main-1-induction}}\,({\rm{cdr}}\,({\it{left\/}}), {\rm{cdr}}\,({\it{right\/}}), {\rm{cddr}}\,({\it{oracle\/}}))\index{main-1-induction} \\ 
{\bf else }{\rm{main-1-induction}}\,({\it{left\/}}, {\rm{cddr}}\,({\it{right\/}}), {\rm{cddr}}\,({\it{oracle\/}}))\index{main-1-induction}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Definition}:\index{alt2-p} \\  
\=\+{\rm{alt2-p}}\,({\it{x\/}})\index{alt2-p} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{x\/}})) \\ 
{\bf then }($\neg$ {\rm{same-color}}\,({\rm{car}}\,({\it{x\/}}), {\rm{cadr}}\,({\it{x\/}}))\index{same-color}) $\wedge$ {\rm{alt2-p}}\,({\rm{cddr}}\,({\it{x\/}}))\index{alt2-p} \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  altp-implies-alt2-p \\ \index{altp-implies-alt2-p}
{\rm{altp}}\,({\it{x\/}})\index{altp} $\rightarrow$ ({\rm{alt2-p}}\,({\it{x\/}})\index{alt2-p} $=$ {\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec})
\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{verbatim};; Now we may prove a version of the first half.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  main-1 \\ \index{main-1}
\=\+(\=\+{\rm{listp}}\,({\it{left\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{right\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{even-length-p-rec} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{left\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{right\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{same-color}}\,({\rm{car}}\,({\it{left\/}}), {\rm{car}}\,({\it{right\/}}))\index{same-color}) \\ 
$\wedge$$\;\;\;\;$($\neg$ {\rm{same-color}}\,({\rm{last}}\,({\it{left\/}})\index{last}, {\rm{last}}\,({\it{right\/}})\index{last})\index{same-color}))\- \\ 
$\rightarrow$$\;\;\;\;${\rm{alt2-p}}\,({\rm{shuffle}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle})\index{alt2-p}\-
\end{tabbing}

\begin{verbatim};; For the other half, we modify the notion of alt2-p (calling the
;; result by the weird name alt3-p), except that we expect an odd
;; number of cards.  Our strategy is to first prove that in the second
;; case, the CDR of the shuffle has this alt3-p property
;; (main-2-lemma).  Then we can show that when we move the final card
;; of the shuffle to the top, the result is an alt2-p.  The lemma
;; alt3-p-to-alt2-p below lets us do that little adjustment, once we
;; know (by the lemma shuffle-preserves-reds-equal-blacks) that the
;; shuffle has the property that the numbers of red and black cards in
;; it are the same.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{alt3-p} \\  
\=\+{\rm{alt3-p}}\,({\it{x\/}})\index{alt3-p} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{listp}}\,({\it{x\/}}) \\ 
{\bf then }\=\+{\bf if }{\rm{listp}}\,({\rm{cdr}}\,({\it{x\/}})) \\ 
{\bf then }($\neg$ {\rm{same-color}}\,({\rm{car}}\,({\it{x\/}}), {\rm{cadr}}\,({\it{x\/}}))\index{same-color}) $\wedge$ {\rm{alt3-p}}\,({\rm{cddr}}\,({\it{x\/}}))\index{alt3-p} \\ 
{\bf else }{\bf{t}}$\;${\bf  endif}\- \\ 
{\bf else }{\bf{f}}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};; The following lemma is analogous to one proved for main-1; then the
;; proof of main-2-lemma goes through.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  altp-implies-alt3-p \\ \index{altp-implies-alt3-p}
{\rm{altp}}\,({\it{x\/}})\index{altp} $\rightarrow$ ({\rm{alt3-p}}\,({\it{x\/}})\index{alt3-p} $=$ ($\neg$ {\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec}))
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  main-2-lemma \\ \index{main-2-lemma}
\=\+(\=\+{\rm{listp}}\,({\it{left\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{right\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{even-length-p-rec} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{left\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{right\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{same-color}}\,({\rm{car}}\,({\it{left\/}}), {\rm{car}}\,({\it{right\/}}))\index{same-color} \\ 
$\wedge$$\;\;\;\;${\rm{same-color}}\,({\rm{last}}\,({\it{left\/}})\index{last}, {\rm{last}}\,({\it{right\/}})\index{last})\index{same-color})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{alt3-p}}\,({\rm{cdr}}\,({\rm{shuffle}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle}))\index{alt3-p}\-
\end{tabbing}

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

\begin{tabbing}{\sc Definition}:\index{reds-equal-blacks} \\  
{\rm{reds-equal-blacks}}\,({\it{x\/}})\index{reds-equal-blacks} $=$ ({\rm{count-color}}\,({\bf{t}}, {\it{x\/}})\index{count-color} $=$ {\rm{count-color}}\,({\bf{f}}, {\it{x\/}})\index{count-color})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  alt-implies-reds-equal-blacks \\ \index{alt-implies-reds-equal-blacks}
\=\+{\rm{altp}}\,({\it{x\/}})\index{altp} \\ 
$\rightarrow$$\;\;\;\;$\=\+{\bf if }{\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec}$\;\;${\bf then }{\rm{count-color}}\,({\bf{t}}, {\it{x\/}})\index{count-color} $=$ {\rm{count-color}}\,({\bf{f}}, {\it{x\/}})\index{count-color} \\ 
{\bf elseif }{\rm{color}}\,({\rm{car}}\,({\it{x\/}}))\index{color}$\;\;${\bf then }\=\+{\rm{count-color}}\,({\bf{t}}, {\it{x\/}})\index{count-color} \\ 
$=$$\;\;\;\;$($1\;+$ {\rm{count-color}}\,({\bf{f}}, {\it{x\/}})\index{count-color})\- \\ 
{\bf else }($1\;+$ {\rm{count-color}}\,({\bf{t}}, {\it{x\/}})\index{count-color}) $=$ {\rm{count-color}}\,({\bf{f}}, {\it{x\/}})\index{count-color}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  count-color-shuffle \\ \index{count-color-shuffle}
\=\+{\rm{count-color}}\,({\it{color\/}}, {\rm{shuffle}}\,({\it{x\/}}, {\it{y\/}}, {\it{oracle\/}})\index{shuffle})\index{count-color} \\ 
$=$$\;\;\;\;$({\rm{count-color}}\,({\it{color\/}}, {\it{x\/}})\index{count-color} $+$ {\rm{count-color}}\,({\it{color\/}}, {\it{y\/}})\index{count-color})\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  shuffle-preserves-reds-equal-blacks \\ \index{shuffle-preserves-reds-equal-bl!acks}
\=\+({\rm{altp}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{altp} $\wedge$ {\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{x\/}}, {\it{y\/}}))\index{even-length-p-rec}) \\ 
$\rightarrow$$\;\;\;\;${\rm{reds-equal-blacks}}\,({\rm{shuffle}}\,({\it{x\/}}, {\it{y\/}}, {\it{oracle\/}})\index{shuffle})\index{reds-equal-blacks}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  alt3-p-to-alt2-p \\ \index{alt3-p-to-alt2-p}
\=\+({\rm{reds-equal-blacks}}\,({\rm{cons}}\,({\it{a\/}}, {\it{x\/}}))\index{reds-equal-blacks} $\wedge$ {\rm{alt3-p}}\,({\it{x\/}})\index{alt3-p}) \\ 
$\rightarrow$$\;\;\;\;${\rm{alt2-p}}\,({\rm{cons}}\,({\rm{last}}\,({\it{x\/}})\index{last}, {\rm{butlast}}\,({\rm{cons}}\,({\it{a\/}}, {\it{x\/}}))\index{butlast}))\index{alt2-p}\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  shuffle-cdr \\ \index{shuffle-cdr}
\=\+({\rm{listp}}\,({\it{x\/}}) $\wedge$ {\rm{listp}}\,({\it{y\/}})) \\ 
$\rightarrow$$\;\;\;\;$({\rm{listp}}\,({\rm{shuffle}}\,({\it{x\/}}, {\it{y\/}}, {\it{oracle\/}})\index{shuffle}) $\wedge$ {\rm{listp}}\,({\rm{cdr}}\,({\rm{shuffle}}\,({\it{x\/}}, {\it{y\/}}, {\it{oracle\/}})\index{shuffle})))\-
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  main-2 \\ \index{main-2}
\=\+(\=\+{\rm{listp}}\,({\it{left\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{right\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{even-length-p-rec}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{even-length-p-rec} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{left\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\it{right\/}})\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{altp} \\ 
$\wedge$$\;\;\;\;${\rm{same-color}}\,({\rm{car}}\,({\it{left\/}}), {\rm{car}}\,({\it{right\/}}))\index{same-color} \\ 
$\wedge$$\;\;\;\;${\rm{same-color}}\,({\rm{last}}\,({\it{left\/}})\index{last}, {\rm{last}}\,({\it{right\/}})\index{last})\index{same-color})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{alt2-p}}\,({\rm{shuffle-top}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle-top})\index{alt2-p}\-
\end{tabbing}

\begin{verbatim};; The following three events are there simply to show that our
;; definition of ``even length'' is honest.

\end{verbatim}\begin{tabbing}{\sc Definition}:\index{even-length-p}$\;\;$
{\rm{even-length-p}}\,({\it{x\/}})\index{even-length-p} $=$ (({\rm{length}}\,({\it{x\/}})\index{length} ${}${\bf{mod}}${}$ {\tt{2}}) $=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  remainder-2-add1 \\ \index{remainder-2-add1}
((($1\;+$ {\it{x\/}}) ${}${\bf{mod}}${}$ {\tt{2}}) $=$ {\tt{0}}) $=$ (({\it{x\/}} ${}${\bf{mod}}${}$ {\tt{2}}) $\not=$ {\tt{0}})
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  even-length-p-is-even-length-p-rec \\ \index{even-length-p-is-even-length-p-!rec}
{\rm{even-length-p}}\,({\it{x\/}})\index{even-length-p} $=$ {\rm{even-length-p-rec}}\,({\it{x\/}})\index{even-length-p-rec}
\end{tabbing}

\begin{tabbing}{\sc Theorem}:  main \\ \index{main}
\=\+(\=\+{\rm{listp}}\,({\it{left\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{listp}}\,({\it{right\/}}) \\ 
$\wedge$$\;\;\;\;${\rm{even-length-p}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{even-length-p} \\ 
$\wedge$$\;\;\;\;${\rm{altp}}\,({\rm{append}}\,({\it{left\/}}, {\it{right\/}}))\index{altp})\- \\ 
$\rightarrow$$\;\;\;\;${\rm{alt2-p}}\,({\rm{shuffle-top}}\,({\it{left\/}}, {\it{right\/}}, {\it{oracle\/}})\index{shuffle-top})\index{alt2-p}\-
\end{tabbing}

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