Chapter 11

The ACL2 counterpart

The J-Bob repository has two folders, scheme/ and acl2/. Every example so far ran the Scheme files. This section reads the ACL2 ones. ACL2 is not installed here, and nothing in this section ran in ACL2.which acl2 acl2s saved_acl2 finds nothing, and the local Racket has no Dracula package, so the README’s Dracula recipe (README.md:35–46) cannot be run either.Dracula. A Racket package for programming in ACL2. The README of the J-Bob repository says that Dracula includes J-Bob The examples read the ACL2 files as data in CHICKEN, or run J-Bob on claims taken from them. What ACL2 does is background, read from the ACL2 files of the repository or recalled from ACL2’s documentation and books Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER; Matt Kaufmann, Panagiotis Manolios, and J Strother Moore. Computer-Aided Reasoning: An Approach. Kluwer Academic Publishers, Boston, 2000; and Matt Kaufmann and J Strother Moore. A Precise Description of the ACL2 Logic, 1997. Department of Computer Sciences, University of Texas at Austin, not checked against them here, and is marked as such.

The ACL2 files do not give the book’s theorems to ACL2’s prover. As we read them, they make J-Bob an ACL2 program: ACL2 is meant to prove that J-Bob’s own functions terminate, and then to run J-Bob on the same quoted proofs as CHICKEN does. We compare the files (Section 11.1), read the ACL2 language file and its dethm macro (Section 11.2 and Section 11.3), and explain the four :measure declarations (Section 11.4). The last two subsections are background on ACL2’s logic and prover (Section 11.5 and Section 11.6); Table 11.2 sums up.

11.1Two copies of one program

Table 11.1 lists the three pairs of files. Two of the pairs differ by a few lines, which diff prints in full:

$ diff scheme/j-bob.scm acl2/j-bob.lisp
0a1,2
> (in-package "ACL2")
> (include-book "j-bob-lang")
364a367
>   (declare (xargs :measure (size defs)))
389a393
>   (declare (xargs :measure (size pfs)))
739a744
>   (declare (xargs :measure (size pfs)))
753a759
>   (declare (xargs :measure (size pfs)))
$ diff scheme/little-prover.scm acl2/little-prover.lisp
0a1,2
> (in-package "ACL2")
> (include-book "j-bob")
Table 11.1: The Scheme and ACL2 files of the repository (wc -l; the differences are those of diff).
pairlinesdifference
j-bob.scm, .lisp879, 8852 header lines, 4 declares
little-prover.scm, .lisp1157, 11592 header lines
j-bob-lang.scm, .lisp38, 24different files

diff compares text. lisp-vs-scheme.scm compares data: it reads each file with CHICKEN’s read, drops the forms headed in-package and include-book and every declare, and asks equal?. It also lists what it dropped, with the function and formals of each declare:The program prints with display, because CHICKEN writes the symbol :measure as |:measure|. The […] hides 4 lines, the two headers of little-prover.lisp and an empty declares: list; the full output is in lisp-vs-scheme.out.

lisp-vs-scheme.scm

;; j-bob
forms: lisp 130, scheme 128
headers:
  (in-package "ACL2")
  (include-book "j-bob-lang")
declares:
  defs? (known-defs defs) (declare (xargs :measure (size defs)))
  proofs? (defs pfs) (declare (xargs :measure (size pfs)))
  rewrite/prove+ (defs pfs) (declare (xargs :measure (size pfs)))
  rewrite/define+1 (defs1 defs2 pfs) (declare (xargs :measure (size pfs)))
equal after stripping: #t
;; little-prover
forms: lisp 51, scheme 49
[…]
equal after stripping: #t

So the 128 functions of J-Bob are one text that is both an ACL2 program and, after j-bob-lang.scm is loaded, a Scheme program, and the same holds for the 49 forms of the transcript. This works because J-Bob is written in its own small language (Chapter 2). Eight of its nine primitives (scheme/j-bob.scm:87–89) are ACL2 built-ins; the ninth, size, is defined in both language files.

The chain of include-books, acl2/little-prover.lisp:2 → j-bob and acl2/j-bob.lisp:2 → j-bob-lang, is the chain of loads of the Scheme recipe (Chapter 1).Background. Every ACL2 book, a file of events (definitions and theorems), must begin with an in-package form; these name the package "ACL2". include-book loads the events of another book. certify-book checks a book once and writes a certificate NAME.cert and a compiled file; a later include-book trusts the certificate. The repository’s .gitignore (.gitignore:2–3, added in commit d737d51) lists *.cert and *.dx64fsl, the extension of the compiled files of Clozure CL on macOS (Darwin) x86-64, so we infer that the authors certified the books with an ACL2 built on Clozure CL.Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER The README’s ACL2 recipe includes the three books and then calls (dethm.align/align) (README.md:24–33). That looks as if it asked ACL2 to prove align/align. It does not. The end of lisp-vs-scheme.out counts, in all six files, the forms headed dethm or defthm, outside quoted data and inside it:

;; forms headed dethm, defthm: (outside . inside) quotes
scheme/j-bob-lang.scm dethm (0 . 0) defthm (0 . 0)
scheme/j-bob.scm dethm (0 . 21) defthm (0 . 0)
scheme/little-prover.scm dethm (0 . 21) defthm (0 . 0)
acl2/j-bob-lang.lisp dethm (0 . 0) defthm (0 . 1)
acl2/j-bob.lisp dethm (0 . 21) defthm (0 . 0)
acl2/little-prover.lisp dethm (0 . 21) defthm (0 . 0)

The 21 dethms of j-bob.lisp are the axioms, quoted inside (axioms) (acl2/j-bob.lisp:804–860). The 21 of little-prover.lisp are quoted inside the proofs that the transcript hands to J-Bob/prove and J-Bob/define: the 18 theorems of the book’s chain, the off-chain contradiction, and a first attempt at set?/add-atoms and set?/atoms, which are proved again later (scheme/little-prover.scm:220, 678, 682, 777, 861, in the Scheme copy). The one defthm is in the backquoted template of the dethm macro (Section 11.3), which nothing calls. In ACL2, then, as in CHICKEN, a theorem of the book is data, and (dethm.align/align) is a call of an ordinary function that runs the checker; in CHICKEN it returns the 60 definitions of the book (Chapter 8). ACL2’s prover is meant to do its work earlier, when it admits J-Bob’s own defuns (Section 11.4; background).

11.2The language file

The third pair is two different files. j-bob-lang.scm builds, inside Scheme, the primitives of the J-Bob language: total car and cdr, an equal that returns the symbols t and nil, an if for which only nil is false, and so on (scheme/j-bob-lang.scm:2–23; Chapter 2). j-bob-lang.lisp needs none of this.Background. In ACL2 these are built in, and total by completion axioms: car of a non-pair is nil, and + and < treat a non-number as 0. j-bob-lang.scm rebuilds these completions, but with '() where ACL2 has nil (scheme/j-bob-lang.scm:11–12; Section 2.5).Matt Kaufmann and J Strother Moore. A Precise Description of the ACL2 Logic, 1997. Department of Computer Sciences, University of Texas at Austin It defines only the function if->implies, the macro dethm and the function size, which ACL2 does not provide (background).The ACL2 size adds three numbers with one + (line 24 below); the Scheme one nests two +s (scheme/j-bob-lang.scm:38), because J-Bob’s Scheme + takes two arguments (scheme/j-bob-lang.scm:16). Commit 5ee27f2 made that change (git log -1 5ee27f2: Justin Holguin, 2015-08-16, “Fix call to scheme size function”); before it the Scheme text was the ACL2 text. Background. In ACL2, + is a macro: (+ a b c) stands for (binary-+ a (binary-+ b c)), so the two files say the same thing. It is short enough to show in full:

acl2/j-bob-lang.lisp

 1(in-package "ACL2")
 2
 3(defun if->implies (exp hyps)
 4  (case-match exp
 5    (('if Q A E)
 6     (append
 7       (if->implies A `(,@hyps ,Q))
 8       (if->implies E `(,@hyps (not ,Q)))))
 9    (('equal X Y)
10     `((:rewrite :corollary
11         (implies (and ,@hyps)
12           (equal ,X ,Y)))))
13    (& '())))
14
15(defmacro dethm (name args body)
16  (declare (ignore args))
17  (let ((rules (if->implies body '())))
18    `(defthm ,name ,body
19       :rule-classes ,rules)))
20
21(defun size (x)
22  (if (atom x)
23    '0
24    (+ '1 (size (car x)) (size (cdr x)))))

One difference between the hosts is not in the files. In ACL2 the symbol nil and the empty list are one object.Background. ACL2 reads () as the symbol nil. In the Scheme host they are two values, and Section 2.5 ran the consequences: a step evaluates (equal 'nil '()) to 'nil, if-false does not apply to (if '() a b), and the car of an atom is '(), which J-Bob’s if takes as true. In ACL2 we expect the first to give 't, the second to apply, and the car of an atom to be nil, which is false. The difference does not stop the book: in the Scheme host J-Bob accepts all 31 entries of the transcript, ending with the 60 definitions (Chapter 8).

Each file also has a dethm. In Scheme it is a macro that expands to a define (scheme/j-bob-lang.scm:30–33), so a theorem would become a function of its formals that one could call on values. In ACL2 it is a macro that turns a theorem into a defthm, a theorem for ACL2 to prove.

11.3The dethm macro

The macro (lines 3–19 above) shows how the authors map a J-Bob theorem to ACL2 rules. First, what ACL2 does with a defthm:

Background — not run here. defthm asks ACL2 to prove the formula, and :rule-classes says how to use it afterwards. (:rewrite :corollary C) stores a rewrite rule made from C, which must follow from the theorem. A rewrite rule from (implies (and h₁ … hₙ) (equal X Y)) has the left-hand side X, the term ACL2 looks for. It replaces an instance of X, found by matching, by the same instance of Y, from left to right only, when ACL2 can prove the instances of the hypotheses, usually by rewriting them to true in the current context. (and) with no arguments is t. An empty list of rule classes stores the theorem with no rule Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER.

case-match is ACL2’s pattern matcher: in a pattern, a quoted symbol matches itself, a plain symbol binds a variable, and & matches anything.Background. case-match, defmacro, :rule-classes and :corollary as in the ACL2 documentation.Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER So if->implies walks the if-tree of the theorem’s body and keeps the list hyps of questions on the way down, each one negated on the else side. At every (equal X Y) leaf it makes one rule, and at any other leaf it makes none. The macro passes the list of rules as the theorem’s :rule-classes.

dethm-expand.scm transliterates the two definitions into Scheme (with cond for case-match) and applies them to the 21 axioms and to the 18 theorems that (book-defs) holds.This is a simulation of the macro, not ACL2. A Racket transliteration from the research notes (lang/if-implies.rkt, Racket 8.15) gives the same expansions on its 10 test theorems; we compared them once, outside run.sh, by reading Racket’s output back into CHICKEN. The first lines of dethm-expand.out count the rules; a pair (n . k) says that k theorems give n rules each. Every axiom and every theorem of the chain has exactly one equal leaf, so each gives one rule:

dethm-expand.scm

;; axioms: 21 theorems; (rules . theorems): ((0 . 0) (1 . 21) (2 . 0))
;; book: 18 theorems; (rules . theorems): ((0 . 0) (1 . 18) (2 . 0))
;; rules whose left-hand side is a variable
(equal-if)
;; rules whose left-hand side is an if
(if-same if-true if-false if-nest-E if-nest-A)

The other lines list the rules that ACL2 might not accept as they are.Background. We believe ACL2 refuses a rewrite rule whose left-hand side is a variable, as equal-if’s (implies (and (equal x y)) (equal x y)) is; whether it accepts the five rules whose left-hand side is an if we do not know. As we recall, equal-swap and commute-+ would be permutative rules (the two sides differ only in the order of the variables), which ACL2 applies only when the result is smaller in its term order. None of this was checked. In J-Bob, equal-if is how equals are substituted; ACL2, as we understand it, substitutes equals by itself (background; Section 11.6). For the book in ACL2 this does not matter, because the axioms are J-Bob data.

The rest of the output shows expansions. The axiom car/cons (scheme/j-bob.scm:801–802) has no premise, so its rule gets the empty (and). A body that is neither an if nor an equal gives no rule, like the book’s contradiction (scheme/little-prover.scm:215–231). A body with two equal leaves gives two rules; the axioms and the book have none, so dethm-expand.scm adds a made-up theorem, two-leaves:The first […] hides 70 lines, the expansions of if-nest-E, equal-if, size/cdr (scheme/j-bob.scm:831–834; its rule has the hypothesis (not (atom x))), natp/+, memb?/remb0, ctx?/sub, set?/nil and align/align; the second hides 2 lines, a second made-up theorem, nat-size, whose body (natp (size x)) gives no rule either. See dethm-expand.out.

;; dethm car/cons
(defthm
  car/cons
  (equal (car (cons x y)) x)
  :rule-classes
  ((:rewrite
     :corollary
     (implies (and) (equal (car (cons x y)) x)))))
[…]
;; dethm contradiction (transcript entry dethm.contradiction)
(defthm contradiction 'nil :rule-classes ())
[…]
;; dethm two-leaves (made up)
(defthm
  two-leaves
  (if (atom x)
    (equal (car x) '())
    (equal (cons (car x) (cdr x)) x))
  :rule-classes
  ((:rewrite
     :corollary
     (implies (and (atom x)) (equal (car x) '())))
   (:rewrite
     :corollary
     (implies
       (and (not (atom x)))
       (equal (cons (car x) (cdr x)) x)))))

J-Bob reads a theorem in a similar way. A step (path (thm args)) walks the if-tree of thm with follow-prems (scheme/j-bob.scm:604–611): at each if it takes the A branch or the E branch when the question is a premise on that side (see below), and otherwise stops there. app-of-equal? and equality/equation (scheme/j-bob.scm:657–674) rewrite only if the leaf is an application of equal; any other leaf leaves the focus as it was (Chapter 5). That is the catch-all (& '()) of line 13 above: in both, a non-equal leaf gives no rewrite.

The two readings differ in three ways. The first is how a hypothesis is met. ACL2 tries to prove it (background). J-Bob only looks: prem-A? and prem-E? (scheme/j-bob.scm:578–602) accept a premise only if it is literally the question of an if that encloses the focus, on the matching side. The axiom size/cdr is (if (atom x) 't (equal (< (size (cdr x)) (size x)) 't)) (scheme/j-bob.scm:831–834); its equal leaf is in the E branch, so the focus must lie in the E branch of an enclosing (if (atom a) …). premises.scm applies size/cdr in three claims:Each […] hides one line, the ;; final: line of a trace; the full output is in premises.out.

premises.scm

;; 1. the premise is an enclosing if question, focus on its E side
;; claim
(if (atom a) 't (< (size (cdr a)) (size a)))
;; step 1: ((E) (size/cdr a))
(if (atom a) 't 't)
[…]
;; 2. no enclosing if
;; claim
(< (size (cdr a)) (size a))
;; step 1: (() (size/cdr a))  [no change: J-Bob stops here]
[…]
;; 3. the focus is on the A side
;; claim
(if (atom a) (< (size (cdr a)) (size a)) 't)
;; step 1: ((A) (size/cdr a))  [no change: J-Bob stops here]
[…]

Only the first step applies; that claim still needs if-same to reach 't. The second difference is the direction. J-Bob’s equality (scheme/j-bob.scm:662–667) rewrites the focus to the other side when it is either side of the equation; an ACL2 rewrite rule works from left to right only (background). The third is the instance. In J-Bob the step names it, (car/cons a b), and the focus must be literally one of its sides; ACL2 finds the instance by matching (background). equality.scm shows the J-Bob side of both differences:

;; focus (car (cons a b)), step (() (car/cons a b))
a
;; focus a, step (() (car/cons a b))
(car (cons a b))
;; focus (car (cons a b)), step (() (car/cons x y))
(car (cons a b))

11.4Four measures

In ACL2, a recursive defun is admitted only after a proof that the function terminates.Background. The measure conjecture of Section 11.5.Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER; and Matt Kaufmann, Panagiotis Manolios, and J Strother Moore. Computer-Aided Reasoning: An Approach. Kluwer Academic Publishers, Boston, 2000 J-Bob asks the same of a defun (Chapter 6): the seed of its proof is a measure, and totality/claim (scheme/j-bob.scm:480–492) builds the totality claim, that the measure is a natural number and gets smaller at every recursive call. The ACL2 files give a measure, (declare (xargs :measure M)), to four functions. Take defs?:

scheme/j-bob.scm

364(defun defs? (known-defs defs)
365  (if (atom defs)
366    't
367    (if (def? known-defs (car defs))
368      (defs? (list-extend known-defs (car defs))
369        (cdr defs))
370      'nil)))

With the declared measure (size defs), the totality claim is the first block below; with the size of the other formal, the second:

measures.scm

;; defs?, measure (size defs)
(if (natp (size defs))
  (if (atom defs)
    't
    (if (def? known-defs (car defs))
      (< (size (cdr defs)) (size defs))
      't))
  'nil)
;; defs?, measure (size known-defs)
(if (natp (size known-defs))
  (if (atom defs)
    't
    (if (def? known-defs (car defs))
      (< (size (list-extend known-defs (car defs)))
         (size known-defs))
      't))
  'nil)

The second claim is false, since list-extend (scheme/j-bob.scm:227–233) never makes known-defs shorter. All four declared functions have this shape: the recursion takes the cdr of a later formal and changes an earlier one.

J-Bob can prove the totality claims with the declared measures. In self-measures.scm, (check name seed steps) builds the proof (def seed step…) for the defun called name in j-bob.scm and prints what J-Bob/prove and J-Bob/define return. The defs are (prelude) followed by the defuns of j-bob.scm that come before the function, put into the list as they are: J-Bob/prove checks the defs only with defs?, which asks that each definition be well-formed (scheme/j-bob.scm:784–789; Section A.5, defs), so they need no proofs of their own.The first […] hides 21 lines, the comments and helpers; the second, the three other calls of check. Both are in self-measures.scm.

self-measures.scm

[…]
(check 'defs? '(size defs)
  '(((Q) (natp/size defs))
    (() (if-true (if (atom defs) 't
                     (if (def? known-defs (car defs))
                         (< (size (cdr defs)) (size defs))
                         't))
                 'nil))
    ((E A) (size/cdr defs))
    ((E) (if-same (def? known-defs (car defs)) 't))
    (() (if-same (atom defs) 't))))
[…]
;; defs?, seed (size defs), 101 defs
J-Bob/prove: 't
J-Bob/define adds: (defs?)
[…]
;; rewrite/define+1, seed (size pfs), 144 defs
J-Bob/prove: 't
J-Bob/define adds: (rewrite/define+1)

natp/size settles the question, if-true drops the outer if, size/cdr rewrites the comparison under the premise (atom defs) on its E side, and two if-sames collapse the ifs whose arms are both 't. The six lines left out of the output say the same of proofs? and rewrite/prove+. So the four termination arguments that ACL2 is told to use are also J-Bob proofs, of four or five steps each.

Why do only these four need a declaration? Without one, ACL2 guesses a measure.Background. As we recall the documentation of defun, the guess is (acl2-count v) for the first formal v that is both tested in the conditions above a recursive call and changed by a call. acl2-count is ACL2’s built-in size of a value; on conses of symbols it counts as J-Bob’s size does. We did not check either fact, and the rule may be more subtle.Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER The second half of measures.out finds, for each of the 35 recursive functions of j-bob.scm, the first formal that some if question above a recursive call mentions and some recursive call changes, and what the calls pass in its place:The full list is in measures.out; 31 of its lines are left out here.

;; recursive functions: 35
[…]
list-union (xs ys) ys <- ((cdr ys))
[…]
defs? (known-defs defs) known-defs <- ((list-extend known-defs (car defs)))
proofs? (defs pfs) defs <- ((list-extend defs (elem1 (car pfs))))
[…]
follow-prems (path e thm) thm <- ((if.A thm) (if.E thm))
[…]
rewrite/prove+ (defs pfs) pfs <- ((cdr pfs))
rewrite/define+1 (defs1 defs2 pfs) defs1 <- (defs2)

For 32 functions, rewrite/prove+ among them, this formal gets smaller: a cdr, a part of an if (follow-prems passes (if.A thm) and (if.E thm)), or a part of the first element (exprs? passes (app.args (car es))). For defs?, proofs? and rewrite/define+1 it does not: known-defs and defs grow, and defs1 becomes defs2. These are three of the four declared functions. list-union also grows its first formal, but no question mentions it, and it has no declaration. We infer that the guess of the sidenote would fail for exactly those three, and that the declaration on rewrite/prove+ is not needed. That is an inference from a recalled rule; with no ACL2 here it is not verified.

A fifth declaration was removed in 2021:

$ git log --format='%h %an %ad%n    %s' --date=short -1 2a4567b
2a4567b Eric Smith 2021-03-18
    Fix error about :measure for non-recursive function.

Its diff deletes (declare (xargs :measure (size pfs))) from rewrite/define+ (acl2/j-bob.lisp:771–779 now; scheme/j-bob.scm:765–773 in Scheme), which is not recursive (it calls rewrite/define+1). Its message calls this an error, which suggests that someone certified the books with a 2021 ACL2 and that the other four declarations were accepted.

11.5Background: the ACL2 logic

The totality claim of defs? in Section 11.4 has a twin in ACL2, the conjecture that ACL2 must prove to admit defs? with its declared measure.Background. Guards. An ACL2 function may declare a guard, the inputs it is meant for. J-Bob’s functions declare none, so ACL2 does not verify guards for them, and what matters is the logical, completed meaning of the primitives. We infer that some would not pass guard verification with guard t: elem1 takes the car of anything (scheme/j-bob.scm:8).

Background — not run here. The definitional principle. ACL2 admits a recursive (defun f (x₁ … xₙ) body) only after proving the measure conjecture for a measure m: (o-p m), that is, m is an ordinal, and for every recursive call (f a₁ … aₙ), (implies RULERS (o< m' m)), where m' is m with each xᵢ replaced by aᵢ and RULERS are the tests of the ifs above the call Matt Kaufmann, Panagiotis Manolios, and J Strother Moore. Computer-Aided Reasoning: An Approach. Kluwer Academic Publishers, Boston, 2000; and Matt Kaufmann and J Strother Moore. A Precise Description of the ACL2 Logic, 1997. Department of Computer Sciences, University of Texas at Austin. For defs? with :measure (size defs), the conjectures are:

(o-p (size defs))
(implies (and (not (atom defs)) (def? known-defs (car defs)))
         (o< (size (cdr defs)) (size defs)))

The ordinals extend the natural numbers: ω comes after every natural, then ω+1, …, ω·2, …, and ACL2’s ordinals are those below ε₀. They let a measure be, for instance, a lexicographic pair. The naturals are the ordinals below ω, and on them o< is <. In J-Bob’s totality claim, natp plays the role of o-p, < that of o<, and the enclosing if questions that of the rulers, so J-Bob’s measures are the ordinals below ω. Admission is what makes the defining equation safe to use as an axiom; dethm.contradiction shows what goes wrong without it (Chapter 6).

Once admitted, J-Bob’s defuns would be functions of the ACL2 logic, all known to terminate, J-Bob/prove included (scheme/j-bob.scm:784–789; background). A statement about J-Bob, such as “if J-Bob/prove returns 't, the theorem is true”, would then be an ACL2 conjecture. Stating it needs a meaning for J-Bob’s expressions inside ACL2, an evaluator. Since a J-Bob expression may call a function that does not terminate, a total evaluator takes a clock n, a step budget after which it gives up; hence the measure (nfix n) below. The ACL2 copy had such an evaluator for a single commit:

$ git show 999464b -- acl2/j-bob.lisp | grep -e '^-(defun' -e xargs
-(defun eval-app (def app)
-(defun eval-once (defs es)
-(defun eval-exprs (defs es n)
-  (declare (xargs :measure (nfix n)))
-(defun eval-expr (defs e n)

Commit 999464b (2015-07-09) deleted these four functions, 55 lines; nothing else called them.They had come in with acl2/j-bob.lisp itself, in commit d737d51 a few minutes earlier (git log); the Scheme files never had them. As committed, the evaluator was unfinished. evaluator.lisp holds the deleted lines verbatim, and evaluator.scm defines them on top of J-Bob in CHICKEN (without the declare):

evaluator.scm

;; (eval-expr (prelude) '(car (cons 'a 'b)) '10)
'quote
;; (eval-expr (prelude) '(if (atom 'a) 'x 'y) '10)
(if (atom 'a) 'x 'y)
[…]

The first should be 'a, the second 'x. eval-once tests (quoted-exprs? (app.args (cdr es))) where (car es) is meant, so it applies car to an argument that is not yet a value; and it evaluates the question of an if as if it were a list of expressions, so the if never moves.Lines 30 and 24–25 of evaluator.lisp. The […] hides a third case; see evaluator.out. Background. In ACL2 too (cdr nil) is nil and (quoted-exprs? nil) is t, so the first slip does not depend on the host; the second confuses an expression with a list in any host. With a corrected evaluator, one could perhaps state that every step J-Bob accepts preserves the value of the claim under eval-expr with enough clock. This is our inference; the repository contains no such theorem.

11.6Background: how ACL2 would prove the book

J-Bob checks proofs that a person writes; ACL2 searches for them. The contrast is clearest on align/align, the last theorem of the book (scheme/little-prover.scm:1087–1091). Its seed (align x) makes J-Bob build an induction claim from the recursion of align (Chapter 7), printed in Section 8.4. There is one case per branch of align (scheme/little-prover.scm:986–989), and each recursive branch has one induction hypothesis: the theorem for the argument of the recursive call. The book’s proof rewrites this claim to 't in 34 hand-written steps. Before that, align itself needed a measure other than size, because rotate (scheme/little-prover.scm:877–878) keeps the size of its argument (Section 8.3, Figure 8.1).

Background — not run here. ACL2’s prover passes each goal through a waterfall of processes: simplification (rewriting with the stored rules, type reasoning, linear arithmetic, splitting on ifs), destructor elimination, use of equality hypotheses, generalization, elimination of irrelevant hypotheses, and, when nothing else applies, induction Matt Kaufmann, Panagiotis Manolios, and J Strother Moore. Computer-Aided Reasoning: An Approach. Kluwer Academic Publishers, Boston, 2000; and Robert S. Boyer and J Strother Moore. A Computational Logic. Academic Press, New York, 1979. Each call of a recursive function in the goal whose arguments in the measured positions are distinct variables, not occurring in the arguments that the recursion leaves unchanged, suggests an induction scheme built from the function’s recursion, as J-Bob’s induction/claim builds one by hand (scheme/j-bob.scm:494–524); the schemes are scored and merged. The hint :hints (("Goal" :induct (align x))) imposes the scheme of (align x), the analogue of J-Bob’s seed; J-Bob’s requirement that the seed’s arguments be distinct formals (induction-scheme-for?, scheme/j-bob.scm:303–310) we read as the counterpart of that condition. A J-Bob step is closest to ACL2’s interactive proof-builder, where (dive 1) moves to an argument and (rewrite thm) rewrites there with one rule Matt Kaufmann and J Strother Moore. ACL2 Documentation. The ACL2 home page, https://www.cs.utexas.edu/~moore/acl2/. The topics DEFUN, DEFTHM, RULE-CLASSES, INDUCTION, ORDINALS and PROOF-BUILDER.

What follows is our expectation, not a result. Most theorems of the transcript look like those ACL2 proves with no hints, by simplification and at most one induction that it chooses itself. align is the exception. rotate keeps size there, and we infer that it keeps acl2-count too. So the definition needs an explicit measure, such as the book’s :measure (wt x), and ACL2 may need the facts natp/wt and positive/wt (scheme/little-prover.scm:936, 961) first, unless its type reasoning finds them. With (declare (xargs :measure (wt x))) in align and the hint above on align/align, we do not know whether ACL2 would need more lemmas or hints.

Chapter 12 turns the mechanisms of the earlier sections, and two of these ACL2 questions, into exercises.

J-Bob (where)ACL2 counterpartkind
9 primitives (scheme/j-bob.scm:87–89), rebuilt by j-bob-lang.scm8 built-ins (+ as the macro over binary-+) and their completion axioms; size defined in j-bob-lang.lispread, bg
nil and () are two valuesone objectrun, bg
(axioms) (scheme/j-bob.scm:798–854)built-in axioms and theoremsbg
a dethm quoted in a proof (data, checked by J-Bob)what a defthm would be if the dethm macro were usedread, bg
dethm macro (acl2/j-bob-lang.lisp:15–19)one :rewrite :corollary rule per equal leaf; never usedrun, read
follow-prems, equality/equation (scheme/j-bob.scm:604–611, 657–674): premises looked up; either side; instance given by the userconditional rewriting: hypotheses proved; left to right; instance found by matchingrun, bg
seed of a defun; totality/claim (scheme/j-bob.scm:480–492):measure; the measure conjecturerun, bg
natp, < on measureso-p, o< on the ordinals below ε₀bg
no default measurea guessed acl2-count measurebg
seed (f x …); induction/claim (scheme/j-bob.scm:519–524)the induction scheme of (f x …); :induct hintrun, bg
list-induction, star-induction (scheme/j-bob.scm:856–879)functions defined to suggest an inductionread, bg
a path and a stepproof-builder dive and rewritebg
the residual claim J-Bob/prove returns (scheme/j-bob.scm:784–789)the goal the prover could not proveread, bg
the defs list threaded through the transcriptthe logical world; include-bookread, bg
every step written by handthe waterfallbg
J-Bob’s defuns, 4 with :measureadmitted when the book is certifiedrun, bg
Table 11.2: J-Bob and ACL2. Kind: run, shown by an example of this section; read, read in the source; bg, background, not run here.