; README  --  introduction to cli-misc directory
; Copyright (C) 1997  Computational Logic, Inc.

; This book is free software; you can redistribute it and/or modify
; it under the terms of the GNU General Public License as published by
; the Free Software Foundation; either version 2 of the License, or
; (at your option) any later version.

; This book is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
; GNU General Public License for more details.

; You should have received a copy of the GNU General Public License
; along with this book; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

This directory contains a bunch of ACL2 books that were created over the
years at CLI.  They don't have any relation to each other; this is
really a grab-bag.

===============================================================================

Installation

The makefile and other files all assume that this library is installed in the
local directory that exists in the ACL2 source distribution, i.e., that `..'
is the main directory of ACL2 books, and ../data-structures is the
data-structures library directory.  If for some reason you move this
directory away from here, things will start to break.

To certify all books type

% make all

to certify all books with the ACL2 image "acl2", assuming that the underlying
Lisp creates object files with .o extensions.  You can also do

% make all ACL2=<acl2-image>

===============================================================================

bash.lisp -- simplification of top-level goal

If you submit (bash term), you will get back a list of terms produced by the
ACL2 simplifier.  See the description at the top of bash.lisp for details.

See also defopener.lisp and expander.lisp.

===============================================================================

beta-reduce.lisp -- proof of correctness for a beta-reduction routine

The final event in this book illustrates how to use this book to prove
correctness for a simple beta-reduction routine for an arbitrary ACL2
evaluator.

===============================================================================

book-thms.lisp -- returns theorems and axioms at the top level of an included
                  book

===============================================================================

computed-hint-rewrite.lisp -- interface to the rewriter for computed hints

===============================================================================

computed-hint.lisp -- examples of computed hints

===============================================================================

csort.lisp  -- a proof of the ``feed-drain'' systolic sort algorithm

Specification and proof of correctness of an abstract comparator array
sorting algorithm.  This is the comparator array sort whose implementation on
the Motorola CAP DSP model was verified by CLI.  A paper describing this
proof is A Mechanical Checked Proof of a Comparator Sort Algorithm, by
Brock and Moore.

http://www.cs.utexas.edu/users/moore/acl2

===============================================================================

definline.lisp -- utility for defining inlined functions

See the documentation provided by the author (Jared Davis) in the file.

===============================================================================

defmac.lisp -- alternative to defmacro that can be more efficient for
               macro expansion

See also :doc defmac after including this book.

===============================================================================

misc2/defpun-exec-domain-example.lisp -- execute partial functions on a
                                         specified domain

===============================================================================

defopener.lisp -- create theorem equating term with its simplification

For documentation:
(include-book "misc/defopener" :dir :system)
followed by
:doc! defopener.

See also bash.lisp and expander.lisp.

===============================================================================

defpun.lisp -- define partial functions using defpun
defp.lisp   -- define partial functions using defp

These books provides macros by which you can introduce some function
``definitions'' that do not always terminate.  In particular, the defpun macro
allows certain tail-recursive function definitions to be admitted, and the defp
macro builds on defpun to allow more general forms of tail recursion.

Details of defpun are provided by Manolios and Moore in ``Partial Functions in
ACL2'' http://www.cs.utexas.edu/users/moore/publications/defpun/index.html

===============================================================================

dft.lisp    -- write proofs in a sort of familiar style using dft macro
dft-ex.lisp -- examples of use of dft book

The book dft defines a macro named dft (a named derived from DeFThm).  The book
dft-ex illustrates the macro with a few simple arithmetic proofs.  Basically,
the macro allows you to write proofs in a sort of familiar style.  Here is a
simple example:

(dft comm2-test-1
     (equal (* a (* b c)) (* b (* a c)))
     :rule-classes nil
     :otf-flg nil
     :proof
     ((consider (* a (* b c)))
      (= (* (* a b) c))
      (= (* (* b a) c) :disable (associativity-of-*))
      (= (* b (* a c)))))

Each line in the :proof generates a lemma and at the end all the lemmas
are assembled to prove the main theorem in a pretty empty theory.  You can
see how this is actually done by using :trans1 on the dft command,

ACL2 !>:trans1 (dft comm2-test-1 ...)

and looking at the output.  The second book contains a few more interesting
examples, e.g., of case analysis and other things.  There is no documentation,
but perhaps the examples will help some.

===============================================================================

evalable-printing.lisp -- a
"beginner-friendly" way of printing objects such that evaluating the
printed result gives that same result

See also ../hacking/evalable-ld-printing.lisp, which prints LD results
in "evalable" way, as provided by "evalable-printing" book.  To
activate, include this book and assign a non-nil value to the state
global EVALABLE-LD-PRINTINGP, as in (assign evalable-ld-printingp t).

===============================================================================

expander.lisp     --   symbolic expansion utilities for ACL2
dump-events.lisp  --   file-dumping utility for ACL2

See also simplify-defuns.lisp for a related tool.

These books contains various experimental symbolic expansion programs for
ACL2, and an event dumping utility.  This stuff can really be helpful when
doing a big project with ACL2.  In expander.lisp the documented macros are
SYMSIM and DEFTHM?.  In dump-events.lisp, see the documentation for
DUMP-EVENTS. 

Unfortunately, the real-world examples of the uses of these utilities are in
proprietary proofs, so all we will do here is give a few hints.  The idea was
to save time in large proofs by using DEFTHM? to pre-compute the reduced
expansions of complex functions.  We used DEFTHM? to write theorems of the
form (EQUAL (HAIRY-FN ...) (... <expanded and reduced body> ...)).  We then
used DUMP-EVENTS to dump the lemmas produced by DEFTHM? to a file, which was
then certified. 

===============================================================================

fast-coerce.lisp -- a replacement for coerce, which speeds up (coerce x 'list)

This just providse the function fast-coerce, which is a drop-in replacement
for coerce and is faster at converting strings to lists.

===============================================================================


fibonacci.lisp -- a thm. on the Fibonacci sequence and greatest common divisor
-- Supporting books: --
int-division.lisp
grcd.lisp

The main theorem main-grcd-fib states that if fib(i) is the ith Fibonacci
number and grcd is the greatest common divisor function, then for positive
integers n and k, grcd(fib(k), fib(n)) = fib(grcd(k,n)).

===============================================================================

file-io.lisp -- utilities for reading and writing files

(read-list fname ctx state) returns (mv nil lst state) where lst is the list
of top-level forms in the file named fname.  Except, if there is an error
then (mv t nil state) is returned.

(write-list list fname ctx state) pretty-prints the given list of forms to
file fname, except that strings are printed without any formatting.

===============================================================================

find-lemmas.lisp -- utility for finding relevant lemmas

(Find-lemmas (fn1 fn2 ...)) returns all lemmas in which all of the indicated
function symbols occur, except those lemmas in the ground-zero world.  In
order to include those as well, give a second argument of nil:
(find-lemmas (fn1 fn2 ...) nil).

If fns is a symbol, then fns is replaced by (list fns).

===============================================================================

gentle.lisp -- analogues of known functions with weaker guards (often, T)

===============================================================================

getprop.lisp -- user-managed fast property lists

The ACL2 utilities GETPROP and PUTPROP take advantage of under-the-hood Lisp
(hashed) property lists.  This book contains an example showing how this works.

===============================================================================

goodstein.lisp -- Goodstein function in ACL2

===============================================================================

hacker.lisp -- Utilities in support of building ACL2 extensions/modifications

THIS BOOK HAS BEEN REMOVED.  Instead please use
books/hacking/hacker.lisp in the ACL2 distribution.

===============================================================================

hanoi.lisp -- A solution to the Towers of Hanoi problem

===============================================================================

hons-help.lisp and hons-help2.lisp -- Support for HONS extension of ACL2

===============================================================================

how-to-prove-thms.lisp -- solutions to the exercises in
                          "How To Prove Theorems Formally"

See: http://www.cs.utexas.edu/users/moore/publications/how-to-prove-thms

===============================================================================

integer-type-set-test.lisp -- Tests of enhancement to integer reasoning

===============================================================================

invariants.lisp -- Tries to prove lemmas stating that if a certain
property is true of the arguments to a function, that property will be
true of the arguments to all its recursive calls.

===============================================================================

meta-lemmas.lisp  --  meta-lemmas for nth and member

This book simply provides 2 meta-lemmas.  The first, REDUCE-NTH-META-CORRECT,
quickly reduces NTH applied to formal proper lists, e.g.,

(NTH 2 (CONS x (CONS y (CONS z NIL)))) ==> z.

The second, REDUCE-MEMBER-META-CORRECT, quickly transforms MEMBER applied to
EQLABLE-LISTP constants to nested IFs, e.g.,

(MEMBER x '(:MEDIUM LARGE)) ==> (IF (EQL x :MEDIUM) '(:MEDIUM :LARGE)
                                    (IF (EQL x :LARGE) '(:LARGE)
                                        NIL)),

which is propositionally equivalent to (OR (EQL x :MEDIUM) (EQL x :LARGE)).

===============================================================================

misc2/misc.lisp -- miscellaneous support, e.g. for lemmas proved to support
                   decisions made in the ACL2 sources

===============================================================================

mult.lisp -- verification of a multiplication program written for the Mostek
             6502 microprocessor

As described near the top of the file, this solves a challenge posed by Bill
Legato, to prove that a program written for the Mostek 6502 microprocessor
correctly implements multiplication.

===============================================================================

oprof.lisp -- simple performance profiling tool for OpenMCL

This book only works on the OpenMCL-based version of ACL2.  It implements a 
simple performance profiler that allows you to see which functions are taking
the most time during some computation.  See the comments inside this book for 
usage instructions and examples.  Also note that this book uses a ttag, so to
include it you will need to run something like this:
  (include-book "misc/oprof" :dir :system :ttags '(oprof)).

===============================================================================

priorities.lisp -- priority-based rewriting

===============================================================================

problem13.lisp -- solution to a UTCS Problem 13

The theorem shows that a function on the naturals satisfying a certain property
must be the identity function.

===============================================================================

process-book-readme.lisp -- checker for Readme.lsp for user-contributed books

===============================================================================

radix.lisp -- support for radix conversion

===============================================================================

random.lisp -- a pseudo-random number generator

===============================================================================

records.lisp   --  canonical key-value record structures
records0.lisp  --  canonical key-value record structures

These books provide similar functionality, though the approaches differ; the
history is given below.  Their purpose is to make it convenient to reason about
finite functions, which we call "record structures" and can be thought of as
(finite) lists of field-value pairs.  Why not simply use association lists?
Imagine for example starting with the empty record (function), then associating
'a with 1 and then 'b with 2.  Presumably the result would be '((b . 2) (a
. 1)).  But if the updates were done in the other order, then the result would
presumably be '((a . 1) (b . 2)).  Sometimes it is convenient to have only one
"canonical" representation for a finite function.  The record books provide
such a representation, as explained in comments near the top.

Rob Sumners originally created a book of record structures such that two such
structures with the same field-value associations are equal.  However, exported
lemmas required hypotheses that the structures were well-formed.

Matt Kaufmann eliminated the need for such hypotheses.  Instead, all that was
necessary was that the fields are symbols.  Matt posted this problem to the
acl2 mailing list, and Matt WIlding also came up with such a solution (not
included here).

Meanwhile, Pete Manolios was pushing for a total order on the ACL2 universe,
and he created events for such a purpose.  Ultimately, built-in ACL2 function
lexorder was made a total order, and Pete's events were modified to use
lexorder.  The result is total-order.lisp (documented in brief below).

Rob Sumners subsequently made some modifications to Matt Kaufmann's book,
primarily by using the total-order book to eliminate hypotheses that keys are
symbols.  The result is essentially records0.lisp.

Later, Rob came up with an alternate, simpler approach to providing the same
exported theorems.  The result is records.lisp.

===============================================================================

redef-pkg.lisp -- handy (though potentially unsound) utility for adding
                  symbols to packages

===============================================================================

misc2/reverse-by-separation.lisp -- destructive linked-list program
                                    verification example

Quoting the file:

; The following proof is a translation to ACL2 of a proof by Magnus Myreen
; (Univ. of Cambridge), inspired by separation logic, about reversing linked
; lists.

===============================================================================

seq.lisp -- the seq macro language
seqw.lisp -- the seqw macro language
seq-examples.lsp -- examples of using the seq macro
seqw-examples.lsp -- examples of using the seqw.macro

SEQ is a macro language for implementing parsers or otherwise applying
"actions" to "streams".  See the comments at the top of seq.lisp and also
see the examples in seq-examples.lsp for more information.

===============================================================================

simplify-defuns.lisp -- simplify definitions in a file and prove equivalence

See simplify-defuns.txt (which can be printed out as 8 pages with 12 point
courier font).  Also see expander.lisp for a related tool.

===============================================================================

simplify-thm.lisp -- a simple event generator which breaks a term
                     thought to be a theorem into some number of
                     theorems of a form where none of the hyps nor the
                     conclusion contain IFs.

Someone may wish to extend this with rule-classes and other more
flexible options.

===============================================================================

sin-cos.lisp  --  rational approximations to SIN and COS with Maclaurin series

This library contains both "obvious" and "fast" series approximation functions
for SIN and COS.  Homework:  Prove that the "fast" and "obvious" versions are
identical.

===============================================================================

sort-symbols.lisp -- correctness of a mergesort routine for symbols, used
                     by defpkg

===============================================================================

sticky-disable.lisp -- theory maintenance in spite of included books

This book uses ACL2 tables to specify rules that should remain enabled or
disabled even after an include-book.  Macros sticky-disable and sticky-enable
allow the specification of these rules, and macro sticky-include-book
implements the specified enabling and disabling after include-book.

===============================================================================

symbol-btree.lisp -- log time access on a key

A symbol-btree is a data structure of the form (symbol value left . right)
where left and right are symbol-btrees.  These data structures give faster
access to values than alists, using function (symbol-btree-lookup key btree).
See the top of the file for examples and a relevant theorem.

===============================================================================

misc2/ruler-extenders-tests.lisp -- tests for ruler-extenders

This suite of tests is mainly for regression, though users interested
in more information about ruler-extenders, beyond that provided in
:doc ruler-extenders, may find this file to be interesting.

===============================================================================

total-order.lisp -- total order for ACL2

===============================================================================

trace-star.lisp -- a beginner-friendly variant of trace$.  Features
"evalable" printing, provided by "evalable-printing" book, and
other modifications.

===============================================================================

trace1.lisp -- alternate implementation of tracing

===============================================================================

transfinite.lisp -- generic proof by strong ordinal induction

This book presents a way to use functional instantiation to reduce a theorem to
its inductive step in a proof by transfinite induction.  There is an example in
the book that shows how this works.

===============================================================================

untranslate-patterns.lisp -- simple, pattern-based untranslation for ACL2

===============================================================================

wet.lisp -- a backtrace utility (see :DOC wet)

===============================================================================
