Chapter 8
The book’s proofs
The earlier sections took the transcript scheme/little-prover.scm
one mechanism at a time. This section reads it as one development. It runs
the whole chain of definitions and counts what it contains. It then follows
the two places where the transcript shows a first attempt that fails, and
the repair of each: a theorem generalised so that its induction hypotheses
are strong enough, and a better measure. A third idea closes the
transcript: induction along align, whose recursion is not on a part of
its argument. The section ends with a catalogue of the techniques of the
transcript.
8.1One development in 31 entries#
Each J-Bob/define entry of the transcript (Section 5.3)
passes the value of the J-Bob/define entry before it as its
definitions:
scheme/little-prover.scm
670(defun defun.atoms ()
671 (J-Bob/define (defun.add-atoms)
672 '(((defun atoms (x)
673 (add-atoms x '()))
674 nil))))Calling any entry therefore runs every entry before it, so calling the last
one, (dethm.align/align), checks the whole book. The program
chain.scm reads the transcript as data (the helper transcript of
examples/jbob.scm) and gives the proofs of each entry to
J-Bob/define with the definitions returned for the entry before, so
that no proof is run twice (each call still checks that all its definitions
are well-formed, scheme/j-bob.scm:792). For every entry it also checks two things:
that the entry passes the value of the entry before it (the first one
passes (prelude)), and that its result holds exactly one new name for
each of its proofs:
chain.scm
forms: 49, J-Bob/step 15, J-Bob/define 31, J-Bob/prove 3
1 defun.pair 23->24 (pair)
[…]
26 dethm.set?/atoms 49->53 (set?/t set?/nil set?/add-atoms set?/atoms)
[…]
31 dethm.align/align 59->60 (align/align)
entries: 31, definitions: 60
each entry names the previous one and adds all its proofs: #t
same as (dethm.align/align): #tThe excerpt leaves out 28 of the 31 entries.Timings, with
time in examples/08-book: csi -q -s chain.scm takes 0.45 s.
About half of it is the last comparison, since (book-defs) computes the
book again: csi -q -e '(load "../jbob.scm") (book-defs)' takes 0.22 s,
the time of one call of (dethm.align/align). The program
each-entry.scm calls
the 31 entries one after the other, each on its own, and takes 2.1 s,
because entry reruns the entries before it, each with its own
defs? check (scheme/j-bob.scm:792). J-Bob/define drops a failed proof
without saying so (Section 5.2), so the check that every
proof adds its name is the test of acceptance: all 31 entries are accepted.
The definitions grow from the 23 of the prelude to 60, the list that
(dethm.align/align) returns. The other 18 entries are the 15
J-Bob/step warm-ups of Chapters 1 and 2 of the transcript and three
side entries that call J-Bob/prove. These return a claim, not
definitions, so no entry builds on them, and the J-Bob/define entry
after each skips over it. For example, defun.align.attempt sits between
dethm.rotate/cons and defun.wt in the file, and defun.wt
passes (dethm.rotate/cons)
(scheme/little-prover.scm:917–918).
The program steps.scm sorts the steps of the 37 proofs by their app
(Section 3.2): an axiom, a primitive applied to quoted
values, the unfolding of a defun, or a theorem proved earlier in the
book.
proofs: 37, steps: 466, by kind: (380 8 60 18)
[…]
((if-same . 99)
[…]
;; uses of if-same, if-true, if-false, if-nest-A, if-nest-E
242
;; proofs by induction, and their steps
(9 284)So 380 of the 466 steps use axioms, and 242 of those are the five axioms
about if; if-same alone is used 99 times. The counts suggest that
a proof in J-Bob is mostly bookkeeping on the if-tree of the claim.
The 9 proofs by induction take 284 steps.The excerpt shows 6 of
the 65 lines of steps.out. The others give one line per proof
(Table 8.1 takes its seeds and step counts from them), the step counts
of the three side entries, and the count of every axiom used. 19 of the 21
axioms are used; equal-swap and cons/car+cdr appear only in
Chapters 1 and 2 and in defun.align.attempt.
Table 8.1 shows the shape of the book. The 9 entries with 0 steps
define functions that do not recur, whose totality claim is already
't (scheme/j-bob.scm:481–486, Section 6.2). Every other defun has a measure,
size for all but align. Three entries hold several proofs, of
which the name gives only one: dethm.ctx?/sub adds 2 definitions,
dethm.set?/atoms 4 and defun.align 3; the earlier proofs are
lemmas for the later ones. Two seeds apply functions of the book, not the
induction functions of the prelude: (add-atoms a bs) in entry 26 and
(align x) in entry 31. Entry 30 needs a measure other than size.
The rest of the section follows these three.
| # | entry, proofs | seed | steps | defs |
|---|---|---|---|---|
| 1 | defun.pair | 0 | 24 | |
| 2 | defun.first-of | 0 | 25 | |
| 3 | defun.second-of | 0 | 26 | |
| 4 | dethm.first-of-pair | 4 | 27 | |
| 5 | dethm.second-of-pair | 5 | 28 | |
| 6 | defun.in-pair? | 0 | 29 | |
| 7 | dethm.in-first-of-pair | 7 | 30 | |
| 8 | dethm.in-second-of-pair | 10 | 31 | |
| 9 | defun.list0? | 0 | 32 | |
| 10 | defun.list1? | 0 | 33 | |
| 11 | defun.list2? | 0 | 34 | |
| 12 | defun.list? | (size x) | 4 | 35 |
| 13 | defun.sub | (size y) | 6 | 36 |
| 14 | defun.memb? | (size xs) | 5 | 37 |
| 15 | defun.remb | (size xs) | 4 | 38 |
| 16 | dethm.memb?/remb0 | 7 | 39 | |
| 17 | dethm.memb?/remb1 | 20 | 40 | |
| 18 | dethm.memb?/remb2 | 20 | 41 | |
| 19 | dethm.memb?/remb | (list-induction xs) | 23 | 42 |
| 20 | defun.ctx? | (size x) | 7 | 43 |
| 21 | dethm.ctx?/sub | 45 | ||
ctx?/t | (star-induction x) | 35 | ||
ctx?/sub | (star-induction y) | 58 | ||
| 22 | defun.member? | (size ys) | 5 | 46 |
| 23 | defun.set? | (size xs) | 5 | 47 |
| 24 | defun.add-atoms | (size x) | 6 | 48 |
| 25 | defun.atoms | 0 | 49 | |
| 26 | dethm.set?/atoms | 53 | ||
set?/t | (list-induction xs) | 27 | ||
set?/nil | (list-induction xs) | 27 | ||
set?/add-atoms | (add-atoms a bs) | 42 | ||
set?/atoms | 8 | |||
| 27 | defun.rotate | 0 | 54 | |
| 28 | dethm.rotate/cons | 7 | 55 | |
| 29 | defun.wt | (size x) | 6 | 56 |
| 30 | defun.align | 59 | ||
natp/wt | (star-induction x) | 19 | ||
positive/wt | (star-induction x) | 19 | ||
align | (wt x) | 46 | ||
| 31 | dethm.align/align | (align x) | 34 | 60 |
chain.out and
steps.out. The groups are Chapters 3 to 6 (left) and 7 to 9 (right)
of the transcript
(scheme/little-prover.scm:119, 195, 260, 379, 425, 619, 873).
An empty seed is nil; defs is the number of definitions after
the entry (23 before the first). An entry with several proofs lists them
below its name.8.2Generalising an accumulator#
Chapter 8 of the transcript defines member?, set?, a list with no
repeated element, whose body is
(if (atom xs) 't (if (member? (car xs) (cdr xs)) 'nil (set? (cdr xs))))
(scheme/little-prover.scm:637–638), and a function that collects
the atoms of a tree into an accumulator ys, with nested recursion:
scheme/little-prover.scm
653 '(((defun add-atoms (x ys)
654 (if (atom x)
655 (if (member? x ys) ys (cons x ys))
656 (add-atoms (car x) (add-atoms (cdr x) ys))))(atoms x) is (add-atoms x '())
(scheme/little-prover.scm:670–674), and the goal is
(equal (set? (atoms a)) 't). The entry dethm.set?/atoms.attempt
tries the obvious route with J-Bob/prove: a lemma
set?/add-atoms, (equal (set? (add-atoms a '())) 't), with seed
(star-induction a) and one step, which unfolds add-atoms in the
case of a pair, then set?/atoms from the lemma in three steps
(scheme/little-prover.scm:676–687). The program
set-atoms-attempt.scm runs the entry and then each proof on its own:
set-atoms-attempt.scm
;; (dethm.set?/atoms.attempt)
(if (atom a)
(equal (set? (add-atoms a '())) 't)
(if (equal (set? (add-atoms (car a) '())) 't)
(if (equal (set? (add-atoms (cdr a) '())) 't)
(equal (set? (if (atom a)
(if (member? a '()) '() (cons a '()))
(add-atoms (car a) (add-atoms (cdr a) '()))))
't)
't)
't))
[…]
;; second proof alone, against (defun.atoms)
'nil
;; proofs? of the second proof alone, against (defun.atoms)
nil
;; second proof, (defun.atoms) plus the unproved set?/add-atoms
't
[…]The entry returns the claim of the lemma after its one step.The
excerpt leaves out 11 lines, the same claim from the first proof alone, and
the last 27 lines, which show that J-Bob/define of both proofs adds no
name and then replay the first proof. The second proof is not at fault.
Against (defun.atoms) it is ill-formed because it names
set?/add-atoms: proofs? returns nil, so this 'nil is
not a residual claim (Section 5.2). With the unproved lemma
added by list-extend it gives 't. J-Bob/prove checks each
proof against the claims before it, proved or not, and returns the result of
the last proof that fails (scheme/j-bob.scm:739–745, Section 5.6).
Why does the induction not go through? The seed gives one hypothesis for
(car a) and one for (cdr a), both with the accumulator
'(). In the case of a pair the goal needs
(add-atoms (car a) (add-atoms (cdr a) '())), whose accumulator is not
'(), and no hypothesis says anything about add-atoms with another
accumulator. The theorem is too weak to prove itself by induction.Background. The Boyer–Moore provers have an automatic
generalisation step, which replaces subterms that occur more than once
in a goal (not variables or constants) by new variables before inducting. Turning an accumulator constant into a
variable and adding a premise such as (set? bs) is still a lemma the
user states, in those provers as in J-Bob.Robert S. Boyer and J Strother Moore. A Computational Logic. Academic Press, New York, 1979; and Matt Kaufmann, Panagiotis Manolios, and J Strother Moore. Computer-Aided Reasoning: An Approach. Kluwer Academic Publishers, Boston, 2000
The repair, dethm.set?/atoms, replaces '() by a variable
bs, adds the premise (set? bs), which '() satisfies, and
inducts along add-atoms itself:
scheme/little-prover.scm
777 ((dethm set?/add-atoms (a bs)
778 (if (set? bs) (equal (set? (add-atoms a bs)) 't) 't))
779 (add-atoms a bs)The seed applies a defun to distinct formals of the theorem, so
seed? accepts it (scheme/j-bob.scm:241–248, 303–329), and the induction claim
follows the if-tree of add-atoms, with one hypothesis per
recursive call (scheme/j-bob.scm:494–524; Table 7.1).
set-add-atoms.scm is (replay 'dethm.set?/atoms 'set?/add-atoms);
after 8 header lines it prints the claim before the first step:
(if (atom a)
(if (set? bs) (equal (set? (add-atoms a bs)) 't) 't)
(if (if (set? (add-atoms (cdr a) bs))
(equal (set? (add-atoms (car a) (add-atoms (cdr a) bs)))
't)
't)
(if (if (set? bs)
(equal (set? (add-atoms (cdr a) bs)) 't)
't)
(if (set? bs) (equal (set? (add-atoms a bs)) 't) 't)
't)
't))The first hypothesis is for the outer call, with bs replaced by
(add-atoms (cdr a) bs): exactly the term the attempt could not reach.
The two hypotheses fit together. Under (set? bs) the inner one says
that (add-atoms (cdr a) bs) is a set, which is the premise of the outer
one.
They do not yet match, though. The outer hypothesis has the bare question
(set? (add-atoms (cdr a) bs)), while the inner one gives the equation
(equal (set? (add-atoms (cdr a) bs)) 't). No axiom rewrites a term to
't because it is a true question: equal-if uses only an equation,
and the primitive equal evaluates only quoted values. The proof splits
on the bare question and, in each branch, rewrites the set? inside the
equation to a quoted value. The first two proofs of the entry are the
lemmas for this, each by list induction in 27 steps: set?/t,
(if (set? xs) (equal (set? xs) 't) 't)
(scheme/little-prover.scm:691–692), rewrites (set? xs) to
't where it is known to be true, and set?/nil,
(if (set? xs) 't (equal (set? xs) 'nil))
(scheme/little-prover.scm:734–735), rewrites it to
'nil where it is known to be false.
Steps 1 to 17 prove the case of an atom. Steps 18 to 24 lift the premise
(set? bs) over the case of a pair (T5 in Table 8.2), which
drops it from the inner hypothesis and from the goal. Step 25 splits the
case of a pair on (set? (add-atoms (cdr a) bs)), steps 26 and 27 use
the split to simplify the outer hypothesis, and step 28 drops it where it
has become 't. The claim after step 28 is
(if (atom a)
't
(if (set? bs)
(if (set? (add-atoms (cdr a) bs))
(if (equal (set? (add-atoms (car a) (add-atoms (cdr a) bs)))
't)
(if (equal (set? (add-atoms (cdr a) bs)) 't)
(equal (set? (add-atoms a bs)) 't)
't)
't)
(if (equal (set? (add-atoms (cdr a) bs)) 't)
(equal (set? (add-atoms a bs)) 't)
't))
't))The inner hypothesis is now the question at (E A A A Q), in the branch
where the split is true, and at (E A E Q), where it is false.
set-add-atoms-focus.scm prints both after steps 29 to 32:
;; after step 29
(E A A A Q) (equal 't 't)
(E A E Q) (equal (set? (add-atoms (cdr a) bs)) 't)
;; after step 30
(E A A A Q) (equal 't 't)
(E A E Q) (equal 'nil 't)
;; after step 31
(E A A A Q) 't
(E A E Q) (equal 'nil 't)
;; after step 32
(E A A A Q) 't
(E A E Q) 'nilThe last 2 lines of the output, the claim 't after all 42 steps, are
left out. Steps 29 and 30 apply set?/t and set?/nil inside the
equal; steps 31 and 32 evaluate it
(scheme/little-prover.scm:843–846). In the false branch the
hypothesis is now 'nil, and if-false turns the branch into
't (step 34): that case contradicts the hypothesis. In the true branch
step 33 drops the hypothesis 't, and the outer hypothesis is an
equation in a question; after steps 35 and 36 unfold
(add-atoms a bs), step 37 uses it with equal-if. The replay in
set-add-atoms.scm ends:
;; step 42: (() (if-same (atom a) 't))
't
;; final: 't PROVEDThe last proof of the entry returns to (atoms a). The lemma is
conditional, so its premise (set? '()) must be the question of an
if around the focus (Section 5.4). The claim has no
such if, and the proof builds one by backwards rewriting
(Section 3.3). set-atoms.scm is
(replay 'dethm.set?/atoms 'set?/atoms):
[…]
;; claim
(equal (set? (atoms a)) 't)
;; step 1: ((1 1) (atoms a))
(equal (set? (add-atoms a '())) 't)
;; step 2: (() (if-true (equal (set? (add-atoms a '())) 't) 't))
(if 't (equal (set? (add-atoms a '())) 't) 't)
;; step 3: ((Q) (if-true 't (if (member? (car '()) (cdr '())) 'nil (set? (cdr '())))))
(if (if 't
't
(if (member? (car '()) (cdr '())) 'nil (set? (cdr '()))))
(equal (set? (add-atoms a '())) 't)
't)
;; step 4: ((Q Q) (atom '()))
(if (if (atom '())
't
(if (member? (car '()) (cdr '())) 'nil (set? (cdr '()))))
(equal (set? (add-atoms a '())) 't)
't)
;; step 5: ((Q) (set? '()))
(if (set? '()) (equal (set? (add-atoms a '())) 't) 't)
;; step 6: ((A 1) (set?/add-atoms a '()))
(if (set? '()) (equal 't 't) 't)
;; step 7: ((A) (equal-same 't))
(if (set? '()) 't 't)
;; step 8: (() (if-same (set? '()) 't))
't
;; final: 't PROVEDOnly the five header lines are left out. Steps 2 to 5 rewrite backwards. In
step 2 the focus is the right-hand side x of if-true, which
becomes (if 't x y) with 't for y. Step 3 does the same to
the question 't, with the inner if of the body of set? on
'() as y. Step 4 replaces the value 't by the application
(atom '()) that has it, and step 5 folds the body of set? back
into (set? '()). Step 6 can then apply the lemma.
8.3A better measure#
Chapter 9 of the transcript defines rotate, whose body
(cons (car (car x)) (cons (cdr (car x)) (cdr x))) moves the left
subtree of the left subtree up (scheme/little-prover.scm:877–878),
proves rotate/cons, and defines a function that rotates until the left
subtree is an atom, then keeps that atom and aligns the rest:
scheme/little-prover.scm
986 ((defun align (x)
987 (if (atom x)
988 x
989 (if (atom (car x)) (cons (car x) (align (cdr x))) (align (rotate x)))))The argument of (align (rotate x)) is not a part of x, so the
measure must decrease under rotate. defun.align.attempt tries
(size x), and align-attempt.scm runs it:
align-attempt.scm
;; (defun.align.attempt)
(if (atom x)
't
(if (atom (car x))
't
(< (size (cons (car (car x)) (cons (cdr (car x)) (cdr x))))
(size (cons (cons (car (car x)) (cdr (car x))) (cdr x))))))
[…]The other 74 lines of align-attempt.out replay the 8 steps. Steps 4 to
7 apply cons/car+cdr twice to x and twice to (car x). Its
premise, that the argument is not an atom, holds on the path (E E),
where (atom x) and (atom (car x)) are both false, so that
rotate/cons matches in step 8. What is left is false: size counts
pairs (scheme/j-bob-lang.scm:35–38), so both sides are 2 plus
the sizes of the same three subtrees.
Figure 8.1: ((a . b) . c) and its rotation (a b . c). Each pair is a
circle holding its wt; an atom weighs 1. Both trees have size 2.
Values from size-vs-wt.out.
The repair is a weight that counts the left subtree twice:
scheme/little-prover.scm
919 '(((defun wt (x)
920 (if (atom x) '1 (+ (+ (wt (car x)) (wt (car x))) (wt (cdr x)))))size-vs-wt.scm evaluates the 21 defuns of (book-defs), the
19 of the book and the prelude’s list-induction and
star-induction, as Scheme definitions (defun is define,
scheme/j-bob-lang.scm:25–28) and runs them on
x = ((a . b) . c) and on y = (((a . b) . c) . (d . e)):
;; size of x and (rotate x); wt of x and (rotate x)
(2 2 7 5)
;; wt of (a . b) and of (b . c)
(3 3)
[…]
;; (align y)
(a b c d . e)
;; (align '((a . b) . (c . d)))
(a b c . d)
;; (atoms '((a . b) . (a . c)))
(b a c)
;; (set? '(a b a)), (set? '(a b c))
(nil t)
;; (equal? (dethm.align/align) (book-defs)), after the eval
#tThe block leaves out the first 4 lines and the 4 about y and
(rotate y). In general, with , , the weights of
(car (car x)), (cdr (car x)) and (cdr x) (a, b
and c in Figure 8.1), x weighs and
(rotate x) weighs , less by . Run as Scheme, align
lists the atoms of a tree from left to right, the last one as the final
cdr, and atoms lists each atom once.Evaluating the book redefines four functions of J-Bob: the book’s
list0?, list1?, list2? and member? have the same names
as J-Bob’s own (scheme/j-bob.scm:3, 6, 11, 80) and the same bodies. So the program
calls (book-defs) before it evaluates the book, and the book is
checked with J-Bob’s own definitions; its last line checks the whole book
again after the evaluation, with the same result.
wt itself is accepted with (size x). The entry defun.align
then proves two lemmas by star induction. natp/wt,
(equal (natp (wt x)) 't), settles the question (natp (wt x)) of
the totality claim. positive/wt, (equal (< '0 (wt x)) 't), makes
positive. The third proof is align, with the measure
(wt x). align-totality.scm replays it (428 lines); after 12
header lines comes the claim:
(if (natp (wt x))
(if (atom x)
't
(if (atom (car x))
(< (wt (cdr x)) (wt x))
(< (wt (rotate x)) (wt x))))
'nil)Step 1 rewrites (natp (wt x)) to 't with natp/wt, step 2
drops that if with if-true, and steps 3 and 4 unfold (wt x)
in the branch (E A), where (car x) is an atom. Two of the
arithmetic axioms that the proof uses, identity-+ and
positives-+, are conditional (scheme/j-bob.scm:845–850, 853–854), and their
premises must again stand in questions around the focus.
align-totality-focus.scm prints the branch (E A) after steps 5
to 12:
;; step 5: ((E A) (if-true (< (wt (cdr x)) (+ (+ (wt (car x)) (wt (car x))) (wt (cdr x)))) 't))
(E A) (if 't (< (wt (cdr x)) (+ (+ (wt (car x)) (wt (car x))) (wt (cdr x)))) 't)
;; step 6: ((E A Q) (natp/wt (cdr x)))
(E A) (if (natp (wt (cdr x))) (< (wt (cdr x)) (+ (+ (wt (car x)) (wt (car x))) (wt (cdr x)))) 't)
;; step 7: ((E A A 1) (identity-+ (wt (cdr x))))
(E A) (if (natp (wt (cdr x))) (< (+ '0 (wt (cdr x))) (+ (+ (wt (car x)) (wt (car x))) (wt (cdr x)))) 't)
;; step 8: ((E A A) (common-addends-< '0 (+ (wt (car x)) (wt (car x))) (wt (cdr x))))
(E A) (if (natp (wt (cdr x))) (< '0 (+ (wt (car x)) (wt (car x)))) 't)
;; step 9: ((E A Q) (natp/wt (cdr x)))
(E A) (if 't (< '0 (+ (wt (car x)) (wt (car x)))) 't)
;; step 10: ((E A Q) (positive/wt (car x)))
(E A) (if (< '0 (wt (car x))) (< '0 (+ (wt (car x)) (wt (car x)))) 't)
;; step 11: ((E A A) (positives-+ (wt (car x)) (wt (car x))))
(E A) (if (< '0 (wt (car x))) 't 't)
;; step 12: ((E A) (if-same (< '0 (wt (car x))) 't))
(E A) 't
[…]The last 2 lines, the claim 't after all 46 steps, are left out.
Step 5 wraps the goal in (if 't C 't). In step 6 the question
't is the right-hand side of natp/wt at (cdr x) and becomes
(natp (wt (cdr x))), the premise of identity-+ in step 7. Step 8
cancels (wt (cdr x)). Step 9 turns the question back into 't,
and step 10 puts the premise of positives-+ there; both of its
premises are (< '0 (wt (car x))), so one question serves for two. The
branch (E E), where align calls itself on (rotate x), takes
steps 13 to 44. They unfold rotate and the wts, cancel
(wt (cdr x)) (step 33) and then the unfolded (wt (car x)) (step
36) with associate-+, commute-+ and common-addends-<, and
close with the pattern of steps 5 to 12, with (cdr (car x)) in place of
(cdr x) and (car (car x)) in place of (car x) (steps 37 to
44; scheme/little-prover.scm:1009–1083).
scheme/little-prover.scm where each is used. Lines 98 and 106–111
are warm-ups of Chapter 2 and 911–915 is defun.align.attempt; T10 is
used in none of the 37 proofs. T1 to T6 and T10 are about rewriting and
premises (Chapter 3 and Chapter 5); T7 to T9 about induction and
measures (Chapter 6 and Chapter 7).| technique | lines | |
|---|---|---|
| T1 | Unfold the outer function first or the inner one first; aim the paths again after each step. | 144–145; 154–155 |
| T2 | Split cases with if-same used backwards; to lift a call over an if, follow it with if-nest-A and if-nest-E. | 106–111; 400–407 |
| T3 | Collapse (if C 't 't) with if-same, the last step of most proofs. | 423; 1157 |
| T4 | Build terms by backwards rewriting: if-true, a primitive, a definition or a lemma. | 865–868; 1002 |
| T5 | Put a premise in a question: wrap the goal in (if 't C 't), or lift the theorem’s premise over the whole claim. | 1000–1002; 507–519 |
| T6 | Use a hypothesis with equal-if once it is an equation in a question. | 408; 1136; 1153 |
| T7 | Normalise a predicate to 't or 'nil with lemmas. | 449–450; 691–692; 734–735 |
| T8 | Generalise an accumulator and induct along the function’s own recursion. | 777–779 |
| T9 | Choose a measure that decreases, with its lemmas in the same entry. | 919–920; 936–990 |
| T10 | Expose a pair with cons/car+cdr under a false (atom E), so that an equation about its parts matches: a hypothesis by equal-if, or rotate/cons. | 98; 911–915 |
8.4Induction along align#
The last theorem, (equal (align (align x)) (align x)), has the seed
(align x). A seed must name a defun in the definitions
(scheme/j-bob.scm:303–318), so this is possible only after the totality proof of
align. align-align.scm is
(replay 'dethm.align/align 'align/align); after 6 header lines, the
claim follows the three branches of align:
align-align.scm
(if (atom x)
(equal (align (align x)) (align x))
(if (atom (car x))
(if (equal (align (align (cdr x))) (align (cdr x)))
(equal (align (align x)) (align x))
't)
(if (equal (align (align (rotate x))) (align (rotate x)))
(equal (align (align x)) (align x))
't)))The hypothesis of the third branch is about (rotate x), which is not
a part of x, and star induction could not give it. It is justified
because align is total: wt decreases at every recursive call
(Section 7.6). After steps 24 to 29 unfold both
(align x) of that branch, the goal is the hypothesis itself:
;; step 29: ((E E A 2) (if-nest-E (atom (car x)) (cons (car x) (align (cdr x))) (align (rotate x))))
(if (atom x)
't
(if (atom (car x))
't
(if (equal (align (align (rotate x))) (align (rotate x)))
(equal (align (align (rotate x))) (align (rotate x)))
't)))
;; step 30: ((E E A 1) (equal-if (align (align (rotate x))) (align (rotate x))))
[…]
;; step 32: ((E E) (if-same (equal (align (align (rotate x))) (align (rotate x))) 't))
(if (atom x) 't (if (atom (car x)) 't 't))
[…]
;; final: 't PROVEDThe excerpt starts after step 28 and leaves out 15 lines after step 30 and
4 before the last line. The second branch takes 16 steps against 9, because
align of (cons (car x) (align (cdr x))) must be unfolded as well
before the hypothesis on (cdr x) applies
(scheme/little-prover.scm:1108–1138).
8.5The techniques of the transcript#
Table 8.2 collects the techniques that recur in the transcript,
with places where each can be seen. Most follow from two facts of the
earlier sections: an equation can be used in both directions
(scheme/j-bob.scm:662–667), and a premise is usable only as the question of an
if around the focus (scheme/j-bob.scm:604–611).
The next section reads the checker that accepted these 466 steps.