\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 Alex Bronstein and Carolyn Talcott.  All Rights
 Reserved.

 You may copy and distribute verbatim copies of this Nqthm-1992 event script as
 you receive it, in any medium, including embedding it verbatim in derivative
 works, provided that you conspicuously and appropriately publish on each copy
 a valid copyright notice "Copyright (C) 1994 by Alex Bronstein and Carolyn
 Talcott.  All Rights Reserved."

 NO WARRANTY

 Alex Bronstein and Carolyn Talcott PROVIDE 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 Alex Bronstein or Carolyn Talcott BE LIABLE TO YOU FOR ANY
 DAMAGES, ANY LOST PROFITS, LOST MONIES, OR OTHER SPECIAL, INCIDENTAL OR
 CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THIS SCRIPT
 (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE
 OR LOSSES SUSTAINED BY THIRD PARTIES), EVEN IF YOU HAVE ADVISED US OF THE
 POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.

|#

\end{verbatim}
\noindent{\sc Event}:   Start with the library {\tt{"mlp"}} using the compiled version.

\addvspace{18pt}

\begin{verbatim};(setq theta '(

; theta.bm
;   This is a 2nd order circuit constructor, derived from all the "Accumulator"
; examples, as well as the simple counter example.  Basically, it arises in
; a case where the SPEC is easily expressible: as the iteration of "last-char"
; function which can be expressed only using the input string (x).  So in other
; words, we have a string to char function "last-char" which defines the 
; circuit, for example: the sum of all inputs, the length of input, etc...
; and we just build the corresponding string function in a "standard" fashion.
; This standard fashion is the THETA operator.
; This file just attempts to abstract the construction, and the correctness
; proof that goes with it, to facilitate future instantiations.
; 
; Clearly, there is no sugar involved.
;
; Standard hints necessary for a PROVE-LEMMA have been removed in the
; corresponding ADD-AXIOM.

;;; DEFINITION OF CIRCUIT:

\end{verbatim}
\noindent{\sc Event}:   Introduce the function symbol {\it sysd-theta\index{sysd-theta}\/} of 2 arguments.

\addvspace{18pt}

\begin{verbatim};sysd-stringp is normally deduced by BM.
\end{verbatim}\begin{tabbing}{\sc Axiom}:  sysd-stringp \\ \index{sysd-stringp}
{\rm{stringp}}\,({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta})\index{stringp}
\end{tabbing}

\begin{verbatim};;; SPEC definition:

\end{verbatim}
\noindent{\sc Event}:   Introduce the function symbol {\it spec-theta-lastchar\index{spec-theta-lastchar}\/} of one argument.

\addvspace{18pt}

\begin{verbatim}; this is the standard extension from last-char-fun to MLP-string-fun.
\end{verbatim}\begin{tabbing}{\sc Definition}:\index{spec-theta} \\  
\=\+{\rm{spec-theta}}\,({\it{x\/}})\index{spec-theta} \\ 
$=$$\;\;\;\;$\=\+{\bf if }{\rm{empty}}\,({\it{x\/}})\index{empty}$\;\;${\bf then }{\sc{e}}\index{e} \\ 
{\bf else }{\rm{a}}\,({\rm{spec-theta}}\,({\rm{p}}\,({\it{x\/}})\index{p})\index{spec-theta}, {\rm{spec-theta-lastchar}}\,({\it{x\/}})\index{spec-theta-lastchar})\index{a}$\;${\bf  endif}\-\-
\end{tabbing}

\begin{verbatim};;; PROOF of equivalence with spec:

;;; 2nd order instantiations for circuits:
;; theta-begin
\end{verbatim}\begin{tabbing}{\sc Axiom}:  a2-empty-theta \\ \index{a2-empty-theta}
{\rm{empty}}\,({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta})\index{empty} $=$ {\rm{empty}}\,({\it{x\/}})\index{empty}
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  a2-e-theta \\ \index{a2-e-theta}
({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta} $=$ {\sc{e}}\index{e}) $=$ {\rm{empty}}\,({\it{x\/}})\index{empty}
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  a2-lp-theta \\ \index{a2-lp-theta}
{\rm{len}}\,({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta})\index{len} $=$ {\rm{len}}\,({\it{x\/}})\index{len}
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  a2-lpe-theta \\ \index{a2-lpe-theta}
{\rm{eqlen}}\,({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta}, {\it{x\/}})\index{eqlen}
\end{tabbing}

\begin{tabbing}{\sc Axiom}:  a2-pc-theta \\ \index{a2-pc-theta}
($\neg$ {\rm{empty}}\,({\it{x\/}})\index{empty}) $\rightarrow$ ({\rm{p}}\,({\rm{sysd-theta}}\,({\it{line\/}}, {\it{x\/}})\index{sysd-theta})\index{p} $=$ {\rm{sysd-theta}}\,({\it{line\/}}, {\rm{p}}\,({\it{x\/}})\index{p})\index{sysd-theta})
\end{tabbing}
\begin{verbatim};; theta-end

;;; Circuit CORRECTNESS:

; Theta-correct-ax is a "predicative correctness statement",i.e. what we would
; do if we didn't have functional equality as a specification method, but 
; instead used a purely axiomatic approach.  It matches the intuitive view 
; of just looking at the last char.

\end{verbatim}\begin{tabbing}{\sc Axiom}:  theta-correct-ax \\ \index{theta-correct-ax}
($\neg$ {\rm{empty}}\,({\it{x\/}})\index{empty}) $\rightarrow$ ({\rm{l}}\,({\rm{sysd-theta}}\,({\tt{'}}{\tt{ytheta}}, {\it{x\/}})\index{sysd-theta})\index{l} $=$ {\rm{spec-theta-lastchar}}\,({\it{x\/}})\index{spec-theta-lastchar})
\end{tabbing}

\begin{verbatim}; To go to a functional equality once we have the "last" (ax) statement is
; a trivial induction, if we start out with an P-L split which is unnatural
; for BM, so we force it w/ a USE hint of A-p-l-split

\end{verbatim}\begin{tabbing}{\sc Theorem}:  a-p-l-split \\ \index{a-p-l-split}
\=\+($\neg$ {\rm{empty}}\,({\it{x\/}})\index{empty}) \\ 
$\rightarrow$$\;\;\;\;$(\=\+{\rm{sysd-theta}}\,({\tt{'}}{\tt{ytheta}}, {\it{x\/}})\index{sysd-theta} \\ 
$=$$\;\;\;\;${\rm{a}}\,({\rm{p}}\,({\rm{sysd-theta}}\,({\tt{'}}{\tt{ytheta}}, {\it{x\/}})\index{sysd-theta})\index{p}, {\rm{l}}\,({\rm{sysd-theta}}\,({\tt{'}}{\tt{ytheta}}, {\it{x\/}})\index{sysd-theta})\index{l})\index{a})\-\-
\end{tabbing}

\begin{verbatim}; Interestingly: A-P-L needs to be disabled for theta-correct to go through.
; yet in more specific cases such as macc, or funacc, it is not needed, and 
; in fact just makes a very minor time improvement.

\end{verbatim}\begin{tabbing}{\sc Theorem}:  theta-correct \\ \index{theta-correct}
{\rm{sysd-theta}}\,({\tt{'}}{\tt{ytheta}}, {\it{x\/}})\index{sysd-theta} $=$ {\rm{spec-theta}}\,({\it{x\/}})\index{spec-theta}
\end{tabbing}

\begin{verbatim}; eof: theta.bm
;))
\end{verbatim}
%\end{list}
\printindex
\end{document}
