(BOOT-STRAP NQTHM)
[ 0.1 0.1 0.0 ]
GROUND-ZERO
(PROVE-LEMMA PLUS-RIGHT-ID2
(REWRITE)
(IMPLIES (NOT (NUMBERP Y))
(EQUAL (PLUS X Y) (FIX X)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding the definition of FIX, to the following two new
goals:
Case 2. (IMPLIES (AND (NOT (NUMBERP Y))
(NOT (NUMBERP X)))
(EQUAL (PLUS X Y) 0)).
This again simplifies, opening up the definitions of PLUS and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (PLUS X Y) X)),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definition
of ZEROP establish that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates the following two new formulas:
Case 2. (IMPLIES (AND (ZEROP X)
(NOT (NUMBERP Y))
(NUMBERP X))
(EQUAL (PLUS X Y) X)).
This simplifies, expanding the functions ZEROP, NUMBERP, EQUAL, and PLUS, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (PLUS (SUB1 X) Y) (SUB1 X))
(NOT (NUMBERP Y))
(NUMBERP X))
(EQUAL (PLUS X Y) X)).
This simplifies, using linear arithmetic, to the new conjecture:
(IMPLIES (AND (EQUAL X 0)
(NOT (ZEROP X))
(EQUAL (PLUS (SUB1 X) Y) (SUB1 X))
(NOT (NUMBERP Y))
(NUMBERP X))
(EQUAL (PLUS X Y) X)),
which again simplifies, expanding the function ZEROP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-RIGHT-ID2
(DISABLE PLUS-RIGHT-ID2)
[ 0.0 0.0 0.0 ]
PLUS-RIGHT-ID2-OFF
(PROVE-LEMMA PLUS-ADD1
(REWRITE)
(EQUAL (PLUS X (ADD1 Y))
(IF (NUMBERP Y)
(ADD1 (PLUS X Y))
(ADD1 X)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, obviously, to two new formulas:
Case 2. (IMPLIES (NOT (NUMBERP Y))
(EQUAL (PLUS X (ADD1 Y)) (ADD1 X))),
which again simplifies, rewriting with the lemma SUB1-TYPE-RESTRICTION, to
the conjecture:
(IMPLIES (NOT (NUMBERP Y))
(EQUAL (PLUS X 1) (ADD1 X))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (NUMBERP Y)
(EQUAL (PLUS X (ADD1 Y))
(ADD1 (PLUS X Y)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-ADD1
(DISABLE PLUS-ADD1)
[ 0.0 0.0 0.0 ]
PLUS-ADD1-OFF
(PROVE-LEMMA COMMUTATIVITY2-OF-PLUS
(REWRITE)
(EQUAL (PLUS X (PLUS Y Z))
(PLUS Y (PLUS X Z)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
COMMUTATIVITY2-OF-PLUS
(DISABLE COMMUTATIVITY2-OF-PLUS)
[ 0.0 0.0 0.0 ]
COMMUTATIVITY2-OF-PLUS-OFF
(PROVE-LEMMA COMMUTATIVITY-OF-PLUS
(REWRITE)
(EQUAL (PLUS X Y) (PLUS Y X))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-PLUS
(DISABLE COMMUTATIVITY-OF-PLUS)
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-PLUS-OFF
(PROVE-LEMMA ASSOCIATIVITY-OF-PLUS
(REWRITE)
(EQUAL (PLUS (PLUS X Y) Z)
(PLUS X (PLUS Y Z)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-PLUS
(DISABLE ASSOCIATIVITY-OF-PLUS)
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-PLUS-OFF
(PROVE-LEMMA PLUS-EQUAL-0
(REWRITE)
(EQUAL (EQUAL (PLUS A B) '0)
(AND (ZEROP A) (ZEROP B)))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions ZEROP and AND, to six new
conjectures:
Case 6. (IMPLIES (AND (NOT (EQUAL (PLUS A B) 0))
(NOT (NUMBERP A)))
(NOT (EQUAL B 0))),
which again simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS,
and unfolding the functions NUMBERP and EQUAL, to:
T.
Case 5. (IMPLIES (AND (NOT (EQUAL (PLUS A B) 0))
(NOT (NUMBERP A)))
(NUMBERP B)).
However this again simplifies, applying PLUS-RIGHT-ID2, and unfolding the
function EQUAL, to:
T.
Case 4. (IMPLIES (AND (NOT (EQUAL (PLUS A B) 0))
(EQUAL A 0))
(NOT (EQUAL B 0))).
This again simplifies, using linear arithmetic, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL (PLUS A B) 0))
(EQUAL A 0))
(NUMBERP B)),
which again simplifies, applying the lemma PLUS-RIGHT-ID2, and opening up
the definitions of NUMBERP and EQUAL, to:
T.
Case 2. (IMPLIES (AND (EQUAL (PLUS A B) 0)
(NOT (EQUAL A 0)))
(NOT (NUMBERP A))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (EQUAL (PLUS A B) 0)
(NOT (EQUAL B 0)))
(NOT (NUMBERP B))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-EQUAL-0
(DISABLE PLUS-EQUAL-0)
[ 0.0 0.0 0.0 ]
PLUS-EQUAL-0-OFF
(PROVE-LEMMA DIFFERENCE-X-X
(REWRITE)
(EQUAL (DIFFERENCE X X) '0)
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to:
(IMPLIES (LESSP X X)
(EQUAL (DIFFERENCE X X) 0)).
But this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-X-X
(DISABLE DIFFERENCE-X-X)
[ 0.0 0.0 0.0 ]
DIFFERENCE-X-X-OFF
(PROVE-LEMMA DIFFERENCE-PLUS
(REWRITE)
(AND (EQUAL (DIFFERENCE (PLUS X Y) X)
(FIX Y))
(EQUAL (DIFFERENCE (PLUS Y X) X)
(FIX Y)))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma DIFFERENCE-PLUS is to be stored as zero
type prescription rules, zero compound recognizer rules, zero linear rules,
and two replacement rules.
This formula can be simplified, using the abbreviation AND, to the following
two new conjectures:
Case 2. (EQUAL (DIFFERENCE (PLUS X Y) X)
(FIX Y)).
This simplifies, unfolding the function FIX, to the following two new
formulas:
Case 2.2.
(IMPLIES (NOT (NUMBERP Y))
(EQUAL (DIFFERENCE (PLUS X Y) X) 0)).
However this again simplifies, applying PLUS-RIGHT-ID2, to the following
two new goals:
Case 2.2.2.
(IMPLIES (AND (NOT (NUMBERP Y))
(NOT (NUMBERP X)))
(EQUAL (DIFFERENCE 0 X) 0)).
But this again simplifies, expanding EQUAL and DIFFERENCE, to:
T.
Case 2.2.1.
(IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (DIFFERENCE X X) 0)),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP X X)
(NOT (NUMBERP Y))
(NUMBERP X))
(EQUAL (DIFFERENCE X X) 0)).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (NUMBERP Y)
(EQUAL (DIFFERENCE (PLUS X Y) X) Y)),
which again simplifies, using linear arithmetic, to the conjecture:
(IMPLIES (AND (LESSP (PLUS X Y) X) (NUMBERP Y))
(EQUAL (DIFFERENCE (PLUS X Y) X) Y)).
This again simplifies, using linear arithmetic, to:
T.
Case 1. (EQUAL (DIFFERENCE (PLUS Y X) X)
(FIX Y)),
which simplifies, applying the lemma COMMUTATIVITY-OF-PLUS, and unfolding
FIX, to two new conjectures:
Case 1.2.
(IMPLIES (NOT (NUMBERP Y))
(EQUAL (DIFFERENCE (PLUS X Y) X) 0)),
which again simplifies, rewriting with the lemma PLUS-RIGHT-ID2, to two
new formulas:
Case 1.2.2.
(IMPLIES (AND (NOT (NUMBERP Y))
(NOT (NUMBERP X)))
(EQUAL (DIFFERENCE 0 X) 0)),
which again simplifies, expanding the definitions of EQUAL and
DIFFERENCE, to:
T.
Case 1.2.1.
(IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (DIFFERENCE X X) 0)),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP X X)
(NOT (NUMBERP Y))
(NUMBERP X))
(EQUAL (DIFFERENCE X X) 0)).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (NUMBERP Y)
(EQUAL (DIFFERENCE (PLUS X Y) X) Y)),
which again simplifies, using linear arithmetic, to the formula:
(IMPLIES (AND (LESSP (PLUS X Y) X) (NUMBERP Y))
(EQUAL (DIFFERENCE (PLUS X Y) X) Y)).
This again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS
(DISABLE DIFFERENCE-PLUS)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS-OFF
(PROVE-LEMMA PLUS-CANCELLATION
(REWRITE)
(EQUAL (EQUAL (PLUS A B) (PLUS A C))
(EQUAL (FIX B) (FIX C)))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding the definition of FIX, to the following
seven new formulas:
Case 7. (IMPLIES (AND (NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B C)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))).
This again simplifies, using linear arithmetic, to:
T.
Case 6. (IMPLIES (AND (NUMBERP C)
(NOT (NUMBERP B))
(NOT (EQUAL 0 C)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))),
which again simplifies, rewriting with PLUS-RIGHT-ID2, to the following two
new conjectures:
Case 6.2.
(IMPLIES (AND (NUMBERP C)
(NOT (NUMBERP B))
(NOT (EQUAL 0 C))
(NOT (NUMBERP A)))
(NOT (EQUAL 0 (PLUS A C)))).
This again simplifies, using linear arithmetic, to:
T.
Case 6.1.
(IMPLIES (AND (NUMBERP C)
(NOT (NUMBERP B))
(NOT (EQUAL 0 C))
(NUMBERP A))
(NOT (EQUAL A (PLUS A C)))),
which again simplifies, using linear arithmetic, to:
T.
Case 5. (IMPLIES (AND (NOT (NUMBERP C))
(NUMBERP B)
(NOT (EQUAL B 0)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))),
which again simplifies, rewriting with PLUS-RIGHT-ID2, to the following two
new goals:
Case 5.2.
(IMPLIES (AND (NOT (NUMBERP C))
(NUMBERP B)
(NOT (EQUAL B 0))
(NOT (NUMBERP A)))
(NOT (EQUAL (PLUS A B) 0))).
This again simplifies, using linear arithmetic, to:
T.
Case 5.1.
(IMPLIES (AND (NOT (NUMBERP C))
(NUMBERP B)
(NOT (EQUAL B 0))
(NUMBERP A))
(NOT (EQUAL (PLUS A B) A))),
which again simplifies, using linear arithmetic, to:
T.
Case 4. (IMPLIES (AND (NOT (NUMBERP C))
(NOT (NUMBERP B)))
(EQUAL (EQUAL (PLUS A B) (PLUS A C))
T)),
which again simplifies, rewriting with the lemma PLUS-RIGHT-ID2, and opening
up EQUAL, to:
T.
Case 3. (IMPLIES (AND (NOT (NUMBERP C)) (EQUAL B 0))
(EQUAL (EQUAL (PLUS A B) (PLUS A C))
T)),
which again simplifies, rewriting with COMMUTATIVITY-OF-PLUS and
PLUS-RIGHT-ID2, and expanding the functions EQUAL and PLUS, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP B)) (EQUAL 0 C))
(EQUAL (EQUAL (PLUS A B) (PLUS A C))
T)).
This again simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS,
and opening up EQUAL and PLUS, to:
T.
Case 1. (IMPLIES (AND (NUMBERP C)
(NUMBERP B)
(EQUAL B C))
(EQUAL (EQUAL (PLUS A B) (PLUS A C))
T)).
But this again simplifies, expanding the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-CANCELLATION
(DISABLE PLUS-CANCELLATION)
[ 0.0 0.0 0.0 ]
PLUS-CANCELLATION-OFF
(PROVE-LEMMA DIFFERENCE-0
(REWRITE)
(IMPLIES (NOT (LESSP Y X))
(EQUAL (DIFFERENCE X Y) '0))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest four inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (OR (EQUAL X 0) (NOT (NUMBERP X)))
(p X Y))
(IMPLIES (AND (NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(p X Y))
(IMPLIES (AND (NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(p (SUB1 X) (SUB1 Y)))
(p X Y))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT can be used to show that the measure (COUNT Y) decreases
according to the well-founded relation LESSP in each induction step of the
scheme. Note, however, the inductive instance chosen for X. The above
induction scheme leads to the following four new goals:
Case 4. (IMPLIES (AND (OR (EQUAL X 0) (NOT (NUMBERP X)))
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)).
This simplifies, expanding the definitions of NOT, OR, EQUAL, LESSP, and
DIFFERENCE, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(OR (EQUAL Y 0) (NOT (NUMBERP Y)))
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)).
This simplifies, unfolding NOT, OR, EQUAL, and LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(LESSP (SUB1 Y) (SUB1 X))
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)).
This simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP X 1)
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(LESSP (SUB1 Y) (SUB1 X))
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, opening up the definitions of SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which simplifies, using linear arithmetic, to three new conjectures:
Case 1.3.
(IMPLIES (AND (LESSP X Y)
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, using linear arithmetic, to two new conjectures:
Case 1.3.2.
(IMPLIES (AND (LESSP (SUB1 X) (SUB1 Y))
(LESSP X Y)
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, unfolding the functions LESSP, NOT, OR,
DIFFERENCE, and EQUAL, to:
T.
Case 1.3.1.
(IMPLIES (AND (LESSP X 1)
(LESSP X Y)
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, unfolding SUB1, NUMBERP, EQUAL, LESSP, NOT, and
OR, to:
T.
Case 1.2.
(IMPLIES (AND (LESSP (SUB1 X) (SUB1 Y))
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, expanding the definitions of NOT, OR, LESSP,
DIFFERENCE, and EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (LESSP X 1)
(NOT (OR (EQUAL X 0) (NOT (NUMBERP X))))
(NOT (OR (EQUAL Y 0) (NOT (NUMBERP Y))))
(EQUAL (DIFFERENCE (SUB1 X) (SUB1 Y))
0)
(NOT (LESSP Y X)))
(EQUAL (DIFFERENCE X Y) 0)),
which again simplifies, opening up the definitions of SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-0
(DISABLE DIFFERENCE-0)
[ 0.0 0.0 0.0 ]
DIFFERENCE-0-OFF
(PROVE-LEMMA EQUAL-DIFFERENCE-0
(REWRITE)
(EQUAL (EQUAL '0 (DIFFERENCE X Y))
(NOT (LESSP Y X)))
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, unfolding NOT, to two new conjectures:
Case 2. (IMPLIES (NOT (EQUAL 0 (DIFFERENCE X Y)))
(LESSP Y X)),
which again simplifies, rewriting with the lemma DIFFERENCE-0, and opening
up the definition of EQUAL, to:
T.
Case 1. (IMPLIES (EQUAL 0 (DIFFERENCE X Y))
(NOT (LESSP Y X))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EQUAL-DIFFERENCE-0
(DISABLE EQUAL-DIFFERENCE-0)
[ 0.0 0.0 0.0 ]
EQUAL-DIFFERENCE-0-OFF
(PROVE-LEMMA DIFFERENCE-CANCELLATION-0
(REWRITE)
(EQUAL (EQUAL X (DIFFERENCE X Y))
(AND (NUMBERP X)
(OR (EQUAL X '0) (ZEROP Y))))
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions ZEROP, OR, and AND, to five new
goals:
Case 5. (IMPLIES (EQUAL X (DIFFERENCE X Y))
(NUMBERP X)),
which again simplifies, obviously, to:
T.
Case 4. (IMPLIES (AND (EQUAL X (DIFFERENCE X Y))
(NOT (EQUAL X 0))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))).
But this again simplifies, using linear arithmetic, to the conjecture:
(IMPLIES (AND (LESSP X Y)
(EQUAL X (DIFFERENCE X Y))
(NOT (EQUAL X 0))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))).
This again simplifies, using linear arithmetic and applying DIFFERENCE-0, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL X (DIFFERENCE X Y)))
(NUMBERP X))
(NUMBERP Y)).
But this again simplifies, expanding the definition of DIFFERENCE, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL X (DIFFERENCE X Y)))
(NUMBERP X))
(NOT (EQUAL Y 0))),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP X 0)
(NOT (EQUAL X (DIFFERENCE X 0))))
(NOT (NUMBERP X))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL X (DIFFERENCE X Y)))
(NUMBERP X))
(NOT (EQUAL X 0))),
which again simplifies, using linear arithmetic, applying the lemma
DIFFERENCE-0, and expanding EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-CANCELLATION-0
(DISABLE DIFFERENCE-CANCELLATION-0)
[ 0.0 0.0 0.0 ]
DIFFERENCE-CANCELLATION-0-OFF
(PROVE-LEMMA DIFFERENCE-CANCELLATION-1
(REWRITE)
(EQUAL (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(IF (LESSP X Y)
(NOT (LESSP Y Z))
(IF (LESSP Z Y)
(NOT (LESSP Y X))
(EQUAL (FIX X) (FIX Z)))))
((ENABLE DIFFERENCE-0 EQUAL-DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up NOT and FIX, to the following 11 new goals:
Case 11.(IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NOT (NUMBERP Z))
(NUMBERP X))
(EQUAL (EQUAL X 0) T)).
This again simplifies, using linear arithmetic, applying DIFFERENCE-0 and
EQUAL-DIFFERENCE-0, and expanding LESSP, to the following two new
conjectures:
Case 11.2.
(IMPLIES (AND (NOT (LESSP Y X))
(NOT (LESSP X Y))
(EQUAL Y 0)
(NOT (NUMBERP Z))
(NUMBERP X))
(EQUAL X 0)).
But this again simplifies, using linear arithmetic, to:
T.
Case 11.1.
(IMPLIES (AND (NOT (LESSP Y X))
(NOT (LESSP X Y))
(NOT (NUMBERP Y))
(NOT (NUMBERP Z))
(NUMBERP X))
(EQUAL X 0)),
which again simplifies, unfolding the definition of LESSP, to:
T.
Case 10.(IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NUMBERP Z)
(NOT (NUMBERP X)))
(EQUAL (EQUAL 0 Z) T)),
which again simplifies, using linear arithmetic, rewriting with DIFFERENCE-0
and EQUAL-DIFFERENCE-0, and opening up the functions LESSP and EQUAL, to the
following two new formulas:
Case 10.2.
(IMPLIES (AND (NOT (LESSP Y Z))
(EQUAL Y 0)
(NUMBERP Z)
(NOT (NUMBERP X)))
(EQUAL 0 Z)).
But this again simplifies, using linear arithmetic, to:
T.
Case 10.1.
(IMPLIES (AND (NOT (LESSP Y Z))
(NOT (NUMBERP Y))
(NUMBERP Z)
(NOT (NUMBERP X)))
(EQUAL 0 Z)),
which again simplifies, expanding the function LESSP, to:
T.
Case 9. (IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NUMBERP Z)
(NUMBERP X))
(EQUAL (EQUAL X Z) T)),
which again simplifies, obviously, to the new formula:
(IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NUMBERP Z)
(NUMBERP X))
(EQUAL X Z)),
which again simplifies, using linear arithmetic, to:
T.
Case 8. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NOT (NUMBERP Z)))
(NOT (EQUAL X 0))),
which again simplifies, using linear arithmetic, appealing to the lemma
DIFFERENCE-0, and unfolding the function EQUAL, to:
T.
Case 7. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NOT (NUMBERP X)))
(NOT (EQUAL 0 Z))),
which again simplifies, using linear arithmetic, applying DIFFERENCE-0, and
unfolding the function EQUAL, to:
T.
Case 6. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NUMBERP Z)
(NUMBERP X))
(NOT (EQUAL X Z))).
This again simplifies, clearly, to:
T.
Case 5. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(LESSP X Y))
(LESSP Y Z)).
However this again simplifies, using linear arithmetic, applying
DIFFERENCE-0, and expanding the function EQUAL, to:
T.
Case 4. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(NOT (LESSP Z Y))
(NOT (NUMBERP Z)))
(NUMBERP X)).
However this again simplifies, using linear arithmetic, applying
DIFFERENCE-0, and unfolding the definition of EQUAL, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(LESSP Z Y))
(LESSP Y X)).
But this again simplifies, using linear arithmetic, to three new goals:
Case 3.3.
(IMPLIES (AND (NOT (NUMBERP Y))
(NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(LESSP Z Y))
(LESSP Y X)),
which again simplifies, appealing to the lemma DIFFERENCE-0, and expanding
the definitions of DIFFERENCE and LESSP, to:
T.
Case 3.2.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y)))
(NOT (LESSP X Y))
(LESSP Z Y))
(LESSP Y X)),
which again simplifies, using linear arithmetic, applying DIFFERENCE-0,
and unfolding the function EQUAL, to:
T.
Case 3.1.
(IMPLIES (AND (NUMBERP X)
(NUMBERP Y)
(NOT (EQUAL (DIFFERENCE X X)
(DIFFERENCE Z X)))
(NOT (LESSP X X))
(LESSP Z X))
(LESSP X X)).
However this again simplifies, using linear arithmetic, applying
DIFFERENCE-0, and expanding the function EQUAL, to:
T.
Case 2. (IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(LESSP X Y))
(NOT (LESSP Y Z))).
However this again simplifies, using linear arithmetic and rewriting with
the lemmas DIFFERENCE-0 and EQUAL-DIFFERENCE-0, to:
T.
Case 1. (IMPLIES (AND (EQUAL (DIFFERENCE X Y)
(DIFFERENCE Z Y))
(NOT (LESSP X Y))
(LESSP Z Y))
(NOT (LESSP Y X))),
which again simplifies, using linear arithmetic and rewriting with
DIFFERENCE-0 and EQUAL-DIFFERENCE-0, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-CANCELLATION-1
(DISABLE DIFFERENCE-CANCELLATION-1)
[ 0.0 0.0 0.0 ]
DIFFERENCE-CANCELLATION-1-OFF
(PROVE-LEMMA TIMES-ZERO2
(REWRITE)
(IMPLIES (NOT (NUMBERP Y))
(EQUAL (TIMES X Y) '0))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to prove that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme leads to two new goals:
Case 2. (IMPLIES (AND (ZEROP X) (NOT (NUMBERP Y)))
(EQUAL (TIMES X Y) 0)),
which simplifies, opening up the definitions of ZEROP, EQUAL, and TIMES, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (TIMES (SUB1 X) Y) 0)
(NOT (NUMBERP Y)))
(EQUAL (TIMES X Y) 0)),
which simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS, and
unfolding ZEROP, TIMES, NUMBERP, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-ZERO2
(DISABLE TIMES-ZERO2)
[ 0.0 0.0 0.0 ]
TIMES-ZERO2-OFF
(PROVE-LEMMA DISTRIBUTIVITY-OF-TIMES-OVER-PLUS
(REWRITE)
(EQUAL (TIMES X (PLUS Y Z))
(PLUS (TIMES X Y) (TIMES X Z)))
((ENABLE COMMUTATIVITY2-OF-PLUS ASSOCIATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are four plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y Z))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y Z))
(p X Y Z))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates two new goals:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (TIMES X (PLUS Y Z))
(PLUS (TIMES X Y) (TIMES X Z)))),
which simplifies, opening up the functions ZEROP, EQUAL, TIMES, and PLUS, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (TIMES (SUB1 X) (PLUS Y Z))
(PLUS (TIMES (SUB1 X) Y)
(TIMES (SUB1 X) Z))))
(EQUAL (TIMES X (PLUS Y Z))
(PLUS (TIMES X Y) (TIMES X Z)))),
which simplifies, applying ASSOCIATIVITY-OF-PLUS and COMMUTATIVITY2-OF-PLUS,
and unfolding the functions ZEROP and TIMES, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-PLUS
(DISABLE DISTRIBUTIVITY-OF-TIMES-OVER-PLUS)
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-PLUS-OFF
(PROVE-LEMMA TIMES-ADD1
(REWRITE)
(EQUAL (TIMES X (ADD1 Y))
(IF (NUMBERP Y)
(PLUS X (TIMES X Y))
(FIX X)))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, unfolding the definition of FIX, to three new
conjectures:
Case 3. (IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (TIMES X (ADD1 Y)) X)),
which again simplifies, rewriting with SUB1-TYPE-RESTRICTION, to the new
formula:
(IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (TIMES X 1) X)),
which we will name *1.
Case 2. (IMPLIES (AND (NOT (NUMBERP Y))
(NOT (NUMBERP X)))
(EQUAL (TIMES X (ADD1 Y)) 0)).
However this again simplifies, applying SUB1-TYPE-RESTRICTION, and opening
up the definitions of TIMES and EQUAL, to:
T.
Case 1. (IMPLIES (NUMBERP Y)
(EQUAL (TIMES X (ADD1 Y))
(PLUS X (TIMES X Y)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (TIMES X (ADD1 Y))
(IF (NUMBERP Y)
(PLUS X (TIMES X Y))
(FIX X))),
which we named *1 above. We will appeal to induction. The recursive terms in
the conjecture suggest three inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT X) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme leads to the following two new formulas:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (TIMES X (ADD1 Y))
(IF (NUMBERP Y)
(PLUS X (TIMES X Y))
(FIX X)))).
This simplifies, rewriting with PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS,
and expanding the definitions of ZEROP, EQUAL, TIMES, PLUS, FIX, and NUMBERP,
to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (TIMES (SUB1 X) (ADD1 Y))
(IF (NUMBERP Y)
(PLUS (SUB1 X) (TIMES (SUB1 X) Y))
(FIX (SUB1 X)))))
(EQUAL (TIMES X (ADD1 Y))
(IF (NUMBERP Y)
(PLUS X (TIMES X Y))
(FIX X)))),
which simplifies, applying SUB1-TYPE-RESTRICTION and SUB1-ADD1, and
unfolding the functions ZEROP, FIX, TIMES, and PLUS, to the following two
new formulas:
Case 1.2.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (NUMBERP Y))
(EQUAL (TIMES (SUB1 X) (ADD1 Y))
(SUB1 X)))
(EQUAL (TIMES X 1) X)).
But this further simplifies, rewriting with SUB1-TYPE-RESTRICTION, and
unfolding TIMES, to the new formula:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (NUMBERP Y))
(EQUAL (TIMES (SUB1 X) 1) (SUB1 X)))
(EQUAL (PLUS 1 (SUB1 X)) X)),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NUMBERP Y)
(EQUAL (TIMES (SUB1 X) (ADD1 Y))
(PLUS (SUB1 X) (TIMES (SUB1 X) Y))))
(EQUAL (ADD1 (PLUS Y (TIMES (SUB1 X) (ADD1 Y))))
(PLUS X Y (TIMES (SUB1 X) Y)))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-ADD1
(DISABLE TIMES-ADD1)
[ 0.0 0.0 0.0 ]
TIMES-ADD1-OFF
(PROVE-LEMMA COMMUTATIVITY-OF-TIMES
(REWRITE)
(EQUAL (TIMES X Y) (TIMES Y X))
((ENABLE TIMES-ZERO2 TIMES-ADD1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. Two inductions are suggested by terms in
the conjecture, both of which are flawed. We limit our consideration to the
two suggested by the largest number of nonprimitive recursive functions in the
conjecture. Since both of these are equally likely, we will choose
arbitrarily. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
produces the following two new conjectures:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (TIMES X Y) (TIMES Y X))).
This simplifies, applying TIMES-ZERO2, and opening up the functions ZEROP,
EQUAL, and TIMES, to:
(IMPLIES (EQUAL X 0)
(EQUAL 0 (TIMES Y 0))).
This again simplifies, obviously, to:
(EQUAL 0 (TIMES Y 0)),
which we will name *1.1.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (TIMES (SUB1 X) Y)
(TIMES Y (SUB1 X))))
(EQUAL (TIMES X Y) (TIMES Y X))).
This simplifies, unfolding the definitions of ZEROP and TIMES, to the new
goal:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (TIMES (SUB1 X) Y)
(TIMES Y (SUB1 X))))
(EQUAL (PLUS Y (TIMES Y (SUB1 X)))
(TIMES Y X))).
Applying the lemma SUB1-ELIM, replace X by (ADD1 Z) to eliminate (SUB1 X).
We employ the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. This produces the new goal:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0))
(EQUAL (TIMES Z Y) (TIMES Y Z)))
(EQUAL (PLUS Y (TIMES Y Z))
(TIMES Y (ADD1 Z)))),
which further simplifies, applying the lemma TIMES-ADD1, to:
T.
So we now return to:
(EQUAL 0 (TIMES Y 0)),
which is formula *1.1 above. We will try to prove it by induction. There is
only one suggested induction. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP Y) (p Y))
(IMPLIES (AND (NOT (ZEROP Y)) (p (SUB1 Y)))
(p Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT Y) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme produces two new conjectures:
Case 2. (IMPLIES (ZEROP Y)
(EQUAL 0 (TIMES Y 0))),
which simplifies, unfolding ZEROP, TIMES, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Y))
(EQUAL 0 (TIMES (SUB1 Y) 0)))
(EQUAL 0 (TIMES Y 0))),
which simplifies, unfolding the definitions of ZEROP, TIMES, PLUS, and EQUAL,
to:
T.
That finishes the proof of *1.1, which, in turn, finishes the proof of *1.
Q.E.D.
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-TIMES
(DISABLE COMMUTATIVITY-OF-TIMES)
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-TIMES-OFF
(PROVE-LEMMA COMMUTATIVITY2-OF-TIMES
(REWRITE)
(EQUAL (TIMES X (TIMES Y Z))
(TIMES Y (TIMES X Z)))
((ENABLE DISTRIBUTIVITY-OF-TIMES-OVER-PLUS COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Four inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions,
both of which are unflawed. Since both of these are equally likely, we will
choose arbitrarily. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP Y) (p X Y Z))
(IMPLIES (AND (NOT (ZEROP Y)) (p X (SUB1 Y) Z))
(p X Y Z))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to prove that the measure (COUNT Y) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme leads to two new goals:
Case 2. (IMPLIES (ZEROP Y)
(EQUAL (TIMES X Y Z) (TIMES Y X Z))),
which simplifies, applying the lemma COMMUTATIVITY-OF-TIMES, and opening up
the definitions of ZEROP, EQUAL, and TIMES, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Y))
(EQUAL (TIMES X (SUB1 Y) Z)
(TIMES (SUB1 Y) X Z)))
(EQUAL (TIMES X Y Z) (TIMES Y X Z))),
which simplifies, rewriting with DISTRIBUTIVITY-OF-TIMES-OVER-PLUS, and
opening up the functions ZEROP and TIMES, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
COMMUTATIVITY2-OF-TIMES
(DISABLE COMMUTATIVITY2-OF-TIMES)
[ 0.0 0.0 0.0 ]
COMMUTATIVITY2-OF-TIMES-OFF
(PROVE-LEMMA ASSOCIATIVITY-OF-TIMES
(REWRITE)
(EQUAL (TIMES (TIMES X Y) Z)
(TIMES X (TIMES Y Z)))
((ENABLE COMMUTATIVITY-OF-TIMES COMMUTATIVITY2-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY2-OF-TIMES, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-TIMES
(DISABLE ASSOCIATIVITY-OF-TIMES)
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-TIMES-OFF
(PROVE-LEMMA EQUAL-TIMES-0
(REWRITE)
(EQUAL (EQUAL (TIMES X Y) '0)
(OR (ZEROP X) (ZEROP Y)))
((ENABLE PLUS-EQUAL-0 TIMES-ZERO2 COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions ZEROP and OR, to five new
conjectures:
Case 5. (IMPLIES (NOT (EQUAL (TIMES X Y) 0))
(NUMBERP Y)),
which again simplifies, applying TIMES-ZERO2, and unfolding the function
EQUAL, to:
T.
Case 4. (IMPLIES (NOT (EQUAL (TIMES X Y) 0))
(NOT (EQUAL Y 0))).
However this again simplifies, applying COMMUTATIVITY-OF-TIMES, and
unfolding the functions EQUAL and TIMES, to:
T.
Case 3. (IMPLIES (NOT (EQUAL (TIMES X Y) 0))
(NUMBERP X)).
This again simplifies, opening up the definitions of TIMES and EQUAL, to:
T.
Case 2. (IMPLIES (NOT (EQUAL (TIMES X Y) 0))
(NOT (EQUAL X 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (EQUAL (TIMES X Y) 0)
(NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which we will name *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p Y X))
(IMPLIES (AND (NOT (ZEROP X)) (p Y (SUB1 X)))
(p Y X))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme produces three new conjectures:
Case 3. (IMPLIES (AND (ZEROP X)
(EQUAL (TIMES X Y) 0)
(NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, unfolding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP X))
(NOT (EQUAL (TIMES (SUB1 X) Y) 0))
(EQUAL (TIMES X Y) 0)
(NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, rewriting with the lemma PLUS-EQUAL-0, and expanding the
functions ZEROP and TIMES, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (SUB1 X) 0)
(EQUAL (TIMES X Y) 0)
(NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, rewriting with the lemma PLUS-EQUAL-0, and expanding the
definitions of ZEROP and TIMES, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
EQUAL-TIMES-0
(DISABLE EQUAL-TIMES-0)
[ 0.0 0.0 0.0 ]
EQUAL-TIMES-0-OFF
(DEFN EXP
(I J)
(IF (ZEROP J)
'1
(TIMES I (EXP I (SUB1 J))))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
inform us that the measure (COUNT J) decreases according to the well-founded
relation LESSP in each recursive call. Hence, EXP is accepted under the
definitional principle. From the definition we can conclude that
(NUMBERP (EXP I J)) is a theorem.
[ 0.0 0.0 0.0 ]
EXP
(PROVE-LEMMA EXP-PLUS
(REWRITE)
(EQUAL (EXP I (PLUS J K))
(TIMES (EXP I J) (EXP I K)))
((ENABLE COMMUTATIVITY-OF-TIMES ASSOCIATIVITY-OF-TIMES EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are three plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP J) (p I J K))
(IMPLIES (AND (NOT (ZEROP J)) (p I (SUB1 J) K))
(p I J K))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definition
of ZEROP inform us that the measure (COUNT J) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates two new goals:
Case 2. (IMPLIES (ZEROP J)
(EQUAL (EXP I (PLUS J K))
(TIMES (EXP I J) (EXP I K)))),
which simplifies, opening up the functions ZEROP, EQUAL, PLUS, and EXP, to
four new formulas:
Case 2.4.
(IMPLIES (AND (EQUAL J 0) (NOT (NUMBERP K)))
(EQUAL (EXP I 0)
(TIMES 1 (EXP I K)))),
which again simplifies, opening up EQUAL, EXP, and TIMES, to:
T.
Case 2.3.
(IMPLIES (AND (EQUAL J 0) (NUMBERP K))
(EQUAL (EXP I K)
(TIMES 1 (EXP I K)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP J))
(NOT (NUMBERP K)))
(EQUAL (EXP I 0)
(TIMES 1 (EXP I K)))),
which again simplifies, opening up the definitions of EQUAL, EXP, and
TIMES, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP J)) (NUMBERP K))
(EQUAL (EXP I K)
(TIMES 1 (EXP I K)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP J))
(EQUAL (EXP I (PLUS (SUB1 J) K))
(TIMES (EXP I (SUB1 J)) (EXP I K))))
(EQUAL (EXP I (PLUS J K))
(TIMES (EXP I J) (EXP I K)))),
which simplifies, rewriting with COMMUTATIVITY-OF-TIMES, SUB1-ADD1, and
ASSOCIATIVITY-OF-TIMES, and opening up the functions ZEROP, PLUS, and EXP,
to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
EXP-PLUS
(DISABLE EXP-PLUS)
[ 0.0 0.0 0.0 ]
EXP-PLUS-OFF
(PROVE-LEMMA EQUAL-LESSP
(REWRITE)
(EQUAL (EQUAL (LESSP X Y) Z)
(IF (LESSP X Y)
(EQUAL '*1*TRUE Z)
(EQUAL '*1*FALSE Z)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, clearly, to the following four new formulas:
Case 4. (IMPLIES (AND (EQUAL (LESSP X Y) Z)
(NOT (LESSP X Y)))
(NOT Z)).
This again simplifies, trivially, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL (LESSP X Y) Z))
(NOT (LESSP X Y)))
Z).
This again simplifies, clearly, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL (LESSP X Y) Z))
(LESSP X Y))
(NOT (EQUAL T Z))).
This again simplifies, obviously, to:
T.
Case 1. (IMPLIES (AND (EQUAL (LESSP X Y) Z)
(LESSP X Y))
(EQUAL (EQUAL T Z) T)).
This again simplifies, obviously, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EQUAL-LESSP
(DISABLE EQUAL-LESSP)
[ 0.0 0.0 0.0 ]
EQUAL-LESSP-OFF
(PROVE-LEMMA DIFFERENCE-ELIM
(ELIM)
(IMPLIES (AND (NUMBERP Y) (NOT (LESSP Y X)))
(EQUAL (PLUS X (DIFFERENCE Y X)) Y))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-ELIM
(PROVE-LEMMA REMAINDER-QUOTIENT
(REWRITE)
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
(FIX X))
((ENABLE COMMUTATIVITY2-OF-PLUS COMMUTATIVITY-OF-PLUS TIMES-ZERO2
TIMES-ADD1 COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up the function FIX, to the following two new
goals:
Case 2. (IMPLIES (NOT (NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
0)).
However this again simplifies, rewriting with COMMUTATIVITY-OF-TIMES, and
opening up LESSP, REMAINDER, QUOTIENT, EQUAL, TIMES, and PLUS, to:
T.
Case 1. (IMPLIES (NUMBERP X)
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X)).
Call the above conjecture *1.
We will appeal to induction. Three inductions are suggested by terms in
the conjecture. They merge into two likely candidate inductions. However,
only one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP Y) (p X Y))
(IMPLIES (AND (NOT (ZEROP Y)) (LESSP X Y))
(p X Y))
(IMPLIES (AND (NOT (ZEROP Y))
(NOT (LESSP X Y))
(p (DIFFERENCE X Y) Y))
(p X Y))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP can be used to show that the measure (COUNT X) decreases
according to the well-founded relation LESSP in each induction step of the
scheme. The above induction scheme produces three new goals:
Case 3. (IMPLIES (AND (ZEROP Y) (NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X)),
which simplifies, applying COMMUTATIVITY-OF-PLUS, TIMES-ZERO2, and
COMMUTATIVITY-OF-TIMES, and unfolding the functions ZEROP, EQUAL, REMAINDER,
QUOTIENT, TIMES, and PLUS, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP Y))
(LESSP X Y)
(NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X)).
This simplifies, rewriting with the lemmas COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and opening up the functions ZEROP, REMAINDER,
QUOTIENT, EQUAL, TIMES, and PLUS, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Y))
(NOT (LESSP X Y))
(EQUAL (PLUS (REMAINDER (DIFFERENCE X Y) Y)
(TIMES Y
(QUOTIENT (DIFFERENCE X Y) Y)))
(DIFFERENCE X Y))
(NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X)).
This simplifies, rewriting with TIMES-ADD1 and COMMUTATIVITY2-OF-PLUS, and
opening up the functions ZEROP, REMAINDER, and QUOTIENT, to the goal:
(IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (LESSP X Y))
(EQUAL (PLUS (REMAINDER (DIFFERENCE X Y) Y)
(TIMES Y
(QUOTIENT (DIFFERENCE X Y) Y)))
(DIFFERENCE X Y))
(NUMBERP X))
(EQUAL (PLUS Y (DIFFERENCE X Y)) X)).
But this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-QUOTIENT
(DISABLE REMAINDER-QUOTIENT)
[ 0.0 0.0 0.0 ]
REMAINDER-QUOTIENT-OFF
(PROVE-LEMMA REMAINDER-WRT-1
(REWRITE)
(EQUAL (REMAINDER Y '1) '0)
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP 1) (p Y))
(IMPLIES (AND (NOT (ZEROP 1)) (LESSP Y 1))
(p Y))
(IMPLIES (AND (NOT (ZEROP 1))
(NOT (LESSP Y 1))
(p (DIFFERENCE Y 1)))
(p Y))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP can be used to establish that the measure (COUNT Y)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates the following three new
formulas:
Case 3. (IMPLIES (ZEROP 1)
(EQUAL (REMAINDER Y 1) 0)).
This simplifies, expanding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP 1)) (LESSP Y 1))
(EQUAL (REMAINDER Y 1) 0)).
This simplifies, opening up the functions ZEROP, REMAINDER, EQUAL, and
NUMBERP, to the new goal:
(IMPLIES (AND (LESSP Y 1) (NUMBERP Y))
(EQUAL Y 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP 1))
(NOT (LESSP Y 1))
(EQUAL (REMAINDER (DIFFERENCE Y 1) 1)
0))
(EQUAL (REMAINDER Y 1) 0)),
which simplifies, expanding ZEROP, REMAINDER, EQUAL, and NUMBERP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-WRT-1
(DISABLE REMAINDER-WRT-1)
[ 0.0 0.0 0.0 ]
REMAINDER-WRT-1-OFF
(PROVE-LEMMA REMAINDER-WRT-12
(REWRITE)
(IMPLIES (NOT (NUMBERP X))
(EQUAL (REMAINDER Y X) (FIX Y)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding the definitions of REMAINDER and FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-WRT-12
(DISABLE REMAINDER-WRT-12)
[ 0.0 0.0 0.0 ]
REMAINDER-WRT-12-OFF
(PROVE-LEMMA LESSP-REMAINDER2
(REWRITE GENERALIZE)
(EQUAL (LESSP (REMAINDER X Y) Y)
(NOT (ZEROP Y)))
((ENABLE EQUAL-LESSP REMAINDER-WRT-12)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying EQUAL-LESSP, and unfolding the functions
ZEROP and NOT, to three new goals:
Case 3. (IMPLIES (AND (NOT (LESSP (REMAINDER X Y) Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which we will name *1.
Case 2. (IMPLIES (LESSP (REMAINDER X Y) Y)
(NUMBERP Y)).
This again simplifies, applying REMAINDER-WRT-12, and unfolding the
definition of LESSP, to:
T.
Case 1. (IMPLIES (LESSP (REMAINDER X Y) Y)
(NOT (EQUAL Y 0))).
This again simplifies, using linear arithmetic, to:
T.
So next consider:
(IMPLIES (AND (NOT (LESSP (REMAINDER X Y) Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
named *1 above. Let us appeal to the induction principle. The recursive
terms in the conjecture suggest two inductions. However, only one is unflawed.
We will induct according to the following scheme:
(AND (IMPLIES (ZEROP Y) (p Y X))
(IMPLIES (AND (NOT (ZEROP Y)) (LESSP X Y))
(p Y X))
(IMPLIES (AND (NOT (ZEROP Y))
(NOT (LESSP X Y))
(p Y (DIFFERENCE X Y)))
(p Y X))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT X) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme produces three new conjectures:
Case 3. (IMPLIES (AND (ZEROP Y)
(NOT (LESSP (REMAINDER X Y) Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, unfolding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP Y))
(LESSP X Y)
(NOT (LESSP (REMAINDER X Y) Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, unfolding ZEROP and REMAINDER, to:
(IMPLIES (AND (LESSP X Y)
(NOT (NUMBERP X))
(NOT (LESSP 0 Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))).
This again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Y))
(NOT (LESSP X Y))
(LESSP (REMAINDER (DIFFERENCE X Y) Y)
Y)
(NOT (LESSP (REMAINDER X Y) Y))
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which simplifies, expanding the functions ZEROP and REMAINDER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER2
(DISABLE LESSP-REMAINDER2)
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER2-OFF
(PROVE-LEMMA REMAINDER-X-X
(REWRITE)
(EQUAL (REMAINDER X X) '0)
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, rewriting with DIFFERENCE-0, and expanding the
functions NUMBERP, REMAINDER, LESSP, and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL X 0)) (NUMBERP X))
(NOT (LESSP X X))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-X-X
(DISABLE REMAINDER-X-X)
[ 0.0 0.0 0.0 ]
REMAINDER-X-X-OFF
(PROVE-LEMMA REMAINDER-QUOTIENT-ELIM
(ELIM)
(IMPLIES (AND (NOT (ZEROP Y)) (NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X))
((ENABLE REMAINDER-QUOTIENT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(NUMBERP X))
(EQUAL (PLUS (REMAINDER X Y)
(TIMES Y (QUOTIENT X Y)))
X)),
which simplifies, rewriting with REMAINDER-QUOTIENT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-QUOTIENT-ELIM
(PROVE-LEMMA LESSP-TIMES-1
(REWRITE)
(IMPLIES (NOT (ZEROP I))
(NOT (LESSP (TIMES I J) J)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma LESSP-TIMES-1 is to be stored as zero
type prescription rules, zero compound recognizer rules, one linear rule, and
zero replacement rules.
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL I 0)) (NUMBERP I))
(NOT (LESSP (TIMES I J) J))),
which we will name *1.
We will appeal to induction. There are two plausible inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP I) (p I J))
(IMPLIES (AND (NOT (ZEROP I)) (p (SUB1 I) J))
(p I J))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to show that the measure (COUNT I) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme produces three new conjectures:
Case 3. (IMPLIES (AND (ZEROP I)
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (TIMES I J) J))),
which simplifies, opening up the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP I))
(EQUAL (SUB1 I) 0)
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (TIMES I J) J))),
which simplifies, unfolding the functions ZEROP and TIMES, to the goal:
(IMPLIES (AND (EQUAL (SUB1 I) 0)
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (PLUS J (TIMES (SUB1 I) J))
J))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP I))
(NOT (LESSP (TIMES (SUB1 I) J) J))
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (TIMES I J) J))),
which simplifies, opening up ZEROP and TIMES, to:
(IMPLIES (AND (NOT (LESSP (TIMES (SUB1 I) J) J))
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (PLUS J (TIMES (SUB1 I) J))
J))).
But this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-TIMES-1
(DISABLE LESSP-TIMES-1)
[ 0.0 0.0 0.0 ]
LESSP-TIMES-1-OFF
(PROVE-LEMMA LESSP-TIMES-2
(REWRITE)
(IMPLIES (NOT (ZEROP I))
(NOT (LESSP (TIMES J I) J)))
((ENABLE COMMUTATIVITY-OF-TIMES LESSP-TIMES-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma LESSP-TIMES-2 is to be stored as zero
type prescription rules, zero compound recognizer rules, one linear rule, and
zero replacement rules.
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL I 0)) (NUMBERP I))
(NOT (LESSP (TIMES J I) J))),
which simplifies, rewriting with the lemma COMMUTATIVITY-OF-TIMES, to:
(IMPLIES (AND (NOT (EQUAL I 0)) (NUMBERP I))
(NOT (LESSP (TIMES I J) J))).
But this again simplifies, using linear arithmetic and applying the lemma
LESSP-TIMES-1, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-TIMES-2
(DISABLE LESSP-TIMES-2)
[ 0.0 0.0 0.0 ]
LESSP-TIMES-2-OFF
(PROVE-LEMMA LESSP-QUOTIENT1
(REWRITE)
(EQUAL (LESSP (QUOTIENT I J) I)
(AND (NOT (ZEROP I))
(OR (ZEROP J) (NOT (EQUAL J '1)))))
((ENABLE PLUS-EQUAL-0 DIFFERENCE-0 EQUAL-DIFFERENCE-0
EQUAL-TIMES-0 EQUAL-LESSP LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM LESSP-TIMES-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, rewriting with EQUAL-LESSP, and opening up the
definitions of ZEROP, NOT, OR, and AND, to the following six new formulas:
Case 6. (IMPLIES (AND (NOT (LESSP (QUOTIENT I J) I))
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (EQUAL J 0))).
But this again simplifies, opening up EQUAL, QUOTIENT, and LESSP, to:
T.
Case 5. (IMPLIES (AND (NOT (LESSP (QUOTIENT I J) I))
(NOT (EQUAL I 0))
(NUMBERP I))
(NUMBERP J)),
which again simplifies, unfolding the definitions of QUOTIENT, EQUAL, and
LESSP, to:
T.
Case 4. (IMPLIES (AND (NOT (LESSP (QUOTIENT I J) I))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL J 1)).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace I by
(PLUS Z (TIMES J X)) to eliminate (QUOTIENT I J) and (REMAINDER I J). We
employ LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was
introduced to restrict the new variables. We thus obtain the following
three new formulas:
Case 4.3.
(IMPLIES (AND (EQUAL J 0)
(NOT (LESSP (QUOTIENT I J) I))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL J 1)).
However this further simplifies, opening up the definitions of EQUAL,
QUOTIENT, and LESSP, to:
T.
Case 4.2.
(IMPLIES (AND (NOT (NUMBERP J))
(NOT (LESSP (QUOTIENT I J) I))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL J 1)),
which further simplifies, opening up QUOTIENT, EQUAL, and LESSP, to:
T.
Case 4.1.
(IMPLIES (AND (NUMBERP X)
(NUMBERP Z)
(EQUAL (LESSP Z J) (NOT (ZEROP J)))
(NUMBERP J)
(NOT (EQUAL J 0))
(NOT (LESSP X (PLUS Z (TIMES J X))))
(NOT (EQUAL (PLUS Z (TIMES J X)) 0)))
(EQUAL J 1)),
which further simplifies, rewriting with the lemmas EQUAL-TIMES-0 and
PLUS-EQUAL-0, and expanding the functions ZEROP and NOT, to two new goals:
Case 4.1.2.
(IMPLIES (AND (NUMBERP X)
(NUMBERP Z)
(LESSP Z J)
(NUMBERP J)
(NOT (EQUAL J 0))
(NOT (LESSP X (PLUS Z (TIMES J X))))
(NOT (EQUAL Z 0)))
(EQUAL J 1)),
which again simplifies, using linear arithmetic and applying
LESSP-TIMES-1, to:
T.
Case 4.1.1.
(IMPLIES (AND (NUMBERP X)
(NUMBERP Z)
(LESSP Z J)
(NUMBERP J)
(NOT (EQUAL J 0))
(NOT (LESSP X (PLUS Z (TIMES J X))))
(NOT (EQUAL X 0)))
(EQUAL J 1)),
which we would usually push and work on later by induction. But if we
must use induction to prove the input conjecture, we prefer to induct on
the original formulation of the problem. Thus we will disregard all
that we have previously done, give the name *1 to the original input,
and work on it.
So now let us consider:
(EQUAL (LESSP (QUOTIENT I J) I)
(AND (NOT (ZEROP I))
(OR (ZEROP J) (NOT (EQUAL J 1))))).
We gave this the name *1 above. Perhaps we can prove it by induction. Two
inductions are suggested by terms in the conjecture, both of which are
unflawed. So we will choose the one suggested by the largest number of
nonprimitive recursive functions. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP J) (p I J))
(IMPLIES (AND (NOT (ZEROP J)) (LESSP I J))
(p I J))
(IMPLIES (AND (NOT (ZEROP J))
(NOT (LESSP I J))
(p (DIFFERENCE I J) J))
(p I J))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT I) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme leads to the following three new formulas:
Case 3. (IMPLIES (ZEROP J)
(EQUAL (LESSP (QUOTIENT I J) I)
(AND (NOT (ZEROP I))
(OR (ZEROP J) (NOT (EQUAL J 1)))))).
This simplifies, expanding the definitions of ZEROP, EQUAL, QUOTIENT, LESSP,
NOT, OR, and AND, to the following four new goals:
Case 3.4.
(IMPLIES (AND (EQUAL J 0)
(NOT (EQUAL I 0))
(NOT (NUMBERP I)))
(EQUAL (NUMBERP I) F)).
This again simplifies, clearly, to:
T.
Case 3.3.
(IMPLIES (AND (EQUAL J 0)
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (NUMBERP I) T)).
This again simplifies, clearly, to:
T.
Case 3.2.
(IMPLIES (AND (NOT (NUMBERP J))
(NOT (EQUAL I 0))
(NOT (NUMBERP I)))
(EQUAL (NUMBERP I) F)).
This again simplifies, clearly, to:
T.
Case 3.1.
(IMPLIES (AND (NOT (NUMBERP J))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (NUMBERP I) T)).
This again simplifies, trivially, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP J)) (LESSP I J))
(EQUAL (LESSP (QUOTIENT I J) I)
(AND (NOT (ZEROP I))
(OR (ZEROP J) (NOT (EQUAL J 1)))))).
This simplifies, expanding the definitions of ZEROP, QUOTIENT, EQUAL, LESSP,
NOT, OR, and AND, to the following three new goals:
Case 2.3.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(LESSP I J)
(NOT (EQUAL I 0))
(EQUAL J 1))
(EQUAL (NUMBERP I) F)).
This again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL 1 0))
(NUMBERP 1)
(LESSP I 1)
(NOT (EQUAL I 0)))
(EQUAL (NUMBERP I) F)).
This again simplifies, clearly, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(LESSP I J)
(NOT (EQUAL I 0))
(NOT (NUMBERP I)))
(EQUAL (NUMBERP I) F)).
This again simplifies, obviously, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(LESSP I J)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL J 1)))
(EQUAL (NUMBERP I) T)).
This again simplifies, obviously, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP J))
(NOT (LESSP I J))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J))
(AND (NOT (ZEROP (DIFFERENCE I J)))
(OR (ZEROP J) (NOT (EQUAL J 1))))))
(EQUAL (LESSP (QUOTIENT I J) I)
(AND (NOT (ZEROP I))
(OR (ZEROP J) (NOT (EQUAL J 1)))))).
This simplifies, applying EQUAL-DIFFERENCE-0, EQUAL-LESSP, and SUB1-ADD1,
and unfolding the functions ZEROP, NOT, OR, AND, EQUAL, QUOTIENT, and LESSP,
to four new goals:
Case 1.4.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (LESSP I J))
(NOT (LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J)))
(EQUAL J 1))
(NOT (LESSP (QUOTIENT I 1) I))),
which again simplifies, unfolding EQUAL and NUMBERP, to the goal:
(IMPLIES (AND (NOT (LESSP I 1))
(NOT (LESSP (QUOTIENT (DIFFERENCE I 1) 1)
(DIFFERENCE I 1))))
(NOT (LESSP (QUOTIENT I 1) I))).
However this again simplifies, applying SUB1-ADD1, and opening up the
functions NUMBERP, EQUAL, QUOTIENT, and LESSP, to the new formula:
(IMPLIES (AND (NOT (LESSP I 1))
(NOT (LESSP (QUOTIENT (DIFFERENCE I 1) 1)
(DIFFERENCE I 1)))
(NOT (EQUAL I 0))
(NUMBERP I))
(NOT (LESSP (QUOTIENT (DIFFERENCE I 1) 1)
(SUB1 I)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (LESSP I J))
(NOT (LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J)))
(NOT (LESSP J I))
(NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL J 1))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE I J) J)
(SUB1 I))
F)),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NOT (EQUAL 1 0))
(NUMBERP 1)
(NOT (LESSP 1 1))
(NOT (LESSP (QUOTIENT (DIFFERENCE 1 1) 1)
(DIFFERENCE 1 1)))
(NOT (LESSP 1 1))
(NOT (EQUAL 1 0))
(NUMBERP 1))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE 1 1) 1)
(SUB1 1))
F)).
However this again simplifies, unfolding EQUAL, NUMBERP, LESSP, DIFFERENCE,
QUOTIENT, and SUB1, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (LESSP I J))
(NOT (LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J)))
(NOT (LESSP J I))
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL J 1)))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE I J) J)
(SUB1 I))
T)),
which again simplifies, using linear arithmetic, to the conjecture:
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LESSP I I))
(NOT (LESSP (QUOTIENT (DIFFERENCE I I) I)
(DIFFERENCE I I)))
(NOT (LESSP I I))
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL I 1)))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE I I) I)
(SUB1 I))
T)).
This again simplifies, applying DIFFERENCE-0, and expanding the
definitions of LESSP, EQUAL, and QUOTIENT, to the new formula:
(IMPLIES (AND (NOT (LESSP I I))
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL I 1)))
(NOT (EQUAL (SUB1 I) 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (LESSP I J))
(LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J))
(LESSP J I)
(NOT (EQUAL J 1))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE I J) J)
(SUB1 I))
T)),
which again simplifies, obviously, to:
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (LESSP I J))
(LESSP (QUOTIENT (DIFFERENCE I J) J)
(DIFFERENCE I J))
(LESSP J I)
(NOT (EQUAL J 1))
(NOT (EQUAL I 0))
(NUMBERP I))
(LESSP (QUOTIENT (DIFFERENCE I J) J)
(SUB1 I))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT1
(DISABLE LESSP-QUOTIENT1)
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT1-OFF
(PROVE-LEMMA LESSP-REMAINDER1
(REWRITE)
(EQUAL (LESSP (REMAINDER X Y) X)
(AND (NOT (ZEROP Y))
(AND (NOT (ZEROP X))
(NOT (LESSP X Y)))))
((ENABLE PLUS-EQUAL-0 COMMUTATIVITY-OF-TIMES EQUAL-TIMES-0
EQUAL-LESSP REMAINDER-WRT-12 LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, rewriting with EQUAL-LESSP, and opening up the
definitions of ZEROP, NOT, and AND, to the following six new formulas:
Case 6. (IMPLIES (AND (NOT (LESSP (REMAINDER X Y) X))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL X 0))
(NUMBERP X))
(LESSP X Y)).
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace X by
(PLUS Z (TIMES Y V)) to eliminate (REMAINDER X Y) and (QUOTIENT X Y). We
rely upon LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER
was introduced, and the type restriction lemma noted when QUOTIENT was
introduced to constrain the new variables. We must thus prove:
(IMPLIES (AND (NUMBERP Z)
(EQUAL (LESSP Z Y) (NOT (ZEROP Y)))
(NUMBERP V)
(NOT (LESSP Z (PLUS Z (TIMES Y V))))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL (PLUS Z (TIMES Y V)) 0)))
(LESSP (PLUS Z (TIMES Y V)) Y)).
However this further simplifies, appealing to the lemmas
COMMUTATIVITY-OF-TIMES, EQUAL-TIMES-0, and PLUS-EQUAL-0, and unfolding the
definitions of ZEROP and NOT, to two new conjectures:
Case 6.2.
(IMPLIES (AND (NUMBERP Z)
(LESSP Z Y)
(NUMBERP V)
(NOT (LESSP Z (PLUS Z (TIMES V Y))))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Z 0)))
(LESSP (PLUS Z (TIMES V Y)) Y)),
which again simplifies, using linear arithmetic, to:
T.
Case 6.1.
(IMPLIES (AND (NUMBERP Z)
(LESSP Z Y)
(NUMBERP V)
(NOT (LESSP Z (PLUS Z (TIMES V Y))))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL V 0)))
(LESSP (PLUS Z (TIMES V Y)) Y)),
which again simplifies, using linear arithmetic, to:
T.
Case 5. (IMPLIES (LESSP (REMAINDER X Y) X)
(NOT (LESSP X Y))),
which again simplifies, unfolding the functions REMAINDER and LESSP, to two
new formulas:
Case 5.2.
(IMPLIES (AND (NOT (NUMBERP X))
(LESSP 0 X)
(NOT (EQUAL Y 0)))
(NOT (NUMBERP Y))),
which again simplifies, opening up LESSP, to:
T.
Case 5.1.
(IMPLIES (AND (NUMBERP X) (LESSP X X))
(NOT (LESSP X Y))),
which again simplifies, using linear arithmetic, to:
T.
Case 4. (IMPLIES (LESSP (REMAINDER X Y) X)
(NUMBERP X)),
which again simplifies, expanding the functions LESSP and REMAINDER, to:
T.
Case 3. (IMPLIES (LESSP (REMAINDER X Y) X)
(NOT (EQUAL X 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (LESSP (REMAINDER X Y) X)
(NUMBERP Y)),
which again simplifies, rewriting with REMAINDER-WRT-12, to the following
two new conjectures:
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP X)) (LESSP 0 X))
(NUMBERP Y)).
However this again simplifies, unfolding the function LESSP, to:
T.
Case 2.1.
(IMPLIES (AND (NUMBERP X) (LESSP X X))
(NUMBERP Y)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (LESSP (REMAINDER X Y) X)
(NOT (EQUAL Y 0))),
which again simplifies, opening up the definitions of EQUAL and REMAINDER,
to two new formulas:
Case 1.2.
(IMPLIES (NOT (NUMBERP X))
(NOT (LESSP 0 X))),
which again simplifies, unfolding the function LESSP, to:
T.
Case 1.1.
(IMPLIES (NUMBERP X)
(NOT (LESSP X X))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER1
(DISABLE LESSP-REMAINDER1)
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER1-OFF
(PROVE-LEMMA DIFFERENCE-PLUS1
(REWRITE)
(EQUAL (DIFFERENCE (PLUS X Y) X)
(FIX Y))
((ENABLE DIFFERENCE-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemma DIFFERENCE-PLUS, and
expanding the function FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS1
(DISABLE DIFFERENCE-PLUS1)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS1-OFF
(PROVE-LEMMA DIFFERENCE-PLUS2
(REWRITE)
(EQUAL (DIFFERENCE (PLUS Y X) X)
(FIX Y))
((ENABLE COMMUTATIVITY-OF-PLUS DIFFERENCE-PLUS1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemmas COMMUTATIVITY-OF-PLUS and
DIFFERENCE-PLUS1, and expanding the function FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS2
(DISABLE DIFFERENCE-PLUS2)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS2-OFF
(PROVE-LEMMA DIFFERENCE-PLUS-CANCELATION
(REWRITE)
(EQUAL (DIFFERENCE (PLUS X Y) (PLUS X Z))
(DIFFERENCE Y Z))
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to the following two new conjectures:
Case 2. (IMPLIES (LESSP (PLUS X Y) (PLUS X Z))
(EQUAL (DIFFERENCE (PLUS X Y) (PLUS X Z))
(DIFFERENCE Y Z))).
But this again simplifies, using linear arithmetic, applying DIFFERENCE-0,
and opening up the function EQUAL, to:
T.
Case 1. (IMPLIES (LESSP Y Z)
(EQUAL (DIFFERENCE (PLUS X Y) (PLUS X Z))
(DIFFERENCE Y Z))).
But this again simplifies, using linear arithmetic, applying the lemma
DIFFERENCE-0, and expanding EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS-CANCELATION
(DISABLE DIFFERENCE-PLUS-CANCELATION)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS-CANCELATION-OFF
(PROVE-LEMMA TIMES-DIFFERENCE
(REWRITE)
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X) (TIMES W X)))
((ENABLE PLUS-EQUAL-0 DIFFERENCE-0 EQUAL-DIFFERENCE-0
COMMUTATIVITY-OF-TIMES EQUAL-TIMES-0 DIFFERENCE-ELIM
DIFFERENCE-PLUS-CANCELATION)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Appealing to the lemma DIFFERENCE-ELIM, we now replace C by (PLUS W Z) to
eliminate (DIFFERENCE C W). We use the type restriction lemma noted when
DIFFERENCE was introduced to constrain the new variable. The result is three
new goals:
Case 3. (IMPLIES (LESSP C W)
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X)
(TIMES W X)))),
which simplifies, using linear arithmetic, appealing to the lemmas
DIFFERENCE-0, COMMUTATIVITY-OF-TIMES, and EQUAL-DIFFERENCE-0, and unfolding
EQUAL and TIMES, to:
(IMPLIES (LESSP C W)
(NOT (LESSP (TIMES W X) (TIMES C X)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X) (TIMES W X))),
which we named *1 above. We will appeal to induction. There are five
plausible inductions. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP C) (p X C W))
(IMPLIES (AND (NOT (ZEROP C)) (ZEROP W))
(p X C W))
(IMPLIES (AND (NOT (ZEROP C))
(NOT (ZEROP W))
(p X (SUB1 C) (SUB1 W)))
(p X C W))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT C) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for W. The above induction scheme produces the
following three new goals:
Case 3. (IMPLIES (ZEROP C)
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X)
(TIMES W X)))).
This simplifies, using linear arithmetic, rewriting with DIFFERENCE-0 and
COMMUTATIVITY-OF-TIMES, and unfolding the functions ZEROP, EQUAL, and TIMES,
to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP C)) (ZEROP W))
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X)
(TIMES W X)))),
which simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES,
PLUS-EQUAL-0, and EQUAL-TIMES-0, and unfolding the functions ZEROP, EQUAL,
DIFFERENCE, and TIMES, to four new conjectures:
Case 2.4.
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(EQUAL W 0)
(NOT (NUMBERP X)))
(EQUAL (PLUS X (TIMES (SUB1 C) X))
0)),
which again simplifies, applying EQUAL-TIMES-0, and opening up the
function PLUS, to:
T.
Case 2.3.
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(EQUAL W 0)
(EQUAL X 0))
(EQUAL (PLUS X (TIMES (SUB1 C) X))
0)).
But this again simplifies, applying COMMUTATIVITY-OF-TIMES, and expanding
the functions EQUAL, TIMES, and PLUS, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(NOT (NUMBERP W))
(NOT (NUMBERP X)))
(EQUAL (PLUS X (TIMES (SUB1 C) X))
0)).
This again simplifies, applying EQUAL-TIMES-0, and unfolding the
definition of PLUS, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(NOT (NUMBERP W))
(EQUAL X 0))
(EQUAL (PLUS X (TIMES (SUB1 C) X))
0)).
However this again simplifies, rewriting with COMMUTATIVITY-OF-TIMES, and
expanding the definitions of EQUAL, TIMES, and PLUS, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP C))
(NOT (ZEROP W))
(EQUAL (TIMES X
(DIFFERENCE (SUB1 C) (SUB1 W)))
(DIFFERENCE (TIMES (SUB1 C) X)
(TIMES (SUB1 W) X))))
(EQUAL (TIMES X (DIFFERENCE C W))
(DIFFERENCE (TIMES C X)
(TIMES W X)))).
This simplifies, rewriting with DIFFERENCE-PLUS-CANCELATION, and unfolding
the definitions of ZEROP, DIFFERENCE, and TIMES, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-DIFFERENCE
(DISABLE TIMES-DIFFERENCE)
[ 0.0 0.0 0.0 ]
TIMES-DIFFERENCE-OFF
(DEFN DIVIDES
(X Y)
(ZEROP (REMAINDER Y X))
NIL)
Note that (OR (FALSEP (DIVIDES X Y)) (TRUEP (DIVIDES X Y))) is a theorem.
[ 0.0 0.0 0.0 ]
DIVIDES
(PROVE-LEMMA DIVIDES-TIMES
(REWRITE)
(EQUAL (REMAINDER (TIMES X Z) Z) '0)
((ENABLE COMMUTATIVITY-OF-TIMES EQUAL-TIMES-0 REMAINDER-WRT-12
DIFFERENCE-PLUS1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Z))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Z))
(p X Z))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT X) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme produces the following two new goals:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (REMAINDER (TIMES X Z) Z) 0)).
This simplifies, expanding ZEROP, EQUAL, TIMES, LESSP, NUMBERP, and
REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (REMAINDER (TIMES (SUB1 X) Z) Z)
0))
(EQUAL (REMAINDER (TIMES X Z) Z) 0)).
This simplifies, rewriting with DIFFERENCE-PLUS1, and unfolding the
definitions of ZEROP, TIMES, and REMAINDER, to three new goals:
Case 1.3.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (REMAINDER (TIMES (SUB1 X) Z) Z)
0)
(NOT (NUMBERP Z)))
(EQUAL (PLUS Z (TIMES (SUB1 X) Z))
0)),
which again simplifies, applying REMAINDER-WRT-12 and EQUAL-TIMES-0, and
unfolding the function PLUS, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (REMAINDER (TIMES (SUB1 X) Z) Z)
0)
(EQUAL Z 0))
(EQUAL (PLUS Z (TIMES (SUB1 X) Z))
0)).
However this again simplifies, applying COMMUTATIVITY-OF-TIMES, and
unfolding the functions EQUAL, TIMES, REMAINDER, and PLUS, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (REMAINDER (TIMES (SUB1 X) Z) Z)
0)
(LESSP (PLUS Z (TIMES (SUB1 X) Z)) Z))
(EQUAL (PLUS Z (TIMES (SUB1 X) Z))
0)).
However this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DIVIDES-TIMES
(DISABLE DIVIDES-TIMES)
[ 0.0 0.0 0.0 ]
DIVIDES-TIMES-OFF
(PROVE-LEMMA DIFFERENCE-PLUS3
(REWRITE)
(EQUAL (DIFFERENCE (PLUS B (PLUS A C)) A)
(PLUS B C))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
(IMPLIES (LESSP (PLUS B A C) A)
(EQUAL (DIFFERENCE (PLUS B A C) A)
(PLUS B C))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS3
(DISABLE DIFFERENCE-PLUS3)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS3-OFF
(PROVE-LEMMA DIFFERENCE-ADD1-CANCELLATION
(REWRITE)
(EQUAL (DIFFERENCE (ADD1 (PLUS Y Z)) Z)
(ADD1 Y))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to:
(IMPLIES (LESSP (ADD1 (PLUS Y Z)) Z)
(EQUAL (DIFFERENCE (ADD1 (PLUS Y Z)) Z)
(ADD1 Y))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-CANCELLATION
(DISABLE DIFFERENCE-ADD1-CANCELLATION)
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-CANCELLATION-OFF
(PROVE-LEMMA REMAINDER-ADD1
(REWRITE)
(IMPLIES (AND (NOT (ZEROP Y))
(NOT (EQUAL Y '1)))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES X Y)) Y)
'0)))
((ENABLE COMMUTATIVITY-OF-PLUS DIFFERENCE-0
COMMUTATIVITY-OF-TIMES DIFFERENCE-ADD1-CANCELLATION)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES X Y)) Y)
0))).
Name the above subgoal *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme leads
to the following two new formulas:
Case 2. (IMPLIES (AND (ZEROP X)
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES X Y)) Y)
0))).
This simplifies, using linear arithmetic, applying the lemma DIFFERENCE-0,
and opening up the definitions of ZEROP, EQUAL, TIMES, ADD1, NUMBERP,
REMAINDER, and LESSP, to the following two new goals:
Case 2.2.
(IMPLIES (AND (EQUAL X 0)
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(LESSP 1 Y)).
This again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(LESSP 1 Y)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES (SUB1 X) Y))
Y)
0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES X Y)) Y)
0))),
which simplifies, expanding the functions ZEROP and TIMES, to:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL (REMAINDER (ADD1 (TIMES (SUB1 X) Y))
Y)
0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (PLUS Y (TIMES (SUB1 X) Y)))
Y)
0))).
But this further simplifies, rewriting with the lemma COMMUTATIVITY-OF-TIMES,
to:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL (REMAINDER (ADD1 (TIMES Y (SUB1 X)))
Y)
0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (PLUS Y (TIMES Y (SUB1 X))))
Y)
0))).
Appealing to the lemma SUB1-ELIM, we now replace X by (ADD1 Z) to eliminate
(SUB1 X). We employ the type restriction lemma noted when SUB1 was
introduced to constrain the new variable. We must thus prove the conjecture:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0))
(NOT (EQUAL (REMAINDER (ADD1 (TIMES Y Z)) Y)
0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (PLUS Y (TIMES Y Z)))
Y)
0))).
This further simplifies, trivially, to the new goal:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (REMAINDER (ADD1 (TIMES Y Z)) Y)
0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (PLUS Y (TIMES Y Z)))
Y)
0))),
which we generalize by replacing (TIMES Y Z) by A. We restrict the new
variable by recalling the type restriction lemma noted when TIMES was
introduced. We would thus like to prove:
(IMPLIES (AND (NUMBERP A)
(NUMBERP Z)
(NOT (EQUAL (REMAINDER (ADD1 A) Y) 0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1)))
(NOT (EQUAL (REMAINDER (ADD1 (PLUS Y A)) Y)
0))),
which further simplifies, appealing to the lemmas COMMUTATIVITY-OF-PLUS,
DIFFERENCE-ADD1-CANCELLATION, and SUB1-ADD1, and unfolding LESSP and
REMAINDER, to:
(IMPLIES (AND (NUMBERP A)
(NUMBERP Z)
(NOT (EQUAL (REMAINDER (ADD1 A) Y) 0))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL Y 1))
(LESSP (PLUS A Y) (SUB1 Y)))
(NOT (EQUAL (ADD1 (PLUS A Y)) 0))).
This finally simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
REMAINDER-ADD1
(DISABLE REMAINDER-ADD1)
[ 0.0 0.0 0.0 ]
REMAINDER-ADD1-OFF
(PROVE-LEMMA DIVIDES-PLUS-REWRITE1
(REWRITE)
(IMPLIES (AND (EQUAL (REMAINDER X Z) '0)
(EQUAL (REMAINDER Y Z) '0))
(EQUAL (REMAINDER (PLUS X Y) Z) '0))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY2-OF-PLUS
COMMUTATIVITY-OF-PLUS ASSOCIATIVITY-OF-PLUS
COMMUTATIVITY-OF-TIMES DIFFERENCE-ELIM REMAINDER-WRT-12
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM DIVIDES-TIMES
DIFFERENCE-PLUS3)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace X by (PLUS V (TIMES Z W))
to eliminate (REMAINDER X Z) and (QUOTIENT X Z). We employ LESSP-REMAINDER2,
the type restriction lemma noted when REMAINDER was introduced, and the type
restriction lemma noted when QUOTIENT was introduced to restrict the new
variables. We would thus like to prove the following four new conjectures:
Case 4. (IMPLIES (AND (NOT (NUMBERP X))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)).
However this simplifies, expanding LESSP, REMAINDER, EQUAL, and PLUS, to the
conjecture:
(IMPLIES (AND (NOT (NUMBERP X))
(EQUAL (REMAINDER Y Z) 0)
(NOT (NUMBERP Y)))
(EQUAL (REMAINDER 0 Z) 0)).
But this again simplifies, expanding the definitions of LESSP, REMAINDER,
EQUAL, and NUMBERP, to:
T.
Case 3. (IMPLIES (AND (EQUAL Z 0)
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)),
which simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS, and
expanding the definitions of EQUAL, REMAINDER, PLUS, and NUMBERP, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP Z))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)).
But this simplifies, applying REMAINDER-WRT-12, PLUS-RIGHT-ID2, and
COMMUTATIVITY-OF-PLUS, and opening up the definitions of PLUS, NUMBERP, and
EQUAL, to:
T.
Case 1. (IMPLIES (AND (NUMBERP V)
(EQUAL (LESSP V Z) (NOT (ZEROP Z)))
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(EQUAL V 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS (PLUS V (TIMES Z W)) Y)
Z)
0)).
However this simplifies, applying COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and unfolding the functions NUMBERP, EQUAL, LESSP,
ZEROP, NOT, and PLUS, to the new formula:
(IMPLIES (AND (NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS Y (TIMES W Z)) Z)
0)).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace Y by
(PLUS V (TIMES Z D)) to eliminate (REMAINDER Y Z) and (QUOTIENT Y Z). We
rely upon LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER
was introduced, and the type restriction lemma noted when QUOTIENT was
introduced to restrict the new variables. This produces the following two
new formulas:
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP Y))
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS Y (TIMES W Z)) Z)
0)).
However this further simplifies, rewriting with DIVIDES-TIMES, and opening
up LESSP, REMAINDER, EQUAL, and PLUS, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP V)
(EQUAL (LESSP V Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(EQUAL V 0))
(EQUAL (REMAINDER (PLUS (PLUS V (TIMES Z D))
(TIMES W Z))
Z)
0)).
However this further simplifies, applying COMMUTATIVITY-OF-TIMES, and
opening up NUMBERP, EQUAL, LESSP, ZEROP, NOT, and PLUS, to:
(IMPLIES (AND (NUMBERP D)
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0)))
(EQUAL (REMAINDER (PLUS (TIMES D Z) (TIMES W Z))
Z)
0)),
which we would normally push and work on later by induction. But if we
must use induction to prove the input conjecture, we prefer to induct on
the original formulation of the problem. Thus we will disregard all that
we have previously done, give the name *1 to the original input, and work
on it.
So now let us return to:
(IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)).
We named this *1. We will try to prove it by induction. There are three
plausible inductions, two of which are unflawed. So we will choose the one
suggested by the largest number of nonprimitive recursive functions. We will
induct according to the following scheme:
(AND (IMPLIES (ZEROP Z) (p X Y Z))
(IMPLIES (AND (NOT (ZEROP Z)) (LESSP X Z))
(p X Y Z))
(IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(p (DIFFERENCE X Z) Y Z))
(p X Y Z))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT X) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme produces four new goals:
Case 4. (IMPLIES (AND (ZEROP Z)
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)),
which simplifies, rewriting with the lemmas PLUS-RIGHT-ID2,
COMMUTATIVITY-OF-PLUS, and REMAINDER-WRT-12, and expanding ZEROP, EQUAL,
REMAINDER, PLUS, and NUMBERP, to:
T.
Case 3. (IMPLIES (AND (NOT (ZEROP Z))
(LESSP X Z)
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)),
which simplifies, unfolding ZEROP, REMAINDER, EQUAL, and PLUS, to two new
conjectures:
Case 3.2.
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP X Z)
(EQUAL X 0)
(EQUAL (REMAINDER Y Z) 0)
(NOT (NUMBERP Y)))
(EQUAL (REMAINDER 0 Z) 0)),
which again simplifies, unfolding EQUAL, LESSP, REMAINDER, and NUMBERP, to:
T.
Case 3.1.
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP X Z)
(NOT (NUMBERP X))
(EQUAL (REMAINDER Y Z) 0)
(NOT (NUMBERP Y)))
(EQUAL (REMAINDER 0 Z) 0)),
which again simplifies, unfolding the functions LESSP, REMAINDER, EQUAL,
and NUMBERP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(NOT (EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)),
which simplifies, unfolding the definitions of ZEROP and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(EQUAL (REMAINDER (PLUS (DIFFERENCE X Z) Y)
Z)
0)
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)),
which simplifies, rewriting with COMMUTATIVITY-OF-PLUS, and opening up ZEROP
and REMAINDER, to:
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP X Z))
(EQUAL (REMAINDER (PLUS Y (DIFFERENCE X Z))
Z)
0)
(EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)).
Applying the lemmas DIFFERENCE-ELIM and REMAINDER-QUOTIENT-ELIM, replace X
by (PLUS Z V) to eliminate (DIFFERENCE X Z) and V by (PLUS W (TIMES Z D)) to
eliminate (REMAINDER V Z) and (QUOTIENT V Z). We use the type restriction
lemma noted when DIFFERENCE was introduced, LESSP-REMAINDER2, the type
restriction lemma noted when REMAINDER was introduced, and the type
restriction lemma noted when QUOTIENT was introduced to restrict the new
variables. This produces the following two new conjectures:
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP X Z))
(EQUAL (REMAINDER (PLUS Y (DIFFERENCE X Z))
Z)
0)
(EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS X Y) Z) 0)).
This further simplifies, unfolding the function LESSP, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP W)
(EQUAL (LESSP W Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP (PLUS Z W (TIMES Z D)) Z))
(EQUAL (REMAINDER (PLUS Y W (TIMES Z D)) Z)
0)
(EQUAL W 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (REMAINDER (PLUS (PLUS Z W (TIMES Z D)) Y)
Z)
0)),
which further simplifies, rewriting with the lemmas COMMUTATIVITY-OF-TIMES,
COMMUTATIVITY-OF-PLUS, COMMUTATIVITY2-OF-PLUS, ASSOCIATIVITY-OF-PLUS, and
DIFFERENCE-PLUS3, and unfolding the functions NUMBERP, EQUAL, LESSP, ZEROP,
NOT, PLUS, and REMAINDER, to:
(IMPLIES (AND (NUMBERP D)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP (PLUS Z (TIMES D Z)) Z))
(EQUAL (REMAINDER (PLUS Y (TIMES D Z)) Z)
0)
(EQUAL (REMAINDER Y Z) 0)
(LESSP (PLUS Y Z (TIMES D Z)) Z))
(EQUAL (PLUS Y Z (TIMES D Z)) 0)).
However this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
DIVIDES-PLUS-REWRITE1
(DISABLE DIVIDES-PLUS-REWRITE1)
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE1-OFF
(PROVE-LEMMA DIVIDES-PLUS-REWRITE2
(REWRITE)
(IMPLIES (AND (EQUAL (REMAINDER X Z) '0)
(NOT (EQUAL (REMAINDER Y Z) '0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) '0)))
((ENABLE COMMUTATIVITY2-OF-PLUS COMMUTATIVITY-OF-PLUS
ASSOCIATIVITY-OF-PLUS COMMUTATIVITY-OF-TIMES
DIFFERENCE-ELIM REMAINDER-WRT-12 LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM DIFFERENCE-PLUS3)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace X by (PLUS V (TIMES Z W))
to eliminate (REMAINDER X Z) and (QUOTIENT X Z). We use LESSP-REMAINDER2, the
type restriction lemma noted when REMAINDER was introduced, and the type
restriction lemma noted when QUOTIENT was introduced to restrict the new
variables. We would thus like to prove the following four new formulas:
Case 4. (IMPLIES (AND (NOT (NUMBERP X))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))).
But this simplifies, unfolding the definitions of LESSP, REMAINDER, EQUAL,
and PLUS, to:
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL (REMAINDER Y Z) 0))
(NOT (NUMBERP Y)))
(NOT (EQUAL (REMAINDER 0 Z) 0))).
This again simplifies, expanding the functions LESSP, REMAINDER, and EQUAL,
to:
T.
Case 3. (IMPLIES (AND (EQUAL Z 0)
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, expanding the functions EQUAL, REMAINDER, and PLUS, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP Z))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, rewriting with REMAINDER-WRT-12, and expanding EQUAL and
PLUS, to:
T.
Case 1. (IMPLIES (AND (NUMBERP V)
(EQUAL (LESSP V Z) (NOT (ZEROP Z)))
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(EQUAL V 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS (PLUS V (TIMES Z W)) Y)
Z)
0))).
This simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and expanding the functions NUMBERP, EQUAL, LESSP,
ZEROP, NOT, and PLUS, to:
(IMPLIES (AND (NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS Y (TIMES W Z)) Z)
0))).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace Y by
(PLUS V (TIMES Z D)) to eliminate (REMAINDER Y Z) and (QUOTIENT Y Z). We
rely upon LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER
was introduced, and the type restriction lemma noted when QUOTIENT was
introduced to restrict the new variables. We thus obtain the following two
new conjectures:
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP Y))
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS Y (TIMES W Z)) Z)
0))).
This further simplifies, unfolding the definitions of LESSP, REMAINDER,
and EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP V)
(EQUAL (LESSP V Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL V 0)))
(NOT (EQUAL (REMAINDER (PLUS (PLUS V (TIMES Z D))
(TIMES W Z))
Z)
0))),
which further simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
ASSOCIATIVITY-OF-PLUS, and opening up ZEROP and NOT, to:
(IMPLIES (AND (NUMBERP V)
(LESSP V Z)
(NUMBERP D)
(NUMBERP W)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL V 0)))
(NOT (EQUAL (REMAINDER (PLUS V (TIMES D Z) (TIMES W Z))
Z)
0))),
which we would normally push and work on later by induction. But if we
must use induction to prove the input conjecture, we prefer to induct on
the original formulation of the problem. Thus we will disregard all that
we have previously done, give the name *1 to the original input, and work
on it.
So now let us return to:
(IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))).
We named this *1. We will try to prove it by induction. Three inductions are
suggested by terms in the conjecture, two of which are unflawed. So we will
choose the one suggested by the largest number of nonprimitive recursive
functions. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP Z) (p X Y Z))
(IMPLIES (AND (NOT (ZEROP Z)) (LESSP X Z))
(p X Y Z))
(IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(p (DIFFERENCE X Z) Y Z))
(p X Y Z))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT X) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme generates four new formulas:
Case 4. (IMPLIES (AND (ZEROP Z)
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, rewriting with the lemma REMAINDER-WRT-12, and unfolding
the definitions of ZEROP, EQUAL, REMAINDER, and PLUS, to:
T.
Case 3. (IMPLIES (AND (NOT (ZEROP Z))
(LESSP X Z)
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, expanding the functions ZEROP, REMAINDER, EQUAL, and PLUS,
to two new goals:
Case 3.2.
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP X Z)
(EQUAL X 0)
(NOT (EQUAL (REMAINDER Y Z) 0))
(NOT (NUMBERP Y)))
(NOT (EQUAL (REMAINDER 0 Z) 0))),
which again simplifies, opening up EQUAL, LESSP, and REMAINDER, to:
T.
Case 3.1.
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP X Z)
(NOT (NUMBERP X))
(NOT (EQUAL (REMAINDER Y Z) 0))
(NOT (NUMBERP Y)))
(NOT (EQUAL (REMAINDER 0 Z) 0))),
which again simplifies, expanding the functions LESSP, REMAINDER, and
EQUAL, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(NOT (EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, unfolding the functions ZEROP and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Z))
(NOT (LESSP X Z))
(NOT (EQUAL (REMAINDER (PLUS (DIFFERENCE X Z) Y)
Z)
0))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which simplifies, rewriting with the lemma COMMUTATIVITY-OF-PLUS, and
opening up the definitions of ZEROP and REMAINDER, to the goal:
(IMPLIES (AND (NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP X Z))
(NOT (EQUAL (REMAINDER (PLUS Y (DIFFERENCE X Z))
Z)
0))
(EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))).
Appealing to the lemmas DIFFERENCE-ELIM and REMAINDER-QUOTIENT-ELIM, we now
replace X by (PLUS Z V) to eliminate (DIFFERENCE X Z) and V by
(PLUS W (TIMES Z D)) to eliminate (REMAINDER V Z) and (QUOTIENT V Z). We
use the type restriction lemma noted when DIFFERENCE was introduced,
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was
introduced to constrain the new variables. We must thus prove two new
formulas:
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP X Z))
(NOT (EQUAL (REMAINDER (PLUS Y (DIFFERENCE X Z))
Z)
0))
(EQUAL (REMAINDER (DIFFERENCE X Z) Z)
0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which further simplifies, opening up LESSP, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP W)
(EQUAL (LESSP W Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP (PLUS Z W (TIMES Z D)) Z))
(NOT (EQUAL (REMAINDER (PLUS Y W (TIMES Z D)) Z)
0))
(EQUAL W 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS (PLUS Z W (TIMES Z D)) Y)
Z)
0))),
which further simplifies, applying COMMUTATIVITY-OF-TIMES,
COMMUTATIVITY-OF-PLUS, COMMUTATIVITY2-OF-PLUS, ASSOCIATIVITY-OF-PLUS, and
DIFFERENCE-PLUS3, and unfolding the definitions of NUMBERP, EQUAL, LESSP,
ZEROP, NOT, PLUS, and REMAINDER, to:
(IMPLIES (AND (NUMBERP D)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (LESSP (PLUS Z (TIMES D Z)) Z))
(NOT (EQUAL (REMAINDER (PLUS Y (TIMES D Z)) Z)
0))
(NOT (EQUAL (REMAINDER Y Z) 0))
(LESSP (PLUS Y Z (TIMES D Z)) Z))
(NOT (EQUAL (PLUS Y Z (TIMES D Z)) 0))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
DIVIDES-PLUS-REWRITE2
(DISABLE DIVIDES-PLUS-REWRITE2)
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE2-OFF
(PROVE-LEMMA DIVIDES-PLUS-REWRITE
(REWRITE)
(IMPLIES (EQUAL (REMAINDER X Z) '0)
(EQUAL (EQUAL (REMAINDER (PLUS X Y) Z) '0)
(EQUAL (REMAINDER Y Z) '0)))
((ENABLE DIVIDES-PLUS-REWRITE1 DIVIDES-PLUS-REWRITE2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, clearly, to two new conjectures:
Case 2. (IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER Y Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X Y) Z) 0))),
which again simplifies, applying DIVIDES-PLUS-REWRITE2, to:
T.
Case 1. (IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER Y Z) 0))
(EQUAL (EQUAL (REMAINDER (PLUS X Y) Z) 0)
T)).
However this again simplifies, applying DIVIDES-PLUS-REWRITE1, and unfolding
the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE
(DISABLE DIVIDES-PLUS-REWRITE)
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE-OFF
(PROVE-LEMMA LESSP-PLUS-CANCELATION
(REWRITE)
(EQUAL (LESSP (PLUS X Y) (PLUS X Z))
(LESSP Y Z))
((ENABLE EQUAL-LESSP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with EQUAL-LESSP, to two new formulas:
Case 2. (IMPLIES (NOT (LESSP (PLUS X Y) (PLUS X Z)))
(NOT (LESSP Y Z))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (LESSP (PLUS X Y) (PLUS X Z))
(LESSP Y Z)),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-PLUS-CANCELATION
(DISABLE LESSP-PLUS-CANCELATION)
[ 0.0 0.0 0.0 ]
LESSP-PLUS-CANCELATION-OFF
(PROVE-LEMMA DIVIDES-PLUS-REWRITE-COMMUTED
(REWRITE)
(IMPLIES (EQUAL (REMAINDER X Z) '0)
(EQUAL (EQUAL (REMAINDER (PLUS Y X) Z) '0)
(EQUAL (REMAINDER Y Z) '0)))
((ENABLE COMMUTATIVITY-OF-PLUS DIVIDES-PLUS-REWRITE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying COMMUTATIVITY-OF-PLUS and
DIVIDES-PLUS-REWRITE, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE-COMMUTED
(DISABLE DIVIDES-PLUS-REWRITE-COMMUTED)
[ 0.0 0.0 0.0 ]
DIVIDES-PLUS-REWRITE-COMMUTED-OFF
(PROVE-LEMMA EUCLID
(REWRITE)
(IMPLIES (EQUAL (REMAINDER X Z) '0)
(EQUAL (EQUAL (REMAINDER (DIFFERENCE Y X) Z)
'0)
(IF (LESSP X Y)
(EQUAL (REMAINDER Y Z) '0)
'*1*TRUE)))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY2-OF-PLUS
COMMUTATIVITY-OF-PLUS DIFFERENCE-0
COMMUTATIVITY-OF-TIMES DIFFERENCE-ELIM REMAINDER-WRT-12
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM DIVIDES-TIMES
DIVIDES-PLUS-REWRITE1 DIVIDES-PLUS-REWRITE-COMMUTED)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, obviously, to the following three new conjectures:
Case 3. (IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)))
(LESSP X Y)).
This again simplifies, applying DIFFERENCE-0, and expanding LESSP, EQUAL,
NUMBERP, and REMAINDER, to:
T.
Case 2. (IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)))
(NOT (EQUAL (REMAINDER Y Z) 0))).
Appealing to the lemmas DIFFERENCE-ELIM and REMAINDER-QUOTIENT-ELIM, we now
replace Y by (PLUS X V) to eliminate (DIFFERENCE Y X) and V by
(PLUS W (TIMES Z D)) to eliminate (REMAINDER V Z) and (QUOTIENT V Z). We
rely upon the type restriction lemma noted when DIFFERENCE was introduced,
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was
introduced to constrain the new variables. We must thus prove five new
goals:
Case 2.5.
(IMPLIES (AND (LESSP Y X)
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)))
(NOT (EQUAL (REMAINDER Y Z) 0))),
which further simplifies, using linear arithmetic, rewriting with
DIFFERENCE-0, and expanding the definitions of LESSP, EQUAL, NUMBERP, and
REMAINDER, to:
T.
Case 2.4.
(IMPLIES (AND (NOT (NUMBERP Y))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)))
(NOT (EQUAL (REMAINDER Y Z) 0))).
However this further simplifies, using linear arithmetic, rewriting with
the lemma DIFFERENCE-0, and unfolding LESSP, EQUAL, NUMBERP, and REMAINDER,
to:
T.
Case 2.3.
(IMPLIES (AND (EQUAL Z 0)
(NUMBERP V)
(NOT (LESSP (PLUS X V) X))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER V Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X V) Z) 0))),
which further simplifies, rewriting with COMMUTATIVITY-OF-PLUS and
PLUS-RIGHT-ID2, and opening up the functions EQUAL, REMAINDER, and PLUS,
to:
T.
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP Z))
(NUMBERP V)
(NOT (LESSP (PLUS X V) X))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL (REMAINDER V Z) 0)))
(NOT (EQUAL (REMAINDER (PLUS X V) Z) 0))).
But this further simplifies, rewriting with COMMUTATIVITY-OF-PLUS,
REMAINDER-WRT-12, and PLUS-RIGHT-ID2, and expanding the functions EQUAL
and PLUS, to:
T.
Case 2.1.
(IMPLIES (AND (NUMBERP W)
(EQUAL (LESSP W Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (LESSP (PLUS X W (TIMES Z D)) X))
(EQUAL (REMAINDER X Z) 0)
(NOT (EQUAL W 0)))
(NOT (EQUAL (REMAINDER (PLUS X W (TIMES Z D)) Z)
0))).
But this further simplifies, applying the lemmas COMMUTATIVITY-OF-TIMES,
COMMUTATIVITY2-OF-PLUS, DIVIDES-PLUS-REWRITE1, DIVIDES-TIMES, and
DIVIDES-PLUS-REWRITE-COMMUTED, and expanding the functions ZEROP, NOT,
EQUAL, and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)
(LESSP X Y))
(EQUAL (EQUAL (REMAINDER Y Z) 0) T)),
which again simplifies, trivially, to the new formula:
(IMPLIES (AND (EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)
(LESSP X Y))
(EQUAL (REMAINDER Y Z) 0)).
Applying the lemmas DIFFERENCE-ELIM and REMAINDER-QUOTIENT-ELIM, replace Y
by (PLUS X V) to eliminate (DIFFERENCE Y X) and V by (PLUS W (TIMES Z D)) to
eliminate (REMAINDER V Z) and (QUOTIENT V Z). We use the type restriction
lemma noted when DIFFERENCE was introduced, LESSP-REMAINDER2, the type
restriction lemma noted when REMAINDER was introduced, and the type
restriction lemma noted when QUOTIENT was introduced to restrict the new
variables. We would thus like to prove the following five new goals:
Case 1.5.
(IMPLIES (AND (LESSP Y X)
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)
(LESSP X Y))
(EQUAL (REMAINDER Y Z) 0)).
But this further simplifies, using linear arithmetic, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (NUMBERP Y))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER (DIFFERENCE Y X) Z)
0)
(LESSP X Y))
(EQUAL (REMAINDER Y Z) 0)),
which further simplifies, expanding DIFFERENCE, LESSP, EQUAL, NUMBERP, and
REMAINDER, to:
T.
Case 1.3.
(IMPLIES (AND (EQUAL Z 0)
(NUMBERP V)
(NOT (LESSP (PLUS X V) X))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER V Z) 0)
(LESSP X (PLUS X V)))
(EQUAL (REMAINDER (PLUS X V) Z) 0)),
which further simplifies, applying the lemmas COMMUTATIVITY-OF-PLUS and
PLUS-RIGHT-ID2, and opening up the functions EQUAL, REMAINDER, PLUS, LESSP,
and NUMBERP, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP Z))
(NUMBERP V)
(NOT (LESSP (PLUS X V) X))
(EQUAL (REMAINDER X Z) 0)
(EQUAL (REMAINDER V Z) 0)
(LESSP X (PLUS X V)))
(EQUAL (REMAINDER (PLUS X V) Z) 0)),
which further simplifies, applying the lemmas COMMUTATIVITY-OF-PLUS,
REMAINDER-WRT-12, and PLUS-RIGHT-ID2, and opening up PLUS, LESSP, NUMBERP,
and EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP W)
(EQUAL (LESSP W Z) (NOT (ZEROP Z)))
(NUMBERP D)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (LESSP (PLUS X W (TIMES Z D)) X))
(EQUAL (REMAINDER X Z) 0)
(EQUAL W 0)
(LESSP X (PLUS X W (TIMES Z D))))
(EQUAL (REMAINDER (PLUS X W (TIMES Z D)) Z)
0)),
which further simplifies, applying the lemmas COMMUTATIVITY-OF-TIMES,
DIVIDES-TIMES, and DIVIDES-PLUS-REWRITE1, and opening up NUMBERP, EQUAL,
LESSP, ZEROP, NOT, and PLUS, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EUCLID
(DISABLE EUCLID)
[ 0.0 0.0 0.0 ]
EUCLID-OFF
(PROVE-LEMMA LESSP-TIMES-CANCELLATION
(REWRITE)
(EQUAL (LESSP (TIMES X Z) (TIMES Y Z))
(AND (NOT (ZEROP Z)) (LESSP X Y)))
((ENABLE TIMES-ZERO2 COMMUTATIVITY-OF-TIMES EQUAL-TIMES-0
EQUAL-LESSP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, rewriting with EQUAL-LESSP, and expanding the
definitions of ZEROP, NOT, and AND, to the following four new goals:
Case 4. (IMPLIES (AND (NOT (LESSP (TIMES X Z) (TIMES Y Z)))
(NOT (EQUAL Z 0))
(NUMBERP Z))
(NOT (LESSP X Y))).
Call the above conjecture *1.
Case 3. (IMPLIES (LESSP (TIMES X Z) (TIMES Y Z))
(LESSP X Y)),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (LESSP (TIMES X Z) (TIMES Y Z))
(AND (NOT (ZEROP Z)) (LESSP X Y))).
We gave this the name *1 above. Perhaps we can prove it by induction. The
recursive terms in the conjecture suggest four inductions. However, they
merge into one likely candidate induction. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP X) (p X Z Y))
(IMPLIES (AND (NOT (ZEROP X))
(p (SUB1 X) Z (SUB1 Y)))
(p X Z Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to show that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for Y. The above induction scheme
produces two new conjectures:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (LESSP (TIMES X Z) (TIMES Y Z))
(AND (NOT (ZEROP Z)) (LESSP X Y)))),
which simplifies, expanding ZEROP, EQUAL, TIMES, LESSP, NOT, and AND, to ten
new conjectures:
Case 2.10.
(IMPLIES (AND (EQUAL X 0)
(EQUAL Z 0)
(NOT (EQUAL Y 0))
(NUMBERP Y))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)),
which again simplifies, rewriting with COMMUTATIVITY-OF-TIMES, and
expanding the functions EQUAL, TIMES, and PLUS, to:
T.
Case 2.9.
(IMPLIES (AND (EQUAL X 0)
(NOT (NUMBERP Z))
(NOT (EQUAL Y 0))
(NUMBERP Y))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)).
This again simplifies, applying EQUAL-TIMES-0, and opening up the
definition of PLUS, to:
T.
Case 2.8.
(IMPLIES (AND (EQUAL X 0)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (EQUAL Y 0))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z)) 0))
(EQUAL F (NUMBERP Y))).
But this again simplifies, using linear arithmetic, to:
T.
Case 2.7.
(IMPLIES (AND (EQUAL X 0)
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (EQUAL Y 0))
(NOT (NUMBERP Y)))
(EQUAL F (NUMBERP Y))),
which again simplifies, trivially, to:
T.
Case 2.6.
(IMPLIES (AND (EQUAL X 0)
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)))
(EQUAL T (NUMBERP Y))).
This again simplifies, obviously, to:
T.
Case 2.5.
(IMPLIES (AND (NOT (NUMBERP X))
(EQUAL Z 0)
(NOT (EQUAL Y 0))
(NUMBERP Y))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)).
However this again simplifies, rewriting with COMMUTATIVITY-OF-TIMES, and
expanding EQUAL, TIMES, and PLUS, to:
T.
Case 2.4.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (NUMBERP Z))
(NOT (EQUAL Y 0))
(NUMBERP Y))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)).
However this again simplifies, applying the lemma EQUAL-TIMES-0, and
expanding PLUS, to:
T.
Case 2.3.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (EQUAL Y 0))
(EQUAL (PLUS Z (TIMES (SUB1 Y) Z)) 0))
(EQUAL F (NUMBERP Y))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(NOT (EQUAL Y 0))
(NOT (NUMBERP Y)))
(EQUAL F (NUMBERP Y))),
which again simplifies, clearly, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL (PLUS Z (TIMES (SUB1 Y) Z))
0)))
(EQUAL T (NUMBERP Y))).
This again simplifies, clearly, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z))
(AND (NOT (ZEROP Z))
(LESSP (SUB1 X) (SUB1 Y)))))
(EQUAL (LESSP (TIMES X Z) (TIMES Y Z))
(AND (NOT (ZEROP Z)) (LESSP X Y)))).
This simplifies, applying EQUAL-LESSP, TIMES-ZERO2, and
COMMUTATIVITY-OF-TIMES, and unfolding the definitions of ZEROP, NOT, AND,
TIMES, LESSP, and EQUAL, to six new goals:
Case 1.6.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z)))
(NOT (LESSP (SUB1 X) (SUB1 Y)))
(NOT (EQUAL Y 0))
(NUMBERP Y))
(NOT (LESSP (PLUS Z (TIMES (SUB1 X) Z))
(PLUS Z (TIMES (SUB1 Y) Z))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z)))
(NOT (LESSP (SUB1 X) (SUB1 Y)))
(EQUAL Y 0))
(NOT (LESSP (PLUS Z (TIMES (SUB1 X) Z))
0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z)))
(NOT (LESSP (SUB1 X) (SUB1 Y)))
(NOT (NUMBERP Y)))
(NOT (LESSP (PLUS Z (TIMES (SUB1 X) Z))
0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP (SUB1 X) (SUB1 Y))
(NOT (NUMBERP Y)))
(NOT (LESSP (PLUS Z (TIMES (SUB1 X) Z))
0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP (SUB1 X) (SUB1 Y))
(EQUAL Y 0))
(NOT (LESSP (PLUS Z (TIMES (SUB1 X) Z))
0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(LESSP (TIMES (SUB1 X) Z)
(TIMES (SUB1 Y) Z))
(NOT (EQUAL Z 0))
(NUMBERP Z)
(LESSP (SUB1 X) (SUB1 Y))
(NOT (EQUAL Y 0))
(NUMBERP Y))
(LESSP (PLUS Z (TIMES (SUB1 X) Z))
(PLUS Z (TIMES (SUB1 Y) Z)))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
LESSP-TIMES-CANCELLATION
(DISABLE LESSP-TIMES-CANCELLATION)
[ 0.0 0.0 0.0 ]
LESSP-TIMES-CANCELLATION-OFF
(PROVE-LEMMA LESSP-PLUS-CANCELLATION3
(REWRITE)
(EQUAL (LESSP Y (PLUS X Y))
(NOT (ZEROP X)))
((ENABLE EQUAL-LESSP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying EQUAL-LESSP, and unfolding the functions
ZEROP and NOT, to three new goals:
Case 3. (IMPLIES (AND (NOT (LESSP Y (PLUS X Y)))
(NOT (EQUAL X 0)))
(NOT (NUMBERP X))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (LESSP Y (PLUS X Y))
(NUMBERP X)),
which again simplifies, expanding PLUS, to two new conjectures:
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP Y)) (LESSP Y 0))
(NUMBERP X)),
which again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (NUMBERP Y) (LESSP Y Y))
(NUMBERP X)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (LESSP Y (PLUS X Y))
(NOT (EQUAL X 0))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-PLUS-CANCELLATION3
(DISABLE LESSP-PLUS-CANCELLATION3)
[ 0.0 0.0 0.0 ]
LESSP-PLUS-CANCELLATION3-OFF
(PROVE-LEMMA QUOTIENT-TIMES1
(REWRITE)
(IMPLIES (AND (NUMBERP Y)
(AND (NUMBERP X)
(AND (NOT (EQUAL X '0))
(DIVIDES X Y))))
(EQUAL (TIMES X (QUOTIENT Y X)) Y))
((ENABLE LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM DIVIDES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations NOT, AND, IMPLIES, and
DIVIDES, to:
(IMPLIES (AND (NUMBERP Y)
(NUMBERP X)
(NOT (EQUAL X 0))
(EQUAL (REMAINDER Y X) 0))
(EQUAL (TIMES X (QUOTIENT Y X)) Y)).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace Y by (PLUS Z (TIMES X V))
to eliminate (REMAINDER Y X) and (QUOTIENT Y X). We rely upon
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was introduced
to restrict the new variables. We thus obtain:
(IMPLIES (AND (NUMBERP Z)
(EQUAL (LESSP Z X) (NOT (ZEROP X)))
(NUMBERP V)
(NUMBERP X)
(NOT (EQUAL X 0))
(EQUAL Z 0))
(EQUAL (TIMES X V)
(PLUS Z (TIMES X V)))),
which simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES1
(DISABLE QUOTIENT-TIMES1)
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES1-OFF
(PROVE-LEMMA QUOTIENT-LESSP
(REWRITE)
(IMPLIES (AND (NOT (ZEROP X)) (LESSP X Y))
(NOT (EQUAL (QUOTIENT Y X) '0)))
((ENABLE COMMUTATIVITY-OF-PLUS COMMUTATIVITY-OF-TIMES
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(LESSP X Y))
(NOT (EQUAL (QUOTIENT Y X) 0))).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace Y by (PLUS V (TIMES X Z))
to eliminate (QUOTIENT Y X) and (REMAINDER Y X). We rely upon
LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was introduced
to restrict the new variables. We thus obtain the following two new goals:
Case 2. (IMPLIES (AND (NOT (NUMBERP Y))
(NOT (EQUAL X 0))
(NUMBERP X)
(LESSP X Y))
(NOT (EQUAL (QUOTIENT Y X) 0))).
However this simplifies, opening up the definition of LESSP, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NUMBERP V)
(EQUAL (LESSP V X) (NOT (ZEROP X)))
(NOT (EQUAL X 0))
(NUMBERP X)
(LESSP X (PLUS V (TIMES X Z))))
(NOT (EQUAL Z 0))),
which simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and expanding the definitions of NUMBERP, ZEROP, NOT,
EQUAL, TIMES, and PLUS, to:
(IMPLIES (AND (NUMBERP V)
(LESSP V X)
(NOT (EQUAL X 0))
(NUMBERP X))
(NOT (LESSP X V))).
However this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-LESSP
(DISABLE QUOTIENT-LESSP)
[ 0.0 0.0 0.0 ]
QUOTIENT-LESSP-OFF
(PROVE-LEMMA TIMES-ID-IFF-1
(REWRITE)
(EQUAL (EQUAL Z (TIMES W Z))
(AND (NUMBERP Z)
(OR (EQUAL Z '0) (EQUAL W '1))))
((ENABLE COMMUTATIVITY-OF-PLUS TIMES-ZERO2 COMMUTATIVITY-OF-TIMES
LESSP-TIMES-2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding the functions OR and AND, to the
following four new formulas:
Case 4. (IMPLIES (AND (EQUAL Z (TIMES W Z))
(NOT (EQUAL Z 0)))
(EQUAL (EQUAL W 1) T)).
This again simplifies, clearly, to the new conjecture:
(IMPLIES (AND (EQUAL Z (TIMES W Z))
(NOT (EQUAL Z 0)))
(EQUAL W 1)).
We use the above equality hypothesis by substituting (TIMES W Z) for Z and
keeping the equality hypothesis. The result is:
(IMPLIES (AND (EQUAL Z (TIMES W Z))
(NOT (EQUAL (TIMES W Z) 0)))
(EQUAL W 1)).
This further simplifies, obviously, to:
(IMPLIES (AND (EQUAL Z (TIMES W Z))
(NOT (EQUAL Z 0)))
(EQUAL W 1)),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (EQUAL Z (TIMES W Z))
(AND (NUMBERP Z)
(OR (EQUAL Z 0) (EQUAL W 1)))),
named *1. Let us appeal to the induction principle. There is only one
suggested induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP W) (p Z W))
(IMPLIES (AND (NOT (ZEROP W)) (p Z (SUB1 W)))
(p Z W))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT W) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
produces two new goals:
Case 2. (IMPLIES (ZEROP W)
(EQUAL (EQUAL Z (TIMES W Z))
(AND (NUMBERP Z)
(OR (EQUAL Z 0) (EQUAL W 1))))),
which simplifies, expanding the functions ZEROP, EQUAL, TIMES, OR, and AND,
to four new formulas:
Case 2.4.
(IMPLIES (AND (EQUAL W 0) (EQUAL Z 0))
(EQUAL (EQUAL Z 0) T)),
which again simplifies, unfolding EQUAL, to:
T.
Case 2.3.
(IMPLIES (AND (EQUAL W 0) (EQUAL Z 0))
(NUMBERP Z)),
which again simplifies, clearly, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP W)) (EQUAL Z 0))
(EQUAL (EQUAL Z 0) T)).
This again simplifies, opening up EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP W)) (EQUAL Z 0))
(NUMBERP Z)),
which again simplifies, trivially, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP W))
(EQUAL (EQUAL Z (TIMES (SUB1 W) Z))
(AND (NUMBERP Z)
(OR (EQUAL Z 0) (EQUAL (SUB1 W) 1)))))
(EQUAL (EQUAL Z (TIMES W Z))
(AND (NUMBERP Z)
(OR (EQUAL Z 0) (EQUAL W 1))))).
This simplifies, applying TIMES-ZERO2 and COMMUTATIVITY-OF-TIMES, and
expanding ZEROP, OR, AND, TIMES, EQUAL, and NUMBERP, to six new goals:
Case 1.6.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(EQUAL Z (TIMES (SUB1 W) Z))
(NUMBERP Z)
(EQUAL (EQUAL (SUB1 W) 1) T)
(NOT (EQUAL Z (PLUS Z Z))))
(NOT (EQUAL Z 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(EQUAL Z (TIMES (SUB1 W) Z))
(NUMBERP Z)
(EQUAL (EQUAL (SUB1 W) 1) T)
(NOT (EQUAL Z (PLUS Z Z))))
(NOT (EQUAL W 1))),
which again simplifies, opening up the definitions of EQUAL, NUMBERP, SUB1,
and TIMES, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(EQUAL Z (TIMES (SUB1 W) Z))
(NUMBERP Z)
(EQUAL (EQUAL (SUB1 W) 1) T)
(EQUAL Z (PLUS Z Z))
(NOT (EQUAL Z 0)))
(EQUAL (EQUAL W 1) T)),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(NOT (EQUAL Z (TIMES (SUB1 W) Z)))
(NOT (EQUAL Z 0))
(NOT (EQUAL (SUB1 W) 1))
(EQUAL Z (PLUS Z (TIMES (SUB1 W) Z))))
(EQUAL (EQUAL W 1) T)),
which again simplifies, obviously, to the new formula:
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(NOT (EQUAL Z (TIMES (SUB1 W) Z)))
(NOT (EQUAL Z 0))
(NOT (EQUAL (SUB1 W) 1))
(EQUAL Z (PLUS Z (TIMES (SUB1 W) Z))))
(EQUAL W 1)),
which again simplifies, using linear arithmetic and applying LESSP-TIMES-2,
to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(NOT (EQUAL Z (TIMES (SUB1 W) Z)))
(NOT (EQUAL Z 0))
(NOT (EQUAL (SUB1 W) 1))
(NOT (EQUAL Z (PLUS Z (TIMES (SUB1 W) Z))))
(NUMBERP Z))
(NOT (EQUAL W 1))).
However this again simplifies, rewriting with the lemma
COMMUTATIVITY-OF-PLUS, and unfolding EQUAL, NUMBERP, SUB1, TIMES, and PLUS,
to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL W 0))
(NUMBERP W)
(NOT (EQUAL Z (TIMES (SUB1 W) Z)))
(NOT (EQUAL Z 0))
(NOT (EQUAL (SUB1 W) 1))
(EQUAL Z (PLUS Z (TIMES (SUB1 W) Z))))
(NUMBERP Z)),
which again simplifies, clearly, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-ID-IFF-1
(DISABLE TIMES-ID-IFF-1)
[ 0.0 0.0 0.0 ]
TIMES-ID-IFF-1-OFF
(PROVE-LEMMA DIVIDES-TIMES1
(REWRITE)
(IMPLIES (EQUAL A (TIMES Z Y))
(EQUAL (REMAINDER A Z) '0))
((ENABLE COMMUTATIVITY-OF-TIMES DIVIDES-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that DIVIDES-TIMES1 contains the free variable Y which will be
chosen by instantiating the hypothesis (EQUAL A (TIMES Z Y)).
This formula simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES and
DIVIDES-TIMES, and expanding the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIVIDES-TIMES1
(DISABLE DIVIDES-TIMES1)
[ 0.0 0.0 0.0 ]
DIVIDES-TIMES1-OFF
(PROVE-LEMMA TIMES-IDENTITY1
(REWRITE)
(IMPLIES (AND (NUMBERP Y)
(AND (NOT (EQUAL Y '1))
(AND (NOT (EQUAL Y '0))
(NOT (EQUAL X '0)))))
(NOT (EQUAL X (TIMES X Y))))
((ENABLE LESSP-TIMES-2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
We now use the above equality hypothesis by substituting (TIMES X Y) for X and
keeping the equality hypothesis. This generates:
(IMPLIES (AND (NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL (TIMES X Y) 0)))
(NOT (EQUAL X (TIMES X Y)))).
This simplifies, clearly, to:
(IMPLIES (AND (NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0)))
(NOT (EQUAL X (TIMES X Y)))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(IMPLIES (AND (NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0)))
(NOT (EQUAL X (TIMES X Y)))),
named *1. Let us appeal to the induction principle. There is only one
suggested induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates three new conjectures:
Case 3. (IMPLIES (AND (ZEROP X)
(NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0)))
(NOT (EQUAL X (TIMES X Y)))),
which simplifies, unfolding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (SUB1 X) 0)
(NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0)))
(NOT (EQUAL X (TIMES X Y)))),
which simplifies, opening up ZEROP and TIMES, to:
(IMPLIES (AND (EQUAL (SUB1 X) 0)
(NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0))
(NUMBERP X))
(NOT (EQUAL X
(PLUS Y (TIMES (SUB1 X) Y))))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(NOT (EQUAL (SUB1 X) (TIMES (SUB1 X) Y)))
(NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0)))
(NOT (EQUAL X (TIMES X Y)))),
which simplifies, expanding the functions ZEROP and TIMES, to the formula:
(IMPLIES (AND (NOT (EQUAL (SUB1 X) (TIMES (SUB1 X) Y)))
(NUMBERP Y)
(NOT (EQUAL Y 1))
(NOT (EQUAL Y 0))
(NOT (EQUAL X 0))
(NUMBERP X))
(NOT (EQUAL X
(PLUS Y (TIMES (SUB1 X) Y))))).
However this again simplifies, using linear arithmetic and rewriting with
the lemma LESSP-TIMES-2, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-IDENTITY1
(DISABLE TIMES-IDENTITY1)
[ 0.0 0.0 0.0 ]
TIMES-IDENTITY1-OFF
(PROVE-LEMMA TIMES-IDENTITY
(REWRITE)
(EQUAL (EQUAL X (TIMES X Y))
(OR (EQUAL X '0)
(AND (NUMBERP X) (EQUAL Y '1))))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS
COMMUTATIVITY-OF-TIMES LESSP-TIMES-2 TIMES-ID-IFF-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding the functions AND and OR, to the
following four new formulas:
Case 4. (IMPLIES (AND (EQUAL X (TIMES X Y))
(NOT (EQUAL X 0)))
(EQUAL (EQUAL Y 1) T)).
This again simplifies, clearly, to the new conjecture:
(IMPLIES (AND (EQUAL X (TIMES X Y))
(NOT (EQUAL X 0)))
(EQUAL Y 1)).
We use the above equality hypothesis by substituting (TIMES X Y) for X and
keeping the equality hypothesis. The result is:
(IMPLIES (AND (EQUAL X (TIMES X Y))
(NOT (EQUAL (TIMES X Y) 0)))
(EQUAL Y 1)).
This further simplifies, obviously, to:
(IMPLIES (AND (EQUAL X (TIMES X Y))
(NOT (EQUAL X 0)))
(EQUAL Y 1)),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (EQUAL X (TIMES X Y))
(OR (EQUAL X 0)
(AND (NUMBERP X) (EQUAL Y 1)))),
named *1. Let us appeal to the induction principle. There is only one
suggested induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
produces two new goals:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (EQUAL X (TIMES X Y))
(OR (EQUAL X 0)
(AND (NUMBERP X) (EQUAL Y 1))))),
which simplifies, expanding the functions ZEROP, EQUAL, TIMES, NUMBERP, AND,
and OR, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (EQUAL (SUB1 X) (TIMES (SUB1 X) Y))
(OR (EQUAL (SUB1 X) 0)
(AND (NUMBERP (SUB1 X))
(EQUAL Y 1)))))
(EQUAL (EQUAL X (TIMES X Y))
(OR (EQUAL X 0)
(AND (NUMBERP X) (EQUAL Y 1))))),
which simplifies, unfolding ZEROP, AND, OR, and TIMES, to four new formulas:
Case 1.4.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (SUB1 X) (TIMES (SUB1 X) Y))
(EQUAL (EQUAL Y 1) T))
(EQUAL X (PLUS Y (SUB1 X)))),
which again simplifies, applying ADD1-SUB1, and opening up the definitions
of SUB1, NUMBERP, EQUAL, and PLUS, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(NOT (EQUAL (SUB1 X) (TIMES (SUB1 X) Y)))
(NOT (EQUAL (SUB1 X) 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL X
(PLUS Y (TIMES (SUB1 X) Y))))).
This again simplifies, clearly, to:
(IMPLIES (AND (NOT (EQUAL X 0))
(NOT (EQUAL (SUB1 X) (TIMES (SUB1 X) Y)))
(NOT (EQUAL (SUB1 X) 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL X
(PLUS Y (TIMES (SUB1 X) Y))))),
which further simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
TIMES-ID-IFF-1, to:
(IMPLIES (AND (NOT (EQUAL X 0))
(NOT (EQUAL (SUB1 X) 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL X
(PLUS Y (TIMES Y (SUB1 X)))))).
Applying the lemma SUB1-ELIM, replace X by (ADD1 Z) to eliminate (SUB1 X).
We employ the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. This produces the following two new
conjectures:
Case 1.3.2.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (EQUAL X 0))
(NOT (EQUAL (SUB1 X) 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL X
(PLUS Y (TIMES Y (SUB1 X)))))).
This further simplifies, clearly, to:
T.
Case 1.3.1.
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0))
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))).
This further simplifies, obviously, to the new formula:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))),
which we will finally name *1.1.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (SUB1 X) (TIMES (SUB1 X) Y))
(EQUAL (SUB1 X) 0)
(NOT (EQUAL Y 1)))
(NOT (EQUAL X (PLUS Y (SUB1 X))))).
This again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NOT (NUMBERP Y))
(NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL 0 (TIMES 0 Y))
(EQUAL (SUB1 X) 0)
(NOT (EQUAL Y 1)))
(NOT (EQUAL X (PLUS Y 0)))).
But this again simplifies, rewriting with PLUS-RIGHT-ID2 and
COMMUTATIVITY-OF-PLUS, and unfolding the definitions of NUMBERP and EQUAL,
to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (SUB1 X) (TIMES (SUB1 X) Y))
(EQUAL (SUB1 X) 0)
(EQUAL Y 1))
(EQUAL (EQUAL X (PLUS Y (SUB1 X)))
T)).
This again simplifies, unfolding the functions TIMES, EQUAL, and PLUS, to:
(IMPLIES (AND (NOT (EQUAL X 0))
(NUMBERP X)
(EQUAL (SUB1 X) 0))
(EQUAL X 1)).
This again simplifies, using linear arithmetic, to:
T.
So let us turn our attention to:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))),
named *1.1 above. We will try to prove it by induction. The recursive terms
in the conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP Y) (p Z Y))
(IMPLIES (AND (NOT (ZEROP Y)) (p Z (SUB1 Y)))
(p Z Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT Y) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme generates three new formulas:
Case 3. (IMPLIES (AND (ZEROP Y)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))),
which simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS, and
expanding the functions ZEROP, EQUAL, TIMES, PLUS, and NUMBERP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP Y))
(EQUAL (SUB1 Y) 1)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))).
This simplifies, unfolding the functions ZEROP and TIMES, to:
(IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(EQUAL (SUB1 Y) 1)
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y Z (TIMES (SUB1 Y) Z))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP Y))
(NOT (EQUAL (ADD1 Z)
(PLUS (SUB1 Y) (TIMES (SUB1 Y) Z))))
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y (TIMES Y Z))))),
which simplifies, expanding the definitions of ZEROP and TIMES, to:
(IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(NOT (EQUAL (ADD1 Z)
(PLUS (SUB1 Y) (TIMES (SUB1 Y) Z))))
(NUMBERP Z)
(NOT (EQUAL Z 0))
(NOT (EQUAL Y 1)))
(NOT (EQUAL (ADD1 Z)
(PLUS Y Z (TIMES (SUB1 Y) Z))))).
This again simplifies, using linear arithmetic and rewriting with the lemma
LESSP-TIMES-2, to:
T.
That finishes the proof of *1.1, which finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-IDENTITY
(DISABLE TIMES-IDENTITY)
[ 0.0 0.0 0.0 ]
TIMES-IDENTITY-OFF
(PROVE-LEMMA QUOTIENT-DIVIDES
(REWRITE)
(IMPLIES (AND (NUMBERP Y)
(NOT (EQUAL (TIMES X (QUOTIENT Y X)) Y)))
(NOT (EQUAL (REMAINDER Y X) '0)))
((ENABLE TIMES-ZERO2 COMMUTATIVITY-OF-TIMES REMAINDER-WRT-12
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace Y by (PLUS V (TIMES X Z))
to eliminate (QUOTIENT Y X) and (REMAINDER Y X). We rely upon
LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was introduced
to restrict the new variables. This produces the following three new
conjectures:
Case 3. (IMPLIES (AND (EQUAL X 0)
(NUMBERP Y)
(NOT (EQUAL (TIMES X (QUOTIENT Y X)) Y)))
(NOT (EQUAL (REMAINDER Y X) 0))).
But this simplifies, opening up the functions EQUAL, QUOTIENT, TIMES, and
REMAINDER, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP X))
(NUMBERP Y)
(NOT (EQUAL (TIMES X (QUOTIENT Y X)) Y)))
(NOT (EQUAL (REMAINDER Y X) 0))),
which simplifies, rewriting with TIMES-ZERO2, COMMUTATIVITY-OF-TIMES, and
REMAINDER-WRT-12, and opening up the definition of QUOTIENT, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NUMBERP V)
(EQUAL (LESSP V X) (NOT (ZEROP X)))
(NUMBERP X)
(NOT (EQUAL X 0))
(NOT (EQUAL (TIMES X Z)
(PLUS V (TIMES X Z)))))
(NOT (EQUAL V 0))).
But this simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-DIVIDES
(DISABLE QUOTIENT-DIVIDES)
[ 0.0 0.0 0.0 ]
QUOTIENT-DIVIDES-OFF
(PROVE-LEMMA REMAINDER-TIMES
(REWRITE)
(EQUAL (REMAINDER (TIMES Y X) Y) '0)
((ENABLE COMMUTATIVITY-OF-TIMES DIVIDES-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES and
DIVIDES-TIMES, and expanding the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES
(DISABLE REMAINDER-TIMES)
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES-OFF
(PROVE-LEMMA QUOTIENT-TIMES
(REWRITE)
(EQUAL (QUOTIENT (TIMES Y X) Y)
(IF (ZEROP Y) '0 (FIX X)))
((ENABLE TIMES-ZERO2 COMMUTATIVITY-OF-TIMES DIFFERENCE-PLUS1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying COMMUTATIVITY-OF-TIMES, and expanding the
functions ZEROP and FIX, to four new conjectures:
Case 4. (IMPLIES (EQUAL Y 0)
(EQUAL (QUOTIENT (TIMES X Y) Y) 0)),
which again simplifies, applying COMMUTATIVITY-OF-TIMES, and opening up
EQUAL, TIMES, and QUOTIENT, to:
T.
Case 3. (IMPLIES (NOT (NUMBERP Y))
(EQUAL (QUOTIENT (TIMES X Y) Y) 0)).
This again simplifies, applying TIMES-ZERO2, and opening up the functions
QUOTIENT and EQUAL, to:
T.
Case 2. (IMPLIES (NOT (NUMBERP X))
(EQUAL (QUOTIENT (TIMES X Y) Y) 0)).
However this again simplifies, unfolding the definitions of TIMES, LESSP,
EQUAL, and QUOTIENT, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL Y 0))
(NUMBERP Y)
(NUMBERP X))
(EQUAL (QUOTIENT (TIMES X Y) Y) X)),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates two new goals:
Case 2. (IMPLIES (AND (ZEROP X)
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NUMBERP X))
(EQUAL (QUOTIENT (TIMES X Y) Y) X)),
which simplifies, opening up ZEROP, NUMBERP, EQUAL, TIMES, LESSP, and
QUOTIENT, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (QUOTIENT (TIMES (SUB1 X) Y) Y)
(SUB1 X))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NUMBERP X))
(EQUAL (QUOTIENT (TIMES X Y) Y) X)),
which simplifies, rewriting with ADD1-SUB1 and DIFFERENCE-PLUS1, and
expanding the functions ZEROP, TIMES, and QUOTIENT, to the new formula:
(IMPLIES (AND (NOT (EQUAL X 0))
(EQUAL (QUOTIENT (TIMES (SUB1 X) Y) Y)
(SUB1 X))
(NOT (EQUAL Y 0))
(NUMBERP Y)
(NUMBERP X))
(NOT (LESSP (PLUS Y (TIMES (SUB1 X) Y))
Y))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES
(DISABLE QUOTIENT-TIMES)
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES-OFF
(PROVE-LEMMA DISTRIBUTIVITY-OF-DIVIDES
(REWRITE)
(IMPLIES (AND (NOT (ZEROP A)) (DIVIDES A W))
(EQUAL (TIMES C (QUOTIENT W A))
(QUOTIENT (TIMES C W) A)))
((ENABLE TIMES-ZERO2 COMMUTATIVITY-OF-TIMES
COMMUTATIVITY2-OF-TIMES LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM QUOTIENT-TIMES DIVIDES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
IMPLIES, and DIVIDES, to:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL (REMAINDER W A) 0))
(EQUAL (TIMES C (QUOTIENT W A))
(QUOTIENT (TIMES C W) A))).
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace W by
(PLUS X (TIMES A Z)) to eliminate (REMAINDER W A) and (QUOTIENT W A). We use
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was introduced
to constrain the new variables. This generates two new conjectures:
Case 2. (IMPLIES (AND (NOT (NUMBERP W))
(NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL (REMAINDER W A) 0))
(EQUAL (TIMES C (QUOTIENT W A))
(QUOTIENT (TIMES C W) A))),
which simplifies, rewriting with COMMUTATIVITY-OF-TIMES and TIMES-ZERO2, and
opening up LESSP, REMAINDER, EQUAL, QUOTIENT, and TIMES, to:
T.
Case 1. (IMPLIES (AND (NUMBERP X)
(EQUAL (LESSP X A) (NOT (ZEROP A)))
(NUMBERP Z)
(NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL X 0))
(EQUAL (TIMES C Z)
(QUOTIENT (TIMES C (PLUS X (TIMES A Z)))
A))).
But this simplifies, rewriting with COMMUTATIVITY2-OF-TIMES and
QUOTIENT-TIMES, and expanding the functions NUMBERP, EQUAL, LESSP, ZEROP,
NOT, and PLUS, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-DIVIDES
(DISABLE DISTRIBUTIVITY-OF-DIVIDES)
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-DIVIDES-OFF
(PROVE-LEMMA IF-TIMES-THEN-DIVIDES
(REWRITE)
(IMPLIES (AND (NOT (ZEROP C))
(NOT (DIVIDES C X)))
(NOT (EQUAL (TIMES C Y) X)))
((ENABLE REMAINDER-TIMES DIVIDES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND,
IMPLIES, and DIVIDES, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER X C) 0)))
(NOT (EQUAL (TIMES C Y) X))),
which simplifies, applying REMAINDER-TIMES, and unfolding the function EQUAL,
to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
IF-TIMES-THEN-DIVIDES
(DISABLE IF-TIMES-THEN-DIVIDES)
[ 0.0 0.0 0.0 ]
IF-TIMES-THEN-DIVIDES-OFF
(PROVE-LEMMA TIMES-EQUAL-1
(REWRITE)
(EQUAL (EQUAL (TIMES A B) '1)
(AND (NOT (EQUAL A '0))
(AND (NOT (EQUAL B '0))
(AND (NUMBERP A)
(AND (NUMBERP B)
(AND (EQUAL (SUB1 A) '0)
(EQUAL (SUB1 B) '0)))))))
((ENABLE PLUS-RIGHT-ID2 COMMUTATIVITY-OF-PLUS
COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying COMMUTATIVITY-OF-TIMES, and opening up
the definitions of TIMES, NOT, and AND, to the following five new formulas:
Case 5. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (PLUS B
(SUB1 A)
(TIMES (SUB1 A) (SUB1 B)))
1))
(EQUAL (EQUAL (SUB1 B) 0) T)).
But this again simplifies, using linear arithmetic, to the conjecture:
(IMPLIES (AND (NOT (EQUAL 1 0))
(NUMBERP 1)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (PLUS B
(SUB1 1)
(TIMES (SUB1 1) (SUB1 B)))
1))
(EQUAL (EQUAL (SUB1 B) 0) T)).
This again simplifies, applying the lemma COMMUTATIVITY-OF-PLUS, and opening
up the functions EQUAL, NUMBERP, SUB1, TIMES, and PLUS, to:
T.
Case 4. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL (PLUS B
(SUB1 A)
(TIMES (SUB1 A) (SUB1 B)))
1))
(EQUAL (SUB1 A) 0))
(NOT (EQUAL (SUB1 B) 0))),
which again simplifies, rewriting with the lemma COMMUTATIVITY-OF-PLUS, and
expanding the functions TIMES, PLUS, and EQUAL, to the goal:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL B 1))
(EQUAL (SUB1 A) 0))
(NOT (EQUAL (SUB1 B) 0))).
But this again simplifies, using linear arithmetic, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL B 0))
(NOT (EQUAL (PLUS B 0) 1))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (NUMBERP B)))
(NOT (EQUAL (PLUS B 0) 1))),
which again simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS,
and expanding NUMBERP and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (PLUS B
(SUB1 A)
(TIMES (SUB1 A) (SUB1 B)))
1))
(EQUAL (SUB1 A) 0)).
But this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-EQUAL-1
(DISABLE TIMES-EQUAL-1)
[ 0.0 0.0 0.0 ]
TIMES-EQUAL-1-OFF
(PROVE-LEMMA DIVIDES-IMPLIES-TIMES
(REWRITE)
(IMPLIES (AND (NOT (ZEROP A))
(AND (NUMBERP C)
(EQUAL (TIMES A C) B)))
(EQUAL (EQUAL C (QUOTIENT B A))
'*1*TRUE))
((ENABLE QUOTIENT-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NUMBERP C)
(EQUAL (TIMES A C) B))
(EQUAL (EQUAL C (QUOTIENT B A)) T)).
This simplifies, applying the lemma QUOTIENT-TIMES, and opening up EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIVIDES-IMPLIES-TIMES
(DISABLE DIVIDES-IMPLIES-TIMES)
[ 0.0 0.0 0.0 ]
DIVIDES-IMPLIES-TIMES-OFF
(PROVE-LEMMA DIFFERENCE-1
(REWRITE)
(EQUAL (DIFFERENCE X '1) (SUB1 X))
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
(IMPLIES (LESSP X 1)
(EQUAL (DIFFERENCE X 1) (SUB1 X))).
However this again simplifies, using linear arithmetic and applying
DIFFERENCE-0, to:
(IMPLIES (LESSP X 1)
(EQUAL 0 (SUB1 X))).
Applying the lemma SUB1-ELIM, replace X by (ADD1 Z) to eliminate (SUB1 X). We
rely upon the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. We would thus like to prove the following three
new conjectures:
Case 3. (IMPLIES (AND (EQUAL X 0) (LESSP X 1))
(EQUAL 0 (SUB1 X))).
But this further simplifies, unfolding the functions LESSP, SUB1, and EQUAL,
to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP X)) (LESSP X 1))
(EQUAL 0 (SUB1 X))),
which further simplifies, rewriting with SUB1-NNUMBERP, and expanding the
definitions of NUMBERP, EQUAL, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0))
(LESSP (ADD1 Z) 1))
(EQUAL 0 Z)).
This further simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-1
(DISABLE DIFFERENCE-1)
[ 0.0 0.0 0.0 ]
DIFFERENCE-1-OFF
(PROVE-LEMMA DIFFERENCE-2
(REWRITE)
(EQUAL (DIFFERENCE (ADD1 (ADD1 X)) '2)
(FIX X))
((ENABLE DIFFERENCE-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying DIFFERENCE-1 and SUB1-ADD1, and opening up
the functions SUB1, NUMBERP, EQUAL, DIFFERENCE, and FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-2
(DISABLE DIFFERENCE-2)
[ 0.0 0.0 0.0 ]
DIFFERENCE-2-OFF
(PROVE-LEMMA HALF-PLUS
(REWRITE)
(EQUAL (QUOTIENT (PLUS X (PLUS X Y)) '2)
(PLUS X (QUOTIENT Y '2)))
((ENABLE PLUS-RIGHT-ID2 PLUS-ADD1 COMMUTATIVITY2-OF-PLUS
COMMUTATIVITY-OF-PLUS LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM DIVIDES-IMPLIES-TIMES
DIFFERENCE-2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace Y by
(PLUS V (TIMES 2 Z)) to eliminate (QUOTIENT Y 2) and (REMAINDER Y 2). We rely
upon LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was introduced
to constrain the new variables. The result is four new conjectures:
Case 4. (IMPLIES (NOT (NUMBERP Y))
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2)))),
which simplifies, rewriting with the lemmas PLUS-RIGHT-ID2 and
COMMUTATIVITY-OF-PLUS, and unfolding the functions LESSP, NUMBERP, EQUAL,
QUOTIENT, and PLUS, to two new formulas:
Case 4.2.
(IMPLIES (AND (NOT (NUMBERP Y))
(NOT (NUMBERP X)))
(EQUAL (QUOTIENT (PLUS X 0) 2) 0)),
which again simplifies, applying PLUS-RIGHT-ID2 and COMMUTATIVITY-OF-PLUS,
and expanding the definitions of NUMBERP, QUOTIENT, and EQUAL, to:
T.
Case 4.1.
(IMPLIES (AND (NOT (NUMBERP Y)) (NUMBERP X))
(EQUAL (QUOTIENT (PLUS X X) 2) X)).
This again simplifies, using linear arithmetic, rewriting with
DIVIDES-IMPLIES-TIMES, and expanding EQUAL, to:
T.
Case 3. (IMPLIES (EQUAL 2 0)
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2)))).
However this simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (NOT (NUMBERP 2))
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2)))),
which simplifies, clearly, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NUMBERP V)
(EQUAL (LESSP V 2) (NOT (ZEROP 2)))
(NOT (EQUAL 2 0)))
(EQUAL (QUOTIENT (PLUS X X V (TIMES 2 Z)) 2)
(PLUS X Z))).
This simplifies, applying COMMUTATIVITY2-OF-PLUS, and unfolding the
functions ZEROP, NOT, and EQUAL, to:
(IMPLIES (AND (NUMBERP Z)
(NUMBERP V)
(LESSP V 2))
(EQUAL (QUOTIENT (PLUS V X X (TIMES 2 Z)) 2)
(PLUS X Z))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2))),
named *1. Let us appeal to the induction principle. The recursive terms in
the conjecture suggest four inductions. They merge into two likely candidate
inductions. However, only one is unflawed. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP X) (p X Y))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X) Y))
(p X Y))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definition
of ZEROP can be used to prove that the measure (COUNT X) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme leads to the following two new formulas:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2)))).
This simplifies, opening up ZEROP, EQUAL, and PLUS, to the following two new
goals:
Case 2.2.
(IMPLIES (AND (EQUAL X 0) (NOT (NUMBERP Y)))
(EQUAL (QUOTIENT 0 2)
(QUOTIENT Y 2))).
This again simplifies, expanding the definitions of QUOTIENT, LESSP,
NUMBERP, and EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP X))
(NOT (NUMBERP Y)))
(EQUAL (QUOTIENT 0 2)
(QUOTIENT Y 2))),
which again simplifies, expanding the functions QUOTIENT, LESSP, NUMBERP,
and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (QUOTIENT (PLUS (SUB1 X) (SUB1 X) Y)
2)
(PLUS (SUB1 X) (QUOTIENT Y 2))))
(EQUAL (QUOTIENT (PLUS X X Y) 2)
(PLUS X (QUOTIENT Y 2)))),
which simplifies, applying PLUS-ADD1, DIFFERENCE-2, and SUB1-ADD1, and
expanding ZEROP, PLUS, LESSP, SUB1, NUMBERP, EQUAL, and QUOTIENT, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
HALF-PLUS
(DISABLE HALF-PLUS)
[ 0.0 0.0 0.0 ]
HALF-PLUS-OFF
(PROVE-LEMMA TIMES-1
(REWRITE)
(EQUAL (TIMES '1 X) (FIX X))
((ENABLE TIMES-ZERO2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding FIX, to two new formulas:
Case 2. (IMPLIES (NOT (NUMBERP X))
(EQUAL (TIMES 1 X) 0)),
which again simplifies, rewriting with TIMES-ZERO2, and unfolding the
definition of EQUAL, to:
T.
Case 1. (IMPLIES (NUMBERP X)
(EQUAL (TIMES 1 X) X)).
This again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-1
(DISABLE TIMES-1)
[ 0.0 0.0 0.0 ]
TIMES-1-OFF
(PROVE-LEMMA EXP-OF-0
(REWRITE)
(EQUAL (EXP '0 K)
(IF (ZEROP K) '1 '0))
((ENABLE EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions TIMES, EQUAL, EXP, and ZEROP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-OF-0
(DISABLE EXP-OF-0)
[ 0.0 0.0 0.0 ]
EXP-OF-0-OFF
(PROVE-LEMMA EXP-OF-1
(REWRITE)
(EQUAL (EXP '1 K) '1)
((ENABLE EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p K))
(IMPLIES (AND (NOT (ZEROP K)) (p (SUB1 K)))
(p K))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates the following two new formulas:
Case 2. (IMPLIES (ZEROP K)
(EQUAL (EXP 1 K) 1)).
This simplifies, expanding the definitions of ZEROP, EQUAL, and EXP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (EXP 1 (SUB1 K)) 1))
(EQUAL (EXP 1 K) 1)).
This simplifies, opening up the functions ZEROP, EXP, TIMES, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-OF-1
(DISABLE EXP-OF-1)
[ 0.0 0.0 0.0 ]
EXP-OF-1-OFF
(PROVE-LEMMA EXP-BY-0
(REWRITE)
(EQUAL (EXP X '0) '1)
((ENABLE EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding EQUAL and EXP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-BY-0
(DISABLE EXP-BY-0)
[ 0.0 0.0 0.0 ]
EXP-BY-0-OFF
(PROVE-LEMMA EXP-TIMES
(REWRITE)
(EQUAL (EXP (TIMES I J) K)
(TIMES (EXP I K) (EXP J K)))
((ENABLE COMMUTATIVITY2-OF-TIMES ASSOCIATIVITY-OF-TIMES EXP-BY-0
EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are four plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p I J K))
(IMPLIES (AND (NOT (ZEROP K)) (p I J (SUB1 K)))
(p I J K))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT K) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates two new goals:
Case 2. (IMPLIES (ZEROP K)
(EQUAL (EXP (TIMES I J) K)
(TIMES (EXP I K) (EXP J K)))),
which simplifies, appealing to the lemma EXP-BY-0, and unfolding ZEROP,
TIMES, EQUAL, and EXP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (EXP (TIMES I J) (SUB1 K))
(TIMES (EXP I (SUB1 K))
(EXP J (SUB1 K)))))
(EQUAL (EXP (TIMES I J) K)
(TIMES (EXP I K) (EXP J K)))),
which simplifies, rewriting with the lemmas ASSOCIATIVITY-OF-TIMES and
COMMUTATIVITY2-OF-TIMES, and expanding the functions ZEROP and EXP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-TIMES
(DISABLE EXP-TIMES)
[ 0.0 0.0 0.0 ]
EXP-TIMES-OFF
(PROVE-LEMMA EXP-EXP
(REWRITE)
(EQUAL (EXP (EXP I J) K)
(EXP I (TIMES J K)))
((ENABLE EXP-PLUS EXP-OF-1 EXP-BY-0 EXP-TIMES EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP J) (p I J K))
(IMPLIES (AND (NOT (ZEROP J)) (p I (SUB1 J) K))
(p I J K))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to prove that the measure (COUNT J) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme leads to two new goals:
Case 2. (IMPLIES (ZEROP J)
(EQUAL (EXP (EXP I J) K)
(EXP I (TIMES J K)))),
which simplifies, applying the lemmas EXP-BY-0 and EXP-OF-1, and opening up
the definitions of ZEROP, EQUAL, TIMES, and EXP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP J))
(EQUAL (EXP (EXP I (SUB1 J)) K)
(EXP I (TIMES (SUB1 J) K))))
(EQUAL (EXP (EXP I J) K)
(EXP I (TIMES J K)))),
which simplifies, rewriting with EXP-TIMES and EXP-PLUS, and opening up the
functions ZEROP, EXP, and TIMES, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-EXP
(DISABLE EXP-EXP)
[ 0.0 0.0 0.0 ]
EXP-EXP-OFF
(PROVE-LEMMA REMAINDER-PLUS-TIMES-1
(REWRITE)
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))
((ENABLE COMMUTATIVITY2-OF-PLUS COMMUTATIVITY-OF-PLUS
ASSOCIATIVITY-OF-PLUS TIMES-ZERO2 COMMUTATIVITY-OF-TIMES
EQUAL-TIMES-0 REMAINDER-WRT-12 LESSP-REMAINDER2
REMAINDER-QUOTIENT-ELIM DIFFERENCE-PLUS1 DIVIDES-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace X by (PLUS Z (TIMES J V))
to eliminate (REMAINDER X J) and (QUOTIENT X J). We rely upon
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was introduced
to restrict the new variables. We thus obtain the following four new
conjectures:
Case 4. (IMPLIES (NOT (NUMBERP X))
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))).
But this simplifies, applying the lemma DIVIDES-TIMES, and opening up the
definitions of PLUS, LESSP, REMAINDER, and EQUAL, to:
T.
Case 3. (IMPLIES (EQUAL J 0)
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))),
which simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and opening up the functions EQUAL, TIMES, PLUS, and
REMAINDER, to:
T.
Case 2. (IMPLIES (NOT (NUMBERP J))
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))).
But this simplifies, rewriting with TIMES-ZERO2, COMMUTATIVITY-OF-PLUS, and
REMAINDER-WRT-12, and opening up the functions EQUAL and PLUS, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(EQUAL (LESSP Z J) (NOT (ZEROP J)))
(NUMBERP V)
(NUMBERP J)
(NOT (EQUAL J 0)))
(EQUAL (REMAINDER (PLUS (PLUS Z (TIMES J V))
(TIMES I J))
J)
Z)).
But this simplifies, applying COMMUTATIVITY-OF-PLUS and
ASSOCIATIVITY-OF-PLUS, and opening up the functions ZEROP and NOT, to:
(IMPLIES (AND (NUMBERP Z)
(LESSP Z J)
(NUMBERP V)
(NUMBERP J)
(NOT (EQUAL J 0)))
(EQUAL (REMAINDER (PLUS Z (TIMES I J) (TIMES J V))
J)
Z)),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J)),
named *1. Let us appeal to the induction principle. The recursive terms in
the conjecture suggest three inductions. However, only one is unflawed. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP I) (p X I J))
(IMPLIES (AND (NOT (ZEROP I)) (p X (SUB1 I) J))
(p X I J))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT I) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme generates two new formulas:
Case 2. (IMPLIES (ZEROP I)
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))),
which simplifies, rewriting with COMMUTATIVITY-OF-PLUS, and expanding ZEROP,
EQUAL, TIMES, and PLUS, to the following two new conjectures:
Case 2.2.
(IMPLIES (AND (EQUAL I 0) (NOT (NUMBERP X)))
(EQUAL (REMAINDER 0 J)
(REMAINDER X J))).
However this again simplifies, unfolding the definitions of LESSP, EQUAL,
NUMBERP, and REMAINDER, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP X)))
(EQUAL (REMAINDER 0 J)
(REMAINDER X J))),
which again simplifies, opening up the definitions of LESSP, EQUAL,
NUMBERP, and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP I))
(EQUAL (REMAINDER (PLUS X (TIMES (SUB1 I) J))
J)
(REMAINDER X J)))
(EQUAL (REMAINDER (PLUS X (TIMES I J)) J)
(REMAINDER X J))),
which simplifies, applying COMMUTATIVITY2-OF-PLUS and DIFFERENCE-PLUS1, and
unfolding ZEROP, TIMES, REMAINDER, EQUAL, and PLUS, to the following three
new goals:
Case 1.3.
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL (REMAINDER (PLUS X (TIMES (SUB1 I) J))
J)
(REMAINDER X J))
(NOT (EQUAL J 0))
(NUMBERP J)
(LESSP (PLUS J X (TIMES (SUB1 I) J))
J))
(EQUAL (PLUS J X (TIMES (SUB1 I) J))
(REMAINDER X J))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL (REMAINDER (PLUS X (TIMES (SUB1 I) J))
J)
(REMAINDER X J))
(EQUAL J 0))
(EQUAL (PLUS X (TIMES (SUB1 I) J))
(REMAINDER X J))),
which again simplifies, applying COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and unfolding EQUAL, TIMES, PLUS, and REMAINDER, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL (REMAINDER (PLUS X (TIMES (SUB1 I) J))
J)
(REMAINDER X J))
(NOT (NUMBERP J)))
(EQUAL (PLUS X (TIMES (SUB1 I) J))
(REMAINDER X J))).
This again simplifies, applying the lemmas REMAINDER-WRT-12 and
EQUAL-TIMES-0, and opening up the function PLUS, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-TIMES-1
(DISABLE REMAINDER-PLUS-TIMES-1)
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-TIMES-1-OFF
(PROVE-LEMMA REMAINDER-PLUS-TIMES-2
(REWRITE)
(EQUAL (REMAINDER (PLUS X (TIMES J I)) J)
(REMAINDER X J))
((ENABLE COMMUTATIVITY-OF-TIMES REMAINDER-PLUS-TIMES-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with COMMUTATIVITY-OF-TIMES and
REMAINDER-PLUS-TIMES-1, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-TIMES-2
(DISABLE REMAINDER-PLUS-TIMES-2)
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-TIMES-2-OFF
(PROVE-LEMMA REMAINDER-TIMES-1
(REWRITE)
(EQUAL (REMAINDER (TIMES B (TIMES A C)) A)
'0)
((ENABLE COMMUTATIVITY2-OF-TIMES REMAINDER-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying COMMUTATIVITY2-OF-TIMES and REMAINDER-TIMES,
and opening up the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES-1
(DISABLE REMAINDER-TIMES-1)
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES-1-OFF
(PROVE-LEMMA REMAINDER-OF-1
(REWRITE)
(EQUAL (REMAINDER '1 X)
(IF (EQUAL X '1) '0 '1))
((ENABLE DIFFERENCE-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with DIFFERENCE-0, and opening up DIFFERENCE, EQUAL,
SUB1, LESSP, NUMBERP, and REMAINDER, to four new conjectures:
Case 4. (IMPLIES (AND (NOT (EQUAL X 1))
(NOT (EQUAL X 0))
(NUMBERP X))
(LESSP 1 X)),
which again simplifies, using linear arithmetic, to:
T.
Case 3. (IMPLIES (EQUAL X 1)
(NOT (LESSP 1 X))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (EQUAL X 1) (NUMBERP X)),
which again simplifies, trivially, to:
T.
Case 1. (IMPLIES (EQUAL X 1)
(NOT (EQUAL X 0))).
But this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-OF-1
(DISABLE REMAINDER-OF-1)
[ 0.0 0.0 0.0 ]
REMAINDER-OF-1-OFF
(PROVE-LEMMA REMAINDER-DIFFERENCE-TIMES
(REWRITE)
(EQUAL (REMAINDER (DIFFERENCE (TIMES P X) (TIMES P Y))
P)
'0)
((USE (DIVIDES-TIMES (X (DIFFERENCE X Y))
(Z P)))
(DISABLE DIVIDES-TIMES)
(ENABLE COMMUTATIVITY-OF-TIMES TIMES-DIFFERENCE DIVIDES-TIMES
EUCLID REMAINDER-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviation DIVIDES-TIMES, to the
new conjecture:
(IMPLIES (EQUAL 0 0)
(EQUAL (REMAINDER (DIFFERENCE (TIMES P X) (TIMES P Y))
P)
0)),
which simplifies, rewriting with REMAINDER-TIMES and EUCLID, and opening up
the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-DIFFERENCE-TIMES
(DISABLE REMAINDER-DIFFERENCE-TIMES)
[ 0.0 0.0 0.0 ]
REMAINDER-DIFFERENCE-TIMES-OFF
(PROVE-LEMMA LESSP-REMAINDER-DIVISOR
(REWRITE)
(IMPLIES (NOT (ZEROP Y))
(LESSP (REMAINDER X Y) Y))
((ENABLE LESSP-REMAINDER2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma LESSP-REMAINDER-DIVISOR is to be stored
as zero type prescription rules, zero compound recognizer rules, one linear
rule, and zero replacement rules.
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL Y 0)) (NUMBERP Y))
(LESSP (REMAINDER X Y) Y)),
which simplifies, appealing to the lemma LESSP-REMAINDER2, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER-DIVISOR
(DISABLE LESSP-REMAINDER-DIVISOR)
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER-DIVISOR-OFF
(DEFTHEORY CL-ARITHMETIC
(LESSP-REMAINDER-DIVISOR REMAINDER-DIFFERENCE-TIMES REMAINDER-OF-1
REMAINDER-TIMES-1 REMAINDER-PLUS-TIMES-2
REMAINDER-PLUS-TIMES-1 EXP-EXP EXP-TIMES
EXP-BY-0 EXP-OF-1 EXP-OF-0 TIMES-1
HALF-PLUS DIFFERENCE-2 DIFFERENCE-1
DIVIDES-IMPLIES-TIMES TIMES-EQUAL-1
IF-TIMES-THEN-DIVIDES
DISTRIBUTIVITY-OF-DIVIDES QUOTIENT-TIMES
REMAINDER-TIMES QUOTIENT-DIVIDES
TIMES-IDENTITY TIMES-IDENTITY1
DIVIDES-TIMES1 TIMES-ID-IFF-1
QUOTIENT-LESSP QUOTIENT-TIMES1
LESSP-PLUS-CANCELLATION3
LESSP-TIMES-CANCELLATION EUCLID
DIVIDES-PLUS-REWRITE-COMMUTED
LESSP-PLUS-CANCELATION
DIVIDES-PLUS-REWRITE DIVIDES-PLUS-REWRITE2
DIVIDES-PLUS-REWRITE1 REMAINDER-ADD1
DIFFERENCE-ADD1-CANCELLATION
DIFFERENCE-PLUS3 DIVIDES-TIMES DIVIDES
TIMES-DIFFERENCE
DIFFERENCE-PLUS-CANCELATION
DIFFERENCE-PLUS2 DIFFERENCE-PLUS1
LESSP-REMAINDER1 LESSP-QUOTIENT1
LESSP-TIMES-2 LESSP-TIMES-1
REMAINDER-QUOTIENT-ELIM REMAINDER-X-X
LESSP-REMAINDER2 REMAINDER-WRT-12
REMAINDER-WRT-1 REMAINDER-QUOTIENT
DIFFERENCE-ELIM EQUAL-LESSP EXP-PLUS
EQUAL-TIMES-0 ASSOCIATIVITY-OF-TIMES
COMMUTATIVITY2-OF-TIMES
COMMUTATIVITY-OF-TIMES TIMES-ADD1
DISTRIBUTIVITY-OF-TIMES-OVER-PLUS
TIMES-ZERO2 DIFFERENCE-CANCELLATION-1
DIFFERENCE-CANCELLATION-0
EQUAL-DIFFERENCE-0 DIFFERENCE-0
PLUS-CANCELLATION DIFFERENCE-PLUS
DIFFERENCE-X-X PLUS-EQUAL-0
ASSOCIATIVITY-OF-PLUS
COMMUTATIVITY-OF-PLUS
COMMUTATIVITY2-OF-PLUS PLUS-ADD1
PLUS-RIGHT-ID2))
[ 0.0 0.0 0.0 ]
CL-ARITHMETIC
(DEFN NUMBER-AND-LIST-INDUCTION
(N L)
(IF (ZEROP N)
'0
(IF (LISTP L)
(NUMBER-AND-LIST-INDUCTION (SUB1 N)
(CDR L))
'0))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each recursive call. Hence, NUMBER-AND-LIST-INDUCTION is
accepted under the principle of definition. The definition of:
NUMBER-AND-LIST-INDUCTION
can be justified in another way. Linear arithmetic and the lemma CDR-LESSP
can be used to establish that the measure (COUNT L) decreases according to the
well-founded relation LESSP in each recursive call. Note that:
(NUMBERP (NUMBER-AND-LIST-INDUCTION N L))
is a theorem.
[ 0.0 0.0 0.0 ]
NUMBER-AND-LIST-INDUCTION
(DEFN DOUBLE-NUMBER-INDUCTION
(X Y)
(IF (OR (ZEROP X) (ZEROP Y))
'0
(DOUBLE-NUMBER-INDUCTION (SUB1 X)
(SUB1 Y)))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definitions of OR and
ZEROP establish that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each recursive call. Hence,
DOUBLE-NUMBER-INDUCTION is accepted under the definitional principle. The
definition of DOUBLE-NUMBER-INDUCTION can be justified in another way. Linear
arithmetic, the lemma COUNT-NUMBERP, and the definitions of OR and ZEROP
inform us that the measure (COUNT Y) decreases according to the well-founded
relation LESSP in each recursive call. Observe that:
(NUMBERP (DOUBLE-NUMBER-INDUCTION X Y))
is a theorem.
[ 0.0 0.0 0.0 ]
DOUBLE-NUMBER-INDUCTION
(DEFN DOUBLE-NUMBER-DOUBLE-LIST-INDUCTION
(I J L1 L2)
(IF (AND (LISTP L1) (LISTP L2))
(IF (OR (ZEROP I) (ZEROP J))
'0
(DOUBLE-NUMBER-DOUBLE-LIST-INDUCTION (SUB1 I)
(SUB1 J)
(CDR L1)
(CDR L2)))
'0)
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definitions of OR,
ZEROP, and AND inform us that the measure (COUNT I) decreases according to the
well-founded relation LESSP in each recursive call. Hence,
DOUBLE-NUMBER-DOUBLE-LIST-INDUCTION
is accepted under the principle of definition. There are three other measures
and well-founded functions explaining the recursion above. Linear arithmetic,
the lemma COUNT-NUMBERP, and the definitions of OR, ZEROP, and AND establish
that the measure (COUNT J) decreases according to the well-founded relation
LESSP in each recursive call. Linear arithmetic, the lemmas CDR-LESSEQP and
CDR-LESSP, and the definitions of OR, ZEROP, and AND can be used to establish
that the measure (COUNT L1) decreases according to the well-founded relation
LESSP in each recursive call. Finally, linear arithmetic, the lemmas
CDR-LESSEQP and CDR-LESSP, and the definitions of OR, ZEROP, and AND can be
used to prove that the measure (COUNT L2) decreases according to the
well-founded relation LESSP in each recursive call. From the definition we
can conclude that (NUMBERP (DOUBLE-NUMBER-DOUBLE-LIST-INDUCTION I J L1 L2)) is
a theorem.
[ 0.0 0.0 0.1 ]
DOUBLE-NUMBER-DOUBLE-LIST-INDUCTION
(PROVE-LEMMA PLUS-0
(REWRITE)
(EQUAL (PLUS A '0) (FIX A))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding FIX, to two new formulas:
Case 2. (IMPLIES (NOT (NUMBERP A))
(EQUAL (PLUS A 0) 0)),
which again simplifies, unfolding NUMBERP, PLUS, and EQUAL, to:
T.
Case 1. (IMPLIES (NUMBERP A)
(EQUAL (PLUS A 0) A)),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-0
(DISABLE PLUS-0)
[ 0.0 0.0 0.0 ]
PLUS-0-OFF
(PROVE-LEMMA PLUS-1
(REWRITE)
(EQUAL (PLUS '1 X) (ADD1 X))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-1
(DISABLE PLUS-1)
[ 0.0 0.0 0.0 ]
PLUS-1-OFF
(PROVE-LEMMA PLUS-0-ARG1
(REWRITE)
(EQUAL (PLUS '0 X) (FIX X))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding EQUAL, PLUS, and FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-0-ARG1
(DISABLE PLUS-0-ARG1)
[ 0.0 0.0 0.0 ]
PLUS-0-ARG1-OFF
(PROVE-LEMMA PLUS-DIFFERENCE-CANCELLATION
(REWRITE)
(IMPLIES (IF (LESSP B A) '*1*FALSE '*1*TRUE)
(EQUAL (PLUS A (DIFFERENCE B A))
(FIX B)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up the definition of FIX, to the following
two new formulas:
Case 2. (IMPLIES (AND (NOT (LESSP B A))
(NOT (NUMBERP B)))
(EQUAL (PLUS A (DIFFERENCE B A)) 0)).
But this again simplifies, unfolding the functions LESSP, DIFFERENCE, PLUS,
EQUAL, and NUMBERP, to:
T.
Case 1. (IMPLIES (AND (NOT (LESSP B A)) (NUMBERP B))
(EQUAL (PLUS A (DIFFERENCE B A)) B)),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-DIFFERENCE-CANCELLATION
(DISABLE PLUS-DIFFERENCE-CANCELLATION)
[ 0.0 0.0 0.0 ]
PLUS-DIFFERENCE-CANCELLATION-OFF
(PROVE-LEMMA CANONICALIZE-PLUS-TERMS1
(REWRITE)
(EQUAL (ADD1 (PLUS (ADD1 A) B))
(PLUS (ADD1 (ADD1 A)) B))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS1
(DISABLE CANONICALIZE-PLUS-TERMS1)
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS1-OFF
(PROVE-LEMMA CANONICALIZE-PLUS-TERMS2
(REWRITE)
(EQUAL (PLUS (ADD1 A) (PLUS (ADD1 B) C))
(PLUS (PLUS (ADD1 A) (ADD1 B)) C))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS2
(DISABLE CANONICALIZE-PLUS-TERMS2)
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS2-OFF
(PROVE-LEMMA CANONICALIZE-PLUS-TERMS3
(REWRITE)
(EQUAL (PLUS (TIMES A B) (PLUS (ADD1 C) D))
(PLUS (ADD1 C) (PLUS D (TIMES A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS3
(DISABLE CANONICALIZE-PLUS-TERMS3)
[ 0.0 0.0 0.0 ]
CANONICALIZE-PLUS-TERMS3-OFF
(PROVE-LEMMA PLUS-PLUS-DIFFERENCE
(REWRITE)
(IMPLIES (AND (NUMBERP I)
(AND (NUMBERP N)
(IF (LESSP N I)
'*1*FALSE
'*1*TRUE)))
(EQUAL (PLUS I (PLUS J (DIFFERENCE N I)))
(PLUS N J)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-PLUS-DIFFERENCE
(DISABLE PLUS-PLUS-DIFFERENCE)
[ 0.0 0.0 0.0 ]
PLUS-PLUS-DIFFERENCE-OFF
(PROVE-LEMMA PLUS-TIMES-REDUCTION
(REWRITE)
(EQUAL (PLUS A (TIMES B A))
(TIMES (ADD1 B) A))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying SUB1-ADD1, and opening up the function TIMES,
to:
(IMPLIES (NOT (NUMBERP B))
(EQUAL (PLUS A (TIMES B A))
(PLUS A (TIMES 0 A)))),
which again simplifies, opening up the functions TIMES and EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-TIMES-REDUCTION
(DISABLE PLUS-TIMES-REDUCTION)
[ 0.0 0.0 0.0 ]
PLUS-TIMES-REDUCTION-OFF
(PROVE-LEMMA PLUS-TIMES-SUB1-REDUCTION
(REWRITE)
(IMPLIES (NOT (ZEROP B))
(EQUAL (PLUS A (TIMES (SUB1 B) A))
(TIMES B A)))
((ENABLE PLUS-TIMES-REDUCTION)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, IMPLIES,
and PLUS-TIMES-REDUCTION, to:
(IMPLIES (AND (NOT (EQUAL B 0)) (NUMBERP B))
(EQUAL (TIMES (ADD1 (SUB1 B)) A)
(TIMES B A))),
which simplifies, rewriting with ADD1-SUB1 and PLUS-TIMES-REDUCTION, and
expanding the function TIMES, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-TIMES-SUB1-REDUCTION
(DISABLE PLUS-TIMES-SUB1-REDUCTION)
[ 0.0 0.0 0.0 ]
PLUS-TIMES-SUB1-REDUCTION-OFF
(PROVE-LEMMA PLUS-COMMUTATIVITY-ASSOCIATIVITY-CROCK
(REWRITE)
(EQUAL (PLUS B (PLUS A C))
(PLUS A (PLUS B C)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-COMMUTATIVITY-ASSOCIATIVITY-CROCK
(DISABLE PLUS-COMMUTATIVITY-ASSOCIATIVITY-CROCK)
[ 0.0 0.0 0.0 ]
PLUS-COMMUTATIVITY-ASSOCIATIVITY-CROCK-OFF
(PROVE-LEMMA DISTRIBUTIVITY-OF-TIMES-OVER-PLUS-BACKWARDS
(REWRITE)
(EQUAL (PLUS (TIMES A B) (TIMES A C))
(TIMES A (PLUS B C)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are four plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p A B C))
(IMPLIES (AND (NOT (ZEROP A)) (p (SUB1 A) B C))
(p A B C))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT A) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates two new goals:
Case 2. (IMPLIES (ZEROP A)
(EQUAL (PLUS (TIMES A B) (TIMES A C))
(TIMES A (PLUS B C)))),
which simplifies, opening up the functions ZEROP, EQUAL, TIMES, and PLUS, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (PLUS (TIMES (SUB1 A) B)
(TIMES (SUB1 A) C))
(TIMES (SUB1 A) (PLUS B C))))
(EQUAL (PLUS (TIMES A B) (TIMES A C))
(TIMES A (PLUS B C)))),
which simplifies, expanding ZEROP and TIMES, to the conjecture:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL (PLUS (TIMES (SUB1 A) B)
(TIMES (SUB1 A) C))
(TIMES (SUB1 A) (PLUS B C))))
(EQUAL (PLUS (PLUS B (TIMES (SUB1 A) B))
C
(TIMES (SUB1 A) C))
(PLUS (PLUS B C)
(TIMES (SUB1 A) (PLUS B C))))).
But this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-PLUS-BACKWARDS
(DISABLE DISTRIBUTIVITY-OF-TIMES-OVER-PLUS-BACKWARDS)
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-PLUS-BACKWARDS-OFF
(PROVE-LEMMA DIFFERENCE-IS-ZERO
(REWRITE)
(IMPLIES (LESSP A B)
(EQUAL (DIFFERENCE A B) '0))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will try to prove it by induction. There are four plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (OR (EQUAL B 0) (NOT (NUMBERP B)))
(p A B))
(IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(OR (EQUAL A 0) (NOT (NUMBERP A))))
(p A B))
(IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(p (SUB1 A) (SUB1 B)))
(p A B))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT inform us that the measure (COUNT A) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for B. The above induction scheme
generates four new goals:
Case 4. (IMPLIES (AND (OR (EQUAL B 0) (NOT (NUMBERP B)))
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which simplifies, expanding NOT, OR, EQUAL, and LESSP, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(OR (EQUAL A 0) (NOT (NUMBERP A)))
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which simplifies, opening up the functions NOT, OR, EQUAL, LESSP, and
DIFFERENCE, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(NOT (LESSP (SUB1 A) (SUB1 B)))
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which simplifies, using linear arithmetic, to the formula:
(IMPLIES (AND (LESSP A 1)
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(NOT (LESSP (SUB1 A) (SUB1 B)))
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)).
But this again simplifies, unfolding the functions SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which simplifies, using linear arithmetic, to two new goals:
Case 1.2.
(IMPLIES (AND (LESSP (SUB1 A) (SUB1 B))
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which again simplifies, expanding NOT, OR, LESSP, DIFFERENCE, and EQUAL,
to:
T.
Case 1.1.
(IMPLIES (AND (LESSP A 1)
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(LESSP A B))
(EQUAL (DIFFERENCE A B) 0)),
which again simplifies, unfolding SUB1, NUMBERP, EQUAL, LESSP, NOT, and OR,
to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-IS-ZERO
(DISABLE DIFFERENCE-IS-ZERO)
[ 0.0 0.0 0.0 ]
DIFFERENCE-IS-ZERO-OFF
(PROVE-LEMMA DIFFERENCE-BY-LARGER-NUMBER
(REWRITE)
(EQUAL (DIFFERENCE (SUB1 X) X) '0)
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Appealing to the lemma SUB1-ELIM, we now replace X by (ADD1 Z) to eliminate
(SUB1 X). We employ the type restriction lemma noted when SUB1 was introduced
to constrain the new variable. We must thus prove three new formulas:
Case 3. (IMPLIES (EQUAL X 0)
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which simplifies, expanding the definitions of SUB1, DIFFERENCE, and EQUAL,
to:
T.
Case 2. (IMPLIES (NOT (NUMBERP X))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which simplifies, applying SUB1-NNUMBERP, and opening up the functions EQUAL
and DIFFERENCE, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0)))
(EQUAL (DIFFERENCE Z (ADD1 Z)) 0)).
However this simplifies, applying SUB1-ADD1, and unfolding DIFFERENCE, to:
(IMPLIES (AND (NUMBERP Z) (NOT (EQUAL Z 0)))
(EQUAL (DIFFERENCE (SUB1 Z) Z) 0)),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (DIFFERENCE (SUB1 X) X) 0),
named *1. Let us appeal to the induction principle. There is only one
suggested induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP (SUB1 X)) (p X))
(IMPLIES (AND (NOT (ZEROP (SUB1 X))) (ZEROP X))
(p X))
(IMPLIES (AND (NOT (ZEROP (SUB1 X)))
(NOT (ZEROP X))
(p (SUB1 X)))
(p X))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT X) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates three new formulas:
Case 3. (IMPLIES (ZEROP (SUB1 X))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which simplifies, expanding the definitions of ZEROP, EQUAL, and DIFFERENCE,
to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP (SUB1 X))) (ZEROP X))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which simplifies, applying SUB1-NNUMBERP, and opening up ZEROP, SUB1,
DIFFERENCE, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP (SUB1 X)))
(NOT (ZEROP X))
(EQUAL (DIFFERENCE (SUB1 (SUB1 X)) (SUB1 X))
0))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)).
This simplifies, using linear arithmetic, to the following three new goals:
Case 1.3.
(IMPLIES (AND (LESSP (SUB1 (SUB1 X)) (SUB1 X))
(NOT (ZEROP (SUB1 X)))
(NOT (ZEROP X))
(EQUAL (DIFFERENCE (SUB1 (SUB1 X)) (SUB1 X))
0))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)).
But this again simplifies, unfolding the functions ZEROP, DIFFERENCE, and
EQUAL, to:
T.
Case 1.2.
(IMPLIES (AND (EQUAL (SUB1 X) 0)
(NOT (ZEROP (SUB1 X)))
(NOT (ZEROP X))
(EQUAL (DIFFERENCE (SUB1 (SUB1 X)) (SUB1 X))
0))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which again simplifies, unfolding the function ZEROP, to:
T.
Case 1.1.
(IMPLIES (AND (LESSP X 1)
(NOT (ZEROP (SUB1 X)))
(NOT (ZEROP X))
(EQUAL (DIFFERENCE (SUB1 (SUB1 X)) (SUB1 X))
0))
(EQUAL (DIFFERENCE (SUB1 X) X) 0)),
which again simplifies, applying SUB1-NNUMBERP, and unfolding the
definitions of SUB1, NUMBERP, EQUAL, LESSP, and ZEROP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-BY-LARGER-NUMBER
(DISABLE DIFFERENCE-BY-LARGER-NUMBER)
[ 0.0 0.0 0.0 ]
DIFFERENCE-BY-LARGER-NUMBER-OFF
(PROVE-LEMMA DIFFERENCE-ADD1-ARG1
(REWRITE)
(IMPLIES (IF (LESSP A B) '*1*FALSE '*1*TRUE)
(EQUAL (DIFFERENCE (ADD1 A) B)
(ADD1 (DIFFERENCE A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP (ADD1 A) B)
(NOT (LESSP A B)))
(EQUAL (DIFFERENCE (ADD1 A) B)
(ADD1 (DIFFERENCE A B)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-ARG1
(DISABLE DIFFERENCE-ADD1-ARG1)
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-ARG1-OFF
(PROVE-LEMMA DIFFERENCE-ADD1-ARG2
(REWRITE)
(IMPLIES (LESSP B A)
(EQUAL (DIFFERENCE A (ADD1 B))
(SUB1 (DIFFERENCE A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to the following two new
conjectures:
Case 2. (IMPLIES (AND (LESSP A (ADD1 B)) (LESSP B A))
(EQUAL (DIFFERENCE A (ADD1 B))
(SUB1 (DIFFERENCE A B)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (LESSP A B) (LESSP B A))
(EQUAL (DIFFERENCE A (ADD1 B))
(SUB1 (DIFFERENCE A B)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-ARG2
(DISABLE DIFFERENCE-ADD1-ARG2)
[ 0.0 0.0 0.0 ]
DIFFERENCE-ADD1-ARG2-OFF
(PROVE-LEMMA SUB1-DIFFERENCE
(REWRITE)
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))
((INDUCT (DOUBLE-NUMBER-INDUCTION A B))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, OR, and
AND, to the following two new formulas:
Case 2. (IMPLIES (OR (ZEROP A) (ZEROP B))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))).
This simplifies, using linear arithmetic, to the following four new goals:
Case 2.4.
(IMPLIES (AND (NOT (LESSP B A))
(OR (ZEROP A) (ZEROP B)))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))).
However this again simplifies, appealing to the lemma SUB1-NNUMBERP, and
expanding the definitions of ZEROP, OR, EQUAL, DIFFERENCE, and SUB1, to
eight new formulas:
Case 2.4.8.
(IMPLIES (AND (NOT (LESSP B A))
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))),
which again simplifies, trivially, to:
T.
Case 2.4.7.
(IMPLIES (AND (NOT (LESSP B A))
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, applying SUB1-NNUMBERP, and opening up the
definitions of LESSP and EQUAL, to:
T.
Case 2.4.6.
(IMPLIES (AND (NOT (LESSP B A))
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)).
This again simplifies, clearly, to:
T.
Case 2.4.5.
(IMPLIES (AND (NOT (LESSP B A))
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
However this again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP A 1)
(NOT (LESSP 0 A))
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
This again simplifies, rewriting with SUB1-NNUMBERP, and expanding
NUMBERP, EQUAL, LESSP, and SUB1, to:
T.
Case 2.4.4.
(IMPLIES (AND (NOT (LESSP B A))
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, trivially, to:
T.
Case 2.4.3.
(IMPLIES (AND (NOT (LESSP B A))
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
But this again simplifies, applying SUB1-NNUMBERP, and expanding LESSP
and EQUAL, to:
T.
Case 2.4.2.
(IMPLIES (AND (NOT (LESSP B A))
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)).
This again simplifies, clearly, to:
T.
Case 2.4.1.
(IMPLIES (AND (NOT (LESSP B A))
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
This again simplifies, applying SUB1-NNUMBERP, and expanding LESSP,
EQUAL, and SUB1, to:
T.
Case 2.3.
(IMPLIES (AND (LESSP A B)
(OR (ZEROP A) (ZEROP B)))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))).
However this again simplifies, applying SUB1-NNUMBERP, and opening up the
functions ZEROP, OR, EQUAL, DIFFERENCE, and SUB1, to the following eight
new goals:
Case 2.3.8.
(IMPLIES (AND (LESSP A B)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, clearly, to:
T.
Case 2.3.7.
(IMPLIES (AND (LESSP A B)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.3.6.
(IMPLIES (AND (LESSP A B)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)),
which again simplifies, obviously, to:
T.
Case 2.3.5.
(IMPLIES (AND (LESSP A B)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
This again simplifies, using linear arithmetic, to:
T.
Case 2.3.4.
(IMPLIES (AND (LESSP A B)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))),
which again simplifies, clearly, to:
T.
Case 2.3.3.
(IMPLIES (AND (LESSP A B)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
But this again simplifies, unfolding LESSP, to:
T.
Case 2.3.2.
(IMPLIES (AND (LESSP A B)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)),
which again simplifies, trivially, to:
T.
Case 2.3.1.
(IMPLIES (AND (LESSP A B)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
However this again simplifies, unfolding the function LESSP, to:
T.
Case 2.2.
(IMPLIES (AND (LESSP (SUB1 A) B)
(OR (ZEROP A) (ZEROP B)))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))),
which again simplifies, rewriting with SUB1-NNUMBERP, and unfolding the
definitions of ZEROP, OR, EQUAL, DIFFERENCE, and SUB1, to the following
eight new conjectures:
Case 2.2.8.
(IMPLIES (AND (LESSP (SUB1 A) B)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, obviously, to:
T.
Case 2.2.7.
(IMPLIES (AND (LESSP (SUB1 A) B)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, applying SUB1-NNUMBERP, and expanding the
definition of LESSP, to:
T.
Case 2.2.6.
(IMPLIES (AND (LESSP (SUB1 A) B)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)).
This again simplifies, trivially, to:
T.
Case 2.2.5.
(IMPLIES (AND (LESSP (SUB1 A) B)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
But this again simplifies, using linear arithmetic, to:
T.
Case 2.2.4.
(IMPLIES (AND (LESSP (SUB1 A) B)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))),
which again simplifies, clearly, to:
T.
Case 2.2.3.
(IMPLIES (AND (LESSP (SUB1 A) B)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
But this again simplifies, appealing to the lemma SUB1-NNUMBERP, and
unfolding LESSP, to:
T.
Case 2.2.2.
(IMPLIES (AND (LESSP (SUB1 A) B)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)),
which again simplifies, trivially, to:
T.
Case 2.2.1.
(IMPLIES (AND (LESSP (SUB1 A) B)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
But this again simplifies, opening up the definition of LESSP, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A 1)
(OR (ZEROP A) (ZEROP B)))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))),
which again simplifies, applying the lemma SUB1-NNUMBERP, and expanding
the functions ZEROP, OR, EQUAL, DIFFERENCE, and SUB1, to eight new
conjectures:
Case 2.1.8.
(IMPLIES (AND (LESSP A 1)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))),
which again simplifies, trivially, to:
T.
Case 2.1.7.
(IMPLIES (AND (LESSP A 1)
(EQUAL B 0)
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
But this again simplifies, rewriting with SUB1-NNUMBERP, and unfolding
NUMBERP, EQUAL, and LESSP, to:
T.
Case 2.1.6.
(IMPLIES (AND (LESSP A 1)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)).
This again simplifies, obviously, to:
T.
Case 2.1.5.
(IMPLIES (AND (LESSP A 1)
(EQUAL B 0)
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
But this again simplifies, rewriting with SUB1-NNUMBERP, and opening up
the definitions of NUMBERP, EQUAL, LESSP, and SUB1, to:
T.
Case 2.1.4.
(IMPLIES (AND (LESSP A 1)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(EQUAL A 0))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, clearly, to:
T.
Case 2.1.3.
(IMPLIES (AND (LESSP A 1)
(NOT (NUMBERP B))
(NOT (EQUAL (SUB1 A) 0))
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) (SUB1 A))).
This again simplifies, rewriting with SUB1-NNUMBERP, and unfolding the
definitions of NUMBERP, EQUAL, and LESSP, to:
T.
Case 2.1.2.
(IMPLIES (AND (LESSP A 1)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(EQUAL A 0))
(EQUAL (SUB1 0) 0)).
This again simplifies, clearly, to:
T.
Case 2.1.1.
(IMPLIES (AND (LESSP A 1)
(NOT (NUMBERP B))
(EQUAL (SUB1 A) 0)
(NOT (NUMBERP A)))
(EQUAL (SUB1 0) 0)).
But this again simplifies, applying SUB1-NNUMBERP, and expanding NUMBERP,
EQUAL, LESSP, and SUB1, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A))
(SUB1 B))))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))).
This simplifies, using linear arithmetic, to the following three new
conjectures:
Case 1.3.
(IMPLIES (AND (NOT (LESSP B A))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A))
(SUB1 B))))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))).
But this again simplifies, expanding the functions LESSP and DIFFERENCE,
to:
(IMPLIES (AND (NOT (LESSP (SUB1 B) (SUB1 A)))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B)))
(EQUAL (SUB1 A) 0))
(EQUAL (DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B))
0)).
However this again simplifies, expanding EQUAL, LESSP, DIFFERENCE, and
SUB1, to:
T.
Case 1.2.
(IMPLIES (AND (LESSP A B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A))
(SUB1 B))))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))),
which again simplifies, expanding LESSP and DIFFERENCE, to:
(IMPLIES (AND (LESSP (SUB1 A) (SUB1 B))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B)))
(EQUAL (SUB1 A) 0))
(EQUAL (DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B))
0)).
This again simplifies, unfolding EQUAL, LESSP, DIFFERENCE, and SUB1, to:
T.
Case 1.1.
(IMPLIES (AND (LESSP (SUB1 A) B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A))
(SUB1 B))))
(EQUAL (SUB1 (DIFFERENCE A B))
(DIFFERENCE (SUB1 A) B))),
which again simplifies, unfolding LESSP, EQUAL, DIFFERENCE, and SUB1, to:
(IMPLIES (AND (LESSP (SUB1 (SUB1 A)) (SUB1 B))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL (SUB1 (DIFFERENCE (SUB1 A) (SUB1 B)))
(DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B)))
(EQUAL (SUB1 A) 0))
(EQUAL (DIFFERENCE (SUB1 (SUB1 A)) (SUB1 B))
0)).
However this again simplifies, unfolding the functions SUB1, EQUAL, LESSP,
and DIFFERENCE, to:
T.
Q.E.D.
[ 0.1 0.0 0.0 ]
SUB1-DIFFERENCE
(DISABLE SUB1-DIFFERENCE)
[ 0.0 0.0 0.0 ]
SUB1-DIFFERENCE-OFF
(PROVE-LEMMA DIFFERENCE-SUB1-ARG1
(REWRITE)
(IMPLIES (LESSP B A)
(EQUAL (DIFFERENCE (SUB1 A) B)
(SUB1 (DIFFERENCE A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to the following three
new conjectures:
Case 3. (IMPLIES (AND (LESSP (SUB1 A) B) (LESSP B A))
(EQUAL (DIFFERENCE (SUB1 A) B)
(SUB1 (DIFFERENCE A B)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LESSP A 1) (LESSP B A))
(EQUAL (DIFFERENCE (SUB1 A) B)
(SUB1 (DIFFERENCE A B)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (LESSP A B) (LESSP B A))
(EQUAL (DIFFERENCE (SUB1 A) B)
(SUB1 (DIFFERENCE A B)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-SUB1-ARG1
(DISABLE DIFFERENCE-SUB1-ARG1)
[ 0.0 0.0 0.0 ]
DIFFERENCE-SUB1-ARG1-OFF
(PROVE-LEMMA DIFFERENCE-SUB1-ARG2
(REWRITE)
(IMPLIES (AND (NOT (ZEROP B))
(IF (LESSP A B) '*1*FALSE '*1*TRUE))
(EQUAL (DIFFERENCE A (SUB1 B))
(ADD1 (DIFFERENCE A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP A B)))
(EQUAL (DIFFERENCE A (SUB1 B))
(ADD1 (DIFFERENCE A B)))).
This simplifies, using linear arithmetic, to the new formula:
(IMPLIES (AND (LESSP A (SUB1 B))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP A B)))
(EQUAL (DIFFERENCE A (SUB1 B))
(ADD1 (DIFFERENCE A B)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-SUB1-ARG2
(DISABLE DIFFERENCE-SUB1-ARG2)
[ 0.0 0.0 0.0 ]
DIFFERENCE-SUB1-ARG2-OFF
(PROVE-LEMMA DIFFERENCE-PLUS-CANCELLATION2-INSTANCE
(REWRITE)
(IMPLIES (IF (LESSP A C) '*1*FALSE '*1*TRUE)
(EQUAL (DIFFERENCE (PLUS (ADD1 A) B)
(ADD1 C))
(PLUS (DIFFERENCE A C) B)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP (PLUS (ADD1 A) B) (ADD1 C))
(NOT (LESSP A C)))
(EQUAL (DIFFERENCE (PLUS (ADD1 A) B)
(ADD1 C))
(PLUS (DIFFERENCE A C) B))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS-CANCELLATION2-INSTANCE
(DISABLE DIFFERENCE-PLUS-CANCELLATION2-INSTANCE)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS-CANCELLATION2-INSTANCE-OFF
(PROVE-LEMMA DIFFERENCE-DIFFERENCE
(REWRITE)
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to the following three new
conjectures:
Case 3. (IMPLIES (LESSP (DIFFERENCE A B) C)
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))).
Give the above formula the name *1.
Case 2. (IMPLIES (LESSP A B)
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C))).
We gave this the name *1 above. Perhaps we can prove it by induction. There
are five plausible inductions. They merge into two likely candidate
inductions. However, only one is unflawed. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP A) (p A B C))
(IMPLIES (AND (NOT (ZEROP A)) (ZEROP B))
(p A B C))
(IMPLIES (AND (NOT (ZEROP A))
(NOT (ZEROP B))
(p (SUB1 A) (SUB1 B) C))
(p A B C))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT A) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for B. The above induction scheme produces the
following three new conjectures:
Case 3. (IMPLIES (ZEROP A)
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))).
This simplifies, using linear arithmetic, to the following three new goals:
Case 3.3.
(IMPLIES (AND (LESSP (DIFFERENCE A B) C)
(ZEROP A))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))).
But this again simplifies, unfolding the functions DIFFERENCE, ZEROP,
EQUAL, and PLUS, to:
T.
Case 3.2.
(IMPLIES (AND (LESSP A B) (ZEROP A))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, opening up ZEROP, EQUAL, DIFFERENCE, and PLUS, to:
T.
Case 3.1.
(IMPLIES (AND (LESSP A (PLUS B C)) (ZEROP A))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, opening up the definitions of PLUS, ZEROP, EQUAL,
and DIFFERENCE, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP A)) (ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which simplifies, using linear arithmetic, to three new conjectures:
Case 2.3.
(IMPLIES (AND (LESSP (DIFFERENCE A B) C)
(NOT (ZEROP A))
(ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, expanding the definitions of DIFFERENCE, ZEROP,
EQUAL, and PLUS, to two new formulas:
Case 2.3.2.
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL B 0)
(LESSP A C)
(NOT (NUMBERP C)))
(EQUAL (DIFFERENCE A C)
(DIFFERENCE A 0))),
which again simplifies, unfolding the definition of LESSP, to:
T.
Case 2.3.1.
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (NUMBERP B))
(LESSP A C)
(NOT (NUMBERP C)))
(EQUAL (DIFFERENCE A C)
(DIFFERENCE A 0))),
which again simplifies, expanding LESSP, to:
T.
Case 2.2.
(IMPLIES (AND (LESSP A B)
(NOT (ZEROP A))
(ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, unfolding the definitions of ZEROP, EQUAL,
DIFFERENCE, and PLUS, to two new goals:
Case 2.2.2.
(IMPLIES (AND (LESSP A B)
(NOT (EQUAL A 0))
(NUMBERP A)
(EQUAL B 0)
(NOT (NUMBERP C)))
(EQUAL (DIFFERENCE A C)
(DIFFERENCE A 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.1.
(IMPLIES (AND (LESSP A B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (NUMBERP B))
(NOT (NUMBERP C)))
(EQUAL (DIFFERENCE A C)
(DIFFERENCE A 0))),
which again simplifies, expanding LESSP, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A (PLUS B C))
(NOT (ZEROP A))
(ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, opening up the functions PLUS, ZEROP, EQUAL, and
DIFFERENCE, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE (SUB1 A) (SUB1 B))
C)
(DIFFERENCE (SUB1 A)
(PLUS (SUB1 B) C))))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which simplifies, using linear arithmetic, to three new conjectures:
Case 1.3.
(IMPLIES (AND (LESSP (DIFFERENCE A B) C)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE (SUB1 A) (SUB1 B))
C)
(DIFFERENCE (SUB1 A)
(PLUS (SUB1 B) C))))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, rewriting with SUB1-ADD1, and opening up the
definitions of DIFFERENCE, ZEROP, and PLUS, to:
T.
Case 1.2.
(IMPLIES (AND (LESSP A B)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE (SUB1 A) (SUB1 B))
C)
(DIFFERENCE (SUB1 A)
(PLUS (SUB1 B) C))))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))).
But this again simplifies, appealing to the lemma SUB1-ADD1, and opening
up the definitions of LESSP, ZEROP, DIFFERENCE, and PLUS, to:
T.
Case 1.1.
(IMPLIES (AND (LESSP A (PLUS B C))
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (DIFFERENCE (SUB1 A) (SUB1 B))
C)
(DIFFERENCE (SUB1 A)
(PLUS (SUB1 B) C))))
(EQUAL (DIFFERENCE (DIFFERENCE A B) C)
(DIFFERENCE A (PLUS B C)))),
which again simplifies, applying SUB1-ADD1, and unfolding PLUS, ZEROP, and
DIFFERENCE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-DIFFERENCE
(DISABLE DIFFERENCE-DIFFERENCE)
[ 0.0 0.0 0.0 ]
DIFFERENCE-DIFFERENCE-OFF
(PROVE-LEMMA YET-ANOTHER-DIFFERENCE-PLUS-CROCK
(REWRITE)
(EQUAL (DIFFERENCE (PLUS N (PLUS B A)) A)
(PLUS N B))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
(IMPLIES (LESSP (PLUS N B A) A)
(EQUAL (DIFFERENCE (PLUS N B A) A)
(PLUS N B))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
YET-ANOTHER-DIFFERENCE-PLUS-CROCK
(DISABLE YET-ANOTHER-DIFFERENCE-PLUS-CROCK)
[ 0.0 0.0 0.0 ]
YET-ANOTHER-DIFFERENCE-PLUS-CROCK-OFF
(PROVE-LEMMA NON-ZERO-DIFFERENCE
(REWRITE)
(IMPLIES (AND (NUMBERP A) (LESSP A B))
(NOT (EQUAL (DIFFERENCE B A) '0)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
NON-ZERO-DIFFERENCE
(DISABLE NON-ZERO-DIFFERENCE)
[ 0.0 0.0 0.0 ]
NON-ZERO-DIFFERENCE-OFF
(PROVE-LEMMA REWRITE-NON-ZERO-DIFFERENCE-AS-LESSP
(REWRITE)
(EQUAL (NOT (EQUAL (DIFFERENCE A B) '0))
(LESSP B A))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the rewrite rule REWRITE-NON-ZERO-DIFFERENCE-AS-LESSP will
be stored so as to apply only to terms with the nonrecursive function symbol
NOT.
This conjecture simplifies, unfolding NOT, to two new conjectures:
Case 2. (IMPLIES (NOT (EQUAL (DIFFERENCE A B) 0))
(EQUAL T (LESSP B A))),
which again simplifies, trivially, to:
(IMPLIES (NOT (EQUAL (DIFFERENCE A B) 0))
(LESSP B A)),
which we will name *1.
Case 1. (IMPLIES (EQUAL (DIFFERENCE A B) 0)
(EQUAL F (LESSP B A))).
This again simplifies, obviously, to:
(IMPLIES (EQUAL (DIFFERENCE A B) 0)
(NOT (LESSP B A))),
which again simplifies, using linear arithmetic, to:
T.
So next consider:
(IMPLIES (NOT (EQUAL (DIFFERENCE A B) 0))
(LESSP B A)),
which is formula *1 above. We will try to prove it by induction. Four
inductions are suggested by terms in the conjecture. However, they merge into
one likely candidate induction. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP A) (p B A))
(IMPLIES (AND (NOT (ZEROP A)) (ZEROP B))
(p B A))
(IMPLIES (AND (NOT (ZEROP A))
(NOT (ZEROP B))
(p (SUB1 B) (SUB1 A)))
(p B A))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT A) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instance chosen for B. The above induction scheme generates four new goals:
Case 4. (IMPLIES (AND (ZEROP A)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which simplifies, expanding ZEROP, EQUAL, and DIFFERENCE, to:
T.
Case 3. (IMPLIES (AND (NOT (ZEROP A))
(ZEROP B)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which simplifies, opening up the functions ZEROP, EQUAL, DIFFERENCE, and
LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which simplifies, using linear arithmetic, to three new formulas:
Case 2.3.
(IMPLIES (AND (LESSP A B)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which again simplifies, using linear arithmetic, to two new formulas:
Case 2.3.2.
(IMPLIES (AND (LESSP (SUB1 A) (SUB1 B))
(LESSP A B)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which again simplifies, expanding the definitions of LESSP, ZEROP,
DIFFERENCE, and EQUAL, to:
T.
Case 2.3.1.
(IMPLIES (AND (LESSP A 1)
(LESSP A B)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which again simplifies, opening up the functions SUB1, NUMBERP, EQUAL,
LESSP, and ZEROP, to:
T.
Case 2.2.
(IMPLIES (AND (LESSP (SUB1 A) (SUB1 B))
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which again simplifies, unfolding the functions ZEROP, DIFFERENCE, and
EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A 1)
(NOT (ZEROP A))
(NOT (ZEROP B))
(EQUAL (DIFFERENCE (SUB1 A) (SUB1 B))
0)
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which again simplifies, unfolding the definitions of SUB1, NUMBERP, EQUAL,
LESSP, and ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(NOT (ZEROP B))
(LESSP (SUB1 B) (SUB1 A))
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)),
which simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP A 1)
(NOT (ZEROP A))
(NOT (ZEROP B))
(LESSP (SUB1 B) (SUB1 A))
(NOT (EQUAL (DIFFERENCE A B) 0)))
(LESSP B A)).
But this again simplifies, unfolding the definitions of SUB1, NUMBERP, EQUAL,
LESSP, and ZEROP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
REWRITE-NON-ZERO-DIFFERENCE-AS-LESSP
(DISABLE REWRITE-NON-ZERO-DIFFERENCE-AS-LESSP)
[ 0.0 0.0 0.0 ]
REWRITE-NON-ZERO-DIFFERENCE-AS-LESSP-OFF
(PROVE-LEMMA REWRITE-ZERO-DIFFERENCE-AS-EQUALITY
(REWRITE)
(IMPLIES (IF (LESSP A B) '*1*FALSE '*1*TRUE)
(EQUAL (EQUAL (DIFFERENCE A B) '0)
(EQUAL (FIX A) (FIX B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, expanding the definition of FIX, to seven new goals:
Case 7. (IMPLIES (AND (NOT (LESSP A B))
(NUMBERP B)
(NUMBERP A)
(NOT (EQUAL A B)))
(NOT (EQUAL (DIFFERENCE A B) 0))),
which again simplifies, using linear arithmetic, to:
T.
Case 6. (IMPLIES (AND (NOT (LESSP A B))
(NUMBERP B)
(NOT (NUMBERP A))
(NOT (EQUAL 0 B)))
(NOT (EQUAL (DIFFERENCE A B) 0))),
which again simplifies, unfolding the function LESSP, to:
T.
Case 5. (IMPLIES (AND (NOT (LESSP A B))
(NOT (NUMBERP B))
(NUMBERP A)
(NOT (EQUAL A 0)))
(NOT (EQUAL (DIFFERENCE A B) 0))),
which again simplifies, expanding the functions LESSP and DIFFERENCE, to:
T.
Case 4. (IMPLIES (AND (NOT (LESSP A B))
(NOT (NUMBERP B))
(NOT (NUMBERP A)))
(EQUAL (EQUAL (DIFFERENCE A B) 0) T)),
which again simplifies, opening up LESSP, DIFFERENCE, and EQUAL, to:
T.
Case 3. (IMPLIES (AND (NOT (LESSP A B))
(NOT (NUMBERP B))
(EQUAL A 0))
(EQUAL (EQUAL (DIFFERENCE A B) 0) T)),
which again simplifies, opening up the definitions of LESSP, EQUAL, and
DIFFERENCE, to:
T.
Case 2. (IMPLIES (AND (NOT (LESSP A B))
(NOT (NUMBERP A))
(EQUAL 0 B))
(EQUAL (EQUAL (DIFFERENCE A B) 0) T)),
which again simplifies, expanding the functions EQUAL, LESSP, and DIFFERENCE,
to:
T.
Case 1. (IMPLIES (AND (NOT (LESSP A B))
(NUMBERP B)
(NUMBERP A)
(EQUAL A B))
(EQUAL (EQUAL (DIFFERENCE A B) 0) T)),
which again simplifies, trivially, to the new formula:
(IMPLIES (AND (NOT (LESSP B B)) (NUMBERP B))
(EQUAL (DIFFERENCE B B) 0)),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REWRITE-ZERO-DIFFERENCE-AS-EQUALITY
(DISABLE REWRITE-ZERO-DIFFERENCE-AS-EQUALITY)
[ 0.0 0.0 0.0 ]
REWRITE-ZERO-DIFFERENCE-AS-EQUALITY-OFF
(PROVE-LEMMA REGROUP-FACT
(REWRITE)
(IMPLIES (AND (IF (LESSP A C) '*1*FALSE '*1*TRUE)
(IF (LESSP B D) '*1*FALSE '*1*TRUE))
(EQUAL (DIFFERENCE (PLUS A B) (PLUS C D))
(PLUS (DIFFERENCE A C)
(DIFFERENCE B D))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to the new goal:
(IMPLIES (AND (LESSP (PLUS A B) (PLUS C D))
(NOT (LESSP A C))
(NOT (LESSP B D)))
(EQUAL (DIFFERENCE (PLUS A B) (PLUS C D))
(PLUS (DIFFERENCE A C)
(DIFFERENCE B D)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REGROUP-FACT
(DISABLE REGROUP-FACT)
[ 0.0 0.0 0.0 ]
REGROUP-FACT-OFF
(PROVE-LEMMA DIFFERENCE-EQUALS-0
(REWRITE)
(IMPLIES (AND (NUMBERP A)
(AND (NUMBERP B)
(IF (LESSP A B)
'*1*FALSE
'*1*TRUE)))
(EQUAL (EQUAL (DIFFERENCE A B) '0)
(EQUAL A B)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, trivially, to the following two new conjectures:
Case 2. (IMPLIES (AND (NUMBERP A)
(NUMBERP B)
(NOT (LESSP A B))
(NOT (EQUAL A B)))
(NOT (EQUAL (DIFFERENCE A B) 0))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NUMBERP A)
(NUMBERP B)
(NOT (LESSP A B))
(EQUAL A B))
(EQUAL (EQUAL (DIFFERENCE A B) 0) T)),
which again simplifies, obviously, to the new goal:
(IMPLIES (AND (NUMBERP B) (NOT (LESSP B B)))
(EQUAL (DIFFERENCE B B) 0)),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-EQUALS-0
(DISABLE DIFFERENCE-EQUALS-0)
[ 0.0 0.0 0.0 ]
DIFFERENCE-EQUALS-0-OFF
(PROVE-LEMMA TIMES-ZERO3
(REWRITE)
(EQUAL (TIMES X '0) '0)
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP X) (p X))
(IMPLIES (AND (NOT (ZEROP X)) (p (SUB1 X)))
(p X))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates the following two new formulas:
Case 2. (IMPLIES (ZEROP X)
(EQUAL (TIMES X 0) 0)).
This simplifies, expanding the definitions of ZEROP, TIMES, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (TIMES (SUB1 X) 0) 0))
(EQUAL (TIMES X 0) 0)).
This simplifies, opening up the functions ZEROP, TIMES, PLUS, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
TIMES-ZERO3
(DISABLE TIMES-ZERO3)
[ 0.0 0.0 0.0 ]
TIMES-ZERO3-OFF
(PROVE-LEMMA DISTRIBUTIVITY-OF-TIMES-OVER-DIFFERENCE
(REWRITE)
(EQUAL (DIFFERENCE (TIMES A B) (TIMES A C))
(TIMES A (DIFFERENCE B C)))
((ENABLE TIMES-DIFFERENCE COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES and
TIMES-DIFFERENCE, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-DIFFERENCE
(DISABLE DISTRIBUTIVITY-OF-TIMES-OVER-DIFFERENCE)
[ 0.0 0.0 0.0 ]
DISTRIBUTIVITY-OF-TIMES-OVER-DIFFERENCE-OFF
(PROVE-LEMMA EXP-2-NEVER-0
(REWRITE)
(EQUAL (LESSP '0 (EXP '2 I))
'*1*TRUE)
((ENABLE EXP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding the definitions of EQUAL and LESSP, to:
(NOT (EQUAL (EXP 2 I) 0)),
which we will name *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP I) (p I))
(IMPLIES (AND (NOT (ZEROP I)) (p (SUB1 I)))
(p I))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT I) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
produces the following two new goals:
Case 2. (IMPLIES (ZEROP I)
(NOT (EQUAL (EXP 2 I) 0))).
This simplifies, expanding the definitions of ZEROP, EQUAL, and EXP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP I))
(NOT (EQUAL (EXP 2 (SUB1 I)) 0)))
(NOT (EQUAL (EXP 2 I) 0))).
This simplifies, opening up the functions ZEROP and EXP, to:
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (EXP 2 (SUB1 I)) 0)))
(NOT (EQUAL (TIMES 2 (EXP 2 (SUB1 I)))
0))),
which again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-2-NEVER-0
(DISABLE EXP-2-NEVER-0)
[ 0.0 0.0 0.0 ]
EXP-2-NEVER-0-OFF
(PROVE-LEMMA EXP-2-NEVER-0-LINEAR
(REWRITE)
(LESSP '0 (EXP '2 I))
((ENABLE EXP-2-NEVER-0)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma EXP-2-NEVER-0-LINEAR is to be stored as
zero type prescription rules, zero compound recognizer rules, one linear rule,
and zero replacement rules.
This conjecture can be simplified, using the abbreviation EXP-2-NEVER-0, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
EXP-2-NEVER-0-LINEAR
(DISABLE EXP-2-NEVER-0-LINEAR)
[ 0.0 0.0 0.0 ]
EXP-2-NEVER-0-LINEAR-OFF
(PROVE-LEMMA REMAINDER-NOOP
(REWRITE)
(IMPLIES (AND (NUMBERP A)
(AND (LESSP A B) (NOT (ZEROP B))))
(EQUAL (REMAINDER A B) A))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to the goal:
(IMPLIES (AND (NUMBERP A)
(LESSP A B)
(NOT (EQUAL B 0))
(NUMBERP B))
(EQUAL (REMAINDER A B) A)).
This simplifies, unfolding REMAINDER, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-NOOP
(DISABLE REMAINDER-NOOP)
[ 0.0 0.0 0.0 ]
REMAINDER-NOOP-OFF
(PROVE-LEMMA REMAINDER-ADD1-CASESPLIT
(REWRITE)
(IMPLIES (LESSP A B)
(EQUAL (REMAINDER (ADD1 A) B)
(IF (EQUAL (ADD1 A) B) '0 (ADD1 A))))
((ENABLE REMAINDER REMAINDER-NOOP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, clearly, to two new conjectures:
Case 2. (IMPLIES (AND (LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which we will name *1.
Case 1. (IMPLIES (AND (LESSP A B) (EQUAL (ADD1 A) B))
(EQUAL (REMAINDER (ADD1 A) B) 0)).
However this again simplifies, using linear arithmetic, applying SUB1-ADD1,
SUB1-TYPE-RESTRICTION, and REMAINDER-NOOP, and opening up the definitions of
LESSP, ADD1, REMAINDER, EQUAL, and DIFFERENCE, to the following four new
goals:
Case 1.4.
(IMPLIES (AND (LESSP (SUB1 A) A)
(NUMBERP A)
(NOT (LESSP A A)))
(EQUAL (DIFFERENCE A A) 0)).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (LESSP (SUB1 A) A)
(NUMBERP A)
(LESSP A A))
(EQUAL (ADD1 A) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (LESSP (SUB1 A) A)
(NOT (NUMBERP A))
(LESSP 0 0))
(EQUAL (ADD1 A) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (LESSP (SUB1 A) A)
(NOT (NUMBERP A))
(NOT (LESSP 0 0)))
(EQUAL (DIFFERENCE 0 0) 0)),
which again simplifies, using linear arithmetic, to:
T.
So next consider:
(IMPLIES (AND (LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which we named *1 above. Let us appeal to the induction principle. The
recursive terms in the conjecture suggest two inductions. However, they merge
into one likely candidate induction. We will induct according to the
following scheme:
(AND (IMPLIES (OR (EQUAL B 0) (NOT (NUMBERP B)))
(p A B))
(IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(OR (EQUAL A 0) (NOT (NUMBERP A))))
(p A B))
(IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(p (SUB1 A) (SUB1 B)))
(p A B))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT inform us that the measure (COUNT A) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for B. The above induction scheme
produces five new goals:
Case 5. (IMPLIES (AND (OR (EQUAL B 0) (NOT (NUMBERP B)))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which simplifies, expanding the functions NOT, OR, EQUAL, and LESSP, to:
T.
Case 4. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(OR (EQUAL A 0) (NOT (NUMBERP A)))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which simplifies, rewriting with SUB1-TYPE-RESTRICTION, and unfolding NOT,
OR, EQUAL, LESSP, and ADD1, to the following two new formulas:
Case 4.2.
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(EQUAL A 0)
(NOT (EQUAL 1 B)))
(EQUAL (REMAINDER 1 B) 1)).
This again simplifies, using linear arithmetic, applying REMAINDER-NOOP,
and opening up the function EQUAL, to:
T.
Case 4.1.
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (NUMBERP A))
(NOT (EQUAL 1 B)))
(EQUAL (REMAINDER 1 B) 1)).
This again simplifies, using linear arithmetic, appealing to the lemma
REMAINDER-NOOP, and unfolding the definition of EQUAL, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(NOT (LESSP (SUB1 A) (SUB1 B)))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP A 1)
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(NOT (LESSP (SUB1 A) (SUB1 B)))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))).
However this again simplifies, expanding the functions SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (ADD1 (SUB1 A)) (SUB1 B))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which simplifies, using linear arithmetic, to two new formulas:
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP B))
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (ADD1 (SUB1 A)) (SUB1 B))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which again simplifies, unfolding the functions NOT and OR, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A 1)
(NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (ADD1 (SUB1 A)) (SUB1 B))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which again simplifies, unfolding SUB1, NUMBERP, EQUAL, LESSP, NOT, and OR,
to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL B 0) (NOT (NUMBERP B))))
(NOT (OR (EQUAL A 0) (NOT (NUMBERP A))))
(EQUAL (REMAINDER (ADD1 (SUB1 A)) (SUB1 B))
(ADD1 (SUB1 A)))
(LESSP A B)
(NOT (EQUAL (ADD1 A) B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which simplifies, using linear arithmetic, rewriting with ADD1-SUB1 and
REMAINDER-NOOP, and expanding the functions NOT, OR, and LESSP, to:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT F)
(LESSP (SUB1 A) (SUB1 B))
(NOT (EQUAL (ADD1 A) B))
(NOT (NUMBERP B)))
(EQUAL (REMAINDER (ADD1 A) B)
(ADD1 A))),
which again simplifies, clearly, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-ADD1-CASESPLIT
(DISABLE REMAINDER-ADD1-CASESPLIT)
[ 0.0 0.0 0.0 ]
REMAINDER-ADD1-CASESPLIT-OFF
(PROVE-LEMMA ZEROP-REMAINDER-DIFFERENCE
(REWRITE)
(IMPLIES (EQUAL (REMAINDER A B) '0)
(EQUAL (REMAINDER (DIFFERENCE A B) B)
'0))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, unfolding the definitions of REMAINDER, DIFFERENCE,
EQUAL, NUMBERP, and LESSP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
ZEROP-REMAINDER-DIFFERENCE
(DISABLE ZEROP-REMAINDER-DIFFERENCE)
[ 0.0 0.0 0.0 ]
ZEROP-REMAINDER-DIFFERENCE-OFF
(PROVE-LEMMA QUOTIENT-X-X
(REWRITE)
(IMPLIES (NOT (ZEROP X))
(EQUAL (QUOTIENT X X) '1))
((ENABLE DIFFERENCE-X-X)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL X 0)) (NUMBERP X))
(EQUAL (QUOTIENT X X) 1)),
which simplifies, rewriting with the lemma DIFFERENCE-X-X, and expanding the
functions QUOTIENT, LESSP, EQUAL, and ADD1, to the goal:
(IMPLIES (AND (NOT (EQUAL X 0)) (NUMBERP X))
(NOT (LESSP X X))).
But this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-X-X
(DISABLE QUOTIENT-X-X)
[ 0.0 0.0 0.0 ]
QUOTIENT-X-X-OFF
(PROVE-LEMMA REMAINDER-TIMES-OTHER-WAY
(REWRITE)
(EQUAL (REMAINDER (TIMES B A) A) '0)
((ENABLE REMAINDER-TIMES COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemmas COMMUTATIVITY-OF-TIMES and
REMAINDER-TIMES, and expanding the function EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES-OTHER-WAY
(DISABLE REMAINDER-TIMES-OTHER-WAY)
[ 0.0 0.0 0.0 ]
REMAINDER-TIMES-OTHER-WAY-OFF
(PROVE-LEMMA QUOTIENT-TIMES-OTHER-WAY
(REWRITE)
(EQUAL (QUOTIENT (TIMES B A) A)
(IF (ZEROP A) '0 (FIX B)))
((ENABLE QUOTIENT-TIMES COMMUTATIVITY-OF-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying COMMUTATIVITY-OF-TIMES and QUOTIENT-TIMES,
and expanding the functions ZEROP and FIX, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES-OTHER-WAY
(DISABLE QUOTIENT-TIMES-OTHER-WAY)
[ 0.0 0.0 0.0 ]
QUOTIENT-TIMES-OTHER-WAY-OFF
(PROVE-LEMMA QUOTIENT-DIFFERENCE
(REWRITE)
(IMPLIES (NOT (LESSP I J))
(EQUAL (QUOTIENT (DIFFERENCE I J) J)
(SUB1 (QUOTIENT I J))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, unfolding the definition of QUOTIENT, to three new
conjectures:
Case 3. (IMPLIES (AND (NOT (LESSP I J))
(NOT (EQUAL J 0))
(NUMBERP J))
(EQUAL (QUOTIENT (DIFFERENCE I J) J)
(SUB1 (ADD1 (QUOTIENT (DIFFERENCE I J) J))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (NOT (LESSP I J)) (EQUAL J 0))
(EQUAL (QUOTIENT (DIFFERENCE I J) J)
(SUB1 0))),
which again simplifies, opening up EQUAL, LESSP, DIFFERENCE, QUOTIENT, and
SUB1, to:
T.
Case 1. (IMPLIES (AND (NOT (LESSP I J))
(NOT (NUMBERP J)))
(EQUAL (QUOTIENT (DIFFERENCE I J) J)
(SUB1 0))),
which again simplifies, unfolding LESSP, DIFFERENCE, QUOTIENT, SUB1, and
EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-DIFFERENCE
(DISABLE QUOTIENT-DIFFERENCE)
[ 0.0 0.0 0.0 ]
QUOTIENT-DIFFERENCE-OFF
(PROVE-LEMMA QUOTIENT-PLUS
(REWRITE)
(IMPLIES (NOT (ZEROP A))
(EQUAL (QUOTIENT (PLUS A B) A)
(ADD1 (QUOTIENT B A))))
((EXPAND (QUOTIENT (PLUS A B) A))
(ENABLE DIFFERENCE-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL A 0)) (NUMBERP A))
(EQUAL (QUOTIENT (PLUS A B) A)
(ADD1 (QUOTIENT B A)))),
which simplifies, rewriting with DIFFERENCE-PLUS, and expanding the function
QUOTIENT, to the following two new goals:
Case 2. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP (PLUS A B) A))
(NOT (NUMBERP B)))
(EQUAL (ADD1 (QUOTIENT 0 A))
(ADD1 (QUOTIENT B A)))).
This again simplifies, opening up the definitions of LESSP, EQUAL, QUOTIENT,
and ADD1, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(LESSP (PLUS A B) A))
(EQUAL 0 (ADD1 (QUOTIENT B A)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-PLUS
(DISABLE QUOTIENT-PLUS)
[ 0.0 0.0 0.0 ]
QUOTIENT-PLUS-OFF
(PROVE-LEMMA QUOTIENT-PLUS-TIMES
(REWRITE)
(IMPLIES (LESSP C B)
(EQUAL (QUOTIENT (PLUS C (TIMES B A)) B)
(FIX A)))
((ENABLE PLUS-0 COMMUTATIVITY2-OF-PLUS COMMUTATIVITY-OF-TIMES
QUOTIENT-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying COMMUTATIVITY-OF-TIMES, and unfolding FIX,
to the following two new conjectures:
Case 2. (IMPLIES (AND (LESSP C B) (NOT (NUMBERP A)))
(EQUAL (QUOTIENT (PLUS C (TIMES A B)) B)
0)).
This again simplifies, appealing to the lemma PLUS-0, and opening up the
definition of TIMES, to two new formulas:
Case 2.2.
(IMPLIES (AND (LESSP C B)
(NOT (NUMBERP A))
(NOT (NUMBERP C)))
(EQUAL (QUOTIENT 0 B) 0)),
which again simplifies, expanding the definitions of LESSP, EQUAL, and
QUOTIENT, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP C B)
(NOT (NUMBERP A))
(NUMBERP C))
(EQUAL (QUOTIENT C B) 0)),
which again simplifies, expanding the functions QUOTIENT and EQUAL, to:
T.
Case 1. (IMPLIES (AND (LESSP C B) (NUMBERP A))
(EQUAL (QUOTIENT (PLUS C (TIMES A B)) B)
A)),
which we will name *1.
We will appeal to induction. There are four plausible inductions. They
merge into two likely candidate inductions. However, only one is unflawed.
We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p C A B))
(IMPLIES (AND (NOT (ZEROP A)) (p C (SUB1 A) B))
(p C A B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT A) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
produces the following two new goals:
Case 2. (IMPLIES (AND (ZEROP A)
(LESSP C B)
(NUMBERP A))
(EQUAL (QUOTIENT (PLUS C (TIMES A B)) B)
A)).
This simplifies, applying the lemma PLUS-0, and opening up ZEROP, NUMBERP,
EQUAL, and TIMES, to the following two new conjectures:
Case 2.2.
(IMPLIES (AND (EQUAL A 0)
(LESSP C B)
(NOT (NUMBERP C)))
(EQUAL (QUOTIENT 0 B) 0)).
This again simplifies, expanding the definitions of LESSP, EQUAL, and
QUOTIENT, to:
T.
Case 2.1.
(IMPLIES (AND (EQUAL A 0)
(LESSP C B)
(NUMBERP C))
(EQUAL (QUOTIENT C B) 0)),
which again simplifies, expanding QUOTIENT and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (QUOTIENT (PLUS C (TIMES (SUB1 A) B))
B)
(SUB1 A))
(LESSP C B)
(NUMBERP A))
(EQUAL (QUOTIENT (PLUS C (TIMES A B)) B)
A)),
which simplifies, appealing to the lemma COMMUTATIVITY2-OF-PLUS, and opening
up the definitions of ZEROP and TIMES, to the conjecture:
(IMPLIES (AND (NOT (EQUAL A 0))
(EQUAL (QUOTIENT (PLUS C (TIMES (SUB1 A) B))
B)
(SUB1 A))
(LESSP C B)
(NUMBERP A))
(EQUAL (QUOTIENT (PLUS B C (TIMES (SUB1 A) B))
B)
A)).
But this further simplifies, rewriting with COMMUTATIVITY-OF-TIMES, to the
new goal:
(IMPLIES (AND (NOT (EQUAL A 0))
(EQUAL (QUOTIENT (PLUS C (TIMES B (SUB1 A)))
B)
(SUB1 A))
(LESSP C B)
(NUMBERP A))
(EQUAL (QUOTIENT (PLUS B C (TIMES B (SUB1 A)))
B)
A)).
Applying the lemma SUB1-ELIM, replace A by (ADD1 X) to eliminate (SUB1 A).
We employ the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. This produces:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(EQUAL (QUOTIENT (PLUS C (TIMES B X)) B)
X)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B C (TIMES B X)) B)
(ADD1 X))),
which further simplifies, obviously, to the new formula:
(IMPLIES (AND (EQUAL (QUOTIENT (PLUS C (TIMES B X)) B)
X)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B C (TIMES B X)) B)
(ADD1 X))).
We use the above equality hypothesis by cross-fertilizing:
(QUOTIENT (PLUS C (TIMES B X)) B)
for X and throwing away the equality. The result is the formula:
(IMPLIES (LESSP C B)
(EQUAL (QUOTIENT (PLUS B C (TIMES B X)) B)
(ADD1 (QUOTIENT (PLUS C (TIMES B X)) B)))).
We will try to prove the above formula by generalizing it, replacing
(TIMES B X) by Y. We restrict the new variable by recalling the type
restriction lemma noted when TIMES was introduced. We would thus like to
prove:
(IMPLIES (AND (NUMBERP Y) (LESSP C B))
(EQUAL (QUOTIENT (PLUS B C Y) B)
(ADD1 (QUOTIENT (PLUS C Y) B)))),
which we generalize by replacing (PLUS C Y) by U. We restrict the new
variable by recalling the type restriction lemma noted when PLUS was
introduced. We thus obtain the new formula:
(IMPLIES (AND (NUMBERP U)
(NUMBERP Y)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B U) B)
(ADD1 (QUOTIENT U B)))),
which has an irrelevant term in it. By eliminating the term we get:
(IMPLIES (AND (NUMBERP U) (LESSP C B))
(EQUAL (QUOTIENT (PLUS B U) B)
(ADD1 (QUOTIENT U B)))),
which we will finally name *1.1.
Perhaps we can prove it by induction. Four inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions,
both of which are flawed. So we will choose the one suggested by the largest
number of nonprimitive recursive functions. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP B) (p B U C))
(IMPLIES (AND (NOT (ZEROP B)) (LESSP U B))
(p B U C))
(IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP U B))
(p B (DIFFERENCE U B) C))
(p B U C))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP establish that the measure (COUNT U) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme leads to the following three new conjectures:
Case 3. (IMPLIES (AND (ZEROP B)
(NUMBERP U)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B U) B)
(ADD1 (QUOTIENT U B)))).
This simplifies, opening up ZEROP, EQUAL, and LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP B))
(LESSP U B)
(NUMBERP U)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B U) B)
(ADD1 (QUOTIENT U B)))).
This simplifies, applying QUOTIENT-PLUS, and unfolding the definitions of
ZEROP, QUOTIENT, ADD1, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP U B))
(EQUAL (QUOTIENT (PLUS B (DIFFERENCE U B)) B)
(ADD1 (QUOTIENT (DIFFERENCE U B) B)))
(NUMBERP U)
(LESSP C B))
(EQUAL (QUOTIENT (PLUS B U) B)
(ADD1 (QUOTIENT U B)))),
which simplifies, applying the lemma QUOTIENT-PLUS, and opening up the
definitions of ZEROP and QUOTIENT, to:
T.
That finishes the proof of *1.1, which finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
QUOTIENT-PLUS-TIMES
(DISABLE QUOTIENT-PLUS-TIMES)
[ 0.0 0.0 0.0 ]
QUOTIENT-PLUS-TIMES-OFF
(PROVE-LEMMA LEQ-TIMES NIL
(IMPLIES (AND (NOT (ZEROP A))
(IF (LESSP C B) '*1*FALSE '*1*TRUE))
(IF (LESSP (TIMES A C) (TIMES A B))
'*1*FALSE
'*1*TRUE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to the conjecture:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (TIMES A C) (TIMES A B)))).
Call the above conjecture *1.
We will appeal to induction. There are four plausible inductions. They
merge into two likely candidate inductions. However, only one is unflawed.
We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p A C B))
(IMPLIES (AND (NOT (ZEROP A)) (p (SUB1 A) C B))
(p A C B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT A) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme leads
to the following three new formulas:
Case 3. (IMPLIES (AND (ZEROP A)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (TIMES A C) (TIMES A B)))).
This simplifies, unfolding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (SUB1 A) 0)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (TIMES A C) (TIMES A B)))).
This simplifies, unfolding the definitions of ZEROP and TIMES, to:
(IMPLIES (AND (EQUAL (SUB1 A) 0)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (PLUS C (TIMES (SUB1 A) C))
(PLUS B (TIMES (SUB1 A) B))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(NOT (LESSP (TIMES (SUB1 A) C)
(TIMES (SUB1 A) B)))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (TIMES A C) (TIMES A B)))),
which simplifies, unfolding the functions ZEROP and TIMES, to:
(IMPLIES (AND (NOT (LESSP (TIMES (SUB1 A) C)
(TIMES (SUB1 A) B)))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP C B)))
(NOT (LESSP (PLUS C (TIMES (SUB1 A) C))
(PLUS B (TIMES (SUB1 A) B))))).
But this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LEQ-TIMES
(PROVE-LEMMA LESSP-REMAINDER-SUB1-CROCK NIL
(IMPLIES (LESSP X N)
(LESSP (SUB1 X) N))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, using linear arithmetic, to the new conjecture:
(IMPLIES (AND (LESSP X 1) (LESSP X N))
(LESSP (SUB1 X) N)).
Applying the lemma SUB1-ELIM, replace X by (ADD1 Z) to eliminate (SUB1 X). We
use the type restriction lemma noted when SUB1 was introduced to restrict the
new variable. We would thus like to prove the following three new formulas:
Case 3. (IMPLIES (AND (EQUAL X 0)
(LESSP X 1)
(LESSP X N))
(LESSP (SUB1 X) N)).
However this further simplifies, unfolding the definitions of LESSP, EQUAL,
and SUB1, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP X))
(LESSP X 1)
(LESSP X N))
(LESSP (SUB1 X) N)),
which further simplifies, rewriting with SUB1-NNUMBERP, and expanding the
definitions of NUMBERP, EQUAL, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL (ADD1 Z) 0))
(LESSP (ADD1 Z) 1)
(LESSP (ADD1 Z) N))
(LESSP Z N)).
But this further simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER-SUB1-CROCK
(PROVE-LEMMA LEQ-PLUS NIL
(IMPLIES (IF (LESSP C (PLUS A B))
'*1*FALSE
'*1*TRUE)
(IF (LESSP C A) '*1*FALSE '*1*TRUE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LEQ-PLUS
(PROVE-LEMMA LEQ-PLUS1 NIL
(IMPLIES (IF (LESSP C (PLUS A B))
'*1*FALSE
'*1*TRUE)
(AND (IF (LESSP C A) '*1*FALSE '*1*TRUE)
(IF (LESSP C B)
'*1*FALSE
'*1*TRUE)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, unfolding the definition of AND, to two new formulas:
Case 2. (IMPLIES (NOT (LESSP C (PLUS A B)))
(NOT (LESSP C A))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (NOT (LESSP C (PLUS A B)))
(NOT (LESSP C B))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LEQ-PLUS1
(PROVE-LEMMA LEQ-PLUS2 NIL
(IMPLIES (IF (LESSP C (PLUS A B))
'*1*FALSE
'*1*TRUE)
(EQUAL (LESSP C A) '*1*FALSE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LEQ-PLUS2
(PROVE-LEMMA LEQ-CASESPLIT NIL
(IMPLIES (AND (NUMBERP A) (NUMBERP B))
(EQUAL (IF (LESSP B A) '*1*FALSE '*1*TRUE)
(OR (LESSP A B) (EQUAL A B))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding OR, to the following three new
conjectures:
Case 3. (IMPLIES (AND (NUMBERP A)
(NUMBERP B)
(LESSP B A))
(EQUAL F (EQUAL A B))).
This again simplifies, obviously, to:
(IMPLIES (AND (NUMBERP B) (LESSP B B))
(NOT (EQUAL A B))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (NUMBERP A)
(NUMBERP B)
(NOT (LESSP A B))
(NOT (LESSP B A)))
(EQUAL T (EQUAL A B))),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NUMBERP A)
(NUMBERP A)
(NOT (LESSP A A))
(NOT (LESSP A A)))
(EQUAL T (EQUAL A A))).
But this again simplifies, expanding the definition of EQUAL, to:
T.
Case 1. (IMPLIES (AND (NUMBERP A)
(NUMBERP B)
(LESSP A B))
(NOT (LESSP B A))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LEQ-CASESPLIT
(PROVE-LEMMA INTEGER-INEQUALITY-CASESPLIT NIL
(IMPLIES (AND (NUMBERP I) (NUMBERP J))
(EQUAL (NOT (EQUAL I J))
(OR (LESSP I J) (LESSP J I))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding the functions NOT and OR, to the
following three new formulas:
Case 3. (IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(EQUAL I J))
(EQUAL F (LESSP J I))).
This again simplifies, clearly, to the new conjecture:
(IMPLIES (NUMBERP J)
(NOT (LESSP J J))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(NOT (LESSP I J))
(NOT (EQUAL I J)))
(EQUAL T (LESSP J I))),
which again simplifies, obviously, to:
(IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(NOT (LESSP I J))
(NOT (EQUAL I J)))
(LESSP J I)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(LESSP I J))
(NOT (EQUAL I J))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
INTEGER-INEQUALITY-CASESPLIT
(PROVE-LEMMA INTEGER-EQUALITY-CROCK NIL
(IMPLIES (AND (NUMBERP A)
(AND (NUMBERP B)
(AND (LESSP A '1) (LESSP B '1))))
(EQUAL A B))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
INTEGER-EQUALITY-CROCK
(PROVE-LEMMA LESSP-REMAINDER-REMAINDER
(REWRITE)
(IMPLIES (AND (NOT (ZEROP C))
(NOT (ZEROP (REMAINDER B C))))
(EQUAL (LESSP (REMAINDER A (REMAINDER B C))
C)
'*1*TRUE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to the new formula:
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0))
(NUMBERP (REMAINDER B C)))
(EQUAL (LESSP (REMAINDER A (REMAINDER B C))
C)
T)),
which simplifies, obviously, to:
(IMPLIES (AND (NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0)))
(LESSP (REMAINDER A (REMAINDER B C))
C)),
which we will name *1.
Perhaps we can prove it by induction. The recursive terms in the
conjecture suggest four inductions. They merge into three likely candidate
inductions, two of which are unflawed. So we will choose the one suggested by
the largest number of nonprimitive recursive functions. We will induct
according to the following scheme:
(AND (IMPLIES (ZEROP C) (p A B C))
(IMPLIES (AND (NOT (ZEROP C)) (LESSP B C))
(p A B C))
(IMPLIES (AND (NOT (ZEROP C))
(NOT (LESSP B C))
(p A (DIFFERENCE B C) C))
(p A B C))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP establish that the measure (COUNT B) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme generates the following four new formulas:
Case 4. (IMPLIES (AND (ZEROP C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0)))
(LESSP (REMAINDER A (REMAINDER B C))
C)).
This simplifies, unfolding the function ZEROP, to:
T.
Case 3. (IMPLIES (AND (NOT (ZEROP C))
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0)))
(LESSP (REMAINDER A (REMAINDER B C))
C)).
This simplifies, unfolding the definitions of ZEROP and REMAINDER, to:
(IMPLIES (AND (LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0)))
(LESSP (REMAINDER A B) C)),
which we will name *1.1.
Case 2. (IMPLIES (AND (NOT (ZEROP C))
(NOT (LESSP B C))
(EQUAL (REMAINDER (DIFFERENCE B C) C)
0)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0)))
(LESSP (REMAINDER A (REMAINDER B C))
C)).
This simplifies, opening up ZEROP, REMAINDER, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP C))
(NOT (LESSP B C))
(LESSP (REMAINDER A
(REMAINDER (DIFFERENCE B C) C))
C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (EQUAL (REMAINDER B C) 0)))
(LESSP (REMAINDER A (REMAINDER B C))
C)).
This simplifies, opening up ZEROP and REMAINDER, to:
T.
So we now return to:
(IMPLIES (AND (LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0)))
(LESSP (REMAINDER A B) C)),
which we named *1.1 above. We will appeal to induction. Four inductions are
suggested by terms in the conjecture. They merge into two likely candidate
inductions. However, only one is unflawed. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP B) (p A B C))
(IMPLIES (AND (NOT (ZEROP B)) (LESSP A B))
(p A B C))
(IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP A B))
(p (DIFFERENCE A B) B C))
(p A B C))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP can be used to show that the measure (COUNT A) decreases
according to the well-founded relation LESSP in each induction step of the
scheme. The above induction scheme generates three new formulas:
Case 3. (IMPLIES (AND (ZEROP B)
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0)))
(LESSP (REMAINDER A B) C)),
which simplifies, expanding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP B))
(LESSP A B)
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0)))
(LESSP (REMAINDER A B) C)),
which simplifies, expanding the functions ZEROP and REMAINDER, to two new
conjectures:
Case 2.2.
(IMPLIES (AND (LESSP A B)
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0))
(NOT (NUMBERP A)))
(LESSP 0 C)),
which again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A B)
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0))
(NUMBERP A))
(LESSP A C)),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP A B))
(LESSP (REMAINDER (DIFFERENCE A B) B)
C)
(LESSP B C)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP B)
(NOT (EQUAL B 0)))
(LESSP (REMAINDER A B) C)),
which simplifies, opening up the functions ZEROP and REMAINDER, to:
T.
That finishes the proof of *1.1, which, in turn, finishes the proof of *1.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER-REMAINDER
(DISABLE LESSP-REMAINDER-REMAINDER)
[ 0.0 0.0 0.0 ]
LESSP-REMAINDER-REMAINDER-OFF
(PROVE-LEMMA LESSP-TIMES
(REWRITE)
(IMPLIES (AND (NOT (ZEROP A)) (LESSP B C))
(LESSP (TIMES A B) (TIMES A C)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: When the linear lemma LESSP-TIMES is stored under (TIMES A C) it
contains the free variable B which will be chosen by instantiating the
hypothesis (LESSP B C).
WARNING: When the linear lemma LESSP-TIMES is stored under (TIMES A B) it
contains the free variable C which will be chosen by instantiating the
hypothesis (LESSP B C).
WARNING: Note that the proposed lemma LESSP-TIMES is to be stored as zero
type prescription rules, zero compound recognizer rules, two linear rules, and
zero replacement rules.
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (TIMES A B) (TIMES A C))).
Name the above subgoal *1.
Perhaps we can prove it by induction. There are four plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p A B C))
(IMPLIES (AND (NOT (ZEROP A)) (p (SUB1 A) B C))
(p A B C))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT A) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme leads to the following three new goals:
Case 3. (IMPLIES (AND (ZEROP A)
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (TIMES A B) (TIMES A C))).
This simplifies, opening up ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (SUB1 A) 0)
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (TIMES A B) (TIMES A C))).
This simplifies, opening up the definitions of ZEROP and TIMES, to:
(IMPLIES (AND (EQUAL (SUB1 A) 0)
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (PLUS B (TIMES (SUB1 A) B))
(PLUS C (TIMES (SUB1 A) C)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(LESSP (TIMES (SUB1 A) B)
(TIMES (SUB1 A) C))
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (TIMES A B) (TIMES A C))),
which simplifies, unfolding the definitions of ZEROP and TIMES, to:
(IMPLIES (AND (LESSP (TIMES (SUB1 A) B)
(TIMES (SUB1 A) C))
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP B C))
(LESSP (PLUS B (TIMES (SUB1 A) B))
(PLUS C (TIMES (SUB1 A) C)))).
However this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-TIMES
(DISABLE LESSP-TIMES)
[ 0.0 0.0 0.0 ]
LESSP-TIMES-OFF
(PROVE-LEMMA LEQ-PLUS-TIMES NIL
(IMPLIES (AND (LESSP B C) (NOT (ZEROP A)))
(IF (LESSP (TIMES A C)
(PLUS A (TIMES A B)))
'*1*FALSE
'*1*TRUE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to:
(IMPLIES (AND (LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (TIMES A C)
(PLUS A (TIMES A B))))),
which we will name *1.
Perhaps we can prove it by induction. Five inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP A) (p A C B))
(IMPLIES (AND (NOT (ZEROP A)) (p (SUB1 A) C B))
(p A C B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT A) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme
generates the following three new formulas:
Case 3. (IMPLIES (AND (ZEROP A)
(LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (TIMES A C)
(PLUS A (TIMES A B))))).
This simplifies, unfolding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (SUB1 A) 0)
(LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (TIMES A C)
(PLUS A (TIMES A B))))).
This simplifies, expanding the functions ZEROP and TIMES, to the new
conjecture:
(IMPLIES (AND (EQUAL (SUB1 A) 0)
(LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (PLUS C (TIMES (SUB1 A) C))
(PLUS A B (TIMES (SUB1 A) B))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(NOT (LESSP (TIMES (SUB1 A) C)
(PLUS (SUB1 A) (TIMES (SUB1 A) B))))
(LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (TIMES A C)
(PLUS A (TIMES A B))))),
which simplifies, expanding the functions ZEROP and TIMES, to the conjecture:
(IMPLIES (AND (NOT (LESSP (TIMES (SUB1 A) C)
(PLUS (SUB1 A) (TIMES (SUB1 A) B))))
(LESSP B C)
(NOT (EQUAL A 0))
(NUMBERP A))
(NOT (LESSP (PLUS C (TIMES (SUB1 A) C))
(PLUS A B (TIMES (SUB1 A) B))))).
This again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
LEQ-PLUS-TIMES
(PROVE-LEMMA LESSP-DIFFERENCE NIL
(IMPLIES (AND (NOT (ZEROP A)) (LESSP A B))
(LESSP (DIFFERENCE B A) B))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(LESSP A B))
(LESSP (DIFFERENCE B A) B)),
which simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP B A)
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP A B))
(LESSP (DIFFERENCE B A) B)).
This again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-DIFFERENCE
(PROVE-LEMMA REMAINDER-DIFFERENCE-NON-ZERO
(REWRITE)
(IMPLIES (AND (NOT (ZEROP A))
(AND (NUMBERP B) (LESSP A B)))
(NOT (ZEROP (REMAINDER (DIFFERENCE B A) B))))
((ENABLE REMAINDER-NOOP)
(DISABLE REMAINDER DIFFERENCE)
(USE (LESSP-DIFFERENCE (A A) (B B)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the rewrite rule REMAINDER-DIFFERENCE-NON-ZERO will be
stored so as to apply only to terms with the nonrecursive function symbol
ZEROP.
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to:
(IMPLIES (AND (IMPLIES (AND (NOT (ZEROP A)) (LESSP A B))
(LESSP (DIFFERENCE B A) B))
(NOT (EQUAL A 0))
(NUMBERP A)
(NUMBERP B)
(LESSP A B))
(NOT (ZEROP (REMAINDER (DIFFERENCE B A) B)))),
which simplifies, using linear arithmetic, applying the lemma REMAINDER-NOOP,
and opening up the definitions of ZEROP, NOT, AND, and IMPLIES, to the goal:
(IMPLIES (AND (LESSP (DIFFERENCE B A) B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NUMBERP B)
(LESSP A B))
(NOT (EQUAL (DIFFERENCE B A) 0))).
This again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-DIFFERENCE-NON-ZERO
(DISABLE REMAINDER-DIFFERENCE-NON-ZERO)
[ 0.0 0.0 0.0 ]
REMAINDER-DIFFERENCE-NON-ZERO-OFF
(PROVE-LEMMA SUM-ZERO-IMPLIES-ADDENDS-ZERO NIL
(IMPLIES (EQUAL (PLUS A B) '0)
(AND (ZEROP A) (ZEROP B)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions ZEROP and AND, to two new
conjectures:
Case 2. (IMPLIES (AND (EQUAL (PLUS A B) 0)
(NOT (EQUAL A 0)))
(NOT (NUMBERP A))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (EQUAL (PLUS A B) 0)
(NOT (EQUAL B 0)))
(NOT (NUMBERP B))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
SUM-ZERO-IMPLIES-ADDENDS-ZERO
(PROVE-LEMMA REMAINDER-ZERO-IMPLIES-LEQ-FACT
(REWRITE)
(IMPLIES (AND (EQUAL (REMAINDER A B) '0)
(NOT (ZEROP A)))
(EQUAL (LESSP A B) '*1*FALSE))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (EQUAL (REMAINDER A B) 0)
(NOT (EQUAL A 0))
(NUMBERP A))
(EQUAL (LESSP A B) F)).
This simplifies, opening up REMAINDER, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-ZERO-IMPLIES-LEQ-FACT
(DISABLE REMAINDER-ZERO-IMPLIES-LEQ-FACT)
[ 0.0 0.0 0.0 ]
REMAINDER-ZERO-IMPLIES-LEQ-FACT-OFF
(DEFN LESSP-QUOTIENT-INDUCTION
(A B C)
(IF (ZEROP B)
'0
(IF (ZEROP C)
'0
(IF (LESSP A C)
'0
(LESSP-QUOTIENT-INDUCTION (DIFFERENCE A C)
(SUB1 B)
C))))
NIL)
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT A) decreases according
to the well-founded relation LESSP in each recursive call. Hence,
LESSP-QUOTIENT-INDUCTION is accepted under the principle of definition. The
definition of LESSP-QUOTIENT-INDUCTION can be justified in another way.
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT B) decreases according to the well-founded
relation LESSP in each recursive call. Observe that:
(NUMBERP (LESSP-QUOTIENT-INDUCTION A B C))
is a theorem.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-INDUCTION
(PROVE-LEMMA LESSP-QUOTIENT-REMAINDER-CROCK
(REWRITE)
(IMPLIES (AND (LESSP A (TIMES B C))
(AND (NOT (EQUAL B '0))
(AND (NUMBERP B)
(AND (NOT (EQUAL C '0))
(AND (NUMBERP C) (NUMBERP A))))))
(LESSP (QUOTIENT A C) B))
((INDUCT (LESSP-QUOTIENT-INDUCTION A B C))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: When the linear lemma LESSP-QUOTIENT-REMAINDER-CROCK is stored under
(QUOTIENT A C) it contains the free variable B which will be chosen by
instantiating the hypothesis (LESSP A (TIMES B C)).
WARNING: Note that the proposed lemma LESSP-QUOTIENT-REMAINDER-CROCK is to be
stored as zero type prescription rules, zero compound recognizer rules, one
linear rule, and zero replacement rules.
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to four new formulas:
Case 4. (IMPLIES (AND (ZEROP B)
(LESSP A (TIMES B C))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP A))
(LESSP (QUOTIENT A C) B)),
which simplifies, unfolding the function ZEROP, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(ZEROP C)
(LESSP A (TIMES B C))
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP A))
(LESSP (QUOTIENT A C) B)),
which simplifies, expanding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(LESSP A C)
(LESSP A (TIMES B C))
(NUMBERP A))
(LESSP (QUOTIENT A C) B)),
which simplifies, expanding the definitions of QUOTIENT, EQUAL, and LESSP,
to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (LESSP A C))
(IMPLIES (AND (LESSP (DIFFERENCE A C)
(TIMES (SUB1 B) C))
(NOT (EQUAL (SUB1 B) 0))
(NUMBERP (SUB1 B))
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP (DIFFERENCE A C)))
(LESSP (QUOTIENT (DIFFERENCE A C) C)
(SUB1 B)))
(LESSP A (TIMES B C))
(NUMBERP A))
(LESSP (QUOTIENT A C) B)),
which simplifies, rewriting with SUB1-ADD1, and expanding NOT, AND, IMPLIES,
TIMES, QUOTIENT, LESSP, and EQUAL, to the following two new goals:
Case 1.2.
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (LESSP A C))
(NOT (LESSP (DIFFERENCE A C)
(TIMES (SUB1 B) C)))
(LESSP A (PLUS C (TIMES (SUB1 B) C)))
(NUMBERP A))
(LESSP (QUOTIENT (DIFFERENCE A C) C)
(SUB1 B))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (LESSP A C))
(EQUAL (SUB1 B) 0)
(LESSP A (PLUS C 0)))
(NOT (NUMBERP A))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-REMAINDER-CROCK
(DISABLE LESSP-QUOTIENT-REMAINDER-CROCK)
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-REMAINDER-CROCK-OFF
(PROVE-LEMMA LESSP-QUOTIENT-REMAINDER
(REWRITE)
(IMPLIES (AND (NOT (ZEROP B)) (NOT (ZEROP C)))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
(FIX B)))
((ENABLE DIVIDES LESSP-REMAINDER2 LESSP-QUOTIENT-REMAINDER-CROCK
EQUAL-TIMES-0 REWRITE-ZERO-DIFFERENCE-AS-EQUALITY
QUOTIENT-X-X)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that the proposed lemma LESSP-QUOTIENT-REMAINDER is to be
stored as zero type prescription rules, zero compound recognizer rules, one
linear rule, and zero replacement rules.
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
(FIX B))).
This simplifies, opening up FIX, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
B)),
which we will name *1.
Perhaps we can prove it by induction. The recursive terms in the
conjecture suggest three inductions. They merge into two likely candidate
inductions, both of which are unflawed. So we will choose the one suggested
by the largest number of nonprimitive recursive functions. We will induct
according to the following scheme:
(AND (IMPLIES (ZEROP (TIMES B C))
(p A B C))
(IMPLIES (AND (NOT (ZEROP (TIMES B C)))
(LESSP A (TIMES B C)))
(p A B C))
(IMPLIES (AND (NOT (ZEROP (TIMES B C)))
(NOT (LESSP A (TIMES B C)))
(p (DIFFERENCE A (TIMES B C)) B C))
(p A B C))).
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP inform us that the measure (COUNT A) decreases according
to the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme leads to the following three new goals:
Case 3. (IMPLIES (AND (ZEROP (TIMES B C))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
B)).
This simplifies, applying EQUAL-TIMES-0, and opening up the definition of
ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP (TIMES B C)))
(LESSP A (TIMES B C))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
B)),
which simplifies, rewriting with EQUAL-TIMES-0, and opening up the functions
ZEROP and REMAINDER, to the following two new formulas:
Case 2.2.
(IMPLIES (AND (LESSP A (TIMES B C))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (NUMBERP A)))
(LESSP (QUOTIENT 0 C) B)).
But this again simplifies, rewriting with EQUAL-TIMES-0, and expanding the
functions LESSP, EQUAL, and QUOTIENT, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP A (TIMES B C))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NUMBERP A))
(LESSP (QUOTIENT A C) B)).
This again simplifies, using linear arithmetic and appealing to the lemma
LESSP-QUOTIENT-REMAINDER-CROCK, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP (TIMES B C)))
(NOT (LESSP A (TIMES B C)))
(LESSP (QUOTIENT (REMAINDER (DIFFERENCE A (TIMES B C))
(TIMES B C))
C)
B)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C))
(LESSP (QUOTIENT (REMAINDER A (TIMES B C)) C)
B)),
which simplifies, applying EQUAL-TIMES-0, and expanding the functions ZEROP
and REMAINDER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-REMAINDER
(DISABLE LESSP-QUOTIENT-REMAINDER)
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-REMAINDER-OFF
(PROVE-LEMMA LESSP-QUOTIENT-TIMES
(REWRITE)
(IMPLIES (LESSP A (TIMES B C))
(EQUAL (LESSP (QUOTIENT A C) B)
'*1*TRUE))
((INDUCT (LESSP-QUOTIENT-INDUCTION A B C))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following four new formulas:
Case 4. (IMPLIES (AND (ZEROP B) (LESSP A (TIMES B C)))
(EQUAL (LESSP (QUOTIENT A C) B) T)).
This simplifies, opening up ZEROP, EQUAL, TIMES, and LESSP, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(ZEROP C)
(LESSP A (TIMES B C)))
(EQUAL (LESSP (QUOTIENT A C) B) T)).
This simplifies, expanding the functions ZEROP, EQUAL, QUOTIENT, and LESSP,
to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(LESSP A C)
(LESSP A (TIMES B C)))
(EQUAL (LESSP (QUOTIENT A C) B) T)).
This simplifies, unfolding the definitions of QUOTIENT, EQUAL, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (LESSP A C))
(IMPLIES (LESSP (DIFFERENCE A C)
(TIMES (SUB1 B) C))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE A C) C)
(SUB1 B))
T))
(LESSP A (TIMES B C)))
(EQUAL (LESSP (QUOTIENT A C) B) T)).
This simplifies, rewriting with SUB1-ADD1, and unfolding IMPLIES, TIMES,
QUOTIENT, LESSP, and EQUAL, to the formula:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL C 0))
(NUMBERP C)
(NOT (LESSP A C))
(NOT (LESSP (DIFFERENCE A C)
(TIMES (SUB1 B) C)))
(LESSP A (PLUS C (TIMES (SUB1 B) C))))
(LESSP (QUOTIENT (DIFFERENCE A C) C)
(SUB1 B))).
This again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-TIMES
(DISABLE LESSP-QUOTIENT-TIMES)
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-TIMES-OFF
(DEFN MIN
(A B)
(IF (LESSP A B) A B)
NIL)
Note that (OR (EQUAL (MIN A B) A) (EQUAL (MIN A B) B)) is a theorem.
[ 0.0 0.0 0.0 ]
MIN
(PROVE-LEMMA LESSP-TRANSITIVITY NIL
(IMPLIES (AND (LESSP A B) (LESSP B C))
(LESSP A C))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-TRANSITIVITY
(PROVE-LEMMA REMAINDER-PLUS
(REWRITE)
(EQUAL (REMAINDER (PLUS A N) A)
(REMAINDER N A))
((ENABLE REMAINDER-WRT-12 PLUS-RIGHT-ID2 DIFFERENCE-PLUS1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying the lemma DIFFERENCE-PLUS1, and expanding
the definitions of REMAINDER, EQUAL, and PLUS, to six new conjectures:
Case 6. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP (PLUS A N) A))
(NOT (NUMBERP N)))
(EQUAL (REMAINDER 0 A)
(REMAINDER N A))),
which again simplifies, applying PLUS-RIGHT-ID2, and opening up NUMBERP,
LESSP, EQUAL, and REMAINDER, to:
T.
Case 5. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(LESSP (PLUS A N) A))
(EQUAL (PLUS A N) (REMAINDER N A))).
But this again simplifies, using linear arithmetic, to:
T.
Case 4. (IMPLIES (AND (EQUAL A 0) (NOT (NUMBERP N)))
(EQUAL 0 (REMAINDER N A))),
which again simplifies, opening up the definitions of EQUAL and REMAINDER,
to:
T.
Case 3. (IMPLIES (AND (NOT (NUMBERP A))
(NOT (NUMBERP N)))
(EQUAL 0 (REMAINDER N A))),
which again simplifies, appealing to the lemma REMAINDER-WRT-12, and opening
up EQUAL, to:
T.
Case 2. (IMPLIES (AND (EQUAL A 0) (NUMBERP N))
(EQUAL N (REMAINDER N A))),
which again simplifies, expanding the definitions of EQUAL and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP A)) (NUMBERP N))
(EQUAL N (REMAINDER N A))),
which again simplifies, rewriting with REMAINDER-WRT-12, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS
(DISABLE REMAINDER-PLUS)
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-OFF
(PROVE-LEMMA REMAINDER-DIVIDES
(REWRITE)
(IMPLIES (AND (DIVIDES A U) (NUMBERP U))
(EQUAL (REMAINDER (PLUS U N) A)
(REMAINDER N A)))
((USE (QUOTIENT-DIVIDES (X A) (Y U)))
(DISABLE REMAINDER PLUS TIMES)
(ENABLE REMAINDER-PLUS-TIMES-2 PLUS-RIGHT-ID2 TIMES-ZERO2
COMMUTATIVITY-OF-TIMES REMAINDER-WRT-12 REMAINDER-PLUS
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM DIVIDES-TIMES1
COMMUTATIVITY-OF-PLUS DIVIDES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations AND, IMPLIES, and
DIVIDES, to:
(IMPLIES (AND (IMPLIES (AND (NUMBERP U)
(NOT (EQUAL (TIMES A (QUOTIENT U A)) U)))
(NOT (EQUAL (REMAINDER U A) 0)))
(EQUAL (REMAINDER U A) 0)
(NUMBERP U))
(EQUAL (REMAINDER (PLUS U N) A)
(REMAINDER N A))).
This simplifies, applying DIVIDES-TIMES1 and COMMUTATIVITY-OF-PLUS, and
unfolding NOT, AND, EQUAL, and IMPLIES, to the goal:
(IMPLIES (EQUAL (TIMES A (QUOTIENT U A)) U)
(EQUAL (REMAINDER (PLUS N U) A)
(REMAINDER N A))).
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace U by
(PLUS Z (TIMES A X)) to eliminate (QUOTIENT U A) and (REMAINDER U A). We
employ LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was introduced
to constrain the new variables. We must thus prove four new conjectures:
Case 4. (IMPLIES (AND (NOT (NUMBERP U))
(EQUAL (TIMES A (QUOTIENT U A)) U))
(EQUAL (REMAINDER (PLUS N U) A)
(REMAINDER N A))),
which further simplifies, obviously, to:
T.
Case 3. (IMPLIES (AND (EQUAL A 0)
(EQUAL (TIMES A (QUOTIENT U A)) U))
(EQUAL (REMAINDER (PLUS N U) A)
(REMAINDER N A))).
But this further simplifies, applying COMMUTATIVITY-OF-PLUS and
REMAINDER-PLUS, and opening up the functions EQUAL, QUOTIENT, and TIMES, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP A))
(EQUAL (TIMES A (QUOTIENT U A)) U))
(EQUAL (REMAINDER (PLUS N U) A)
(REMAINDER N A))).
But this further simplifies, rewriting with the lemmas TIMES-ZERO2,
COMMUTATIVITY-OF-TIMES, COMMUTATIVITY-OF-PLUS, and REMAINDER-WRT-12, and
expanding the function QUOTIENT, to two new conjectures:
Case 2.2.
(IMPLIES (AND (NOT (NUMBERP A))
(EQUAL 0 U)
(NOT (NUMBERP N)))
(EQUAL (PLUS 0 N) 0)),
which again simplifies, rewriting with PLUS-RIGHT-ID2, and expanding the
functions NUMBERP and EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP A))
(EQUAL 0 U)
(NUMBERP N))
(EQUAL (PLUS 0 N) N)).
This again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NUMBERP X)
(NUMBERP Z)
(EQUAL (LESSP Z A) (NOT (ZEROP A)))
(NUMBERP A)
(NOT (EQUAL A 0))
(EQUAL (TIMES A X)
(PLUS Z (TIMES A X))))
(EQUAL (REMAINDER (PLUS N Z (TIMES A X)) A)
(REMAINDER N A))),
which further simplifies, rewriting with REMAINDER-PLUS-TIMES-2, and
unfolding the definitions of ZEROP and NOT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-DIVIDES
(DISABLE REMAINDER-DIVIDES)
[ 0.0 0.0 0.0 ]
REMAINDER-DIVIDES-OFF
(PROVE-LEMMA REMAINDER-REMAINDER
(REWRITE)
(IMPLIES (DIVIDES A B)
(EQUAL (REMAINDER (REMAINDER N B) A)
(REMAINDER N A)))
((INDUCT (REMAINDER N B))
(DISABLE DIVIDES)
(ENABLE ASSOCIATIVITY-OF-PLUS REMAINDER-DIVIDES DIFFERENCE-ELIM
LESSP-REMAINDER2 REMAINDER-QUOTIENT-ELIM
REMAINDER-WRT-12)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new formulas:
Case 3. (IMPLIES (AND (ZEROP B) (DIVIDES A B))
(EQUAL (REMAINDER (REMAINDER N B) A)
(REMAINDER N A))),
which simplifies, applying REMAINDER-WRT-12, and expanding ZEROP, EQUAL, and
REMAINDER, to the following two new formulas:
Case 3.2.
(IMPLIES (AND (EQUAL B 0)
(DIVIDES A 0)
(NOT (NUMBERP N)))
(EQUAL (REMAINDER 0 A)
(REMAINDER N A))).
But this again simplifies, expanding LESSP, EQUAL, NUMBERP, and REMAINDER,
to:
T.
Case 3.1.
(IMPLIES (AND (NOT (NUMBERP B))
(DIVIDES A B)
(NOT (NUMBERP N)))
(EQUAL (REMAINDER 0 A)
(REMAINDER N A))),
which again simplifies, opening up the functions LESSP, EQUAL, NUMBERP,
and REMAINDER, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(LESSP N B)
(DIVIDES A B))
(EQUAL (REMAINDER (REMAINDER N B) A)
(REMAINDER N A))),
which simplifies, expanding the definition of REMAINDER, to:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(LESSP N B)
(DIVIDES A B)
(NOT (NUMBERP N)))
(EQUAL (REMAINDER 0 A)
(REMAINDER N A))).
However this again simplifies, unfolding the definitions of LESSP, EQUAL,
NUMBERP, and REMAINDER, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP N B))
(IMPLIES (DIVIDES A B)
(EQUAL (REMAINDER (REMAINDER (DIFFERENCE N B) B)
A)
(REMAINDER (DIFFERENCE N B) A)))
(DIVIDES A B))
(EQUAL (REMAINDER (REMAINDER N B) A)
(REMAINDER N A))),
which simplifies, opening up IMPLIES and REMAINDER, to the conjecture:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP N B))
(EQUAL (REMAINDER (REMAINDER (DIFFERENCE N B) B)
A)
(REMAINDER (DIFFERENCE N B) A))
(DIVIDES A B))
(EQUAL (REMAINDER (DIFFERENCE N B) A)
(REMAINDER N A))).
Appealing to the lemmas DIFFERENCE-ELIM and REMAINDER-QUOTIENT-ELIM, we now
replace N by (PLUS B X) to eliminate (DIFFERENCE N B), X by
(PLUS Z (TIMES B V)) to eliminate (REMAINDER X B) and (QUOTIENT X B), and Z
by (PLUS X (TIMES A W)) to eliminate (REMAINDER Z A) and (QUOTIENT Z A). We
employ the type restriction lemma noted when DIFFERENCE was introduced,
LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was
introduced to constrain the new variables. This generates four new formulas:
Case 1.4.
(IMPLIES (AND (NOT (NUMBERP N))
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP N B))
(EQUAL (REMAINDER (REMAINDER (DIFFERENCE N B) B)
A)
(REMAINDER (DIFFERENCE N B) A))
(DIVIDES A B))
(EQUAL (REMAINDER (DIFFERENCE N B) A)
(REMAINDER N A))),
which further simplifies, opening up the definition of LESSP, to:
T.
Case 1.3.
(IMPLIES (AND (EQUAL A 0)
(NUMBERP Z)
(EQUAL (LESSP Z B) (NOT (ZEROP B)))
(NUMBERP V)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP (PLUS B Z (TIMES B V)) B))
(EQUAL (REMAINDER Z A)
(REMAINDER (PLUS Z (TIMES B V)) A))
(DIVIDES A B))
(EQUAL (REMAINDER (PLUS Z (TIMES B V)) A)
(REMAINDER (PLUS B Z (TIMES B V))
A))),
which further simplifies, rewriting with REMAINDER-DIVIDES, and expanding
the definitions of ZEROP, NOT, EQUAL, and REMAINDER, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (NUMBERP A))
(NUMBERP Z)
(EQUAL (LESSP Z B) (NOT (ZEROP B)))
(NUMBERP V)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP (PLUS B Z (TIMES B V)) B))
(EQUAL (REMAINDER Z A)
(REMAINDER (PLUS Z (TIMES B V)) A))
(DIVIDES A B))
(EQUAL (REMAINDER (PLUS Z (TIMES B V)) A)
(REMAINDER (PLUS B Z (TIMES B V))
A))).
But this further simplifies, appealing to the lemmas REMAINDER-WRT-12 and
REMAINDER-DIVIDES, and unfolding the functions ZEROP and NOT, to:
T.
Case 1.1.
(IMPLIES (AND (NUMBERP X)
(EQUAL (LESSP X A) (NOT (ZEROP A)))
(NUMBERP W)
(NUMBERP A)
(NOT (EQUAL A 0))
(EQUAL (LESSP (PLUS X (TIMES A W)) B)
(NOT (ZEROP B)))
(NUMBERP V)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP (PLUS B
(PLUS X (TIMES A W))
(TIMES B V))
B))
(EQUAL X
(REMAINDER (PLUS (PLUS X (TIMES A W))
(TIMES B V))
A))
(DIVIDES A B))
(EQUAL (REMAINDER (PLUS (PLUS X (TIMES A W))
(TIMES B V))
A)
(REMAINDER (PLUS B
(PLUS X (TIMES A W))
(TIMES B V))
A))),
which further simplifies, rewriting with ASSOCIATIVITY-OF-PLUS and
REMAINDER-DIVIDES, and unfolding the functions ZEROP and NOT, to:
T.
Q.E.D.
[ 0.0 0.1 0.0 ]
REMAINDER-REMAINDER
(DISABLE REMAINDER-REMAINDER)
[ 0.0 0.0 0.0 ]
REMAINDER-REMAINDER-OFF
(PROVE-LEMMA LESSP-QUOTIENT NIL
(IMPLIES (LESSP N (TIMES A B))
(LESSP (QUOTIENT N A) B))
((INDUCT (LESSP-QUOTIENT-INDUCTION N B A))
(ENABLE TIMES-ADD1 TIMES-ZERO2 TIMES-ZERO3)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to four new conjectures:
Case 4. (IMPLIES (AND (ZEROP B) (LESSP N (TIMES A B)))
(LESSP (QUOTIENT N A) B)),
which simplifies, applying TIMES-ZERO3 and TIMES-ZERO2, and unfolding the
definitions of ZEROP, EQUAL, and LESSP, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(ZEROP A)
(LESSP N (TIMES A B)))
(LESSP (QUOTIENT N A) B)).
This simplifies, expanding the functions ZEROP, EQUAL, TIMES, and LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL A 0))
(NUMBERP A)
(LESSP N A)
(LESSP N (TIMES A B)))
(LESSP (QUOTIENT N A) B)).
This simplifies, expanding the functions QUOTIENT, EQUAL, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP N A))
(IMPLIES (LESSP (DIFFERENCE N A)
(TIMES A (SUB1 B)))
(LESSP (QUOTIENT (DIFFERENCE N A) A)
(SUB1 B)))
(LESSP N (TIMES A B)))
(LESSP (QUOTIENT N A) B)).
This simplifies, appealing to the lemma SUB1-ADD1, and expanding the
functions IMPLIES, QUOTIENT, and LESSP, to the new formula:
(IMPLIES (AND (NOT (EQUAL B 0))
(NUMBERP B)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP N A))
(NOT (LESSP (DIFFERENCE N A)
(TIMES A (SUB1 B))))
(LESSP N (TIMES A B)))
(LESSP (QUOTIENT (DIFFERENCE N A) A)
(SUB1 B))).
Applying the lemma SUB1-ELIM, replace B by (ADD1 X) to eliminate (SUB1 B).
We use the type restriction lemma noted when SUB1 was introduced to restrict
the new variable. We would thus like to prove:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP N A))
(NOT (LESSP (DIFFERENCE N A) (TIMES A X)))
(LESSP N (TIMES A (ADD1 X))))
(LESSP (QUOTIENT (DIFFERENCE N A) A)
X)),
which further simplifies, appealing to the lemma TIMES-ADD1, to:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL A 0))
(NUMBERP A)
(NOT (LESSP N A))
(NOT (LESSP (DIFFERENCE N A) (TIMES A X)))
(LESSP N (PLUS A (TIMES A X))))
(LESSP (QUOTIENT (DIFFERENCE N A) A)
X)).
However this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT
(DEFN LESSP-QUOTIENT-QUOTIENT-INDUCTION
(N A B)
(IF (ZEROP N)
'0
(IF (LESSP A N)
'0
(IF (LESSP B N)
'0
(LESSP-QUOTIENT-QUOTIENT-INDUCTION N
(DIFFERENCE A N)
(DIFFERENCE B N)))))
NIL)
Linear arithmetic, the lemmas COUNT-NUMBERP and COUNT-NOT-LESSP, and the
definition of ZEROP establish that the measure (COUNT A) decreases according
to the well-founded relation LESSP in each recursive call. Hence,
LESSP-QUOTIENT-QUOTIENT-INDUCTION
is accepted under the principle of definition. The definition of:
LESSP-QUOTIENT-QUOTIENT-INDUCTION
can be justified in another way. Linear arithmetic, the lemmas COUNT-NUMBERP
and COUNT-NOT-LESSP, and the definition of ZEROP inform us that the measure
(COUNT B) decreases according to the well-founded relation LESSP in each
recursive call. Note that (NUMBERP (LESSP-QUOTIENT-QUOTIENT-INDUCTION N A B))
is a theorem.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-QUOTIENT-INDUCTION
(PROVE-LEMMA LESSP-QUOTIENT-QUOTIENT
(REWRITE)
(IMPLIES (AND (NOT (ZEROP N))
(AND (EQUAL (REMAINDER B N) '0)
(LESSP A B)))
(EQUAL (LESSP (QUOTIENT A N) (QUOTIENT B N))
'*1*TRUE))
((ENABLE REMAINDER-QUOTIENT-ELIM LESSP-REMAINDER2
COMMUTATIVITY-OF-TIMES)
(INDUCT (LESSP-QUOTIENT-QUOTIENT-INDUCTION N A B))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following four new goals:
Case 4. (IMPLIES (AND (ZEROP N)
(NOT (EQUAL N 0))
(NUMBERP N)
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(EQUAL (LESSP (QUOTIENT A N) (QUOTIENT B N))
T)).
This simplifies, opening up the function ZEROP, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(LESSP A N)
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(EQUAL (LESSP (QUOTIENT A N) (QUOTIENT B N))
T)).
This simplifies, opening up the functions QUOTIENT, EQUAL, and LESSP, to:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(LESSP A N)
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(NOT (EQUAL (QUOTIENT B N) 0))).
Applying the lemma REMAINDER-QUOTIENT-ELIM, replace B by
(PLUS X (TIMES N Z)) to eliminate (REMAINDER B N) and (QUOTIENT B N). We
employ LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was
introduced to restrict the new variables. We thus obtain the following two
new conjectures:
Case 3.2.
(IMPLIES (AND (NOT (NUMBERP B))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP A N)
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(NOT (EQUAL (QUOTIENT B N) 0))).
However this further simplifies, unfolding LESSP, REMAINDER, and EQUAL, to:
T.
Case 3.1.
(IMPLIES (AND (NUMBERP X)
(EQUAL (LESSP X N) (NOT (ZEROP N)))
(NUMBERP Z)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP A N)
(EQUAL X 0)
(LESSP A (PLUS X (TIMES N Z))))
(NOT (EQUAL Z 0))),
which further simplifies, applying COMMUTATIVITY-OF-TIMES, and unfolding
the definitions of NUMBERP, EQUAL, LESSP, ZEROP, NOT, TIMES, and PLUS, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NOT (LESSP A N))
(LESSP B N)
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(EQUAL (LESSP (QUOTIENT A N) (QUOTIENT B N))
T)).
This simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NOT (LESSP A N))
(NOT (LESSP B N))
(IMPLIES (AND (NOT (ZEROP N))
(EQUAL (REMAINDER (DIFFERENCE B N) N)
0)
(LESSP (DIFFERENCE A N)
(DIFFERENCE B N)))
(EQUAL (LESSP (QUOTIENT (DIFFERENCE A N) N)
(QUOTIENT (DIFFERENCE B N) N))
T))
(EQUAL (REMAINDER B N) 0)
(LESSP A B))
(EQUAL (LESSP (QUOTIENT A N) (QUOTIENT B N))
T)).
This simplifies, applying SUB1-ADD1, and unfolding the functions ZEROP, NOT,
AND, IMPLIES, REMAINDER, QUOTIENT, LESSP, and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NOT (LESSP A N))
(NOT (LESSP B N))
(NOT (LESSP (DIFFERENCE A N)
(DIFFERENCE B N)))
(EQUAL (REMAINDER (DIFFERENCE B N) N)
0)
(LESSP A B))
(LESSP (QUOTIENT (DIFFERENCE A N) N)
(QUOTIENT (DIFFERENCE B N) N))).
However this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-QUOTIENT
(DISABLE LESSP-QUOTIENT-QUOTIENT)
[ 0.0 0.0 0.0 ]
LESSP-QUOTIENT-QUOTIENT-OFF
(PROVE-LEMMA LESSP-TIMES-QUOTIENT
(REWRITE)
(IMPLIES (AND (NOT (ZEROP N))
(AND (NUMBERP I)
(AND (LESSP I J)
(EQUAL (REMAINDER J N) '0))))
(EQUAL (LESSP (TIMES N (QUOTIENT I N)) J)
'*1*TRUE))
((USE (LESSP-QUOTIENT-QUOTIENT (A I)
(B J)
(N N))
(QUOTIENT-TIMES1 (X N) (Y J)))
(ENABLE DIVIDES LESSP-TIMES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, IMPLIES,
AND, and DIVIDES, to:
(IMPLIES (AND (IMPLIES (AND (NOT (ZEROP N))
(EQUAL (REMAINDER J N) 0)
(LESSP I J))
(EQUAL (LESSP (QUOTIENT I N) (QUOTIENT J N))
T))
(IMPLIES (AND (NUMBERP J)
(NUMBERP N)
(NOT (EQUAL N 0))
(EQUAL (REMAINDER J N) 0))
(EQUAL (TIMES N (QUOTIENT J N)) J))
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I J)
(EQUAL (REMAINDER J N) 0))
(EQUAL (LESSP (TIMES N (QUOTIENT I N)) J)
T)),
which simplifies, opening up ZEROP, NOT, EQUAL, AND, IMPLIES, and LESSP, to:
(IMPLIES (AND (LESSP (QUOTIENT I N) (QUOTIENT J N))
(EQUAL (TIMES N (QUOTIENT J N)) J)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I J)
(EQUAL (REMAINDER J N) 0))
(LESSP (TIMES N (QUOTIENT I N)) J)).
This again simplifies, using linear arithmetic and applying LESSP-TIMES, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LESSP-TIMES-QUOTIENT
(DISABLE LESSP-TIMES-QUOTIENT)
[ 0.0 0.0 0.0 ]
LESSP-TIMES-QUOTIENT-OFF
(PROVE-LEMMA NOT-LESSP-TIMES-PLUS NIL
(IMPLIES (AND (NUMBERP A)
(AND (NUMBERP V)
(AND (LESSP V N)
(AND (NUMBERP B)
(AND (NOT (EQUAL N '0))
(AND (NUMBERP N)
(LESSP (PLUS V (TIMES A N))
(TIMES B N))))))))
(NOT (LESSP (TIMES B N)
(PLUS (TIMES A N) N))))
((INDUCT (DOUBLE-NUMBER-INDUCTION A B))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following two new formulas:
Case 2. (IMPLIES (AND (OR (ZEROP A) (ZEROP B))
(NUMBERP A)
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V (TIMES A N))
(TIMES B N)))
(NOT (LESSP (TIMES B N)
(PLUS (TIMES A N) N)))).
This simplifies, unfolding the functions ZEROP, OR, NUMBERP, EQUAL, TIMES,
PLUS, and LESSP, to:
(IMPLIES (AND (EQUAL A 0)
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
which again simplifies, clearly, to the new goal:
(IMPLIES (AND (NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
which we will name *1.
Case 1. (IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(IMPLIES (AND (NUMBERP (SUB1 A))
(NUMBERP V)
(LESSP V N)
(NUMBERP (SUB1 B))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V (TIMES (SUB1 A) N))
(TIMES (SUB1 B) N)))
(NOT (LESSP (TIMES (SUB1 B) N)
(PLUS (TIMES (SUB1 A) N) N))))
(NUMBERP V)
(LESSP V N)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V (TIMES A N))
(TIMES B N)))
(NOT (LESSP (TIMES B N)
(PLUS (TIMES A N) N)))).
This simplifies, expanding the definitions of NOT, AND, IMPLIES, and TIMES,
to the following two new conjectures:
Case 1.2.
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP (PLUS V (TIMES (SUB1 A) N))
(TIMES (SUB1 B) N)))
(NUMBERP V)
(LESSP V N)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V N (TIMES (SUB1 A) N))
(PLUS N (TIMES (SUB1 B) N))))
(NOT (LESSP (PLUS N (TIMES (SUB1 B) N))
(PLUS (PLUS N (TIMES (SUB1 A) N))
N)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL A 0))
(NUMBERP A)
(NOT (EQUAL B 0))
(NUMBERP B)
(NOT (LESSP (TIMES (SUB1 B) N)
(PLUS (TIMES (SUB1 A) N) N)))
(NUMBERP V)
(LESSP V N)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V N (TIMES (SUB1 A) N))
(PLUS N (TIMES (SUB1 B) N))))
(NOT (LESSP (PLUS N (TIMES (SUB1 B) N))
(PLUS (PLUS N (TIMES (SUB1 A) N))
N)))),
which again simplifies, using linear arithmetic, to:
T.
So next consider:
(IMPLIES (AND (NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
named *1 above. We will try to prove it by induction. There are six
plausible inductions. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP B) (p B N V))
(IMPLIES (AND (NOT (ZEROP B)) (p (SUB1 B) N V))
(p B N V))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT B) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme generates three new formulas:
Case 3. (IMPLIES (AND (ZEROP B)
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
which simplifies, expanding the functions ZEROP, NUMBERP, EQUAL, TIMES, and
LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP (PLUS V 0) (TIMES (SUB1 B) N)))
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
which simplifies, opening up ZEROP and TIMES, to the formula:
(IMPLIES (AND (NOT (EQUAL B 0))
(NOT (LESSP (PLUS V 0) (TIMES (SUB1 B) N)))
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0)
(PLUS N (TIMES (SUB1 B) N))))
(NOT (LESSP (PLUS N (TIMES (SUB1 B) N))
N))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP B))
(NOT (LESSP (TIMES (SUB1 B) N) N))
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0) (TIMES B N)))
(NOT (LESSP (TIMES B N) N))),
which simplifies, expanding the functions ZEROP and TIMES, to:
(IMPLIES (AND (NOT (EQUAL B 0))
(NOT (LESSP (TIMES (SUB1 B) N) N))
(NUMBERP V)
(LESSP V N)
(NUMBERP B)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V 0)
(PLUS N (TIMES (SUB1 B) N))))
(NOT (LESSP (PLUS N (TIMES (SUB1 B) N))
N))).
But this again simplifies, using linear arithmetic, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
NOT-LESSP-TIMES-PLUS
(PROVE-LEMMA NOT-LESSP-TIMES-PLUS-INSTANCE
(REWRITE)
(IMPLIES (AND (NUMBERP X)
(AND (NUMBERP V)
(AND (LESSP V N)
(AND (NUMBERP Z)
(AND (NOT (EQUAL N '0))
(AND (NUMBERP N)
(LESSP (TIMES N Z)
(PLUS N (TIMES N X)))))))))
(EQUAL (LESSP (PLUS V (TIMES N X))
(TIMES N Z))
'*1*FALSE))
((USE (NOT-LESSP-TIMES-PLUS (A X) (B Z)))
(ENABLE COMMUTATIVITY-OF-TIMES COMMUTATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying the lemmas COMMUTATIVITY-OF-TIMES and
COMMUTATIVITY-OF-PLUS, and unfolding NOT, AND, and IMPLIES, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-LESSP-TIMES-PLUS-INSTANCE
(DISABLE NOT-LESSP-TIMES-PLUS-INSTANCE)
[ 0.0 0.0 0.0 ]
NOT-LESSP-TIMES-PLUS-INSTANCE-OFF
(PROVE-LEMMA NOT-LESSP-PLUS-TIMES-QUOTIENT
(REWRITE)
(IMPLIES (AND (NOT (ZEROP N))
(AND (NUMBERP I)
(AND (LESSP I J)
(EQUAL (REMAINDER J N) '0))))
(EQUAL (LESSP J
(PLUS (TIMES N (QUOTIENT I N)) N))
'*1*FALSE))
((ENABLE-THEORY CL-ARITHMETIC GROUND-ZERO)
(ENABLE NOT-LESSP-TIMES-PLUS-INSTANCE)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, AND,
and IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I J)
(EQUAL (REMAINDER J N) 0))
(EQUAL (LESSP J
(PLUS (TIMES N (QUOTIENT I N)) N))
F)).
This simplifies, rewriting with COMMUTATIVITY-OF-PLUS, to the formula:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I J)
(EQUAL (REMAINDER J N) 0))
(NOT (LESSP J
(PLUS N (TIMES N (QUOTIENT I N)))))).
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace J by
(PLUS X (TIMES N Z)) to eliminate (REMAINDER J N) and (QUOTIENT J N). We
employ LESSP-REMAINDER2, the type restriction lemma noted when REMAINDER was
introduced, and the type restriction lemma noted when QUOTIENT was introduced
to constrain the new variables. We must thus prove two new conjectures:
Case 2. (IMPLIES (AND (NOT (NUMBERP J))
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I J)
(EQUAL (REMAINDER J N) 0))
(NOT (LESSP J
(PLUS N (TIMES N (QUOTIENT I N)))))),
which further simplifies, expanding LESSP, to:
T.
Case 1. (IMPLIES (AND (NUMBERP X)
(EQUAL (LESSP X N) (NOT (ZEROP N)))
(NUMBERP Z)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I (PLUS X (TIMES N Z)))
(EQUAL X 0))
(NOT (LESSP (PLUS X (TIMES N Z))
(PLUS N (TIMES N (QUOTIENT I N)))))),
which further simplifies, unfolding the definitions of NUMBERP, EQUAL, LESSP,
ZEROP, NOT, and PLUS, to the formula:
(IMPLIES (AND (NUMBERP Z)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I (TIMES N Z)))
(NOT (LESSP (TIMES N Z)
(PLUS N (TIMES N (QUOTIENT I N)))))).
Appealing to the lemma REMAINDER-QUOTIENT-ELIM, we now replace I by
(PLUS V (TIMES N X)) to eliminate (QUOTIENT I N) and (REMAINDER I N). We
use LESSP-REMAINDER2, the type restriction lemma noted when QUOTIENT was
introduced, and the type restriction lemma noted when REMAINDER was
introduced to constrain the new variables. The result is the formula:
(IMPLIES (AND (NUMBERP X)
(NUMBERP V)
(EQUAL (LESSP V N) (NOT (ZEROP N)))
(NUMBERP Z)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP (PLUS V (TIMES N X))
(TIMES N Z)))
(NOT (LESSP (TIMES N Z)
(PLUS N (TIMES N X))))).
This further simplifies, applying NOT-LESSP-TIMES-PLUS-INSTANCE, and opening
up ZEROP and NOT, to:
T.
Q.E.D.
[ 0.0 0.1 0.0 ]
NOT-LESSP-PLUS-TIMES-QUOTIENT
(DISABLE NOT-LESSP-PLUS-TIMES-QUOTIENT)
[ 0.0 0.0 0.0 ]
NOT-LESSP-PLUS-TIMES-QUOTIENT-OFF
(PROVE-LEMMA QUOTIENT-PLUS-TIMES-REMAINDER
(REWRITE)
(IMPLIES (NOT (ZEROP N))
(EQUAL (QUOTIENT (PLUS (TIMES N A) (REMAINDER B N))
N)
(FIX A)))
((USE (QUOTIENT-PLUS-TIMES (A A)
(B N)
(C (REMAINDER B N))))
(ENABLE COMMUTATIVITY-OF-PLUS LESSP-REMAINDER2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to the formula:
(IMPLIES
(AND (IMPLIES (LESSP (REMAINDER B N) N)
(EQUAL (QUOTIENT (PLUS (REMAINDER B N) (TIMES N A))
N)
(FIX A)))
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (QUOTIENT (PLUS (TIMES N A) (REMAINDER B N))
N)
(FIX A))).
This simplifies, rewriting with the lemmas LESSP-REMAINDER2 and
COMMUTATIVITY-OF-PLUS, and unfolding the definitions of FIX, IMPLIES, and
EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
QUOTIENT-PLUS-TIMES-REMAINDER
(DISABLE QUOTIENT-PLUS-TIMES-REMAINDER)
[ 0.0 0.0 0.0 ]
QUOTIENT-PLUS-TIMES-REMAINDER-OFF
(PROVE-LEMMA REMAINDER-PLUS-TIMES-REMAINDER
(REWRITE)
(EQUAL (REMAINDER (PLUS (TIMES N A) (REMAINDER B N))
N)
(REMAINDER B N))
((USE (REMAINDER-PLUS-TIMES-2 (J N)
(I A)
(X (REMAINDER B N))))
(ENABLE COMMUTATIVITY-OF-PLUS REMAINDER-REMAINDER DIVIDES
REMAINDER-X-X)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying REMAINDER-X-X, REMAINDER-REMAINDER, and
COMMUTATIVITY-OF-PLUS, and expanding the functions DIVIDES and EQUAL, to:
T.
Q.E.D.
[ 0.1 0.0 0.0 ]
REMAINDER-PLUS-TIMES-REMAINDER
(DISABLE REMAINDER-PLUS-TIMES-REMAINDER)
[ 0.0 0.0 0.0 ]
REMAINDER-PLUS-TIMES-REMAINDER-OFF
(PROVE-LEMMA REMAINDER-NON-ZERO NIL
(IMPLIES (AND (NOT (ZEROP N)) (LESSP N M))
(LESSP '0 (REMAINDER N M)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N M))
(LESSP 0 (REMAINDER N M))),
which simplifies, unfolding the definitions of REMAINDER, EQUAL, and LESSP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-NON-ZERO
(PROVE-LEMMA PLUS-NOT-EQUAL
(REWRITE)
(IMPLIES (NOT (EQUAL (FIX B) (FIX C)))
(NOT (EQUAL (PLUS A B) (PLUS A C))))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up FIX, to the following three new formulas:
Case 3. (IMPLIES (AND (NOT (NUMBERP C))
(NUMBERP B)
(NOT (EQUAL B 0)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))).
Name the above subgoal *1.
Case 2. (IMPLIES (AND (NUMBERP C)
(NOT (NUMBERP B))
(NOT (EQUAL 0 C)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(IMPLIES (NOT (EQUAL (FIX B) (FIX C)))
(NOT (EQUAL (PLUS A B) (PLUS A C)))),
which we named *1 above. We will appeal to induction. The recursive terms in
the conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p A B C))
(IMPLIES (AND (NOT (ZEROP A)) (p (SUB1 A) B C))
(p A B C))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definition
of ZEROP inform us that the measure (COUNT A) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme produces the following two new conjectures:
Case 2. (IMPLIES (AND (ZEROP A)
(NOT (EQUAL (FIX B) (FIX C))))
(NOT (EQUAL (PLUS A B) (PLUS A C)))).
This simplifies, opening up the definitions of ZEROP, FIX, EQUAL, and PLUS,
to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(NOT (EQUAL (PLUS (SUB1 A) B)
(PLUS (SUB1 A) C)))
(NOT (EQUAL (FIX B) (FIX C))))
(NOT (EQUAL (PLUS A B) (PLUS A C)))).
This simplifies, using linear arithmetic, to the new conjecture:
(IMPLIES (AND (LESSP A 1)
(NOT (ZEROP A))
(NOT (EQUAL (PLUS (SUB1 A) B)
(PLUS (SUB1 A) C)))
(NOT (EQUAL (FIX B) (FIX C))))
(NOT (EQUAL (PLUS A B) (PLUS A C)))),
which again simplifies, applying ADD1-EQUAL, and opening up the functions
ZEROP, FIX, and PLUS, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLUS-NOT-EQUAL
(DISABLE PLUS-NOT-EQUAL)
[ 0.0 0.0 0.0 ]
PLUS-NOT-EQUAL-OFF
(PROVE-LEMMA DIFFERENCE-PLUS4
(REWRITE)
(EQUAL (DIFFERENCE (PLUS A (PLUS B C))
(PLUS B C))
(FIX A))
((USE (DIFFERENCE-PLUS (Y A)
(X (PLUS B C))))
(ENABLE ASSOCIATIVITY-OF-PLUS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations AND and
ASSOCIATIVITY-OF-PLUS, to:
T.
This simplifies, obviously, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS4
(DISABLE DIFFERENCE-PLUS4)
[ 0.0 0.0 0.0 ]
DIFFERENCE-PLUS4-OFF
(PROVE-LEMMA REMAINDER-REMAINDER-INVERSE NIL
(IMPLIES (DIVIDES A B)
(EQUAL (REMAINDER N A)
(REMAINDER (REMAINDER N B) A)))
((ENABLE REMAINDER-REMAINDER)
(DISABLE REMAINDER)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, appealing to the lemma REMAINDER-REMAINDER, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REMAINDER-REMAINDER-INVERSE
(PROVE-LEMMA ASSOCIATIVITY-OF-PLUS-INVERSE NIL
(EQUAL (PLUS A (PLUS B C))
(PLUS (PLUS A B) C))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-PLUS-INVERSE
(DEFN LENGTH
(L)
(IF (LISTP L)
(ADD1 (LENGTH (CDR L)))
'0)
NIL)
Linear arithmetic and the lemma CDR-LESSP inform us that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Hence, LENGTH is accepted under the principle of definition.
From the definition we can conclude that (NUMBERP (LENGTH L)) is a theorem.
[ 0.0 0.0 0.0 ]
LENGTH
(DEFN INSERT
(I L)
(IF (LISTP L)
(IF (LESSP I (CAR L))
(CONS I L)
(CONS (CAR L) (INSERT I (CDR L))))
(CONS I L))
NIL)
Linear arithmetic and the lemma CDR-LESSP establish that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Hence, INSERT is accepted under the principle of definition.
Note that (LISTP (INSERT I L)) is a theorem.
[ 0.0 0.0 0.0 ]
INSERT
(DEFN OCCURRENCES
(X L)
(IF (LISTP L)
(IF (EQUAL X (CAR L))
(ADD1 (OCCURRENCES X (CDR L)))
(OCCURRENCES X (CDR L)))
'0)
NIL)
Linear arithmetic and the lemma CDR-LESSP establish that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Hence, OCCURRENCES is accepted under the principle of
definition. From the definition we can conclude that:
(NUMBERP (OCCURRENCES X L))
is a theorem.
[ 0.0 0.0 0.0 ]
OCCURRENCES
(DEFN REMOVE
(X L)
(IF (LISTP L)
(IF (EQUAL X (CAR L))
(CDR L)
(CONS (CAR L) (REMOVE X (CDR L))))
L)
NIL)
Linear arithmetic and the lemma CDR-LESSP inform us that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Hence, REMOVE is accepted under the principle of definition.
[ 0.0 0.0 0.0 ]
REMOVE
(DEFN PERMUTATION
(A B)
(IF (LISTP A)
(AND (MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(NLISTP B))
NIL)
Linear arithmetic and the lemma CDR-LESSP establish that the measure
(COUNT A) decreases according to the well-founded relation LESSP in each
recursive call. Hence, PERMUTATION is accepted under the definitional
principle. From the definition we can conclude that:
(OR (FALSEP (PERMUTATION A B))
(TRUEP (PERMUTATION A B)))
is a theorem.
[ 0.0 0.0 0.0 ]
PERMUTATION
(DEFN PLISTP
(L)
(IF (LISTP L)
(PLISTP (CDR L))
(EQUAL L 'NIL))
NIL)
Linear arithmetic and the lemma CDR-LESSP can be used to establish that
the measure (COUNT L) decreases according to the well-founded relation LESSP
in each recursive call. Hence, PLISTP is accepted under the principle of
definition. From the definition we can conclude that:
(OR (FALSEP (PLISTP L))
(TRUEP (PLISTP L)))
is a theorem.
[ 0.0 0.0 0.0 ]
PLISTP
(DEFN SETP
(L)
(IF (LISTP L)
(AND (NOT (MEMBER (CAR L) (CDR L)))
(SETP (CDR L)))
(EQUAL L 'NIL))
NIL)
Linear arithmetic and the lemma CDR-LESSP establish that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Hence, SETP is accepted under the definitional principle.
From the definition we can conclude that:
(OR (FALSEP (SETP L))
(TRUEP (SETP L)))
is a theorem.
[ 0.0 0.0 0.0 ]
SETP
(DEFN SORTED
(L)
(IF (LISTP L)
(IF (LISTP (CDR L))
(IF (LESSP (CAR (CDR L)) (CAR L))
'*1*FALSE
(SORTED (CDR L)))
'*1*TRUE)
'*1*TRUE)
NIL)
Linear arithmetic and the lemma CDR-LESSP can be used to prove that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each recursive call. Hence, SORTED is accepted under the principle of
definition. Observe that (OR (FALSEP (SORTED L)) (TRUEP (SORTED L))) is a
theorem.
[ 0.0 0.0 0.0 ]
SORTED
(PROVE-LEMMA NOT-LISTP-REMOVE
(REWRITE)
(IMPLIES (NOT (LISTP L))
(NOT (LISTP (REMOVE X (CONS X L)))))
((ENABLE REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
expanding the function REMOVE, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-LISTP-REMOVE
(DISABLE NOT-LISTP-REMOVE)
[ 0.0 0.0 0.0 ]
NOT-LISTP-REMOVE-OFF
(PROVE-LEMMA LENGTH-INSERT
(REWRITE)
(EQUAL (LENGTH (INSERT I L))
(ADD1 (LENGTH L)))
((ENABLE INSERT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. Two inductions are suggested
by terms in the conjecture. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (LESSP I (CAR L)))
(p I L))
(IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(p I (CDR L)))
(p I L))
(IMPLIES (NOT (LISTP L)) (p I L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates three new conjectures:
Case 3. (IMPLIES (AND (LISTP L) (LESSP I (CAR L)))
(EQUAL (LENGTH (INSERT I L))
(ADD1 (LENGTH L)))),
which simplifies, expanding the functions INSERT and LENGTH, to:
(IMPLIES (AND (LISTP L) (LESSP I (CAR L)))
(EQUAL (LENGTH (CONS I L))
(ADD1 (ADD1 (LENGTH (CDR L)))))).
But this again simplifies, applying CDR-CONS, and unfolding the function
LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(EQUAL (LENGTH (INSERT I (CDR L)))
(ADD1 (LENGTH (CDR L)))))
(EQUAL (LENGTH (INSERT I L))
(ADD1 (LENGTH L)))).
This simplifies, rewriting with CDR-CONS, and opening up the functions
INSERT and LENGTH, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (LENGTH (INSERT I L))
(ADD1 (LENGTH L)))),
which simplifies, applying CDR-CONS, and unfolding the definitions of INSERT,
ADD1, LENGTH, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-INSERT
(DISABLE LENGTH-INSERT)
[ 0.0 0.0 0.0 ]
LENGTH-INSERT-OFF
(PROVE-LEMMA LENGTH-REMOVE
(REWRITE)
(EQUAL (LENGTH (REMOVE X L))
(IF (MEMBER X L)
(SUB1 (LENGTH L))
(LENGTH L)))
((ENABLE REMOVE MEMBER LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, obviously, to two new formulas:
Case 2. (IMPLIES (NOT (MEMBER X L))
(EQUAL (LENGTH (REMOVE X L))
(LENGTH L))),
which we will name *1.
Case 1. (IMPLIES (MEMBER X L)
(EQUAL (LENGTH (REMOVE X L))
(SUB1 (LENGTH L)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (LENGTH (REMOVE X L))
(IF (MEMBER X L)
(SUB1 (LENGTH L))
(LENGTH L))),
which we named *1 above. We will appeal to induction. Four inductions are
suggested by terms in the conjecture. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(p X L))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(p X (CDR L)))
(p X L))
(IMPLIES (NOT (LISTP L)) (p X L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following three new
goals:
Case 3. (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(EQUAL (LENGTH (REMOVE X L))
(IF (MEMBER X L)
(SUB1 (LENGTH L))
(LENGTH L)))).
This simplifies, applying SUB1-ADD1, and opening up the definitions of
REMOVE, MEMBER, and LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(EQUAL (LENGTH (REMOVE X (CDR L)))
(IF (MEMBER X (CDR L))
(SUB1 (LENGTH (CDR L)))
(LENGTH (CDR L)))))
(EQUAL (LENGTH (REMOVE X L))
(IF (MEMBER X L)
(SUB1 (LENGTH L))
(LENGTH L)))),
which simplifies, rewriting with CDR-CONS, ADD1-SUB1, and SUB1-ADD1, and
expanding the definitions of REMOVE, LENGTH, and MEMBER, to:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(MEMBER X (CDR L))
(EQUAL (LENGTH (REMOVE X (CDR L)))
(SUB1 (LENGTH (CDR L))))
(EQUAL (LENGTH (CDR L)) 0))
(EQUAL 1 (LENGTH (CDR L)))),
which again simplifies, opening up the functions SUB1 and EQUAL, to the goal:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(MEMBER X (CDR L))
(EQUAL (LENGTH (REMOVE X (CDR L))) 0))
(NOT (EQUAL (LENGTH (CDR L)) 0))).
Appealing to the lemma CAR-CDR-ELIM, we now replace L by (CONS Z V) to
eliminate (CAR L) and (CDR L). We must thus prove:
(IMPLIES (AND (NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))).
Give the above formula the name *1.1.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (LENGTH (REMOVE X L))
(IF (MEMBER X L)
(SUB1 (LENGTH L))
(LENGTH L)))).
This simplifies, opening up the definitions of REMOVE, LENGTH, MEMBER, and
EQUAL, to:
T.
So we now return to:
(IMPLIES (AND (NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))),
named *1.1 above. We will appeal to induction. Three inductions are
suggested by terms in the conjecture. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (NLISTP V) (p V X Z))
(IMPLIES (AND (NOT (NLISTP V))
(EQUAL X (CAR V)))
(p V X Z))
(IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL X (CAR V)))
(p (CDR V) X Z))
(p V X Z))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP inform us that the measure (COUNT V) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme leads to the following five new conjectures:
Case 5. (IMPLIES (AND (NLISTP V)
(NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))).
This simplifies, expanding the definitions of NLISTP and MEMBER, to:
T.
Case 4. (IMPLIES (AND (NOT (NLISTP V))
(EQUAL X (CAR V))
(NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))).
This simplifies, opening up NLISTP, MEMBER, REMOVE, LENGTH, ADD1, and EQUAL,
to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL X (CAR V)))
(NOT (MEMBER X (CDR V)))
(NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))).
This simplifies, expanding NLISTP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL X (CAR V)))
(NOT (EQUAL (LENGTH (REMOVE X (CDR V))) 0))
(NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))).
This simplifies, applying CDR-CONS, and unfolding the definitions of NLISTP,
MEMBER, REMOVE, and LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL X (CAR V)))
(NOT (EQUAL (LENGTH (CDR V)) 0))
(NOT (EQUAL X Z))
(MEMBER X V)
(EQUAL (LENGTH (REMOVE X V)) 0))
(NOT (EQUAL (LENGTH V) 0))),
which simplifies, rewriting with the lemma CDR-CONS, and unfolding the
definitions of NLISTP, MEMBER, REMOVE, and LENGTH, to:
T.
That finishes the proof of *1.1, which, consequently, finishes the proof
of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-REMOVE
(DISABLE LENGTH-REMOVE)
[ 0.0 0.0 0.0 ]
LENGTH-REMOVE-OFF
(PROVE-LEMMA LENGTH-PERMUTATION NIL
(IMPLIES (PERMUTATION A B)
(EQUAL (LENGTH A) (LENGTH B)))
((ENABLE PERMUTATION LENGTH LENGTH-REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
We will appeal to induction. The recursive terms in the conjecture
suggest three inductions. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A)
(p (CDR A) (REMOVE (CAR A) B)))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for B. The above
induction scheme produces the following three new formulas:
Case 3. (IMPLIES (AND (LISTP A)
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(PERMUTATION A B))
(EQUAL (LENGTH A) (LENGTH B))).
This simplifies, expanding the definition of PERMUTATION, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (LENGTH (CDR A))
(LENGTH (REMOVE (CAR A) B)))
(PERMUTATION A B))
(EQUAL (LENGTH A) (LENGTH B))).
This simplifies, applying LENGTH-REMOVE, and expanding the definitions of
PERMUTATION and LENGTH, to the goal:
(IMPLIES (AND (LISTP A)
(MEMBER (CAR A) B)
(EQUAL (LENGTH (CDR A))
(SUB1 (LENGTH B)))
(PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(EQUAL (ADD1 (LENGTH (CDR A)))
(LENGTH B))).
But this again simplifies, using linear arithmetic, to the goal:
(IMPLIES (AND (EQUAL (LENGTH B) 0)
(LISTP A)
(MEMBER (CAR A) B)
(EQUAL (LENGTH (CDR A))
(SUB1 (LENGTH B)))
(PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(EQUAL (ADD1 (LENGTH (CDR A)))
(LENGTH B))).
However this again simplifies, unfolding the functions SUB1, ADD1, and EQUAL,
to:
(IMPLIES (AND (EQUAL (LENGTH B) 0)
(LISTP A)
(MEMBER (CAR A) B)
(EQUAL (LENGTH (CDR A)) 0))
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))).
Appealing to the lemma CAR-CDR-ELIM, we now replace A by (CONS X Z) to
eliminate (CAR A) and (CDR A). This generates:
(IMPLIES (AND (EQUAL (LENGTH B) 0)
(MEMBER X B)
(EQUAL (LENGTH Z) 0))
(NOT (PERMUTATION Z (REMOVE X B)))).
Name the above subgoal *1.1.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B))
(EQUAL (LENGTH A) (LENGTH B))).
This simplifies, opening up PERMUTATION, LENGTH, and EQUAL, to:
T.
So next consider:
(IMPLIES (AND (EQUAL (LENGTH B) 0)
(MEMBER X B)
(EQUAL (LENGTH Z) 0))
(NOT (PERMUTATION Z (REMOVE X B)))),
which we named *1.1 above. Perhaps we can prove it by induction. There are
two plausible inductions. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP Z) (p (CDR Z) X B))
(p Z X B))
(IMPLIES (NOT (LISTP Z)) (p Z X B))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT Z)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates the following three new
formulas:
Case 3. (IMPLIES (AND (LISTP Z)
(NOT (EQUAL (LENGTH (CDR Z)) 0))
(EQUAL (LENGTH B) 0)
(MEMBER X B)
(EQUAL (LENGTH Z) 0))
(NOT (PERMUTATION Z (REMOVE X B)))).
This simplifies, opening up the function LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP Z)
(NOT (PERMUTATION (CDR Z) (REMOVE X B)))
(EQUAL (LENGTH B) 0)
(MEMBER X B)
(EQUAL (LENGTH Z) 0))
(NOT (PERMUTATION Z (REMOVE X B)))).
This simplifies, opening up the function LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP Z))
(EQUAL (LENGTH B) 0)
(MEMBER X B)
(EQUAL (LENGTH Z) 0))
(NOT (PERMUTATION Z (REMOVE X B)))).
This simplifies, unfolding the functions LENGTH, EQUAL, and PERMUTATION, to
the new formula:
(IMPLIES (AND (NOT (LISTP Z))
(EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))),
which has an irrelevant term in it. By eliminating the term we get:
(IMPLIES (AND (EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))),
which we will name *1.1.1.
Perhaps we can prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP B) (p X (CDR B)))
(p X B))
(IMPLIES (NOT (LISTP B)) (p X B))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT B)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following four new
conjectures:
Case 4. (IMPLIES (AND (LISTP B)
(NOT (EQUAL (LENGTH (CDR B)) 0))
(EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))).
This simplifies, unfolding LENGTH, to:
T.
Case 3. (IMPLIES (AND (LISTP B)
(NOT (MEMBER X (CDR B)))
(EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))).
This simplifies, unfolding LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP B)
(LISTP (REMOVE X (CDR B)))
(EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))).
This simplifies, expanding the function LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP B))
(EQUAL (LENGTH B) 0)
(MEMBER X B))
(LISTP (REMOVE X B))).
This simplifies, opening up the functions LENGTH, EQUAL, and MEMBER, to:
T.
That finishes the proof of *1.1.1, which, consequently, also finishes the
proof of *1.1, which, in turn, also finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-PERMUTATION
(PROVE-LEMMA NUMBER-OF-OCCURRENCES-OF-SET-MEMBER-IS-1 NIL
(IMPLIES (AND (SETP L) (MEMBER X L))
(EQUAL (OCCURRENCES X L) '1))
((ENABLE SETP MEMBER OCCURRENCES)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(p X (CDR L)))
(p X L))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(p X (CDR L)))
(p X L))
(IMPLIES (NOT (LISTP L)) (p X L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme leads to the following seven new
conjectures:
Case 7. (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(NOT (SETP (CDR L)))
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, opening up SETP, to:
T.
Case 6. (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(NOT (MEMBER X (CDR L)))
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, rewriting with ADD1-EQUAL, and expanding the functions SETP,
MEMBER, OCCURRENCES, and NUMBERP, to the formula:
(IMPLIES (AND (LISTP L)
(NOT (MEMBER (CAR L) (CDR L)))
(SETP (CDR L)))
(EQUAL (OCCURRENCES (CAR L) (CDR L))
0)).
Appealing to the lemma CAR-CDR-ELIM, we now replace L by (CONS Z V) to
eliminate (CAR L) and (CDR L). The result is the conjecture:
(IMPLIES (AND (NOT (MEMBER Z V)) (SETP V))
(EQUAL (OCCURRENCES Z V) 0)).
Call the above conjecture *1.1.
Case 5. (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(EQUAL (OCCURRENCES X (CDR L)) 1)
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, opening up the functions SETP, MEMBER, ADD1, OCCURRENCES,
and EQUAL, to:
(IMPLIES (AND (LISTP L)
(EQUAL (OCCURRENCES (CAR L) (CDR L))
1)
(NOT (MEMBER (CAR L) (CDR L))))
(NOT (SETP (CDR L)))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS Z V) to eliminate
(CAR L) and (CDR L). We thus obtain:
(IMPLIES (AND (EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which we will name *1.2.
Case 4. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (SETP (CDR L)))
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, opening up the definition of SETP, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (CDR L)))
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, opening up SETP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(EQUAL (OCCURRENCES X (CDR L)) 1)
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, unfolding the definitions of SETP, MEMBER, OCCURRENCES, and
EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(SETP L)
(MEMBER X L))
(EQUAL (OCCURRENCES X L) 1)).
This simplifies, opening up the functions SETP, LISTP, and MEMBER, to:
T.
So we now return to:
(IMPLIES (AND (EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which we named *1.2 above. We will appeal to induction. The recursive terms
in the conjecture suggest three inductions. However, they merge into one
likely candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP V)
(EQUAL Z (CAR V))
(p (CDR V) Z))
(p V Z))
(IMPLIES (AND (LISTP V)
(NOT (EQUAL Z (CAR V)))
(p (CDR V) Z))
(p V Z))
(IMPLIES (NOT (LISTP V)) (p V Z))).
Linear arithmetic and the lemma CDR-LESSP can be used to prove that the
measure (COUNT V) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme produces seven
new formulas:
Case 7. (IMPLIES (AND (LISTP V)
(EQUAL Z (CAR V))
(NOT (EQUAL (OCCURRENCES Z (CDR V)) 1))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, rewriting with ADD1-EQUAL, and opening up OCCURRENCES,
NUMBERP, and MEMBER, to:
T.
Case 6. (IMPLIES (AND (LISTP V)
(EQUAL Z (CAR V))
(MEMBER Z (CDR V))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))).
This simplifies, applying ADD1-EQUAL, and unfolding the definitions of
OCCURRENCES, NUMBERP, and MEMBER, to:
T.
Case 5. (IMPLIES (AND (LISTP V)
(EQUAL Z (CAR V))
(NOT (SETP (CDR V)))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, applying the lemma ADD1-EQUAL, and unfolding the functions
OCCURRENCES, NUMBERP, and MEMBER, to:
T.
Case 4. (IMPLIES (AND (LISTP V)
(NOT (EQUAL Z (CAR V)))
(NOT (EQUAL (OCCURRENCES Z (CDR V)) 1))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, unfolding the function OCCURRENCES, to:
T.
Case 3. (IMPLIES (AND (LISTP V)
(NOT (EQUAL Z (CAR V)))
(MEMBER Z (CDR V))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, expanding the functions OCCURRENCES and MEMBER, to:
T.
Case 2. (IMPLIES (AND (LISTP V)
(NOT (EQUAL Z (CAR V)))
(NOT (SETP (CDR V)))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, expanding the functions OCCURRENCES, MEMBER, and SETP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP V))
(EQUAL (OCCURRENCES Z V) 1)
(NOT (MEMBER Z V)))
(NOT (SETP V))),
which simplifies, unfolding the definitions of OCCURRENCES and EQUAL, to:
T.
That finishes the proof of *1.2.
So we now return to:
(IMPLIES (AND (NOT (MEMBER Z V)) (SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which we named *1.1 above. Let us appeal to the induction principle. Three
inductions are suggested by terms in the conjecture. However, they merge into
one likely candidate induction. We will induct according to the following
scheme:
(AND (IMPLIES (NLISTP V) (p Z V))
(IMPLIES (AND (NOT (NLISTP V))
(EQUAL Z (CAR V)))
(p Z V))
(IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL Z (CAR V)))
(p Z (CDR V)))
(p Z V))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP inform us that the measure (COUNT V) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme leads to five new conjectures:
Case 5. (IMPLIES (AND (NLISTP V)
(NOT (MEMBER Z V))
(SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which simplifies, expanding NLISTP, MEMBER, SETP, LISTP, OCCURRENCES, and
EQUAL, to:
T.
Case 4. (IMPLIES (AND (NOT (NLISTP V))
(EQUAL Z (CAR V))
(NOT (MEMBER Z V))
(SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which simplifies, unfolding the definitions of NLISTP and MEMBER, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL Z (CAR V)))
(MEMBER Z (CDR V))
(NOT (MEMBER Z V))
(SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which simplifies, unfolding NLISTP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL Z (CAR V)))
(NOT (SETP (CDR V)))
(NOT (MEMBER Z V))
(SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which simplifies, unfolding NLISTP, MEMBER, and SETP, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP V))
(NOT (EQUAL Z (CAR V)))
(EQUAL (OCCURRENCES Z (CDR V)) 0)
(NOT (MEMBER Z V))
(SETP V))
(EQUAL (OCCURRENCES Z V) 0)),
which simplifies, unfolding the functions NLISTP, MEMBER, SETP, OCCURRENCES,
and EQUAL, to:
T.
That finishes the proof of *1.1, which finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NUMBER-OF-OCCURRENCES-OF-SET-MEMBER-IS-1
(PROVE-LEMMA PLISTP-REMOVE
(REWRITE)
(EQUAL (PLISTP (REMOVE X L))
(PLISTP L))
((ENABLE PLISTP REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(p X L))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(p X (CDR L)))
(p X L))
(IMPLIES (NOT (LISTP L)) (p X L))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme generates the
following three new formulas:
Case 3. (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(EQUAL (PLISTP (REMOVE X L))
(PLISTP L))).
This simplifies, expanding the definitions of REMOVE and PLISTP, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(EQUAL (PLISTP (REMOVE X (CDR L)))
(PLISTP (CDR L))))
(EQUAL (PLISTP (REMOVE X L))
(PLISTP L))).
This simplifies, appealing to the lemma CDR-CONS, and opening up REMOVE and
PLISTP, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (PLISTP (REMOVE X L))
(PLISTP L))).
This simplifies, unfolding REMOVE and PLISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.1 0.0 0.0 ]
PLISTP-REMOVE
(DISABLE PLISTP-REMOVE)
[ 0.0 0.0 0.0 ]
PLISTP-REMOVE-OFF
(PROVE-LEMMA PLISTP-SET
(REWRITE)
(IMPLIES (SETP L) (PLISTP L))
((ENABLE SETP PLISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. There are two plausible inductions.
However, they merge into one likely candidate induction. We will induct
according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (p (CDR L)))
(p L))
(IMPLIES (NOT (LISTP L)) (p L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following three new
goals:
Case 3. (IMPLIES (AND (LISTP L)
(NOT (SETP (CDR L)))
(SETP L))
(PLISTP L)).
This simplifies, expanding the definition of SETP, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(PLISTP (CDR L))
(SETP L))
(PLISTP L)).
This simplifies, expanding SETP and PLISTP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L)) (SETP L))
(PLISTP L)).
This simplifies, unfolding the functions SETP, EQUAL, LISTP, and PLISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-SET
(DISABLE PLISTP-SET)
[ 0.0 0.0 0.0 ]
PLISTP-SET-OFF
(PROVE-LEMMA INSERT-REMOVE
(REWRITE)
(IMPLIES (AND (SORTED L) (NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L))))
((ENABLE INSERT REMOVE SORTED)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. There are three plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L)))
(p X Y L))
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(p X Y (CDR L)))
(p X Y L))
(IMPLIES (AND (LISTP L) (NOT (LISTP (CDR L))))
(p X Y L))
(IMPLIES (NOT (LISTP L)) (p X Y L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces five new goals:
Case 5. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L))
(SORTED L)
(NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L)))),
which simplifies, opening up SORTED, to:
T.
Case 4. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(NOT (SORTED (CDR L)))
(SORTED L)
(NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L)))),
which simplifies, unfolding the definition of SORTED, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))
(SORTED L)
(NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L)))),
which simplifies, unfolding the definitions of SORTED, REMOVE, and INSERT,
to four new conjectures:
Case 3.4.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))
(SORTED (CDR L))
(NOT (EQUAL X Y))
(NOT (LESSP X (CAR L)))
(NOT (EQUAL Y (CAR L))))
(EQUAL (INSERT X
(CONS (CAR L) (REMOVE Y (CDR L))))
(REMOVE Y
(CONS (CAR L) (INSERT X (CDR L)))))),
which again simplifies, rewriting with CDR-CONS and CAR-CONS, and opening
up the functions INSERT and REMOVE, to:
T.
Case 3.3.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))
(SORTED (CDR L))
(NOT (EQUAL X Y))
(NOT (LESSP X (CAR L)))
(EQUAL Y (CAR L)))
(EQUAL (INSERT X (CDR L))
(REMOVE Y
(CONS (CAR L) (INSERT X (CDR L)))))).
However this again simplifies, rewriting with the lemmas CDR-CONS and
CAR-CONS, and unfolding the definition of REMOVE, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))
(SORTED (CDR L))
(NOT (EQUAL X Y))
(LESSP X (CAR L))
(NOT (EQUAL Y (CAR L))))
(EQUAL (INSERT X
(CONS (CAR L) (REMOVE Y (CDR L))))
(REMOVE Y (CONS X L)))),
which again simplifies, applying CAR-CONS and CDR-CONS, and opening up the
functions INSERT and REMOVE, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))
(SORTED (CDR L))
(NOT (EQUAL X Y))
(LESSP X (CAR L))
(EQUAL Y (CAR L)))
(EQUAL (INSERT X (CDR L))
(REMOVE Y (CONS X L)))).
This again simplifies, applying CDR-CONS and CAR-CONS, and expanding the
function REMOVE, to the new formula:
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(EQUAL (INSERT X (REMOVE (CAR L) (CDR L)))
(REMOVE (CAR L) (INSERT X (CDR L))))
(SORTED (CDR L))
(NOT (EQUAL X (CAR L)))
(LESSP X (CAR L)))
(EQUAL (INSERT X (CDR L))
(CONS X (CDR L)))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS V Z) to eliminate
(CDR L) and (CAR L) and Z by (CONS W D) to eliminate (CAR Z) and (CDR Z).
This produces:
(IMPLIES (AND (NOT (LESSP W V))
(EQUAL (INSERT X (REMOVE V (CONS W D)))
(REMOVE V (INSERT X (CONS W D))))
(SORTED (CONS W D))
(NOT (EQUAL X V))
(LESSP X V))
(EQUAL (INSERT X (CONS W D))
(CONS X (CONS W D)))),
which further simplifies, rewriting with CDR-CONS, CAR-CONS, and
CONS-EQUAL, and expanding the definitions of REMOVE, INSERT, and SORTED,
to the following three new goals:
Case 3.1.3.
(IMPLIES (AND (NOT (LESSP W V))
(NOT (LESSP X W))
(NOT (EQUAL V W))
(EQUAL (INSERT X (CONS W (REMOVE V D)))
(REMOVE V (CONS W (INSERT X D))))
(NOT (LISTP D))
(NOT (EQUAL X V))
(LESSP X V))
(EQUAL W X)).
However this again simplifies, using linear arithmetic, to:
T.
Case 3.1.2.
(IMPLIES (AND (NOT (LESSP W V))
(NOT (LESSP X W))
(NOT (EQUAL V W))
(EQUAL (INSERT X (CONS W (REMOVE V D)))
(REMOVE V (CONS W (INSERT X D))))
(NOT (LESSP (CAR D) W))
(SORTED D)
(NOT (EQUAL X V))
(LESSP X V))
(EQUAL W X)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.1.1.
(IMPLIES (AND (NOT (LESSP W V))
(NOT (LESSP X W))
(NOT (EQUAL V W))
(EQUAL (INSERT X (CONS W (REMOVE V D)))
(REMOVE V (CONS W (INSERT X D))))
(NOT (LESSP (CAR D) W))
(SORTED D)
(NOT (EQUAL X V))
(LESSP X V))
(EQUAL (INSERT X D) (CONS W D))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(SORTED L)
(NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L)))),
which simplifies, unfolding the functions SORTED, REMOVE, and INSERT, to
four new goals:
Case 2.4.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X Y))
(NOT (LESSP X (CAR L)))
(NOT (EQUAL Y (CAR L))))
(EQUAL (INSERT X
(CONS (CAR L) (REMOVE Y (CDR L))))
(REMOVE Y
(CONS (CAR L) (INSERT X (CDR L)))))),
which again simplifies, appealing to the lemmas CDR-CONS, CAR-CONS, and
CONS-EQUAL, and expanding the definitions of INSERT and REMOVE, to:
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X Y))
(NOT (LESSP X (CAR L)))
(NOT (EQUAL Y (CAR L))))
(EQUAL (INSERT X (REMOVE Y (CDR L)))
(REMOVE Y (INSERT X (CDR L))))).
But this further simplifies, applying CDR-CONS and CAR-CONS, and opening
up the definitions of REMOVE and INSERT, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X Y))
(NOT (LESSP X (CAR L)))
(EQUAL Y (CAR L)))
(EQUAL (INSERT X (CDR L))
(REMOVE Y
(CONS (CAR L) (INSERT X (CDR L)))))).
However this again simplifies, applying CDR-CONS and CAR-CONS, and
expanding the definition of REMOVE, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X Y))
(LESSP X (CAR L))
(NOT (EQUAL Y (CAR L))))
(EQUAL (INSERT X
(CONS (CAR L) (REMOVE Y (CDR L))))
(REMOVE Y (CONS X L)))).
However this again simplifies, rewriting with CAR-CONS and CDR-CONS, and
expanding INSERT and REMOVE, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X Y))
(LESSP X (CAR L))
(EQUAL Y (CAR L)))
(EQUAL (INSERT X (CDR L))
(REMOVE Y (CONS X L)))).
However this again simplifies, rewriting with CDR-CONS and CAR-CONS, and
opening up the function REMOVE, to the new goal:
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X (CAR L)))
(LESSP X (CAR L)))
(EQUAL (INSERT X (CDR L))
(CONS X (CDR L)))),
which further simplifies, opening up INSERT, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(SORTED L)
(NOT (EQUAL X Y)))
(EQUAL (INSERT X (REMOVE Y L))
(REMOVE Y (INSERT X L)))),
which simplifies, rewriting with CDR-CONS and CAR-CONS, and unfolding the
definitions of SORTED, REMOVE, and INSERT, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
INSERT-REMOVE
(DISABLE INSERT-REMOVE)
[ 0.0 0.0 0.0 ]
INSERT-REMOVE-OFF
(PROVE-LEMMA MEMBER-INSERT
(REWRITE)
(IMPLIES (MEMBER X L)
(MEMBER X (INSERT I L)))
((ENABLE MEMBER INSERT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. Two inductions are suggested
by terms in the conjecture. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (NLISTP L) (p X I L))
(IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L)))
(p X I L))
(IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(p X I (CDR L)))
(p X I L))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP establish that the measure (COUNT L) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme generates four new conjectures:
Case 4. (IMPLIES (AND (NLISTP L) (MEMBER X L))
(MEMBER X (INSERT I L))),
which simplifies, expanding the functions NLISTP and MEMBER, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L))
(MEMBER X L))
(MEMBER X (INSERT I L))),
which simplifies, opening up the functions NLISTP, MEMBER, and INSERT, to
two new formulas:
Case 3.2.
(IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L))))
(MEMBER (CAR L)
(CONS (CAR L) (INSERT I (CDR L))))),
which again simplifies, rewriting with the lemma CAR-CONS, and opening up
the function MEMBER, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP L) (LESSP I (CAR L)))
(MEMBER (CAR L) (CONS I L))),
which again simplifies, applying CDR-CONS and CAR-CONS, and unfolding the
definition of MEMBER, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (CDR L)))
(MEMBER X L))
(MEMBER X (INSERT I L))).
This simplifies, expanding NLISTP and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(MEMBER X (INSERT I (CDR L)))
(MEMBER X L))
(MEMBER X (INSERT I L))).
This simplifies, expanding the functions NLISTP, MEMBER, and INSERT, to the
following two new goals:
Case 1.2.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(MEMBER X (INSERT I (CDR L)))
(MEMBER X (CDR L))
(NOT (LESSP I (CAR L))))
(MEMBER X
(CONS (CAR L) (INSERT I (CDR L))))).
This again simplifies, applying CDR-CONS and CAR-CONS, and expanding
MEMBER, to:
T.
Case 1.1.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(MEMBER X (INSERT I (CDR L)))
(MEMBER X (CDR L))
(LESSP I (CAR L)))
(MEMBER X (CONS I L))).
This again simplifies, applying CDR-CONS and CAR-CONS, and opening up the
definition of MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
MEMBER-INSERT
(DISABLE MEMBER-INSERT)
[ 0.0 0.0 0.0 ]
MEMBER-INSERT-OFF
(PROVE-LEMMA NOT-MEMBER-INSERT
(REWRITE)
(IMPLIES (AND (NOT (MEMBER X L))
(NOT (EQUAL I X)))
(NOT (MEMBER X (INSERT I L))))
((ENABLE MEMBER INSERT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Let us appeal to the induction principle. There are two plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (NLISTP L) (p X I L))
(IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L)))
(p X I L))
(IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(p X I (CDR L)))
(p X I L))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP inform us that the measure (COUNT L) decreases according to the
well-founded relation LESSP in each induction step of the scheme. The above
induction scheme produces four new formulas:
Case 4. (IMPLIES (AND (NLISTP L)
(NOT (MEMBER X L))
(NOT (EQUAL I X)))
(NOT (MEMBER X (INSERT I L)))),
which simplifies, applying the lemmas CDR-CONS and CAR-CONS, and opening up
NLISTP, MEMBER, and INSERT, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L))
(NOT (MEMBER X L))
(NOT (EQUAL I X)))
(NOT (MEMBER X (INSERT I L)))),
which simplifies, expanding NLISTP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(MEMBER X (CDR L))
(NOT (MEMBER X L))
(NOT (EQUAL I X)))
(NOT (MEMBER X (INSERT I L)))),
which simplifies, opening up NLISTP and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (INSERT I (CDR L))))
(NOT (MEMBER X L))
(NOT (EQUAL I X)))
(NOT (MEMBER X (INSERT I L)))),
which simplifies, expanding NLISTP, MEMBER, and INSERT, to two new formulas:
Case 1.2.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (INSERT I (CDR L))))
(NOT (MEMBER X (CDR L)))
(NOT (EQUAL I X))
(NOT (LESSP I (CAR L))))
(NOT (MEMBER X
(CONS (CAR L) (INSERT I (CDR L)))))),
which again simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS,
and opening up the definition of MEMBER, to:
T.
Case 1.1.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (INSERT I (CDR L))))
(NOT (MEMBER X (CDR L)))
(NOT (EQUAL I X))
(LESSP I (CAR L)))
(NOT (MEMBER X (CONS I L)))),
which again simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS,
and expanding the definition of MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-MEMBER-INSERT
(DISABLE NOT-MEMBER-INSERT)
[ 0.0 0.0 0.0 ]
NOT-MEMBER-INSERT-OFF
(PROVE-LEMMA MEMBER-REMOVE1 NIL
(IMPLIES (MEMBER X (REMOVE Y L))
(MEMBER X L))
((ENABLE MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. Two inductions are suggested
by terms in the conjecture. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (EQUAL Y (CAR L)))
(p X L Y))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL Y (CAR L)))
(p X (CDR L) Y))
(p X L Y))
(IMPLIES (NOT (LISTP L)) (p X L Y))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates four new conjectures:
Case 4. (IMPLIES (AND (LISTP L)
(EQUAL Y (CAR L))
(MEMBER X (REMOVE Y L)))
(MEMBER X L)),
which simplifies, expanding the functions REMOVE and MEMBER, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (EQUAL Y (CAR L)))
(NOT (MEMBER X (REMOVE Y (CDR L))))
(MEMBER X (REMOVE Y L)))
(MEMBER X L)),
which simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
expanding REMOVE and MEMBER, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL Y (CAR L)))
(MEMBER X (CDR L))
(MEMBER X (REMOVE Y L)))
(MEMBER X L)),
which simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS, and
opening up the functions REMOVE and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(MEMBER X (REMOVE Y L)))
(MEMBER X L)),
which simplifies, expanding REMOVE and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
MEMBER-REMOVE1
(PROVE-LEMMA MEMBER-REMOVE2
(REWRITE)
(IMPLIES (AND (MEMBER X L) (NOT (EQUAL X Y)))
(MEMBER X (REMOVE Y L)))
((ENABLE MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (NLISTP L) (p X Y L))
(IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L)))
(p X Y L))
(IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(p X Y (CDR L)))
(p X Y L))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP can be used to show that the measure (COUNT L) decreases according to
the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme generates the following four new conjectures:
Case 4. (IMPLIES (AND (NLISTP L)
(MEMBER X L)
(NOT (EQUAL X Y)))
(MEMBER X (REMOVE Y L))).
This simplifies, opening up the functions NLISTP and MEMBER, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L))
(MEMBER X L)
(NOT (EQUAL X Y)))
(MEMBER X (REMOVE Y L))).
This simplifies, rewriting with CAR-CONS, and opening up the definitions of
NLISTP, MEMBER, and REMOVE, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (CDR L)))
(MEMBER X L)
(NOT (EQUAL X Y)))
(MEMBER X (REMOVE Y L))),
which simplifies, unfolding the functions NLISTP and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(MEMBER X (REMOVE Y (CDR L)))
(MEMBER X L)
(NOT (EQUAL X Y)))
(MEMBER X (REMOVE Y L))),
which simplifies, unfolding the definitions of NLISTP, MEMBER, and REMOVE,
to the goal:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(MEMBER X (REMOVE Y (CDR L)))
(MEMBER X (CDR L))
(NOT (EQUAL X Y))
(NOT (EQUAL Y (CAR L))))
(MEMBER X
(CONS (CAR L) (REMOVE Y (CDR L))))).
But this again simplifies, rewriting with CDR-CONS and CAR-CONS, and opening
up the definition of MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
MEMBER-REMOVE2
(DISABLE MEMBER-REMOVE2)
[ 0.0 0.0 0.0 ]
MEMBER-REMOVE2-OFF
(PROVE-LEMMA NOT-MEMBER-REMOVE1
(REWRITE)
(IMPLIES (SETP L)
(NOT (MEMBER X (REMOVE X L))))
((ENABLE SETP MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
We will appeal to induction. The recursive terms in the conjecture
suggest two inductions. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(p X L))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(p X (CDR L)))
(p X L))
(IMPLIES (NOT (LISTP L)) (p X L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following four new
formulas:
Case 4. (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(SETP L))
(NOT (MEMBER X (REMOVE X L)))).
This simplifies, expanding the definitions of SETP and REMOVE, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (SETP (CDR L)))
(SETP L))
(NOT (MEMBER X (REMOVE X L)))).
This simplifies, expanding the definition of SETP, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (REMOVE X (CDR L))))
(SETP L))
(NOT (MEMBER X (REMOVE X L)))).
This simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
unfolding the functions SETP, REMOVE, and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L)) (SETP L))
(NOT (MEMBER X (REMOVE X L)))).
This simplifies, expanding the functions SETP, LISTP, REMOVE, and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-MEMBER-REMOVE1
(DISABLE NOT-MEMBER-REMOVE1)
[ 0.0 0.0 0.0 ]
NOT-MEMBER-REMOVE1-OFF
(PROVE-LEMMA NOT-MEMBER-REMOVE2
(REWRITE)
(IMPLIES (NOT (MEMBER X L))
(NOT (MEMBER X (REMOVE Y L))))
((ENABLE MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (NLISTP L) (p X Y L))
(IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L)))
(p X Y L))
(IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(p X Y (CDR L)))
(p X Y L))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP can be used to show that the measure (COUNT L) decreases according to
the well-founded relation LESSP in each induction step of the scheme. The
above induction scheme leads to the following four new goals:
Case 4. (IMPLIES (AND (NLISTP L) (NOT (MEMBER X L)))
(NOT (MEMBER X (REMOVE Y L)))).
This simplifies, expanding the definitions of NLISTP, MEMBER, and REMOVE, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP L))
(EQUAL X (CAR L))
(NOT (MEMBER X L)))
(NOT (MEMBER X (REMOVE Y L)))).
This simplifies, unfolding NLISTP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(MEMBER X (CDR L))
(NOT (MEMBER X L)))
(NOT (MEMBER X (REMOVE Y L)))).
This simplifies, unfolding the definitions of NLISTP and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP L))
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (REMOVE Y (CDR L))))
(NOT (MEMBER X L)))
(NOT (MEMBER X (REMOVE Y L)))).
This simplifies, expanding the definitions of NLISTP, MEMBER, and REMOVE, to
the new conjecture:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(NOT (MEMBER X (REMOVE Y (CDR L))))
(NOT (MEMBER X (CDR L)))
(NOT (EQUAL Y (CAR L))))
(NOT (MEMBER X
(CONS (CAR L) (REMOVE Y (CDR L)))))),
which again simplifies, applying the lemmas CDR-CONS and CAR-CONS, and
opening up the function MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-MEMBER-REMOVE2
(DISABLE NOT-MEMBER-REMOVE2)
[ 0.0 0.0 0.0 ]
NOT-MEMBER-REMOVE2-OFF
(PROVE-LEMMA NOT-MEMBER-PERMUTATION NIL
(IMPLIES (AND (PERMUTATION A B)
(NOT (MEMBER X B)))
(NOT (MEMBER X A)))
((ENABLE PERMUTATION MEMBER NOT-MEMBER-REMOVE2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A)
(p X (CDR A) (REMOVE (CAR A) B)))
(p X A B))
(IMPLIES (NOT (LISTP A)) (p X A B))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for B. The above
induction scheme leads to the following four new conjectures:
Case 4. (IMPLIES (AND (LISTP A)
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(PERMUTATION A B)
(NOT (MEMBER X B)))
(NOT (MEMBER X A))).
This simplifies, opening up PERMUTATION, to:
T.
Case 3. (IMPLIES (AND (LISTP A)
(MEMBER X (REMOVE (CAR A) B))
(PERMUTATION A B)
(NOT (MEMBER X B)))
(NOT (MEMBER X A))).
This simplifies, rewriting with NOT-MEMBER-REMOVE2, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(NOT (MEMBER X (CDR A)))
(PERMUTATION A B)
(NOT (MEMBER X B)))
(NOT (MEMBER X A))),
which simplifies, opening up the definitions of PERMUTATION and MEMBER, to:
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (CDR A)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(NOT (MEMBER X B)))
(NOT (EQUAL X (CAR A)))).
This again simplifies, trivially, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B)
(NOT (MEMBER X B)))
(NOT (MEMBER X A))).
This simplifies, unfolding PERMUTATION and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-MEMBER-PERMUTATION
(PROVE-LEMMA MEMBER-PERMUTATION NIL
(IMPLIES (AND (PERMUTATION A B) (MEMBER X B))
(MEMBER X A))
((ENABLE PERMUTATION MEMBER MEMBER-REMOVE2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A)
(p X (CDR A) (REMOVE (CAR A) B)))
(p X A B))
(IMPLIES (NOT (LISTP A)) (p X A B))).
Linear arithmetic and the lemma CDR-LESSP can be used to prove that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. Note, however, the inductive instance
chosen for B. The above induction scheme leads to four new goals:
Case 4. (IMPLIES (AND (LISTP A)
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(PERMUTATION A B)
(MEMBER X B))
(MEMBER X A)),
which simplifies, opening up the definition of PERMUTATION, to:
T.
Case 3. (IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(PERMUTATION A B)
(MEMBER X B))
(MEMBER X A)),
which simplifies, expanding PERMUTATION and MEMBER, to:
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(MEMBER X B)
(NOT (EQUAL X (CAR A))))
(MEMBER X (CDR A))).
But this again simplifies, appealing to the lemma MEMBER-REMOVE2, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(MEMBER X (CDR A))
(PERMUTATION A B)
(MEMBER X B))
(MEMBER X A)),
which simplifies, opening up the definitions of PERMUTATION and MEMBER, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B)
(MEMBER X B))
(MEMBER X A)),
which simplifies, expanding the functions PERMUTATION and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
MEMBER-PERMUTATION
(PROVE-LEMMA REMOVE-REMOVE
(REWRITE)
(IMPLIES (NOT (EQUAL X Y))
(EQUAL (REMOVE Y (REMOVE X L))
(REMOVE X (REMOVE Y L))))
((ENABLE REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Perhaps we can prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (EQUAL X (CAR L)))
(p Y X L))
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(p Y X (CDR L)))
(p Y X L))
(IMPLIES (NOT (LISTP L)) (p Y X L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme leads to the following three new
conjectures:
Case 3. (IMPLIES (AND (LISTP L)
(EQUAL X (CAR L))
(NOT (EQUAL X Y)))
(EQUAL (REMOVE Y (REMOVE X L))
(REMOVE X (REMOVE Y L)))).
This simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
unfolding REMOVE, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(EQUAL (REMOVE Y (REMOVE X (CDR L)))
(REMOVE X (REMOVE Y (CDR L))))
(NOT (EQUAL X Y)))
(EQUAL (REMOVE Y (REMOVE X L))
(REMOVE X (REMOVE Y L)))).
This simplifies, applying CDR-CONS and CAR-CONS, and expanding the
definition of REMOVE, to the conjecture:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL X (CAR L)))
(EQUAL (REMOVE Y (REMOVE X (CDR L)))
(REMOVE X (REMOVE Y (CDR L))))
(NOT (EQUAL X Y))
(NOT (EQUAL Y (CAR L))))
(EQUAL (CONS (CAR L)
(REMOVE X (REMOVE Y (CDR L))))
(REMOVE X
(CONS (CAR L) (REMOVE Y (CDR L)))))).
However this again simplifies, rewriting with CDR-CONS and CAR-CONS, and
expanding the definition of REMOVE, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(NOT (EQUAL X Y)))
(EQUAL (REMOVE Y (REMOVE X L))
(REMOVE X (REMOVE Y L)))).
This simplifies, opening up the function REMOVE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
REMOVE-REMOVE
(DISABLE REMOVE-REMOVE)
[ 0.0 0.0 0.0 ]
REMOVE-REMOVE-OFF
(PROVE-LEMMA SORTED-INSERT
(REWRITE)
(IMPLIES (AND (SORTED L) (NOT (MEMBER I L)))
(SORTED (INSERT I L)))
((ENABLE SORTED INSERT MEMBER)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are three plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L)))
(p I L))
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(p I (CDR L)))
(p I L))
(IMPLIES (AND (LISTP L) (NOT (LISTP (CDR L))))
(p I L))
(IMPLIES (NOT (LISTP L)) (p I L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates six new goals:
Case 6. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, opening up the function SORTED, to:
T.
Case 5. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(NOT (SORTED (CDR L)))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, expanding SORTED, to:
T.
Case 4. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(MEMBER I (CDR L))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, expanding the functions SORTED and MEMBER, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (INSERT I (CDR L)))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, opening up the definitions of SORTED, MEMBER, and INSERT,
to two new conjectures:
Case 3.2.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (INSERT I (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(NOT (LESSP I (CAR L))))
(SORTED (CONS (CAR L) (INSERT I (CDR L))))),
which again simplifies, rewriting with CAR-CONS and CDR-CONS, and opening
up the function SORTED, to:
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (INSERT I (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(NOT (LESSP I (CAR L))))
(NOT (LESSP (CAR (INSERT I (CDR L)))
(CAR L)))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS Z X) to eliminate
(CDR L) and (CAR L) and X by (CONS V W) to eliminate (CAR X) and (CDR X).
This produces the new conjecture:
(IMPLIES (AND (NOT (LESSP V Z))
(SORTED (INSERT I (CONS V W)))
(SORTED (CONS V W))
(NOT (EQUAL I Z))
(NOT (MEMBER I (CONS V W)))
(NOT (LESSP I Z)))
(NOT (LESSP (CAR (INSERT I (CONS V W)))
Z))),
which further simplifies, applying CDR-CONS and CAR-CONS, and opening up
the functions INSERT, SORTED, and MEMBER, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (INSERT I (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(LESSP I (CAR L)))
(SORTED (CONS I L))).
But this again simplifies, applying CAR-CONS and CDR-CONS, and expanding
the function SORTED, to:
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (INSERT I (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(LESSP I (CAR L)))
(NOT (LESSP (CAR L) I))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, expanding the definitions of SORTED, MEMBER, and INSERT,
to two new conjectures:
Case 2.2.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(NOT (LESSP I (CAR L))))
(SORTED (CONS (CAR L) (INSERT I (CDR L))))),
which again simplifies, applying CAR-CONS and CDR-CONS, and unfolding
SORTED, to the following two new formulas:
Case 2.2.2.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(NOT (LESSP I (CAR L))))
(NOT (LESSP (CAR (INSERT I (CDR L)))
(CAR L)))).
But this further simplifies, applying the lemma CAR-CONS, and unfolding
the functions MEMBER and INSERT, to:
T.
Case 2.2.1.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(NOT (LESSP I (CAR L))))
(SORTED (INSERT I (CDR L)))),
which further simplifies, rewriting with CDR-CONS, and expanding the
functions MEMBER, INSERT, and SORTED, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(LESSP I (CAR L)))
(SORTED (CONS I L))).
But this again simplifies, applying CAR-CONS and CDR-CONS, and expanding
the definition of SORTED, to:
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL I (CAR L)))
(NOT (MEMBER I (CDR L)))
(LESSP I (CAR L)))
(NOT (LESSP (CAR L) I))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(SORTED L)
(NOT (MEMBER I L)))
(SORTED (INSERT I L))),
which simplifies, applying the lemma CDR-CONS, and opening up the functions
SORTED, MEMBER, and INSERT, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.1 ]
SORTED-INSERT
(DISABLE SORTED-INSERT)
[ 0.0 0.0 0.0 ]
SORTED-INSERT-OFF
(PROVE-LEMMA SORTED-REMOVE
(REWRITE)
(IMPLIES (SORTED L)
(SORTED (REMOVE X L)))
((ENABLE SORTED REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L)))
(p X L))
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(p X (CDR L)))
(p X L))
(IMPLIES (AND (LISTP L) (NOT (LISTP (CDR L))))
(p X L))
(IMPLIES (NOT (LISTP L)) (p X L))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme generates the
following five new formulas:
Case 5. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(LESSP (CADR L) (CAR L))
(SORTED L))
(SORTED (REMOVE X L))).
This simplifies, expanding the definition of SORTED, to:
T.
Case 4. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(NOT (SORTED (CDR L)))
(SORTED L))
(SORTED (REMOVE X L))).
This simplifies, opening up the function SORTED, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (REMOVE X (CDR L)))
(SORTED L))
(SORTED (REMOVE X L))).
This simplifies, opening up the definitions of SORTED and REMOVE, to:
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (REMOVE X (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL X (CAR L))))
(SORTED (CONS (CAR L) (REMOVE X (CDR L))))),
which again simplifies, applying CAR-CONS and CDR-CONS, and unfolding the
definition of SORTED, to:
(IMPLIES (AND (LISTP L)
(LISTP (CDR L))
(NOT (LESSP (CADR L) (CAR L)))
(SORTED (REMOVE X (CDR L)))
(SORTED (CDR L))
(NOT (EQUAL X (CAR L)))
(LISTP (REMOVE X (CDR L))))
(NOT (LESSP (CAR (REMOVE X (CDR L)))
(CAR L)))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS V Z) to eliminate
(CDR L) and (CAR L) and Z by (CONS W D) to eliminate (CAR Z) and (CDR Z).
We thus obtain:
(IMPLIES (AND (NOT (LESSP W V))
(SORTED (REMOVE X (CONS W D)))
(SORTED (CONS W D))
(NOT (EQUAL X V))
(LISTP (REMOVE X (CONS W D))))
(NOT (LESSP (CAR (REMOVE X (CONS W D)))
V))),
which further simplifies, applying the lemmas CDR-CONS and CAR-CONS, and
expanding the definitions of REMOVE and SORTED, to:
(IMPLIES (AND (NOT (LESSP W V))
(EQUAL X W)
(SORTED D)
(NOT (LESSP (CAR D) W))
(NOT (EQUAL W V))
(LISTP D))
(NOT (LESSP (CAR D) V))).
This again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(SORTED L))
(SORTED (REMOVE X L))),
which simplifies, opening up the functions SORTED and REMOVE, to two new
formulas:
Case 2.2.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X (CAR L))))
(SORTED (CONS (CAR L) (REMOVE X (CDR L))))),
which again simplifies, rewriting with CAR-CONS and CDR-CONS, and opening
up the definition of SORTED, to the following two new formulas:
Case 2.2.2.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X (CAR L)))
(LISTP (REMOVE X (CDR L))))
(SORTED (REMOVE X (CDR L)))).
This further simplifies, expanding REMOVE, to:
T.
Case 2.2.1.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(NOT (EQUAL X (CAR L)))
(LISTP (REMOVE X (CDR L))))
(NOT (LESSP (CAR (REMOVE X (CDR L)))
(CAR L)))),
which further simplifies, expanding the definition of REMOVE, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP L)
(NOT (LISTP (CDR L)))
(EQUAL X (CAR L)))
(SORTED (CDR L))),
which again simplifies, clearly, to the new goal:
(IMPLIES (AND (LISTP L) (NOT (LISTP (CDR L))))
(SORTED (CDR L))),
which further simplifies, opening up the definition of SORTED, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L)) (SORTED L))
(SORTED (REMOVE X L))),
which simplifies, opening up the functions SORTED and REMOVE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
SORTED-REMOVE
(DISABLE SORTED-REMOVE)
[ 0.0 0.0 0.0 ]
SORTED-REMOVE-OFF
(PROVE-LEMMA NOT-PERMUTATION
(REWRITE)
(IMPLIES (AND (LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B)))
((ENABLE PERMUTATION MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Appealing to the lemma CAR-CDR-ELIM, we now replace B by (CONS X Z) to
eliminate (CAR B) and (CDR B). We must thus prove:
(IMPLIES (NOT (MEMBER X A))
(NOT (PERMUTATION A (CONS X Z)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(IMPLIES (AND (LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))),
which we named *1 above. We will appeal to induction. There are two
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (NLISTP A) (p A B))
(IMPLIES (AND (NOT (NLISTP A))
(EQUAL (CAR B) (CAR A)))
(p A B))
(IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(p (CDR A) (REMOVE (CAR A) B)))
(p A B))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP inform us that the measure (COUNT A) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for B. The above induction scheme
produces the following five new goals:
Case 5. (IMPLIES (AND (NLISTP A)
(LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
This simplifies, expanding the definitions of NLISTP, MEMBER, and
PERMUTATION, to:
T.
Case 4. (IMPLIES (AND (NOT (NLISTP A))
(EQUAL (CAR B) (CAR A))
(LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
This simplifies, opening up the definitions of NLISTP and MEMBER, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (LISTP (REMOVE (CAR A) B)))
(LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
This simplifies, expanding the functions NLISTP, MEMBER, and PERMUTATION, to
the new formula:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (LISTP (REMOVE (CAR A) B)))
(LISTP B)
(NOT (MEMBER (CAR B) (CDR A)))
(MEMBER (CAR A) B))
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))),
which further simplifies, unfolding the functions MEMBER and PERMUTATION, to:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (LISTP (REMOVE (CAR A) B)))
(LISTP B)
(NOT (MEMBER (CAR B) (CDR A)))
(MEMBER (CAR A) B))
(LISTP (CDR A))).
However this again simplifies, expanding the definition of MEMBER, to:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (LISTP (REMOVE (CAR A) B)))
(LISTP B)
(MEMBER (CAR A) B))
(LISTP (CDR A))).
Appealing to the lemma CAR-CDR-ELIM, we now replace B by (CONS X Z) to
eliminate (CAR B) and (CDR B). The result is:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL X (CAR A)))
(NOT (LISTP (REMOVE (CAR A) (CONS X Z))))
(MEMBER (CAR A) (CONS X Z)))
(LISTP (CDR A))).
This further simplifies, applying CDR-CONS and CAR-CONS, and opening up the
function REMOVE, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(MEMBER (CAR (REMOVE (CAR A) B))
(CDR A))
(LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
This simplifies, expanding the functions NLISTP, MEMBER, and PERMUTATION, to:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(MEMBER (CAR (REMOVE (CAR A) B))
(CDR A))
(LISTP B)
(NOT (MEMBER (CAR B) (CDR A)))
(MEMBER (CAR A) B))
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))).
Applying the lemma CAR-CDR-ELIM, replace B by (CONS X Z) to eliminate
(CAR B) and (CDR B). We thus obtain the new goal:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL X (CAR A)))
(MEMBER (CAR (REMOVE (CAR A) (CONS X Z)))
(CDR A))
(NOT (MEMBER X (CDR A)))
(MEMBER (CAR A) (CONS X Z)))
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) (CONS X Z))))),
which further simplifies, applying CDR-CONS and CAR-CONS, and expanding
REMOVE, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(LISTP B)
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
This simplifies, unfolding NLISTP, MEMBER, and PERMUTATION, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
NOT-PERMUTATION
(DISABLE NOT-PERMUTATION)
[ 0.0 0.0 0.0 ]
NOT-PERMUTATION-OFF
(PROVE-LEMMA PERMUTATION-RIGHT-CONS1
(REWRITE)
(IMPLIES (AND (LISTP B) (MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B))))
((ENABLE PERMUTATION MEMBER REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma CAR-CDR-ELIM, replace B by (CONS X Z) to eliminate (CAR B)
and (CDR B). We would thus like to prove the new conjecture:
(IMPLIES (MEMBER X A)
(EQUAL (PERMUTATION A (CONS X Z))
(PERMUTATION (REMOVE X A) Z))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(IMPLIES (AND (LISTP B) (MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))),
named *1. Let us appeal to the induction principle. There are three
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (NLISTP A) (p A B))
(IMPLIES (AND (NOT (NLISTP A))
(EQUAL (CAR B) (CAR A)))
(p A B))
(IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(p (CDR A) (REMOVE (CAR A) B)))
(p A B))).
Linear arithmetic, the lemmas CDR-LESSEQP and CDR-LESSP, and the definition of
NLISTP can be used to show that the measure (COUNT A) decreases according to
the well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for B. The above induction scheme
leads to the following five new conjectures:
Case 5. (IMPLIES (AND (NLISTP A)
(LISTP B)
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))).
This simplifies, opening up the functions NLISTP and MEMBER, to:
T.
Case 4. (IMPLIES (AND (NOT (NLISTP A))
(EQUAL (CAR B) (CAR A))
(LISTP B)
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))).
This simplifies, opening up the functions NLISTP, MEMBER, PERMUTATION, and
REMOVE, to:
(IMPLIES (AND (LISTP A)
(EQUAL (CAR B) (CAR A))
(LISTP B))
(EQUAL (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (CDR A) (CDR B)))),
which further simplifies, opening up the function REMOVE, to:
T.
Case 3. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (LISTP (REMOVE (CAR A) B)))
(LISTP B)
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))),
which simplifies, unfolding the functions NLISTP and REMOVE, to:
T.
Case 2. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (MEMBER (CAR (REMOVE (CAR A) B))
(CDR A)))
(LISTP B)
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))),
which simplifies, applying CDR-CONS and CAR-CONS, and expanding the
definitions of NLISTP, MEMBER, PERMUTATION, and REMOVE, to the new
conjecture:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(NOT (MEMBER (CAR (REMOVE (CAR A) B))
(CDR A)))
(LISTP B)
(MEMBER (CAR B) (CDR A))
(MEMBER (CAR A) (CDR B)))
(EQUAL (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (REMOVE (CAR B) (CDR A))
(REMOVE (CAR A) (CDR B))))),
which further simplifies, rewriting with CAR-CONS, and expanding the
function REMOVE, to:
T.
Case 1. (IMPLIES (AND (NOT (NLISTP A))
(NOT (EQUAL (CAR B) (CAR A)))
(EQUAL (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (REMOVE (CAR (REMOVE (CAR A) B))
(CDR A))
(CDR (REMOVE (CAR A) B))))
(LISTP B)
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION A B)
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))).
This simplifies, applying CDR-CONS and CAR-CONS, and expanding NLISTP,
REMOVE, MEMBER, and PERMUTATION, to:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (CAR B) (CAR A)))
(EQUAL (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (REMOVE (CAR (REMOVE (CAR A) B))
(CDR A))
(REMOVE (CAR A) (CDR B))))
(LISTP B)
(MEMBER (CAR B) (CDR A))
(MEMBER (CAR A) (CDR B)))
(EQUAL (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (REMOVE (CAR B) (CDR A))
(REMOVE (CAR A) (CDR B))))).
This further simplifies, rewriting with CAR-CONS, and expanding the
definition of REMOVE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
PERMUTATION-RIGHT-CONS1
(DISABLE PERMUTATION-RIGHT-CONS1)
[ 0.0 0.0 0.0 ]
PERMUTATION-RIGHT-CONS1-OFF
(PROVE-LEMMA PERMUTATION-RIGHT-CONS
(REWRITE)
(EQUAL (PERMUTATION A (CONS X B))
(IF (MEMBER X A)
(PERMUTATION (REMOVE X A) B)
'*1*FALSE))
((ENABLE NOT-PERMUTATION PERMUTATION-RIGHT-CONS1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, trivially, to the following two new goals:
Case 2. (IMPLIES (NOT (MEMBER X A))
(EQUAL (PERMUTATION A (CONS X B)) F)).
But this again simplifies, rewriting with CAR-CONS and NOT-PERMUTATION, and
unfolding the function EQUAL, to:
T.
Case 1. (IMPLIES (MEMBER X A)
(EQUAL (PERMUTATION A (CONS X B))
(PERMUTATION (REMOVE X A) B))).
But this again simplifies, applying CAR-CONS, CDR-CONS, and
PERMUTATION-RIGHT-CONS1, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PERMUTATION-RIGHT-CONS
(DISABLE PERMUTATION-RIGHT-CONS)
[ 0.0 0.0 0.0 ]
PERMUTATION-RIGHT-CONS-OFF
(PROVE-LEMMA COMMUTATIVITY-OF-PERMUTATION
(REWRITE)
(EQUAL (PERMUTATION B A)
(PERMUTATION A B))
((ENABLE PERMUTATION PERMUTATION-RIGHT-CONS)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. Two inductions are suggested by terms in
the conjecture, both of which are unflawed. Since both of these are equally
likely, we will choose arbitrarily. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP B)
(p (CDR B) (REMOVE (CAR B) A)))
(p B A))
(IMPLIES (NOT (LISTP B)) (p B A))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT B)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for A. The above
induction scheme produces the following two new conjectures:
Case 2. (IMPLIES (AND (LISTP B)
(EQUAL (PERMUTATION (CDR B)
(REMOVE (CAR B) A))
(PERMUTATION (REMOVE (CAR B) A)
(CDR B))))
(EQUAL (PERMUTATION B A)
(PERMUTATION A B))).
This simplifies, expanding the function PERMUTATION, to the following two
new conjectures:
Case 2.2.
(IMPLIES (AND (LISTP B)
(EQUAL (PERMUTATION (CDR B)
(REMOVE (CAR B) A))
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))
(NOT (MEMBER (CAR B) A)))
(EQUAL F (PERMUTATION A B))).
This again simplifies, obviously, to:
(IMPLIES (AND (LISTP B)
(EQUAL (PERMUTATION (CDR B)
(REMOVE (CAR B) A))
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))
(NOT (MEMBER (CAR B) A)))
(NOT (PERMUTATION A B))).
Applying the lemma CAR-CDR-ELIM, replace B by (CONS Z X) to eliminate
(CDR B) and (CAR B). We would thus like to prove:
(IMPLIES (AND (EQUAL (PERMUTATION X (REMOVE Z A))
(PERMUTATION (REMOVE Z A) X))
(NOT (MEMBER Z A)))
(NOT (PERMUTATION A (CONS Z X)))),
which further simplifies, rewriting with PERMUTATION-RIGHT-CONS, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP B)
(EQUAL (PERMUTATION (CDR B)
(REMOVE (CAR B) A))
(PERMUTATION (REMOVE (CAR B) A)
(CDR B)))
(MEMBER (CAR B) A))
(EQUAL (PERMUTATION (CDR B)
(REMOVE (CAR B) A))
(PERMUTATION A B))).
Appealing to the lemma CAR-CDR-ELIM, we now replace B by (CONS Z X) to
eliminate (CDR B) and (CAR B). The result is:
(IMPLIES (AND (EQUAL (PERMUTATION X (REMOVE Z A))
(PERMUTATION (REMOVE Z A) X))
(MEMBER Z A))
(EQUAL (PERMUTATION X (REMOVE Z A))
(PERMUTATION A (CONS Z X)))).
However this further simplifies, rewriting with PERMUTATION-RIGHT-CONS, to:
T.
Case 1. (IMPLIES (NOT (LISTP B))
(EQUAL (PERMUTATION B A)
(PERMUTATION A B))).
This simplifies, expanding the functions PERMUTATION and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-PERMUTATION
(DISABLE COMMUTATIVITY-OF-PERMUTATION)
[ 0.0 0.0 0.0 ]
COMMUTATIVITY-OF-PERMUTATION-OFF
(PROVE-LEMMA MEMBER-PERMUTATION2 NIL
(IMPLIES (AND (PERMUTATION B A) (MEMBER X B))
(MEMBER X A))
((USE (COMMUTATIVITY-OF-PERMUTATION (A A)
(B B))
(MEMBER-PERMUTATION (X X)
(A A)
(B B)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, unfolding the functions AND and IMPLIES, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
MEMBER-PERMUTATION2
(PROVE-LEMMA PERMUTATION-REFLEXIVITY
(REWRITE)
(PERMUTATION L L)
((ENABLE PERMUTATION REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (p (CDR L)))
(p L))
(IMPLIES (NOT (LISTP L)) (p L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates the following two new
formulas:
Case 2. (IMPLIES (AND (LISTP L)
(PERMUTATION (CDR L) (CDR L)))
(PERMUTATION L L)).
This simplifies, expanding the functions PERMUTATION, MEMBER, and REMOVE, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(PERMUTATION L L)).
This simplifies, opening up the function PERMUTATION, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PERMUTATION-REFLEXIVITY
(DISABLE PERMUTATION-REFLEXIVITY)
[ 0.0 0.0 0.0 ]
PERMUTATION-REFLEXIVITY-OFF
(PROVE-LEMMA PERMUTATION-APPEND-CAR
(REWRITE)
(PERMUTATION (APPEND L (CONS X 'NIL))
(CONS X L))
((ENABLE PERMUTATION APPEND REMOVE MEMBER)
(INDUCT (LENGTH L))
(EXPAND (APPEND L (LIST X)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations NOT, OR, and AND,
to two new formulas:
Case 2. (IMPLIES (AND (LISTP L)
(PERMUTATION (APPEND (CDR L) (LIST X))
(CONS X (CDR L))))
(PERMUTATION (APPEND L (LIST X))
(CONS X L))),
which simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
unfolding the definitions of APPEND, REMOVE, MEMBER, and PERMUTATION, to the
formula:
(IMPLIES (AND (LISTP L)
(PERMUTATION (APPEND (CDR L) (LIST X))
(CONS X (CDR L)))
(EQUAL (CAR L) X))
(PERMUTATION (APPEND (CDR L) (LIST X))
L)).
This again simplifies, rewriting with CONS-CAR-CDR, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(PERMUTATION (APPEND L (LIST X))
(CONS X L))).
This simplifies, applying the lemmas CDR-CONS and CAR-CONS, and unfolding
APPEND, REMOVE, MEMBER, PERMUTATION, and LISTP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PERMUTATION-APPEND-CAR
(DISABLE PERMUTATION-APPEND-CAR)
[ 0.0 0.0 0.0 ]
PERMUTATION-APPEND-CAR-OFF
(PROVE-LEMMA PERMUTATION-APPEND-INSERT
(REWRITE)
(IMPLIES (AND (PERMUTATION A B)
(AND (SORTED B)
(AND (NOT (MEMBER X A))
(NOT (MEMBER X B)))))
(PERMUTATION (APPEND A (CONS X 'NIL))
(INSERT X B)))
((ENABLE APPEND INSERT PERMUTATION SORTED INSERT-REMOVE
MEMBER-INSERT NOT-LISTP-REMOVE NOT-MEMBER-REMOVE2
SORTED-REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
We will appeal to induction. There are six plausible inductions. They
merge into two likely candidate inductions. However, only one is unflawed.
We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A)
(p (CDR A) X (REMOVE (CAR A) B)))
(p A X B))
(IMPLIES (NOT (LISTP A)) (p A X B))).
Linear arithmetic and the lemma CDR-LESSP can be used to show that the measure
(COUNT A) decreases according to the well-founded relation LESSP in each
induction step of the scheme. Note, however, the inductive instance chosen
for B. The above induction scheme generates six new conjectures:
Case 6. (IMPLIES (AND (LISTP A)
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, opening up the function PERMUTATION, to:
T.
Case 5. (IMPLIES (AND (LISTP A)
(NOT (SORTED (REMOVE (CAR A) B)))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, applying the lemma SORTED-REMOVE, to:
T.
Case 4. (IMPLIES (AND (LISTP A)
(MEMBER X (CDR A))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, expanding the functions PERMUTATION and MEMBER, to:
T.
Case 3. (IMPLIES (AND (LISTP A)
(MEMBER X (REMOVE (CAR A) B))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, applying the lemma NOT-MEMBER-REMOVE2, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(PERMUTATION (APPEND (CDR A) (LIST X))
(INSERT X (REMOVE (CAR A) B)))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, applying CDR-CONS, MEMBER-INSERT, and CAR-CONS, and
opening up the definitions of PERMUTATION, MEMBER, and APPEND, to the new
formula:
(IMPLIES (AND (LISTP A)
(PERMUTATION (APPEND (CDR A) (LIST X))
(INSERT X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(SORTED B)
(NOT (EQUAL X (CAR A)))
(NOT (MEMBER X (CDR A)))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND (CDR A) (LIST X))
(REMOVE (CAR A) (INSERT X B)))),
which again simplifies, applying the lemma INSERT-REMOVE, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B)
(SORTED B)
(NOT (MEMBER X A))
(NOT (MEMBER X B)))
(PERMUTATION (APPEND A (LIST X))
(INSERT X B))),
which simplifies, rewriting with CDR-CONS, CAR-CONS, and NOT-LISTP-REMOVE,
and unfolding the definitions of PERMUTATION, SORTED, MEMBER, APPEND, INSERT,
and LISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PERMUTATION-APPEND-INSERT
(DISABLE PERMUTATION-APPEND-INSERT)
[ 0.0 0.0 0.0 ]
PERMUTATION-APPEND-INSERT-OFF
(PROVE-LEMMA PERMUTATION-REMOVE-REMOVE
(REWRITE)
(IMPLIES (AND (PERMUTATION A B)
(AND (MEMBER X A) (MEMBER X B)))
(PERMUTATION (REMOVE X A)
(REMOVE X B)))
((ENABLE PERMUTATION MEMBER REMOVE MEMBER-REMOVE2 REMOVE-REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are five plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A)
(p X (CDR A) (REMOVE (CAR A) B)))
(p X A B))
(IMPLIES (NOT (LISTP A)) (p X A B))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for B. The above
induction scheme leads to the following five new formulas:
Case 5. (IMPLIES (AND (LISTP A)
(NOT (PERMUTATION (CDR A)
(REMOVE (CAR A) B)))
(PERMUTATION A B)
(MEMBER X A)
(MEMBER X B))
(PERMUTATION (REMOVE X A)
(REMOVE X B))).
This simplifies, opening up the definition of PERMUTATION, to:
T.
Case 4. (IMPLIES (AND (LISTP A)
(NOT (MEMBER X (CDR A)))
(PERMUTATION A B)
(MEMBER X A)
(MEMBER X B))
(PERMUTATION (REMOVE X A)
(REMOVE X B))).
This simplifies, expanding PERMUTATION, MEMBER, and REMOVE, to:
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (CDR A)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(EQUAL X (CAR A))
(MEMBER X B))
(PERMUTATION (CDR A) (REMOVE X B))),
which again simplifies, obviously, to:
T.
Case 3. (IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(PERMUTATION A B)
(MEMBER X A)
(MEMBER X B))
(PERMUTATION (REMOVE X A)
(REMOVE X B))).
This simplifies, unfolding the functions PERMUTATION, MEMBER, and REMOVE, to
the following three new goals:
Case 3.3.
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(EQUAL X (CAR A))
(MEMBER X B))
(PERMUTATION (CDR A) (REMOVE X B))).
This again simplifies, obviously, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(MEMBER X (CDR A))
(MEMBER X B)
(NOT (EQUAL X (CAR A))))
(PERMUTATION (CONS (CAR A) (REMOVE X (CDR A)))
(REMOVE X B))).
This again simplifies, applying MEMBER-REMOVE2, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP A)
(NOT (MEMBER X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(MEMBER X (CDR A))
(MEMBER X B)
(EQUAL X (CAR A)))
(PERMUTATION (CDR A) (REMOVE X B))).
This again simplifies, obviously, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(PERMUTATION (REMOVE X (CDR A))
(REMOVE X (REMOVE (CAR A) B)))
(PERMUTATION A B)
(MEMBER X A)
(MEMBER X B))
(PERMUTATION (REMOVE X A)
(REMOVE X B))).
This simplifies, unfolding PERMUTATION, MEMBER, and REMOVE, to the following
three new conjectures:
Case 2.3.
(IMPLIES (AND (LISTP A)
(PERMUTATION (REMOVE X (CDR A))
(REMOVE X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(EQUAL X (CAR A))
(MEMBER X B))
(PERMUTATION (CDR A) (REMOVE X B))).
This again simplifies, trivially, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP A)
(PERMUTATION (REMOVE X (CDR A))
(REMOVE X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(MEMBER X (CDR A))
(MEMBER X B)
(NOT (EQUAL X (CAR A))))
(PERMUTATION (CONS (CAR A) (REMOVE X (CDR A)))
(REMOVE X B))).
This again simplifies, appealing to the lemmas REMOVE-REMOVE, CDR-CONS,
MEMBER-REMOVE2, and CAR-CONS, and unfolding the definition of PERMUTATION,
to:
T.
Case 2.1.
(IMPLIES (AND (LISTP A)
(PERMUTATION (REMOVE X (CDR A))
(REMOVE X (REMOVE (CAR A) B)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(MEMBER X (CDR A))
(MEMBER X B)
(EQUAL X (CAR A)))
(PERMUTATION (CDR A) (REMOVE X B))),
which again simplifies, obviously, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B)
(MEMBER X A)
(MEMBER X B))
(PERMUTATION (REMOVE X A)
(REMOVE X B))).
This simplifies, opening up the definitions of PERMUTATION and MEMBER, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
PERMUTATION-REMOVE-REMOVE
(DISABLE PERMUTATION-REMOVE-REMOVE)
[ 0.0 0.0 0.0 ]
PERMUTATION-REMOVE-REMOVE-OFF
(DEFN TRANSITIVITY-OF-PERMUTATION-INDUCTION
(A B C)
(IF (LISTP A)
(TRANSITIVITY-OF-PERMUTATION-INDUCTION (CDR A)
(REMOVE (CAR A) B)
(REMOVE (CAR A) C))
'0)
NIL)
Linear arithmetic and the lemma CDR-LESSP can be used to show that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each recursive call. Hence, TRANSITIVITY-OF-PERMUTATION-INDUCTION is accepted
under the definitional principle. Observe that:
(NUMBERP (TRANSITIVITY-OF-PERMUTATION-INDUCTION A B C))
is a theorem.
[ 0.0 0.0 0.0 ]
TRANSITIVITY-OF-PERMUTATION-INDUCTION
(PROVE-LEMMA TRANSITIVITY-OF-PERMUTATION-BASE-CASE NIL
(IMPLIES (AND (NLISTP A)
(AND (PERMUTATION A B)
(PERMUTATION B C)))
(PERMUTATION A C))
((EXPAND (PERMUTATION A B)
(PERMUTATION B C)
(PERMUTATION A C))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations NLISTP, AND, and
IMPLIES, to:
(IMPLIES (AND (NOT (LISTP A))
(PERMUTATION A B)
(PERMUTATION B C))
(PERMUTATION A C)).
This simplifies, expanding the definition of PERMUTATION, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
TRANSITIVITY-OF-PERMUTATION-BASE-CASE
(PROVE-LEMMA TRANSITIVITY-OF-PERMUTATION-INDUCTION-STEP NIL
(IMPLIES (AND (LISTP A)
(AND (IMPLIES (AND (PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION (REMOVE (CAR A) B)
(REMOVE (CAR A) C)))
(PERMUTATION (CDR A)
(REMOVE (CAR A) C)))
(AND (PERMUTATION A B)
(PERMUTATION B C))))
(PERMUTATION A C))
((EXPAND (PERMUTATION A B)
(PERMUTATION A C))
(USE (MEMBER-PERMUTATION2 (X (CAR A))
(B B)
(A C)))
(ENABLE PERMUTATION-REMOVE-REMOVE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, unfolding AND, IMPLIES, and PERMUTATION, to:
(IMPLIES (AND (MEMBER (CAR A) C)
(LISTP A)
(NOT (PERMUTATION (REMOVE (CAR A) B)
(REMOVE (CAR A) C)))
(MEMBER (CAR A) B)
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))
(PERMUTATION B C))
(PERMUTATION (CDR A)
(REMOVE (CAR A) C))),
which again simplifies, rewriting with the lemma PERMUTATION-REMOVE-REMOVE, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
TRANSITIVITY-OF-PERMUTATION-INDUCTION-STEP
(PROVE-LEMMA TRANSITIVITY-OF-PERMUTATION NIL
(IMPLIES (AND (PERMUTATION A B)
(PERMUTATION B C))
(PERMUTATION A C))
((INDUCT (TRANSITIVITY-OF-PERMUTATION-INDUCTION A B C))
(USE (TRANSITIVITY-OF-PERMUTATION-BASE-CASE (A A)
(B B)
(C C))
(TRANSITIVITY-OF-PERMUTATION-INDUCTION-STEP (A A)
(B B)
(C C)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, expanding NLISTP, AND, IMPLIES, NOT, and OR, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
TRANSITIVITY-OF-PERMUTATION
(PROVE-LEMMA SETP-REMOVE
(REWRITE)
(IMPLIES (SETP A) (SETP (REMOVE X A)))
((ENABLE SETP REMOVE NOT-MEMBER-REMOVE2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (EQUAL X (CAR A)))
(p X A))
(IMPLIES (AND (LISTP A)
(NOT (EQUAL X (CAR A)))
(p X (CDR A)))
(p X A))
(IMPLIES (NOT (LISTP A)) (p X A))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme generates the
following four new formulas:
Case 4. (IMPLIES (AND (LISTP A)
(EQUAL X (CAR A))
(SETP A))
(SETP (REMOVE X A))).
This simplifies, expanding the definitions of SETP and REMOVE, to:
T.
Case 3. (IMPLIES (AND (LISTP A)
(NOT (EQUAL X (CAR A)))
(NOT (SETP (CDR A)))
(SETP A))
(SETP (REMOVE X A))).
This simplifies, opening up the function SETP, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(NOT (EQUAL X (CAR A)))
(SETP (REMOVE X (CDR A)))
(SETP A))
(SETP (REMOVE X A))).
This simplifies, applying the lemmas NOT-MEMBER-REMOVE2, CDR-CONS, and
CAR-CONS, and unfolding SETP and REMOVE, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A)) (SETP A))
(SETP (REMOVE X A))).
This simplifies, unfolding the definitions of SETP, LISTP, REMOVE, and EQUAL,
to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
SETP-REMOVE
(DISABLE SETP-REMOVE)
[ 0.0 0.0 0.0 ]
SETP-REMOVE-OFF
(DEFN SETP-PERMUTATION-INDUCTION
(A B)
(IF (LISTP A)
(SETP-PERMUTATION-INDUCTION (CDR A)
(REMOVE (CAR A) B))
'0)
NIL)
Linear arithmetic and the lemma CDR-LESSP inform us that the measure
(COUNT A) decreases according to the well-founded relation LESSP in each
recursive call. Hence, SETP-PERMUTATION-INDUCTION is accepted under the
definitional principle. Observe that:
(NUMBERP (SETP-PERMUTATION-INDUCTION A B))
is a theorem.
[ 0.0 0.0 0.0 ]
SETP-PERMUTATION-INDUCTION
(PROVE-LEMMA SETP-PERMUTATION-BASE-CASE NIL
(IMPLIES (AND (NOT (LISTP A)) (PLISTP A))
(SETP A))
((ENABLE SETP PLISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, expanding the functions PLISTP, EQUAL, LISTP, and
SETP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
SETP-PERMUTATION-BASE-CASE
(PROVE-LEMMA SETP-PERMUTATION-INDUCTION-STEP NIL
(IMPLIES
(AND (LISTP A)
(AND (SETP B)
(AND (PLISTP A)
(AND (PERMUTATION A B)
(IMPLIES (AND (SETP (REMOVE (CAR A) B))
(AND (PLISTP (CDR A))
(PERMUTATION (CDR A)
(REMOVE (CAR A) B))))
(SETP (CDR A)))))))
(SETP A))
((ENABLE SETP PERMUTATION REMOVE MEMBER PLISTP NOT-MEMBER-REMOVE1 SETP-REMOVE)
(USE (NOT-MEMBER-PERMUTATION (X (CAR A))
(A (CDR A))
(B (REMOVE (CAR A) B))))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying NOT-MEMBER-REMOVE1 and SETP-REMOVE, and
unfolding NOT, AND, IMPLIES, PLISTP, PERMUTATION, and SETP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
SETP-PERMUTATION-INDUCTION-STEP
(PROVE-LEMMA SETP-PERMUTATION NIL
(IMPLIES (AND (SETP B)
(AND (PLISTP A) (PERMUTATION A B)))
(SETP A))
((INDUCT (SETP-PERMUTATION-INDUCTION A B))
(USE (SETP-PERMUTATION-BASE-CASE (A A))
(SETP-PERMUTATION-INDUCTION-STEP (A A)
(B B)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up NOT, AND, IMPLIES, and OR, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
SETP-PERMUTATION
(PROVE-LEMMA SETP-INSERT
(REWRITE)
(IMPLIES (AND (SETP L) (NOT (MEMBER I L)))
(SETP (INSERT I L)))
((ENABLE SETP INSERT MEMBER NOT-MEMBER-INSERT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There are three plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (LESSP I (CAR L)))
(p I L))
(IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(p I (CDR L)))
(p I L))
(IMPLIES (NOT (LISTP L)) (p I L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates five new goals:
Case 5. (IMPLIES (AND (LISTP L)
(LESSP I (CAR L))
(SETP L)
(NOT (MEMBER I L)))
(SETP (INSERT I L))),
which simplifies, appealing to the lemmas CDR-CONS and CAR-CONS, and
unfolding SETP, MEMBER, and INSERT, to:
T.
Case 4. (IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(NOT (SETP (CDR L)))
(SETP L)
(NOT (MEMBER I L)))
(SETP (INSERT I L))),
which simplifies, opening up SETP, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(MEMBER I (CDR L))
(SETP L)
(NOT (MEMBER I L)))
(SETP (INSERT I L))),
which simplifies, opening up the definitions of SETP and MEMBER, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (LESSP I (CAR L)))
(SETP (INSERT I (CDR L)))
(SETP L)
(NOT (MEMBER I L)))
(SETP (INSERT I L))),
which simplifies, applying the lemmas NOT-MEMBER-INSERT, CDR-CONS, and
CAR-CONS, and expanding SETP, MEMBER, and INSERT, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(SETP L)
(NOT (MEMBER I L)))
(SETP (INSERT I L))),
which simplifies, applying the lemmas CDR-CONS and CAR-CONS, and opening up
the functions SETP, LISTP, MEMBER, INSERT, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
SETP-INSERT
(DISABLE SETP-INSERT)
[ 0.0 0.0 0.0 ]
SETP-INSERT-OFF
(DEFN GETNTH
(N L)
(IF (LISTP L)
(IF (ZEROP N)
(CAR L)
(GETNTH (SUB1 N) (CDR L)))
'0)
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each recursive call. Hence, GETNTH is accepted under the
principle of definition. The definition of GETNTH can be justified in another
way. Linear arithmetic and the lemma CDR-LESSP can be used to establish that
the measure (COUNT L) decreases according to the well-founded relation LESSP
in each recursive call.
[ 0.0 0.0 0.0 ]
GETNTH
(DEFN PUTNTH
(V N L)
(IF (LISTP L)
(IF (ZEROP N)
(CONS V (CDR L))
(CONS (CAR L)
(PUTNTH V (SUB1 N) (CDR L))))
L)
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each recursive call. Hence, PUTNTH is accepted under the
principle of definition. The definition of PUTNTH can be justified in another
way. Linear arithmetic and the lemma CDR-LESSP inform us that the measure
(COUNT L) decreases according to the well-founded relation LESSP in each
recursive call. Observe that:
(OR (LISTP (PUTNTH V N L))
(EQUAL (PUTNTH V N L) L))
is a theorem.
[ 0.0 0.0 0.0 ]
PUTNTH
(DEFN GETSEG
(N K L)
(IF (ZEROP K)
'NIL
(CONS (GETNTH N L)
(GETSEG (ADD1 N) (SUB1 K) L)))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each recursive call. Hence, GETSEG is accepted under the
principle of definition. From the definition we can conclude that:
(OR (LITATOM (GETSEG N K L))
(LISTP (GETSEG N K L)))
is a theorem.
[ 0.0 0.0 0.0 ]
GETSEG
(DEFN PUTSEG
(S N L)
(IF (LISTP S)
(PUTNTH (CAR S)
N
(PUTSEG (CDR S) (ADD1 N) L))
L)
NIL)
Linear arithmetic and the lemma CDR-LESSP inform us that the measure
(COUNT S) decreases according to the well-founded relation LESSP in each
recursive call. Hence, PUTSEG is accepted under the principle of definition.
Note that (OR (LISTP (PUTSEG S N L)) (EQUAL (PUTSEG S N L) L)) is a theorem.
[ 0.0 0.0 0.0 ]
PUTSEG
(DEFN FIXLENGTH
(N L DEFAULT)
(IF (LISTP L)
(IF (ZEROP N)
'NIL
(CONS (CAR L)
(FIXLENGTH (SUB1 N) (CDR L) DEFAULT)))
(IF (ZEROP N)
'NIL
(CONS DEFAULT
(FIXLENGTH (SUB1 N) L DEFAULT))))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each recursive call. Hence, FIXLENGTH is accepted under the
principle of definition. Observe that:
(OR (LITATOM (FIXLENGTH N L DEFAULT))
(LISTP (FIXLENGTH N L DEFAULT)))
is a theorem.
[ 0.0 0.0 0.0 ]
FIXLENGTH
(DEFN FIRSTN
(N L)
(IF (LISTP L)
(IF (ZEROP N)
'NIL
(CONS (CAR L)
(FIRSTN (SUB1 N) (CDR L))))
'NIL)
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
can be used to establish that the measure (COUNT N) decreases according to the
well-founded relation LESSP in each recursive call. Hence, FIRSTN is accepted
under the principle of definition. The definition of FIRSTN can be justified
in another way. Linear arithmetic and the lemma CDR-LESSP inform us that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each recursive call. Observe that:
(OR (LITATOM (FIRSTN N L))
(LISTP (FIRSTN N L)))
is a theorem.
[ 0.0 0.0 0.0 ]
FIRSTN
(DEFN NTHCDR
(N L)
(IF (LISTP L)
(IF (ZEROP N)
L
(NTHCDR (SUB1 N) (CDR L)))
L)
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
can be used to show that the measure (COUNT N) decreases according to the
well-founded relation LESSP in each recursive call. Hence, NTHCDR is accepted
under the definitional principle. The definition of NTHCDR can be justified
in another way. Linear arithmetic and the lemma CDR-LESSP can be used to
prove that the measure (COUNT L) decreases according to the well-founded
relation LESSP in each recursive call.
[ 0.0 0.0 0.0 ]
NTHCDR
(PROVE-LEMMA NON-ZERO-LENGTH-IMPLIES-LISTP
(REWRITE)
(IMPLIES (NOT (ZEROP (LENGTH L)))
(LISTP L))
((ENABLE LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: NON-ZERO-LENGTH-IMPLIES-LISTP will slow down the theorem-prover
because it will cause backward chaining on every instance of a primitive type
expression.
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL (LENGTH L) 0))
(NUMBERP (LENGTH L)))
(LISTP L)),
which simplifies, opening up LENGTH and EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
NON-ZERO-LENGTH-IMPLIES-LISTP
(DISABLE NON-ZERO-LENGTH-IMPLIES-LISTP)
[ 0.0 0.0 0.0 ]
NON-ZERO-LENGTH-IMPLIES-LISTP-OFF
(PROVE-LEMMA LISTP-IMPLIES-NON-ZERO-LENGTH
(REWRITE)
(IMPLIES (LISTP L)
(NOT (EQUAL (LENGTH L) '0)))
((ENABLE LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (p (CDR L)))
(p L))
(IMPLIES (NOT (LISTP L)) (p L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT L)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates two new goals:
Case 2. (IMPLIES (AND (NOT (LISTP (CDR L))) (LISTP L))
(NOT (EQUAL (LENGTH L) 0))),
which simplifies, expanding LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL (LENGTH (CDR L)) 0))
(LISTP L))
(NOT (EQUAL (LENGTH L) 0))),
which simplifies, opening up the function LENGTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LISTP-IMPLIES-NON-ZERO-LENGTH
(DISABLE LISTP-IMPLIES-NON-ZERO-LENGTH)
[ 0.0 0.0 0.0 ]
LISTP-IMPLIES-NON-ZERO-LENGTH-OFF
(PROVE-LEMMA PLIST-OF-NON-ZERO-LENGTH-IS-A-LIST
(REWRITE)
(IMPLIES (AND (PLISTP A)
(NOT (EQUAL (LENGTH A) '0)))
(LISTP A))
((ENABLE PLISTP LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: PLIST-OF-NON-ZERO-LENGTH-IS-A-LIST will slow down the theorem-prover
because it will cause backward chaining on every instance of a primitive type
expression.
This conjecture simplifies, expanding the definitions of PLISTP, LISTP, LENGTH,
and EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLIST-OF-NON-ZERO-LENGTH-IS-A-LIST
(DISABLE PLIST-OF-NON-ZERO-LENGTH-IS-A-LIST)
[ 0.0 0.0 0.0 ]
PLIST-OF-NON-ZERO-LENGTH-IS-A-LIST-OFF
(PROVE-LEMMA LISTP-APPEND
(REWRITE)
(EQUAL (LISTP (APPEND A B))
(OR (LISTP A) (LISTP B)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding the definition of OR, to the following two new
goals:
Case 2. (IMPLIES (NOT (LISTP A))
(EQUAL (LISTP (APPEND A B))
(LISTP B))).
This again simplifies, opening up the definition of APPEND, to:
T.
Case 1. (IMPLIES (LISTP A)
(EQUAL (LISTP (APPEND A B)) T)),
which again simplifies, trivially, to:
(IMPLIES (LISTP A)
(LISTP (APPEND A B))),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following two new
goals:
Case 2. (IMPLIES (AND (NOT (LISTP (CDR A))) (LISTP A))
(LISTP (APPEND A B))).
This simplifies, opening up the function APPEND, to:
T.
Case 1. (IMPLIES (AND (LISTP (APPEND (CDR A) B))
(LISTP A))
(LISTP (APPEND A B))).
This simplifies, unfolding the definition of APPEND, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LISTP-APPEND
(DISABLE LISTP-APPEND)
[ 0.0 0.0 0.0 ]
LISTP-APPEND-OFF
(PROVE-LEMMA LISTP-APPEND-LEFT
(REWRITE)
(IMPLIES (LISTP A)
(LISTP (APPEND A B)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme generates the
following two new formulas:
Case 2. (IMPLIES (AND (NOT (LISTP (CDR A))) (LISTP A))
(LISTP (APPEND A B))).
This simplifies, expanding the definition of APPEND, to:
T.
Case 1. (IMPLIES (AND (LISTP (APPEND (CDR A) B))
(LISTP A))
(LISTP (APPEND A B))).
This simplifies, opening up the function APPEND, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LISTP-APPEND-LEFT
(DISABLE LISTP-APPEND-LEFT)
[ 0.0 0.0 0.0 ]
LISTP-APPEND-LEFT-OFF
(PROVE-LEMMA LISTP-GETSEG
(REWRITE)
(IMPLIES (NOT (ZEROP K))
(LISTP (GETSEG N K L)))
((ENABLE NON-ZERO-LENGTH-IMPLIES-LISTP GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL K 0)) (NUMBERP K))
(LISTP (GETSEG N K L))),
which we will name *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT K) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instance chosen for N. The above induction scheme leads to the following
three new conjectures:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (EQUAL K 0))
(NUMBERP K))
(LISTP (GETSEG N K L))).
This simplifies, unfolding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (SUB1 K) 0)
(NOT (EQUAL K 0))
(NUMBERP K))
(LISTP (GETSEG N K L))).
This simplifies, expanding the functions ZEROP and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(LISTP (GETSEG (ADD1 N) (SUB1 K) L))
(NOT (EQUAL K 0))
(NUMBERP K))
(LISTP (GETSEG N K L))).
This simplifies, unfolding the functions ZEROP and GETSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LISTP-GETSEG
(DISABLE LISTP-GETSEG)
[ 0.0 0.0 0.0 ]
LISTP-GETSEG-OFF
(PROVE-LEMMA LISTP-PUTNTH
(REWRITE)
(EQUAL (LISTP (PUTNTH V N L))
(LISTP L))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are two plausible inductions.
However, they merge into one likely candidate induction. We will induct
according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP N))
(p V N L))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(p V (SUB1 N) (CDR L)))
(p V N L))
(IMPLIES (NOT (LISTP L)) (p V N L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for L. The above induction scheme produces the
following three new goals:
Case 3. (IMPLIES (AND (LISTP L) (ZEROP N))
(EQUAL (LISTP (PUTNTH V N L))
(LISTP L))).
This simplifies, obviously, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(EQUAL (LISTP (PUTNTH V (SUB1 N) (CDR L)))
(LISTP (CDR L))))
(EQUAL (LISTP (PUTNTH V N L))
(LISTP L))).
This simplifies, obviously, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (LISTP (PUTNTH V N L))
(LISTP L))).
This simplifies, opening up PUTNTH and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
LISTP-PUTNTH
(DISABLE LISTP-PUTNTH)
[ 0.0 0.0 0.0 ]
LISTP-PUTNTH-OFF
(PROVE-LEMMA LISTP-PUTSEG
(REWRITE)
(EQUAL (LISTP (PUTSEG S N L))
(LISTP L))
((ENABLE PUTSEG LISTP-PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP S) (p (CDR S) (ADD1 N) L))
(p S N L))
(IMPLIES (NOT (LISTP S)) (p S N L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces the following two new goals:
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (LISTP (PUTSEG (CDR S) (ADD1 N) L))
(LISTP L)))
(EQUAL (LISTP (PUTSEG S N L))
(LISTP L))).
This simplifies, applying LISTP-PUTNTH, and unfolding the definition of
PUTSEG, to:
T.
Case 1. (IMPLIES (NOT (LISTP S))
(EQUAL (LISTP (PUTSEG S N L))
(LISTP L))),
which simplifies, unfolding the definition of PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LISTP-PUTSEG
(DISABLE LISTP-PUTSEG)
[ 0.0 0.0 0.0 ]
LISTP-PUTSEG-OFF
(PROVE-LEMMA REWRITE-CAR-TO-GETNTH-0
(REWRITE)
(EQUAL (CAR L) (GETNTH '0 L))
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: the newly proposed lemma, REWRITE-CAR-TO-GETNTH-0, could be applied
whenever the previously added lemma CAR-NLISTP could.
WARNING: the newly proposed lemma, REWRITE-CAR-TO-GETNTH-0, could be applied
whenever the previously added lemma CAR-CONS could.
This simplifies, unfolding EQUAL and GETNTH, to:
(IMPLIES (NOT (LISTP L))
(EQUAL (CAR L) 0)).
This again simplifies, rewriting with CAR-NLISTP, and unfolding the definition
of EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
REWRITE-CAR-TO-GETNTH-0
(DISABLE REWRITE-CAR-TO-GETNTH-0)
[ 0.0 0.0 0.0 ]
REWRITE-CAR-TO-GETNTH-0-OFF
(PROVE-LEMMA CAR-APPEND-CASESPLIT
(REWRITE)
(EQUAL (CAR (APPEND A B))
(IF (LISTP A) (CAR A) (CAR B)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, trivially, to the following two new goals:
Case 2. (IMPLIES (NOT (LISTP A))
(EQUAL (CAR (APPEND A B)) (CAR B))).
This again simplifies, expanding APPEND, to:
T.
Case 1. (IMPLIES (LISTP A)
(EQUAL (CAR (APPEND A B)) (CAR A))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). This produces:
(EQUAL (CAR (APPEND (CONS X Z) B)) X),
which further simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS,
and expanding the function APPEND, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CAR-APPEND-CASESPLIT
(DISABLE CAR-APPEND-CASESPLIT)
[ 0.0 0.0 0.0 ]
CAR-APPEND-CASESPLIT-OFF
(PROVE-LEMMA CAR-APPEND
(REWRITE)
(IMPLIES (LISTP A)
(EQUAL (CAR (APPEND A B)) (CAR A)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate (CAR A)
and (CDR A). We would thus like to prove:
(EQUAL (CAR (APPEND (CONS X Z) B)) X),
which simplifies, applying CDR-CONS and CAR-CONS, and opening up the function
APPEND, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CAR-APPEND
(DISABLE CAR-APPEND)
[ 0.0 0.0 0.0 ]
CAR-APPEND-OFF
(PROVE-LEMMA CAR-GETSEG
(REWRITE)
(IMPLIES (NOT (ZEROP K))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L)))
((ENABLE GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL K 0)) (NUMBERP K))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for N. The above induction scheme generates the
following three new conjectures:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (EQUAL K 0))
(NUMBERP K))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))).
This simplifies, opening up the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (SUB1 K) 0)
(NOT (EQUAL K 0))
(NUMBERP K))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))).
This simplifies, appealing to the lemma CAR-CONS, and expanding ZEROP and
GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (CAR (GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (ADD1 N) L))
(NOT (EQUAL K 0))
(NUMBERP K))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))).
This simplifies, applying CAR-CONS, and opening up the definitions of ZEROP
and GETSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
CAR-GETSEG
(DISABLE CAR-GETSEG)
[ 0.0 0.0 0.0 ]
CAR-GETSEG-OFF
(PROVE-LEMMA CAR-PUTNTH-ZERO
(REWRITE)
(IMPLIES (AND (LISTP L) (ZEROP N))
(EQUAL (CAR (PUTNTH V N L)) V))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying CAR-CONS, and expanding the functions
ZEROP, EQUAL, and PUTNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CAR-PUTNTH-ZERO
(DISABLE CAR-PUTNTH-ZERO)
[ 0.0 0.0 0.0 ]
CAR-PUTNTH-ZERO-OFF
(PROVE-LEMMA CAR-PUTSEG-ZERO
(REWRITE)
(IMPLIES (AND (ZEROP N)
(AND (LISTP S) (LISTP L)))
(EQUAL (CAR (PUTSEG S N L)) (CAR S)))
((ENABLE CAR-PUTNTH-ZERO PUTSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, expanding ZEROP, to two new goals:
Case 2. (IMPLIES (AND (EQUAL N 0) (LISTP S) (LISTP L))
(EQUAL (CAR (PUTSEG S 0 L)) (CAR S))),
which again simplifies, trivially, to:
(IMPLIES (AND (LISTP S) (LISTP L))
(EQUAL (CAR (PUTSEG S 0 L)) (CAR S))).
Applying the lemma CAR-CDR-ELIM, replace S by (CONS X Z) to eliminate
(CAR S) and (CDR S). We would thus like to prove:
(IMPLIES (LISTP L)
(EQUAL (CAR (PUTSEG (CONS X Z) 0 L))
X)),
which further simplifies, rewriting with CDR-CONS, CAR-CONS, and
CAR-PUTNTH-ZERO, and expanding ADD1, PUTSEG, and ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP N))
(LISTP S)
(LISTP L))
(EQUAL (CAR (PUTSEG S N L)) (CAR S))).
Appealing to the lemma CAR-CDR-ELIM, we now replace S by (CONS X Z) to
eliminate (CAR S) and (CDR S). We must thus prove:
(IMPLIES (AND (NOT (NUMBERP N)) (LISTP L))
(EQUAL (CAR (PUTSEG (CONS X Z) N L))
X)).
But this further simplifies, applying SUB1-TYPE-RESTRICTION, CDR-CONS,
CAR-CONS, and CAR-PUTNTH-ZERO, and opening up the definitions of PUTSEG and
ZEROP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CAR-PUTSEG-ZERO
(DISABLE CAR-PUTSEG-ZERO)
[ 0.0 0.0 0.0 ]
CAR-PUTSEG-ZERO-OFF
(PROVE-LEMMA CDR-APPEND
(REWRITE)
(EQUAL (CDR (APPEND A B))
(IF (LISTP A)
(APPEND (CDR A) B)
(CDR B)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, unfolding the function APPEND, to:
(IMPLIES (LISTP A)
(EQUAL (CDR (CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (CDR A) B))),
which again simplifies, rewriting with the lemma CDR-CONS, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CDR-APPEND
(DISABLE CDR-APPEND)
[ 0.0 0.0 0.0 ]
CDR-APPEND-OFF
(PROVE-LEMMA CDR-GETSEG
(REWRITE)
(IMPLIES (NOT (ZEROP K))
(EQUAL (CDR (GETSEG N K L))
(GETSEG (ADD1 N) (SUB1 K) L)))
((ENABLE GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to the goal:
(IMPLIES (AND (NOT (EQUAL K 0)) (NUMBERP K))
(EQUAL (CDR (GETSEG N K L))
(GETSEG (ADD1 N) (SUB1 K) L))).
This simplifies, rewriting with CDR-CONS, and unfolding GETSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
CDR-GETSEG
(DISABLE CDR-GETSEG)
[ 0.0 0.0 0.0 ]
CDR-GETSEG-OFF
(PROVE-LEMMA CDR-IS-NIL-WHEN-LENGTH-IS-1
(REWRITE)
(IMPLIES (AND (PLISTP L)
(EQUAL (LENGTH L) '1))
(EQUAL (EQUAL (CDR L) 'NIL)
'*1*TRUE))
((ENABLE PLISTP LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying ADD1-EQUAL, and opening up the
definitions of PLISTP, LISTP, LENGTH, EQUAL, and NUMBERP, to:
(IMPLIES (AND (LISTP L)
(PLISTP (CDR L))
(EQUAL (LENGTH (CDR L)) 0))
(EQUAL (CDR L) NIL)).
Appealing to the lemma CAR-CDR-ELIM, we now replace L by (CONS Z X) to
eliminate (CDR L) and (CAR L). This generates:
(IMPLIES (AND (PLISTP X) (EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(IMPLIES (AND (PLISTP L) (EQUAL (LENGTH L) 1))
(EQUAL (EQUAL (CDR L) NIL) T)).
We gave this the name *1 above. Perhaps we can prove it by induction. The
recursive terms in the conjecture suggest two inductions. However, they merge
into one likely candidate induction. We will induct according to the
following scheme:
(AND (IMPLIES (AND (LISTP L) (p (CDR L)))
(p L))
(IMPLIES (NOT (LISTP L)) (p L))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme leads to four
new conjectures:
Case 4. (IMPLIES (AND (LISTP L)
(NOT (PLISTP (CDR L)))
(PLISTP L)
(EQUAL (LENGTH L) 1))
(EQUAL (EQUAL (CDR L) NIL) T)),
which simplifies, opening up the definition of PLISTP, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (EQUAL (LENGTH (CDR L)) 1))
(PLISTP L)
(EQUAL (LENGTH L) 1))
(EQUAL (EQUAL (CDR L) NIL) T)),
which simplifies, appealing to the lemma ADD1-EQUAL, and unfolding the
functions PLISTP, LENGTH, and NUMBERP, to:
(IMPLIES (AND (LISTP L)
(NOT (EQUAL (LENGTH (CDR L)) 1))
(PLISTP (CDR L))
(EQUAL (LENGTH (CDR L)) 0))
(EQUAL (CDR L) NIL)).
This again simplifies, unfolding EQUAL, to:
(IMPLIES (AND (LISTP L)
(PLISTP (CDR L))
(EQUAL (LENGTH (CDR L)) 0))
(EQUAL (CDR L) NIL)).
Appealing to the lemma CAR-CDR-ELIM, we now replace L by (CONS Z X) to
eliminate (CDR L) and (CAR L). We must thus prove:
(IMPLIES (AND (PLISTP X) (EQUAL (LENGTH X) 0))
(EQUAL X NIL)).
Name the above subgoal *1.1.
Case 2. (IMPLIES (AND (LISTP L)
(EQUAL (EQUAL (CDDR L) NIL) T)
(PLISTP L)
(EQUAL (LENGTH L) 1))
(EQUAL (EQUAL (CDR L) NIL) T)).
This simplifies, appealing to the lemma ADD1-EQUAL, and unfolding the
definitions of PLISTP, LENGTH, and NUMBERP, to:
(IMPLIES (AND (LISTP L)
(EQUAL (CDDR L) NIL)
(PLISTP (CDR L))
(EQUAL (LENGTH (CDR L)) 0))
(EQUAL (CDR L) NIL)),
which further simplifies, unfolding the definitions of PLISTP, EQUAL, LISTP,
LENGTH, and ADD1, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(PLISTP L)
(EQUAL (LENGTH L) 1))
(EQUAL (EQUAL (CDR L) NIL) T)),
which simplifies, unfolding the functions PLISTP, LISTP, LENGTH, and EQUAL,
to:
T.
So we now return to:
(IMPLIES (AND (PLISTP X) (EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
named *1.1 above. Let us appeal to the induction principle. There are two
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP X) (p (CDR X)))
(p X))
(IMPLIES (NOT (LISTP X)) (p X))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT X)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme generates four new formulas:
Case 4. (IMPLIES (AND (LISTP X)
(NOT (PLISTP (CDR X)))
(PLISTP X)
(EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
which simplifies, unfolding the function PLISTP, to:
T.
Case 3. (IMPLIES (AND (LISTP X)
(NOT (EQUAL (LENGTH (CDR X)) 0))
(PLISTP X)
(EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
which simplifies, unfolding PLISTP and LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP X)
(EQUAL (CDR X) NIL)
(PLISTP X)
(EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
which simplifies, unfolding the definitions of PLISTP and LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP X))
(PLISTP X)
(EQUAL (LENGTH X) 0))
(EQUAL X NIL)),
which simplifies, unfolding PLISTP, to:
T.
That finishes the proof of *1.1, which, consequently, finishes the proof
of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
CDR-IS-NIL-WHEN-LENGTH-IS-1
(DISABLE CDR-IS-NIL-WHEN-LENGTH-IS-1)
[ 0.0 0.0 0.0 ]
CDR-IS-NIL-WHEN-LENGTH-IS-1-OFF
(PROVE-LEMMA PLIST-OF-LENGTH-0
(REWRITE)
(IMPLIES (AND (PLISTP L)
(EQUAL (LENGTH L) '0))
(EQUAL (EQUAL L 'NIL) '*1*TRUE))
((ENABLE PLISTP LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. Two inductions are suggested by terms in
the conjecture. However, they merge into one likely candidate induction. We
will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (p (CDR L)))
(p L))
(IMPLIES (NOT (LISTP L)) (p L))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT L) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme leads to four
new goals:
Case 4. (IMPLIES (AND (LISTP L)
(NOT (PLISTP (CDR L)))
(PLISTP L)
(EQUAL (LENGTH L) 0))
(EQUAL L NIL)),
which simplifies, unfolding the function PLISTP, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (EQUAL (LENGTH (CDR L)) 0))
(PLISTP L)
(EQUAL (LENGTH L) 0))
(EQUAL L NIL)),
which simplifies, opening up PLISTP and LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(EQUAL (CDR L) NIL)
(PLISTP L)
(EQUAL (LENGTH L) 0))
(EQUAL L NIL)),
which simplifies, expanding PLISTP and LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(PLISTP L)
(EQUAL (LENGTH L) 0))
(EQUAL L NIL)),
which simplifies, expanding PLISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLIST-OF-LENGTH-0
(DISABLE PLIST-OF-LENGTH-0)
[ 0.0 0.0 0.0 ]
PLIST-OF-LENGTH-0-OFF
(PROVE-LEMMA PLISTP-APPEND
(REWRITE)
(IMPLIES (PLISTP B)
(PLISTP (APPEND A B)))
((ENABLE PLISTP APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. The recursive terms in the
conjecture suggest two inductions. However, only one is unflawed. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP can be used to establish that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme generates the
following two new formulas:
Case 2. (IMPLIES (AND (LISTP A)
(PLISTP (APPEND (CDR A) B))
(PLISTP B))
(PLISTP (APPEND A B))).
This simplifies, applying CDR-CONS, and expanding the functions APPEND and
PLISTP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A)) (PLISTP B))
(PLISTP (APPEND A B))),
which simplifies, opening up the function APPEND, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-APPEND
(DISABLE PLISTP-APPEND)
[ 0.0 0.0 0.0 ]
PLISTP-APPEND-OFF
(PROVE-LEMMA PLISTP-LIST1
(REWRITE)
(PLISTP (CONS X 'NIL))
((ENABLE PLISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, applying CDR-CONS, and opening up the definitions of PLISTP,
EQUAL, and LISTP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-LIST1
(DISABLE PLISTP-LIST1)
[ 0.0 0.0 0.0 ]
PLISTP-LIST1-OFF
(PROVE-LEMMA PLISTP-LIST2
(REWRITE)
(PLISTP (CONS X (CONS Y 'NIL)))
((ENABLE PLISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with CDR-CONS, and unfolding PLISTP, EQUAL, and
LISTP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-LIST2
(DISABLE PLISTP-LIST2)
[ 0.0 0.0 0.0 ]
PLISTP-LIST2-OFF
(PROVE-LEMMA PLISTP-PUTNTH
(REWRITE)
(IMPLIES (PLISTP L)
(PLISTP (PUTNTH V I L)))
((ENABLE PLISTP PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are three plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP I))
(p V I L))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP I))
(p V (SUB1 I) (CDR L)))
(p V I L))
(IMPLIES (NOT (LISTP L)) (p V I L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT I) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for L. The above induction scheme produces the
following four new goals:
Case 4. (IMPLIES (AND (LISTP L) (ZEROP I) (PLISTP L))
(PLISTP (PUTNTH V I L))).
This simplifies, applying CDR-CONS, and unfolding the definitions of ZEROP,
PLISTP, EQUAL, and PUTNTH, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (ZEROP I))
(NOT (PLISTP (CDR L)))
(PLISTP L))
(PLISTP (PUTNTH V I L))),
which simplifies, unfolding the definitions of ZEROP and PLISTP, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (ZEROP I))
(PLISTP (PUTNTH V (SUB1 I) (CDR L)))
(PLISTP L))
(PLISTP (PUTNTH V I L))),
which simplifies, rewriting with CDR-CONS, and expanding the definitions of
ZEROP, PLISTP, and PUTNTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L)) (PLISTP L))
(PLISTP (PUTNTH V I L))).
This simplifies, unfolding PLISTP, LISTP, PUTNTH, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-PUTNTH
(DISABLE PLISTP-PUTNTH)
[ 0.0 0.0 0.0 ]
PLISTP-PUTNTH-OFF
(PROVE-LEMMA PLISTP-GETSEG
(REWRITE)
(PLISTP (GETSEG N K L))
((ENABLE PLISTP GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for N. The above induction scheme leads to two new
formulas:
Case 2. (IMPLIES (ZEROP K)
(PLISTP (GETSEG N K L))),
which simplifies, expanding the functions ZEROP, EQUAL, GETSEG, LISTP, and
PLISTP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(PLISTP (GETSEG (ADD1 N) (SUB1 K) L)))
(PLISTP (GETSEG N K L))),
which simplifies, applying the lemma CDR-CONS, and unfolding ZEROP, GETSEG,
and PLISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-GETSEG
(DISABLE PLISTP-GETSEG)
[ 0.0 0.0 0.0 ]
PLISTP-GETSEG-OFF
(PROVE-LEMMA PLISTP-PUTSEG
(REWRITE)
(IMPLIES (PLISTP L)
(PLISTP (PUTSEG S N L)))
((ENABLE PLISTP PUTSEG PLISTP-PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are two plausible inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP S) (p (CDR S) (ADD1 N) L))
(p S N L))
(IMPLIES (NOT (LISTP S)) (p S N L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces the following two new goals:
Case 2. (IMPLIES (AND (LISTP S)
(PLISTP (PUTSEG (CDR S) (ADD1 N) L))
(PLISTP L))
(PLISTP (PUTSEG S N L))).
This simplifies, applying PLISTP-PUTNTH, and unfolding the definition of
PUTSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S)) (PLISTP L))
(PLISTP (PUTSEG S N L))),
which simplifies, unfolding the definition of PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-PUTSEG
(DISABLE PLISTP-PUTSEG)
[ 0.0 0.0 0.0 ]
PLISTP-PUTSEG-OFF
(PROVE-LEMMA PLISTP-FIXLENGTH
(REWRITE)
(PLISTP (FIXLENGTH N L V))
((ENABLE PLISTP FIXLENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will try to prove it by induction. There is only one suggested
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP N))
(p N L V))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(p (SUB1 N) (CDR L) V))
(p N L V))
(IMPLIES (AND (NOT (LISTP L)) (ZEROP N))
(p N L V))
(IMPLIES (AND (NOT (LISTP L))
(NOT (ZEROP N))
(p (SUB1 N) L V))
(p N L V))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT N) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instances chosen for L. The above induction scheme leads to four
new formulas:
Case 4. (IMPLIES (AND (LISTP L) (ZEROP N))
(PLISTP (FIXLENGTH N L V))),
which simplifies, expanding the functions ZEROP, EQUAL, FIXLENGTH, LISTP,
and PLISTP, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(PLISTP (FIXLENGTH (SUB1 N) (CDR L) V)))
(PLISTP (FIXLENGTH N L V))),
which simplifies, applying the lemma CDR-CONS, and unfolding ZEROP,
FIXLENGTH, and PLISTP, to:
T.
Case 2. (IMPLIES (AND (NOT (LISTP L)) (ZEROP N))
(PLISTP (FIXLENGTH N L V))),
which simplifies, opening up the functions ZEROP, EQUAL, FIXLENGTH, LISTP,
and PLISTP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(NOT (ZEROP N))
(PLISTP (FIXLENGTH (SUB1 N) L V)))
(PLISTP (FIXLENGTH N L V))),
which simplifies, applying the lemma CDR-CONS, and opening up ZEROP,
FIXLENGTH, and PLISTP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PLISTP-FIXLENGTH
(DISABLE PLISTP-FIXLENGTH)
[ 0.0 0.0 0.0 ]
PLISTP-FIXLENGTH-OFF
(PROVE-LEMMA LENGTH-APPEND
(REWRITE)
(EQUAL (LENGTH (APPEND A B))
(PLUS (LENGTH A) (LENGTH B)))
((ENABLE APPEND LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP can be used to prove that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme leads to two
new goals:
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (LENGTH (APPEND (CDR A) B))
(PLUS (LENGTH (CDR A)) (LENGTH B))))
(EQUAL (LENGTH (APPEND A B))
(PLUS (LENGTH A) (LENGTH B)))),
which simplifies, applying the lemmas CDR-CONS and SUB1-ADD1, and opening up
the definitions of APPEND, LENGTH, and PLUS, to:
T.
Case 1. (IMPLIES (NOT (LISTP A))
(EQUAL (LENGTH (APPEND A B))
(PLUS (LENGTH A) (LENGTH B)))),
which simplifies, unfolding the functions APPEND, LENGTH, EQUAL, and PLUS,
to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
LENGTH-APPEND
(DISABLE LENGTH-APPEND)
[ 0.0 0.0 0.0 ]
LENGTH-APPEND-OFF
(PROVE-LEMMA LENGTH-PUTNTH
(REWRITE)
(EQUAL (LENGTH (PUTNTH N V L))
(LENGTH L))
((ENABLE PUTNTH LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are three plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP V))
(p N V L))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP V))
(p N (SUB1 V) (CDR L)))
(p N V L))
(IMPLIES (NOT (LISTP L)) (p N V L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT V) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for L. The above induction scheme produces the
following three new goals:
Case 3. (IMPLIES (AND (LISTP L) (ZEROP V))
(EQUAL (LENGTH (PUTNTH N V L))
(LENGTH L))).
This simplifies, applying CDR-CONS, and unfolding the definitions of ZEROP,
EQUAL, PUTNTH, and LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (ZEROP V))
(EQUAL (LENGTH (PUTNTH N (SUB1 V) (CDR L)))
(LENGTH (CDR L))))
(EQUAL (LENGTH (PUTNTH N V L))
(LENGTH L))),
which simplifies, rewriting with CDR-CONS, and expanding the definitions of
ZEROP, PUTNTH, and LENGTH, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (LENGTH (PUTNTH N V L))
(LENGTH L))).
This simplifies, expanding the definitions of PUTNTH, LENGTH, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-PUTNTH
(DISABLE LENGTH-PUTNTH)
[ 0.0 0.0 0.0 ]
LENGTH-PUTNTH-OFF
(PROVE-LEMMA LENGTH-GETSEG
(REWRITE)
(EQUAL (LENGTH (GETSEG N K L))
(FIX K))
((ENABLE GETSEG LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, opening up the function FIX, to the following two
new goals:
Case 2. (IMPLIES (NOT (NUMBERP K))
(EQUAL (LENGTH (GETSEG N K L)) 0)).
But this again simplifies, expanding the definitions of GETSEG, LISTP,
LENGTH, and EQUAL, to:
T.
Case 1. (IMPLIES (NUMBERP K)
(EQUAL (LENGTH (GETSEG N K L)) K)),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for N. The above induction scheme
generates two new goals:
Case 2. (IMPLIES (AND (ZEROP K) (NUMBERP K))
(EQUAL (LENGTH (GETSEG N K L)) K)),
which simplifies, expanding ZEROP, NUMBERP, EQUAL, GETSEG, LISTP, and LENGTH,
to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (LENGTH (GETSEG (ADD1 N) (SUB1 K) L))
(SUB1 K))
(NUMBERP K))
(EQUAL (LENGTH (GETSEG N K L)) K)),
which simplifies, rewriting with ADD1-SUB1 and CDR-CONS, and unfolding the
definitions of ZEROP, GETSEG, and LENGTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-GETSEG
(DISABLE LENGTH-GETSEG)
[ 0.0 0.0 0.0 ]
LENGTH-GETSEG-OFF
(PROVE-LEMMA LENGTH-PUTSEG
(REWRITE)
(EQUAL (LENGTH (PUTSEG S N L))
(LENGTH L))
((ENABLE LENGTH-PUTNTH PUTSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There is only one plausible
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP S) (p (CDR S) (ADD1 N) L))
(p S N L))
(IMPLIES (NOT (LISTP S)) (p S N L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces the following two new goals:
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
(LENGTH L)))
(EQUAL (LENGTH (PUTSEG S N L))
(LENGTH L))).
This simplifies, applying LENGTH-PUTNTH, and unfolding the definition of
PUTSEG, to:
T.
Case 1. (IMPLIES (NOT (LISTP S))
(EQUAL (LENGTH (PUTSEG S N L))
(LENGTH L))),
which simplifies, unfolding the definition of PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-PUTSEG
(DISABLE LENGTH-PUTSEG)
[ 0.0 0.0 0.0 ]
LENGTH-PUTSEG-OFF
(PROVE-LEMMA LENGTH-FIXLENGTH
(REWRITE)
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
(FIX N))
((ENABLE FIXLENGTH LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, opening up the function FIX, to the following two
new goals:
Case 2. (IMPLIES (NOT (NUMBERP N))
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
0)).
But this again simplifies, expanding the definitions of FIXLENGTH, LISTP,
LENGTH, and EQUAL, to:
T.
Case 1. (IMPLIES (NUMBERP N)
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
N)),
which we will name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP N))
(p N L DEFAULT))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(p (SUB1 N) (CDR L) DEFAULT))
(p N L DEFAULT))
(IMPLIES (AND (NOT (LISTP L)) (ZEROP N))
(p N L DEFAULT))
(IMPLIES (AND (NOT (LISTP L))
(NOT (ZEROP N))
(p (SUB1 N) L DEFAULT))
(p N L DEFAULT))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT N) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instances chosen for L. The above induction scheme
generates four new goals:
Case 4. (IMPLIES (AND (LISTP L) (ZEROP N) (NUMBERP N))
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
N)),
which simplifies, expanding ZEROP, NUMBERP, EQUAL, FIXLENGTH, LISTP, and
LENGTH, to:
T.
Case 3. (IMPLIES (AND (LISTP L)
(NOT (ZEROP N))
(EQUAL (LENGTH (FIXLENGTH (SUB1 N) (CDR L) DEFAULT))
(SUB1 N))
(NUMBERP N))
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
N)),
which simplifies, rewriting with ADD1-SUB1 and CDR-CONS, and unfolding the
definitions of ZEROP, FIXLENGTH, and LENGTH, to:
T.
Case 2. (IMPLIES (AND (NOT (LISTP L))
(ZEROP N)
(NUMBERP N))
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
N)).
This simplifies, opening up ZEROP, NUMBERP, EQUAL, FIXLENGTH, LISTP, and
LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L))
(NOT (ZEROP N))
(EQUAL (LENGTH (FIXLENGTH (SUB1 N) L DEFAULT))
(SUB1 N))
(NUMBERP N))
(EQUAL (LENGTH (FIXLENGTH N L DEFAULT))
N)).
This simplifies, applying the lemmas ADD1-SUB1 and CDR-CONS, and opening up
ZEROP, FIXLENGTH, and LENGTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
LENGTH-FIXLENGTH
(DISABLE LENGTH-FIXLENGTH)
[ 0.0 0.0 0.0 ]
LENGTH-FIXLENGTH-OFF
(PROVE-LEMMA APPEND-NON-LIST-LEFT
(REWRITE)
(IMPLIES (NOT (LISTP A))
(EQUAL (APPEND A B) B))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, expanding APPEND, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-NON-LIST-LEFT
(DISABLE APPEND-NON-LIST-LEFT)
[ 0.0 0.0 0.0 ]
APPEND-NON-LIST-LEFT-OFF
(PROVE-LEMMA APPEND-NON-LIST-LEFT-COROLLARY
(REWRITE)
(IMPLIES (EQUAL (LENGTH A) '0)
(EQUAL (APPEND A B) B))
((ENABLE APPEND LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP can be used to show that the measure
(COUNT A) decreases according to the well-founded relation LESSP in each
induction step of the scheme. The above induction scheme leads to the
following three new goals:
Case 3. (IMPLIES (AND (LISTP A)
(NOT (EQUAL (LENGTH (CDR A)) 0))
(EQUAL (LENGTH A) 0))
(EQUAL (APPEND A B) B)).
This simplifies, expanding the definition of LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (APPEND (CDR A) B) B)
(EQUAL (LENGTH A) 0))
(EQUAL (APPEND A B) B)).
This simplifies, unfolding LENGTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A))
(EQUAL (LENGTH A) 0))
(EQUAL (APPEND A B) B)).
This simplifies, unfolding the definitions of LENGTH, EQUAL, and APPEND, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-NON-LIST-LEFT-COROLLARY
(DISABLE APPEND-NON-LIST-LEFT-COROLLARY)
[ 0.0 0.0 0.0 ]
APPEND-NON-LIST-LEFT-COROLLARY-OFF
(PROVE-LEMMA APPEND-NIL-ON-RIGHT
(REWRITE)
(IMPLIES (PLISTP A)
(EQUAL (APPEND A 'NIL) A))
((ENABLE APPEND PLISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
We will appeal to induction. The recursive terms in the conjecture
suggest two inductions. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A)))
(p A))
(IMPLIES (NOT (LISTP A)) (p A))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following three new
formulas:
Case 3. (IMPLIES (AND (LISTP A)
(NOT (PLISTP (CDR A)))
(PLISTP A))
(EQUAL (APPEND A NIL) A)).
This simplifies, expanding the definition of PLISTP, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (APPEND (CDR A) NIL) (CDR A))
(PLISTP A))
(EQUAL (APPEND A NIL) A)).
This simplifies, applying CONS-CAR-CDR, and expanding the definitions of
PLISTP and APPEND, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP A)) (PLISTP A))
(EQUAL (APPEND A NIL) A)),
which simplifies, opening up PLISTP, APPEND, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-NIL-ON-RIGHT
(DISABLE APPEND-NIL-ON-RIGHT)
[ 0.0 0.0 0.0 ]
APPEND-NIL-ON-RIGHT-OFF
(PROVE-LEMMA APPEND-CDR
(REWRITE)
(IMPLIES (LISTP A)
(EQUAL (APPEND (CDR A) B)
(CDR (APPEND A B))))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, appealing to the lemma CDR-CONS, and opening up the
definition of APPEND, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-CDR
(DISABLE APPEND-CDR)
[ 0.0 0.0 0.0 ]
APPEND-CDR-OFF
(PROVE-LEMMA APPEND-CROCK
(REWRITE)
(EQUAL (APPEND (CONS A 'NIL) (APPEND B C))
(APPEND (CONS A B) C))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying CDR-CONS and CAR-CONS, and unfolding APPEND
and LISTP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-CROCK
(DISABLE APPEND-CROCK)
[ 0.0 0.0 0.0 ]
APPEND-CROCK-OFF
(PROVE-LEMMA ASSOCIATIVITY-OF-APPEND
(REWRITE)
(EQUAL (APPEND (APPEND A B) C)
(APPEND A (APPEND B C)))
((ENABLE APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Three inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B C))
(p A B C))
(IMPLIES (NOT (LISTP A)) (p A B C))).
Linear arithmetic and the lemma CDR-LESSP can be used to prove that the
measure (COUNT A) decreases according to the well-founded relation LESSP in
each induction step of the scheme. The above induction scheme leads to two
new goals:
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (APPEND (APPEND (CDR A) B) C)
(APPEND (CDR A) (APPEND B C))))
(EQUAL (APPEND (APPEND A B) C)
(APPEND A (APPEND B C)))),
which simplifies, applying the lemmas CDR-CONS and CAR-CONS, and opening up
the definition of APPEND, to:
T.
Case 1. (IMPLIES (NOT (LISTP A))
(EQUAL (APPEND (APPEND A B) C)
(APPEND A (APPEND B C)))),
which simplifies, unfolding the function APPEND, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-APPEND
(DISABLE ASSOCIATIVITY-OF-APPEND)
[ 0.0 0.0 0.0 ]
ASSOCIATIVITY-OF-APPEND-OFF
(PROVE-LEMMA APPEND-FIXLENGTH
(REWRITE)
(EQUAL (APPEND (FIXLENGTH A 'NIL DEFAULT)
(FIXLENGTH B 'NIL DEFAULT))
(FIXLENGTH (PLUS A B) 'NIL DEFAULT))
((ENABLE FIXLENGTH APPEND)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are three plausible
inductions. They merge into two likely candidate inductions. However, only
one is unflawed. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP A) (p A DEFAULT B))
(IMPLIES (AND (NOT (ZEROP A))
(p (SUB1 A) DEFAULT B))
(p A DEFAULT B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT A) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme leads to the following two new formulas:
Case 2. (IMPLIES (ZEROP A)
(EQUAL (APPEND (FIXLENGTH A NIL DEFAULT)
(FIXLENGTH B NIL DEFAULT))
(FIXLENGTH (PLUS A B) NIL DEFAULT))).
This simplifies, opening up the definitions of ZEROP, EQUAL, LISTP,
FIXLENGTH, APPEND, and PLUS, to the following two new goals:
Case 2.2.
(IMPLIES (AND (EQUAL A 0) (NOT (NUMBERP B)))
(EQUAL (FIXLENGTH B NIL DEFAULT)
(FIXLENGTH 0 NIL DEFAULT))).
However this again simplifies, unfolding LISTP, FIXLENGTH, and EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP A))
(NOT (NUMBERP B)))
(EQUAL (FIXLENGTH B NIL DEFAULT)
(FIXLENGTH 0 NIL DEFAULT))),
which again simplifies, opening up LISTP, FIXLENGTH, and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP A))
(EQUAL (APPEND (FIXLENGTH (SUB1 A) NIL DEFAULT)
(FIXLENGTH B NIL DEFAULT))
(FIXLENGTH (PLUS (SUB1 A) B)
NIL DEFAULT)))
(EQUAL (APPEND (FIXLENGTH A NIL DEFAULT)
(FIXLENGTH B NIL DEFAULT))
(FIXLENGTH (PLUS A B) NIL DEFAULT))),
which simplifies, rewriting with the lemmas CDR-CONS, CAR-CONS, and
SUB1-ADD1, and opening up the functions ZEROP, FIXLENGTH, LISTP, APPEND, and
PLUS, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
APPEND-FIXLENGTH
(DISABLE APPEND-FIXLENGTH)
[ 0.0 0.0 0.0 ]
APPEND-FIXLENGTH-OFF
(PROVE-LEMMA GETNTH-0-2
(REWRITE)
(EQUAL (GETNTH '0 (CONS A (CONS B 'NIL)))
A)
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, rewriting with CAR-CONS, and unfolding EQUAL and
GETNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-0-2
(DISABLE GETNTH-0-2)
[ 0.0 0.0 0.0 ]
GETNTH-0-2-OFF
(PROVE-LEMMA GETNTH-1-2
(REWRITE)
(EQUAL (GETNTH '1 (CONS A (CONS B 'NIL)))
B)
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, rewriting with CDR-CONS and CAR-CONS, and
unfolding SUB1, NUMBERP, EQUAL, and GETNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-1-2
(DISABLE GETNTH-1-2)
[ 0.0 0.0 0.0 ]
GETNTH-1-2-OFF
(PROVE-LEMMA LIST-GETNTH-0
(REWRITE)
(IMPLIES (AND (PLISTP L)
(EQUAL (LENGTH L) '1))
(EQUAL (CONS (GETNTH '0 L) 'NIL) L))
((ENABLE PLISTP GETNTH LENGTH PLIST-OF-LENGTH-0
NON-ZERO-LENGTH-IMPLIES-LISTP)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, rewriting with NON-ZERO-LENGTH-IMPLIES-LISTP, and
opening up the definitions of EQUAL and GETNTH, to the new goal:
(IMPLIES (AND (PLISTP L) (EQUAL (LENGTH L) 1))
(EQUAL (LIST (CAR L)) L)).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS X Z) to eliminate (CAR L)
and (CDR L). We thus obtain the following two new formulas:
Case 2. (IMPLIES (AND (NOT (LISTP L))
(PLISTP L)
(EQUAL (LENGTH L) 1))
(EQUAL (LIST (CAR L)) L)).
However this further simplifies, appealing to the lemma
NON-ZERO-LENGTH-IMPLIES-LISTP, and unfolding the definition of EQUAL, to:
T.
Case 1. (IMPLIES (AND (PLISTP (CONS X Z))
(EQUAL (LENGTH (CONS X Z)) 1))
(EQUAL (LIST X) (CONS X Z))),
which further simplifies, rewriting with CDR-CONS, ADD1-EQUAL, CAR-CONS, and
PLIST-OF-LENGTH-0, and opening up PLISTP, LENGTH, and NUMBERP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
LIST-GETNTH-0
(DISABLE LIST-GETNTH-0)
[ 0.0 0.0 0.0 ]
LIST-GETNTH-0-OFF
(PROVE-LEMMA OPEN-UP-GETNTH
(REWRITE)
(EQUAL (GETNTH (ADD1 N) (CONS A B))
(GETNTH N B))
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying CDR-CONS and SUB1-ADD1, and opening up the
function GETNTH, to:
(IMPLIES (NOT (NUMBERP N))
(EQUAL (GETNTH 0 B) (GETNTH N B))),
which again simplifies, opening up the functions EQUAL and GETNTH, to:
T.
Q.E.D.
[ 0.1 0.0 0.0 ]
OPEN-UP-GETNTH
(DISABLE OPEN-UP-GETNTH)
[ 0.0 0.0 0.0 ]
OPEN-UP-GETNTH-OFF
(PROVE-LEMMA OPEN-UP-GETNTH1
(REWRITE)
(IMPLIES (NOT (ZEROP N))
(EQUAL (GETNTH N (CONS A B))
(GETNTH (SUB1 N) B)))
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0)) (NUMBERP N))
(EQUAL (GETNTH N (CONS A B))
(GETNTH (SUB1 N) B))),
which simplifies, rewriting with CDR-CONS, and expanding the function GETNTH,
to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
OPEN-UP-GETNTH1
(DISABLE OPEN-UP-GETNTH1)
[ 0.0 0.0 0.0 ]
OPEN-UP-GETNTH1-OFF
(PROVE-LEMMA OPEN-UP-GETNTH-ON-ZERO
(REWRITE)
(EQUAL (GETNTH '0 (CONS A B)) A)
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemma CAR-CONS, and expanding the
functions EQUAL and GETNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
OPEN-UP-GETNTH-ON-ZERO
(DISABLE OPEN-UP-GETNTH-ON-ZERO)
[ 0.0 0.0 0.0 ]
OPEN-UP-GETNTH-ON-ZERO-OFF
(PROVE-LEMMA GETNTH-WITH-NON-NUMBER-INDEX
(REWRITE)
(IMPLIES (NOT (NUMBERP N))
(EQUAL (GETNTH N L) (GETNTH '0 L)))
((ENABLE GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the functions GETNTH and EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-WITH-NON-NUMBER-INDEX
(DISABLE GETNTH-WITH-NON-NUMBER-INDEX)
[ 0.0 0.0 0.0 ]
GETNTH-WITH-NON-NUMBER-INDEX-OFF
(PROVE-LEMMA GETNTH-APPEND-FOR-LENGTH-LEFT
(REWRITE)
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
(IF (LISTP B) (CAR B) '0))
((ENABLE GETNTH APPEND LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, obviously, to two new formulas:
Case 2. (IMPLIES (NOT (LISTP B))
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
0)),
which we will name *1.
Case 1. (IMPLIES (LISTP B)
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
(CAR B))).
Appealing to the lemma CAR-CDR-ELIM, we now replace B by (CONS X Z) to
eliminate (CAR B) and (CDR B). We must thus prove the conjecture:
(EQUAL (GETNTH (LENGTH A)
(APPEND A (CONS X Z)))
X),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
(IF (LISTP B) (CAR B) 0)).
We gave this the name *1 above. Perhaps we can prove it by induction. The
recursive terms in the conjecture suggest two inductions. However, they merge
into one likely candidate induction. We will induct according to the
following scheme:
(AND (IMPLIES (AND (LISTP A) (p (CDR A) B))
(p A B))
(IMPLIES (NOT (LISTP A)) (p A B))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following two new
conjectures:
Case 2. (IMPLIES (AND (LISTP A)
(EQUAL (GETNTH (LENGTH (CDR A))
(APPEND (CDR A) B))
(IF (LISTP B) (CAR B) 0)))
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
(IF (LISTP B) (CAR B) 0))).
This simplifies, applying CDR-CONS and SUB1-ADD1, and expanding the
definitions of LENGTH, APPEND, GETNTH, and EQUAL, to:
T.
Case 1. (IMPLIES (NOT (LISTP A))
(EQUAL (GETNTH (LENGTH A) (APPEND A B))
(IF (LISTP B) (CAR B) 0))),
which simplifies, opening up the functions LENGTH, APPEND, EQUAL, and GETNTH,
to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-FOR-LENGTH-LEFT
(DISABLE GETNTH-APPEND-FOR-LENGTH-LEFT)
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-FOR-LENGTH-LEFT-OFF
(PROVE-LEMMA GETNTH-APPEND-CASESPLIT
(REWRITE)
(EQUAL (GETNTH N (APPEND A B))
(IF (LESSP N (LENGTH A))
(GETNTH N A)
(GETNTH (DIFFERENCE N (LENGTH A)) B)))
((ENABLE GETNTH APPEND CAR-APPEND APPEND-NON-LIST-LEFT LENGTH)
(INDUCT (GETNTH N A))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, OR, and
AND, to three new formulas:
Case 3. (IMPLIES (AND (LISTP A) (ZEROP N))
(EQUAL (GETNTH N (APPEND A B))
(IF (LESSP N (LENGTH A))
(GETNTH N A)
(GETNTH (DIFFERENCE N (LENGTH A))
B)))),
which simplifies, applying CAR-APPEND, and opening up the definitions of
ZEROP, EQUAL, GETNTH, LESSP, and DIFFERENCE, to the following eight new
conjectures:
Case 3.8.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(NOT (EQUAL (LENGTH A) 0))
(NOT (LISTP (APPEND A B))))
(EQUAL 0 (CAR A))).
This again simplifies, obviously, to the new conjecture:
(IMPLIES (AND (LISTP A)
(NOT (EQUAL (LENGTH A) 0))
(NOT (LISTP (APPEND A B))))
(EQUAL 0 (CAR A))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). We thus obtain:
(IMPLIES (AND (NOT (EQUAL (LENGTH (CONS X Z)) 0))
(NOT (LISTP (APPEND (CONS X Z) B))))
(EQUAL 0 X)),
which further simplifies, rewriting with CDR-CONS and CAR-CONS, and
expanding LENGTH and APPEND, to:
T.
Case 3.7.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(LISTP B)
(NOT (LISTP (APPEND A B))))
(EQUAL 0 (CAR B))).
This again simplifies, clearly, to:
T.
Case 3.6.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(LISTP B)
(LISTP (APPEND A B)))
(EQUAL (CAR A) (CAR B))).
This again simplifies, obviously, to the new conjecture:
(IMPLIES (AND (LISTP A)
(EQUAL (LENGTH A) 0)
(LISTP B))
(EQUAL (CAR A) (CAR B))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). We would thus like to prove:
(IMPLIES (AND (EQUAL (LENGTH (CONS X Z)) 0)
(LISTP B))
(EQUAL X (CAR B))),
which further simplifies, applying CDR-CONS, and unfolding the definition
of LENGTH, to:
T.
Case 3.5.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CAR A) 0)).
This again simplifies, clearly, to:
(IMPLIES (AND (LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CAR A) 0)).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). We thus obtain:
(IMPLIES (AND (EQUAL (LENGTH (CONS X Z)) 0)
(NOT (LISTP B))
(LISTP (APPEND (CONS X Z) B)))
(EQUAL X 0)),
which further simplifies, rewriting with CDR-CONS, and unfolding the
function LENGTH, to:
T.
Case 3.4.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH A) 0))
(NOT (LISTP (APPEND A B))))
(EQUAL 0 (CAR A))).
Appealing to the lemma CAR-CDR-ELIM, we now replace A by (CONS X Z) to
eliminate (CAR A) and (CDR A). We must thus prove:
(IMPLIES (AND (NOT (NUMBERP N))
(NOT (EQUAL (LENGTH (CONS X Z)) 0))
(NOT (LISTP (APPEND (CONS X Z) B))))
(EQUAL 0 X)).
But this further simplifies, applying CDR-CONS and CAR-CONS, and unfolding
the definitions of LENGTH and APPEND, to:
T.
Case 3.3.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B)
(NOT (LISTP (APPEND A B))))
(EQUAL 0 (CAR B))).
This again simplifies, obviously, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B)
(LISTP (APPEND A B)))
(EQUAL (CAR A) (CAR B))).
This again simplifies, clearly, to:
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B))
(EQUAL (CAR A) (CAR B))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). We would thus like to prove:
(IMPLIES (AND (NOT (NUMBERP N))
(EQUAL (LENGTH (CONS X Z)) 0)
(LISTP B))
(EQUAL X (CAR B))),
which further simplifies, appealing to the lemma CDR-CONS, and expanding
the function LENGTH, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CAR A) 0)).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS X Z) to eliminate
(CAR A) and (CDR A). This produces:
(IMPLIES (AND (NOT (NUMBERP N))
(EQUAL (LENGTH (CONS X Z)) 0)
(NOT (LISTP B))
(LISTP (APPEND (CONS X Z) B)))
(EQUAL X 0)),
which further simplifies, rewriting with the lemma CDR-CONS, and unfolding
LENGTH, to:
T.
Case 2. (IMPLIES (AND (LISTP A)
(NOT (EQUAL N 0))
(NUMBERP N)
(EQUAL (GETNTH (SUB1 N) (APPEND (CDR A) B))
(IF (LESSP (SUB1 N) (LENGTH (CDR A)))
(GETNTH (SUB1 N) (CDR A))
(GETNTH (DIFFERENCE (SUB1 N) (LENGTH (CDR A)))
B))))
(EQUAL (GETNTH N (APPEND A B))
(IF (LESSP N (LENGTH A))
(GETNTH N A)
(GETNTH (DIFFERENCE N (LENGTH A))
B)))),
which simplifies, rewriting with the lemmas CDR-CONS and SUB1-ADD1, and
opening up APPEND, GETNTH, LENGTH, LESSP, and DIFFERENCE, to:
T.
Case 1. (IMPLIES (NOT (LISTP A))
(EQUAL (GETNTH N (APPEND A B))
(IF (LESSP N (LENGTH A))
(GETNTH N A)
(GETNTH (DIFFERENCE N (LENGTH A))
B)))),
which simplifies, appealing to the lemma APPEND-NON-LIST-LEFT, and opening
up LENGTH, EQUAL, LESSP, and DIFFERENCE, to two new goals:
Case 1.2.
(IMPLIES (AND (NOT (LISTP A))
(NOT (NUMBERP N)))
(EQUAL (GETNTH N B) (GETNTH 0 B))),
which again simplifies, unfolding the functions GETNTH and EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (LISTP A)) (EQUAL N 0))
(EQUAL (GETNTH N B) (GETNTH 0 B))),
which again simplifies, obviously, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-CASESPLIT
(DISABLE GETNTH-APPEND-CASESPLIT)
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-CASESPLIT-OFF
(PROVE-LEMMA GETNTH-APPEND-RIGHT
(REWRITE)
(IMPLIES (IF (LESSP N (LENGTH A))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETNTH N (APPEND A B))
(GETNTH (DIFFERENCE N (LENGTH A)) B)))
((ENABLE GETNTH-APPEND-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, applying GETNTH-APPEND-CASESPLIT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-RIGHT
(DISABLE GETNTH-APPEND-RIGHT)
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-RIGHT-OFF
(PROVE-LEMMA GETNTH-APPEND-LEFT
(REWRITE)
(IMPLIES (LESSP N (LENGTH A))
(EQUAL (GETNTH N (APPEND A B))
(GETNTH N A)))
((ENABLE GETNTH-APPEND-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying GETNTH-APPEND-CASESPLIT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-LEFT
(DISABLE GETNTH-APPEND-LEFT)
[ 0.0 0.0 0.0 ]
GETNTH-APPEND-LEFT-OFF
(PROVE-LEMMA GETNTH-PUTNTH-CASESPLIT
(REWRITE)
(EQUAL (GETNTH I (PUTNTH V J L))
(IF (LESSP I (LENGTH L))
(IF (EQUAL (FIX I) (FIX J))
V
(GETNTH I L))
(GETNTH I L)))
((ENABLE GETNTH PUTNTH LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, opening up FIX, to eight new goals:
Case 8. (IMPLIES (AND (NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (GETNTH I (PUTNTH V J L))
(GETNTH I L))),
which we will name *1.
Case 7. (IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J)))
(EQUAL (GETNTH I (PUTNTH V J L))
(GETNTH I L))).
But this again simplifies, unfolding the definition of GETNTH, to three new
conjectures:
Case 7.3.
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(NOT (LISTP L))
(LISTP (PUTNTH V J L)))
(EQUAL (CAR (PUTNTH V J L)) 0)),
which again simplifies, unfolding the function PUTNTH, to:
T.
Case 7.2.
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP L)
(NOT (LISTP (PUTNTH V J L))))
(EQUAL 0 (CAR L))),
which again simplifies, obviously, to:
T.
Case 7.1.
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP L)
(LISTP (PUTNTH V J L)))
(EQUAL (CAR (PUTNTH V J L)) (CAR L))).
This again simplifies, obviously, to:
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP L))
(EQUAL (CAR (PUTNTH V J L)) (CAR L))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS X Z) to eliminate
(CAR L) and (CDR L). We would thus like to prove the new goal:
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J)))
(EQUAL (CAR (PUTNTH V J (CONS X Z)))
X)),
which further simplifies, applying CDR-CONS and CAR-CONS, and expanding
the function PUTNTH, to:
T.
Case 6. (IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0)))
(EQUAL (GETNTH I (PUTNTH V J L))
(GETNTH I L))).
However this again simplifies, expanding the function PUTNTH, to:
(IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(LISTP L))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH I L))).
However this again simplifies, rewriting with CDR-CONS, and expanding the
definition of GETNTH, to the new conjecture:
(IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(LISTP L))
(EQUAL (GETNTH (SUB1 I) (CDR L))
(GETNTH I L))),
which again simplifies, expanding GETNTH, to:
T.
Case 5. (IMPLIES (NOT (LESSP I (LENGTH L)))
(EQUAL (GETNTH I (PUTNTH V J L))
(GETNTH I L))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(EQUAL (GETNTH I (PUTNTH V J L))
(IF (LESSP I (LENGTH L))
(IF (EQUAL (FIX I) (FIX J))
V
(GETNTH I L))
(GETNTH I L))).
We named this *1. We will try to prove it by induction. There are nine
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP (PUTNTH V J L)) (ZEROP I))
(p I V J L))
(IMPLIES (AND (LISTP (PUTNTH V J L))
(NOT (ZEROP I))
(p (SUB1 I) V (SUB1 J) (CDR L)))
(p I V J L))
(IMPLIES (NOT (LISTP (PUTNTH V J L)))
(p I V J L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT I) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instances chosen for J and L. The above induction scheme produces
three new conjectures:
Case 3. (IMPLIES (AND (LISTP (PUTNTH V J L)) (ZEROP I))
(EQUAL (GETNTH I (PUTNTH V J L))
(IF (LESSP I (LENGTH L))
(IF (EQUAL (FIX I) (FIX J))
V
(GETNTH I L))
(GETNTH I L)))),
which simplifies, expanding the definitions of PUTNTH, ZEROP, EQUAL, GETNTH,
LENGTH, LESSP, and FIX, to ten new goals:
Case 3.10.
(IMPLIES (AND (LISTP L)
(EQUAL I 0)
(NUMBERP J)
(NOT (EQUAL 0 J))
(NOT (EQUAL J 0)))
(EQUAL (CAR (CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(CAR L))),
which again simplifies, applying CAR-CONS, to:
T.
Case 3.9.
(IMPLIES (AND (LISTP L)
(EQUAL I 0)
(NUMBERP J)
(NOT (EQUAL 0 J))
(EQUAL J 0))
(EQUAL (CAR (CONS V (CDR L)))
(CAR L))).
This again simplifies, obviously, to:
T.
Case 3.8.
(IMPLIES (AND (LISTP L)
(EQUAL I 0)
(NUMBERP J)
(EQUAL 0 J)
(NOT (EQUAL J 0)))
(EQUAL (CAR (CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
V)).
This again simplifies, clearly, to:
T.
Case 3.7.
(IMPLIES (AND (LISTP L)
(EQUAL I 0)
(EQUAL 0 J)
(EQUAL J 0))
(EQUAL (CAR (CONS V (CDR L))) V)).
However this again simplifies, rewriting with CAR-CONS, and expanding
EQUAL, to:
T.
Case 3.6.
(IMPLIES (AND (LISTP L)
(EQUAL I 0)
(NOT (NUMBERP J)))
(EQUAL (CAR (CONS V (CDR L))) V)).
However this again simplifies, rewriting with CAR-CONS, to:
T.
Case 3.5.
(IMPLIES (AND (LISTP L)
(NOT (NUMBERP I))
(NUMBERP J)
(NOT (EQUAL 0 J))
(NOT (EQUAL J 0)))
(EQUAL (CAR (CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(CAR L))).
But this again simplifies, appealing to the lemma CAR-CONS, to:
T.
Case 3.4.
(IMPLIES (AND (LISTP L)
(NOT (NUMBERP I))
(NUMBERP J)
(NOT (EQUAL 0 J))
(EQUAL J 0))
(EQUAL (CAR (CONS V (CDR L)))
(CAR L))),
which again simplifies, trivially, to:
T.
Case 3.3.
(IMPLIES (AND (LISTP L)
(NOT (NUMBERP I))
(NUMBERP J)
(EQUAL 0 J)
(NOT (EQUAL J 0)))
(EQUAL (CAR (CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
V)).
This again simplifies, obviously, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP L)
(NOT (NUMBERP I))
(EQUAL 0 J)
(EQUAL J 0))
(EQUAL (CAR (CONS V (CDR L))) V)).
This again simplifies, appealing to the lemma CAR-CONS, and unfolding
EQUAL, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP L)
(NOT (NUMBERP I))
(NOT (NUMBERP J)))
(EQUAL (CAR (CONS V (CDR L))) V)),
which again simplifies, applying CAR-CONS, to:
T.
Case 2. (IMPLIES (AND (LISTP (PUTNTH V J L))
(NOT (ZEROP I))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(IF (LESSP (SUB1 I) (LENGTH (CDR L)))
(IF (EQUAL (FIX (SUB1 I)) (FIX (SUB1 J)))
V
(GETNTH (SUB1 I) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))))
(EQUAL (GETNTH I (PUTNTH V J L))
(IF (LESSP I (LENGTH L))
(IF (EQUAL (FIX I) (FIX J))
V
(GETNTH I L))
(GETNTH I L)))).
This simplifies, rewriting with the lemma SUB1-ADD1, and expanding PUTNTH,
ZEROP, FIX, LENGTH, LESSP, and GETNTH, to the following 15 new goals:
Case 2.15.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NUMBERP J)
(NOT (EQUAL I J))
(NOT (EQUAL J 0)))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(GETNTH (SUB1 I) (CDR L)))).
But this again simplifies, applying CDR-CONS, and expanding the definition
of GETNTH, to:
T.
Case 2.14.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (LESSP (SUB1 I) (LENGTH (CDR L))))
(NOT (EQUAL J 0))
(NUMBERP J))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(GETNTH (SUB1 I) (CDR L)))).
This again simplifies, applying CDR-CONS, and opening up GETNTH, to:
T.
Case 2.13.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (NUMBERP J)))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))).
But this again simplifies, appealing to the lemmas SUB1-NNUMBERP and
CDR-CONS, and unfolding the definition of GETNTH, to:
T.
Case 2.12.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (LESSP (SUB1 I) (LENGTH (CDR L))))
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, applying the lemma CDR-CONS, and expanding the
functions SUB1, EQUAL, PUTNTH, and GETNTH, to:
T.
Case 2.11.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (EQUAL I J))
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, appealing to the lemma CDR-CONS, and unfolding the
functions SUB1, EQUAL, PUTNTH, and GETNTH, to:
T.
Case 2.10.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(LESSP (SUB1 I) (LENGTH (CDR L)))
(NUMBERP J)
(EQUAL I J)
(NOT (EQUAL J 0)))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
V)),
which again simplifies, trivially, to:
T.
Case 2.9.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(LESSP (SUB1 I) (LENGTH (CDR L)))
(NUMBERP J)
(EQUAL I J)
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
V)).
This again simplifies, obviously, to:
T.
Case 2.8.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LESSP (SUB1 I) (LENGTH (CDR L))))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (EQUAL J 0))
(NUMBERP J))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(GETNTH (SUB1 I) (CDR L)))).
But this again simplifies, rewriting with CDR-CONS, and opening up the
definition of GETNTH, to:
T.
Case 2.7.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LESSP (SUB1 I) (LENGTH (CDR L))))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))).
However this again simplifies, appealing to the lemma CDR-CONS, and
expanding the functions SUB1, EQUAL, PUTNTH, and GETNTH, to:
T.
Case 2.6.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LESSP (SUB1 I) (LENGTH (CDR L))))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
(GETNTH (SUB1 I) (CDR L)))
(NOT (NUMBERP J)))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, rewriting with CDR-CONS, and unfolding GETNTH, to:
T.
Case 2.5.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NUMBERP J)
(NOT (EQUAL I J))
(NOT (EQUAL J 0)))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
(GETNTH (SUB1 I) (CDR L)))).
This again simplifies, using linear arithmetic, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NOT (EQUAL I J))
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, rewriting with CDR-CONS, and expanding SUB1, EQUAL,
PUTNTH, and GETNTH, to the following two new conjectures:
Case 2.4.2.
(IMPLIES (AND (LISTP L)
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) 0)
(LISTP (CDR L))
(EQUAL (CAR (CONS V (CDDR L))) V)
(NOT (EQUAL I 0)))
(EQUAL (CADR L)
(GETNTH (SUB1 I) (CDR L)))).
This again simplifies, appealing to the lemma CAR-CONS, and expanding
EQUAL, LESSP, and GETNTH, to:
T.
Case 2.4.1.
(IMPLIES (AND (LISTP L)
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) 0)
(NOT (LISTP (CDR L)))
(EQUAL 0 V)
(NOT (EQUAL I 0)))
(EQUAL 0 (GETNTH (SUB1 I) (CDR L)))),
which again simplifies, expanding the functions EQUAL, LESSP, and GETNTH,
to:
T.
Case 2.3.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NOT (NUMBERP J)))
(EQUAL (GETNTH I (CONS V (CDR L)))
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, rewriting with SUB1-NNUMBERP and CDR-CONS, and
opening up the functions GETNTH and EQUAL, to the following two new
formulas:
Case 2.3.2.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) 0)
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NOT (NUMBERP J))
(NOT (LISTP (CDR L))))
(EQUAL 0 (GETNTH (SUB1 I) (CDR L)))).
This again simplifies, unfolding the definitions of EQUAL, LESSP, and
GETNTH, to:
T.
Case 2.3.1.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) 0)
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NOT (NUMBERP J))
(LISTP (CDR L)))
(EQUAL (CADR L)
(GETNTH (SUB1 I) (CDR L)))),
which again simplifies, expanding EQUAL, LESSP, and GETNTH, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NUMBERP J)
(EQUAL I J)
(NOT (EQUAL J 0)))
(EQUAL (GETNTH I
(CONS (CAR L)
(PUTNTH V (SUB1 J) (CDR L))))
V)),
which again simplifies, applying the lemma CDR-CONS, and expanding the
function GETNTH, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL I 0))
(NUMBERP I)
(LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (GETNTH (SUB1 I)
(PUTNTH V (SUB1 J) (CDR L)))
V)
(NUMBERP J)
(EQUAL I J)
(EQUAL J 0))
(EQUAL (GETNTH I (CONS V (CDR L)))
V)),
which again simplifies, clearly, to:
T.
Case 1. (IMPLIES (NOT (LISTP (PUTNTH V J L)))
(EQUAL (GETNTH I (PUTNTH V J L))
(IF (LESSP I (LENGTH L))
(IF (EQUAL (FIX I) (FIX J))
V
(GETNTH I L))
(GETNTH I L)))).
This simplifies, expanding PUTNTH, GETNTH, LENGTH, EQUAL, and LESSP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
GETNTH-PUTNTH-CASESPLIT
(DISABLE GETNTH-PUTNTH-CASESPLIT)
[ 0.0 0.0 0.0 ]
GETNTH-PUTNTH-CASESPLIT-OFF
(PROVE-LEMMA GETNTH-PUTNTH-COINCIDENCE
(REWRITE)
(IMPLIES (LESSP N (LENGTH L))
(EQUAL (GETNTH N (PUTNTH V N L)) V))
((ENABLE GETNTH-PUTNTH-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, appealing to the lemma GETNTH-PUTNTH-CASESPLIT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-PUTNTH-COINCIDENCE
(DISABLE GETNTH-PUTNTH-COINCIDENCE)
[ 0.0 0.0 0.0 ]
GETNTH-PUTNTH-COINCIDENCE-OFF
(PROVE-LEMMA GETNTH-PUTNTH-NON-INTERFERENCE
(REWRITE)
(IMPLIES (NOT (EQUAL (FIX I) (FIX J)))
(EQUAL (GETNTH I (PUTNTH V J L))
(GETNTH I L)))
((ENABLE GETNTH-PUTNTH-CASESPLIT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying the lemma GETNTH-PUTNTH-CASESPLIT, and
unfolding FIX and LESSP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-PUTNTH-NON-INTERFERENCE
(DISABLE GETNTH-PUTNTH-NON-INTERFERENCE)
[ 0.0 0.0 0.0 ]
GETNTH-PUTNTH-NON-INTERFERENCE-OFF
(PROVE-LEMMA GETNTH-GETSEG-ZERO-INDEX
(REWRITE)
(IMPLIES (AND (NOT (ZEROP K)) (ZEROP I))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH N L)))
((ENABLE GETNTH GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, AND, and
IMPLIES, to the new formula:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(ZEROP I))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH N L))),
which simplifies, opening up the functions ZEROP, EQUAL, and GETNTH, to four
new goals:
Case 4. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL I 0)
(NOT (LISTP (GETSEG N K L))))
(EQUAL 0 (GETNTH N L))),
which again simplifies, clearly, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (LISTP (GETSEG N K L))))
(EQUAL 0 (GETNTH N L))),
which we will name *1.
Case 3. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL I 0)
(LISTP (GETSEG N K L)))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))).
This again simplifies, clearly, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP (GETSEG N K L)))
(EQUAL (CAR (GETSEG N K L))
(GETNTH N L))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(IMPLIES (AND (NOT (ZEROP K)) (ZEROP I))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH N L))).
We named this *1. We will try to prove it by induction. There are four
plausible inductions. They merge into three likely candidate inductions, two
of which are unflawed. So we will choose the one suggested by the largest
number of nonprimitive recursive functions. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP K) (p I N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p I (ADD1 N) (SUB1 K) L))
(p I N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for N. The above induction scheme
produces the following two new conjectures:
Case 2. (IMPLIES (AND (ZEROP (SUB1 K))
(NOT (ZEROP K))
(ZEROP I))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH N L))).
This simplifies, rewriting with the lemma CAR-CONS, and opening up the
functions ZEROP, GETSEG, EQUAL, and GETNTH, to:
T.
Case 1. (IMPLIES (AND (EQUAL (GETNTH I
(GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (ADD1 N) L))
(NOT (ZEROP K))
(ZEROP I))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH N L))).
This simplifies, rewriting with SUB1-ADD1 and CAR-CONS, and opening up the
definitions of GETNTH, ZEROP, GETSEG, and EQUAL, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
GETNTH-GETSEG-ZERO-INDEX
(DISABLE GETNTH-GETSEG-ZERO-INDEX)
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG-ZERO-INDEX-OFF
(DEFN GETNTH-GETSEG-INDUCTION
(I N K)
(IF (OR (ZEROP I) (ZEROP K))
'0
(GETNTH-GETSEG-INDUCTION (SUB1 I)
(ADD1 N)
(SUB1 K)))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definitions of OR and
ZEROP inform us that the measure (COUNT I) decreases according to the
well-founded relation LESSP in each recursive call. Hence,
GETNTH-GETSEG-INDUCTION is accepted under the definitional principle. The
definition of GETNTH-GETSEG-INDUCTION can be justified in another way. Linear
arithmetic, the lemma COUNT-NUMBERP, and the definitions of OR and ZEROP
inform us that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each recursive call. From the definition we can conclude
that (NUMBERP (GETNTH-GETSEG-INDUCTION I N K)) is a theorem.
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG-INDUCTION
(PROVE-LEMMA GETNTH-GETSEG
(REWRITE)
(IMPLIES (LESSP I K)
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH (PLUS N I) L)))
((ENABLE GETSEG GETNTH GETNTH-GETSEG-ZERO-INDEX PLUS-0 PLUS-ADD1
PLUS-RIGHT-ID2)
(INDUCT (GETNTH-GETSEG-INDUCTION I N K))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to two new formulas:
Case 2. (IMPLIES (AND (OR (ZEROP I) (ZEROP K))
(LESSP I K))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH (PLUS N I) L))),
which simplifies, applying the lemmas GETNTH-GETSEG-ZERO-INDEX, PLUS-0, and
PLUS-RIGHT-ID2, and unfolding the definitions of ZEROP, OR, EQUAL, and LESSP,
to two new conjectures:
Case 2.2.
(IMPLIES (AND (EQUAL I 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N)))
(EQUAL (GETNTH N L) (GETNTH 0 L))),
which again simplifies, opening up the definitions of GETNTH and EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N)))
(EQUAL (GETNTH N L) (GETNTH 0 L))),
which again simplifies, expanding GETNTH and EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (LESSP (SUB1 I) (SUB1 K))
(EQUAL (GETNTH (SUB1 I)
(GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (PLUS (ADD1 N) (SUB1 I)) L)))
(LESSP I K))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH (PLUS N I) L))),
which simplifies, rewriting with SUB1-ADD1 and CDR-CONS, and unfolding the
functions PLUS, GETNTH, IMPLIES, LESSP, GETSEG, and EQUAL, to the following
two new goals:
Case 1.2.
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP L)
(NUMBERP N)
(EQUAL (GETNTH (SUB1 I)
(GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (PLUS N (SUB1 I)) (CDR L)))
(LESSP (SUB1 I) (SUB1 K)))
(EQUAL (GETNTH (PLUS N (SUB1 I)) (CDR L))
(GETNTH (PLUS N I) L))).
Appealing to the lemma SUB1-ELIM, we now replace I by (ADD1 X) to
eliminate (SUB1 I). We employ the type restriction lemma noted when SUB1
was introduced to constrain the new variable. The result is:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP L)
(NUMBERP N)
(EQUAL (GETNTH X
(GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (PLUS N X) (CDR L)))
(LESSP X (SUB1 K)))
(EQUAL (GETNTH (PLUS N X) (CDR L))
(GETNTH (PLUS N (ADD1 X)) L))).
However this further simplifies, appealing to the lemmas PLUS-ADD1 and
SUB1-ADD1, and unfolding the definition of GETNTH, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP L)
(NOT (NUMBERP N))
(EQUAL (GETNTH (SUB1 I)
(GETSEG (ADD1 N) (SUB1 K) L))
(GETNTH (PLUS 0 (SUB1 I)) (CDR L)))
(LESSP (SUB1 I) (SUB1 K)))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH I L))),
which again simplifies, rewriting with SUB1-TYPE-RESTRICTION, and
unfolding the functions EQUAL and PLUS, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP L)
(NOT (NUMBERP N))
(EQUAL (GETNTH (SUB1 I)
(GETSEG 1 (SUB1 K) L))
(GETNTH (SUB1 I) (CDR L)))
(LESSP (SUB1 I) (SUB1 K)))
(EQUAL (GETNTH I (GETSEG N K L))
(GETNTH I L))),
which again simplifies, applying SUB1-TYPE-RESTRICTION and CDR-CONS, and
expanding GETNTH and GETSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG
(DISABLE GETNTH-GETSEG)
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG-OFF
(PROVE-LEMMA GETNTH-GETSEG-INVERSE
(REWRITE)
(IMPLIES (LESSP I K)
(EQUAL (GETNTH (PLUS N I) L)
(GETNTH I (GETSEG N K L))))
((ENABLE GETNTH-GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
WARNING: Note that GETNTH-GETSEG-INVERSE contains the free variable K which
will be chosen by instantiating the hypothesis (LESSP I K).
This conjecture simplifies, rewriting with GETNTH-GETSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG-INVERSE
(DISABLE GETNTH-GETSEG-INVERSE)
[ 0.0 0.0 0.0 ]
GETNTH-GETSEG-INVERSE-OFF
(PROVE-LEMMA GETNTH-AFTER-PUTSEG
(REWRITE)
(IMPLIES (IF (LESSP I (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L)))
((ENABLE PUTSEG GETNTH GETNTH-PUTNTH-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Let us appeal to the induction principle. Seven inductions are suggested
by terms in the conjecture. They merge into three likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP S)
(p I (CDR S) (ADD1 N) L))
(p I S N L))
(IMPLIES (NOT (LISTP S))
(p I S N L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces three new goals:
Case 3. (IMPLIES (AND (LISTP S)
(LESSP I
(PLUS (ADD1 N) (LENGTH (CDR S))))
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))),
which simplifies, rewriting with SUB1-ADD1 and GETNTH-PUTNTH-CASESPLIT, and
opening up the definitions of PLUS, LESSP, LENGTH, EQUAL, PUTSEG, GETNTH,
and NUMBERP, to the following 27 new conjectures:
Case 3.27.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
0)).
This again simplifies, using linear arithmetic, to:
T.
Case 3.26.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.25.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(NOT (NUMBERP N)))
(EQUAL (CAR S) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.24.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(EQUAL 0 N))
(EQUAL (CAR S) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.23.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.22.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.21.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (CAR L))),
which again simplifies, trivially, to:
T.
Case 3.20.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NUMBERP N)
(NOT (EQUAL 0 N))
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (CAR L))).
This again simplifies, obviously, to:
T.
Case 3.19.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(NOT (NUMBERP N)))
(EQUAL (CAR S) (CAR L))).
However this again simplifies, using linear arithmetic, to:
T.
Case 3.18.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(EQUAL 0 N))
(EQUAL (CAR S) (CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.17.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.16.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.15.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(NOT (NUMBERP N)))
(EQUAL (CAR S) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.14.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(NOT (LISTP L))
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(EQUAL 0 N))
(EQUAL (CAR S) 0)),
which again simplifies, using linear arithmetic, to:
T.
Case 3.13.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.12.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.11.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0)
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (CAR L))),
which again simplifies, trivially, to:
T.
Case 3.10.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NUMBERP N)
(NOT (EQUAL 0 N))
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (CAR L))).
This again simplifies, obviously, to:
T.
Case 3.9.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(NOT (NUMBERP N)))
(EQUAL (CAR S) (CAR L))).
However this again simplifies, using linear arithmetic, to:
T.
Case 3.8.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP I))
(EQUAL (PLUS N (ADD1 (LENGTH (CDR S))))
0)
(LISTP L)
(NOT (EQUAL (LENGTH (PUTSEG (CDR S) (ADD1 N) L))
0))
(EQUAL 0 N))
(EQUAL (CAR S) (CAR L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.7.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(LESSP (SUB1 I)
(PLUS 0 (LENGTH (CDR S))))
(NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LESSP (SUB1 I) (LENGTH (CDR S)))))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.6.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.5.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(NOT (LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.4.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NUMBERP I)
(EQUAL I N))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.3.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 3.1.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I)
(PLUS N (LENGTH (CDR S))))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N))
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))),
which simplifies, rewriting with GETNTH-PUTNTH-CASESPLIT, and unfolding
LENGTH, PUTSEG, and GETNTH, to the following six new goals:
Case 2.6.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S) (GETNTH I L))).
But this again simplifies, opening up GETNTH, EQUAL, PLUS, and LESSP, to:
T.
Case 2.5.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NOT (NUMBERP N)))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, unfolding GETNTH, PLUS, and LESSP, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NUMBERP I)
(NUMBERP N)
(EQUAL I N))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NUMBERP N)
(NOT (EQUAL 0 N))
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (GETNTH I L))),
which again simplifies, expanding the functions GETNTH, LESSP, LENGTH, and
EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(NOT (LESSP I
(PLUS N (ADD1 (LENGTH (CDR S))))))
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, unfolding the definitions of GETNTH, LESSP, and
EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))),
which simplifies, opening up LENGTH and PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-AFTER-PUTSEG
(DISABLE GETNTH-AFTER-PUTSEG)
[ 0.0 0.0 0.0 ]
GETNTH-AFTER-PUTSEG-OFF
(PROVE-LEMMA GETNTH-BEFORE-PUTSEG
(REWRITE)
(IMPLIES (LESSP I N)
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L)))
((ENABLE PUTSEG GETNTH GETNTH-PUTNTH-CASESPLIT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. Six inductions are suggested by
terms in the conjecture. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP S)
(p I (CDR S) (ADD1 N) L))
(p I S N L))
(IMPLIES (NOT (LISTP S))
(p I S N L))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme leads to the following three new conjectures:
Case 3. (IMPLIES (AND (LISTP S)
(NOT (LESSP I (ADD1 N)))
(LESSP I N))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))).
This simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))).
This simplifies, applying the lemma GETNTH-PUTNTH-CASESPLIT, and unfolding
the definitions of PUTSEG and GETNTH, to the following six new goals:
Case 2.6.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S) (GETNTH I L))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.5.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NOT (NUMBERP N)))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, opening up the definitions of GETNTH and LESSP, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, unfolding the definitions of EQUAL, GETNTH, and
LESSP, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NUMBERP I)
(NUMBERP N)
(EQUAL I N))
(EQUAL (CAR S) (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NUMBERP N)
(NOT (EQUAL 0 N))
(NOT (LISTP (PUTSEG (CDR S) (ADD1 N) L))))
(EQUAL 0 (GETNTH I L))),
which again simplifies, opening up GETNTH, LESSP, and EQUAL, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP S)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))
(LESSP I N)
(LESSP I
(LENGTH (PUTSEG (CDR S) (ADD1 N) L)))
(NOT (NUMBERP I))
(NUMBERP N)
(NOT (EQUAL 0 N))
(LISTP (PUTSEG (CDR S) (ADD1 N) L)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH I L))),
which again simplifies, unfolding the definitions of GETNTH, LESSP, and
EQUAL, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S)) (LESSP I N))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))),
which simplifies, expanding PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETNTH-BEFORE-PUTSEG
(DISABLE GETNTH-BEFORE-PUTSEG)
[ 0.0 0.0 0.0 ]
GETNTH-BEFORE-PUTSEG-OFF
(PROVE-LEMMA GETNTH-PUTSEG-COINCIDENCE
(REWRITE)
(IMPLIES (AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(AND (LESSP (DIFFERENCE I N) (LENGTH S))
(LESSP I (LENGTH L))))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH (DIFFERENCE I N) S)))
((ENABLE PUTSEG GETNTH LENGTH CAR-PUTSEG-ZERO DIFFERENCE-X-X
DIFFERENCE-SUB1-ARG1 GETNTH-PUTNTH-CASESPLIT
LENGTH-PUTSEG LISTP-PUTSEG NON-ZERO-LENGTH-IMPLIES-LISTP)
(INDUCT (PUTSEG S N L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations IMPLIES, NOT, OR, and
AND, to the following two new goals:
Case 2. (IMPLIES (AND (LISTP S)
(IMPLIES (AND (IF (LESSP I (ADD1 N)) F T)
(LESSP (DIFFERENCE I (ADD1 N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I (ADD1 N))
(CDR S))))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S))
(LESSP I (LENGTH L)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH (DIFFERENCE I N) S))).
This simplifies, using linear arithmetic, rewriting with SUB1-ADD1,
CAR-PUTSEG-ZERO, LISTP-PUTSEG, NON-ZERO-LENGTH-IMPLIES-LISTP, LENGTH-PUTSEG,
and GETNTH-PUTNTH-CASESPLIT, and opening up the functions LESSP, DIFFERENCE,
AND, IMPLIES, LENGTH, EQUAL, ZEROP, GETNTH, and PUTSEG, to 27 new goals:
Case 2.27.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(LESSP (SUB1 I) 0)
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.26.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(LESSP (SUB1 I) 0)
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(EQUAL I 0))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, expanding the functions SUB1 and LESSP, to:
T.
Case 2.25.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(LESSP (SUB1 I) 0)
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, applying SUB1-NNUMBERP, and opening up LESSP, to:
T.
Case 2.24.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))).
This again simplifies, rewriting with SUB1-NNUMBERP, and opening up EQUAL
and LESSP, to:
T.
Case 2.23.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))).
This again simplifies, using linear arithmetic, to:
T.
Case 2.22.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, rewriting with SUB1-NNUMBERP, and expanding
NUMBERP and LESSP, to:
T.
Case 2.21.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(EQUAL I N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))).
But this again simplifies, rewriting with the lemma DIFFERENCE-X-X, and
unfolding the definitions of SUB1, EQUAL, LESSP, and GETNTH, to:
T.
Case 2.20.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, appealing to the lemma SUB1-NNUMBERP, and
unfolding the functions EQUAL and LESSP, to:
T.
Case 2.19.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(LESSP (SUB1 I) N)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.18.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I S))),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP (SUB1 I) 0)
(LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I S))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.17.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(EQUAL I 0))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, expanding the definitions of SUB1, DIFFERENCE,
EQUAL, and LESSP, to:
T.
Case 2.16.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, using linear arithmetic, to two new goals:
Case 2.16.2.
(IMPLIES (AND (LESSP (SUB1 I) 0)
(LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, rewriting with SUB1-NNUMBERP, and expanding
LESSP, to:
T.
Case 2.16.1.
(IMPLIES (AND (LESSP I 1)
(LISTP S)
(NOT (NUMBERP N))
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))).
But this again simplifies, rewriting with SUB1-NNUMBERP, and expanding
the definitions of NUMBERP, EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 2.15.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))).
However this again simplifies, using linear arithmetic, to two new
formulas:
Case 2.15.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))),
which again simplifies, rewriting with the lemma SUB1-NNUMBERP, and
opening up the definitions of EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 2.15.1.
(IMPLIES (AND (LESSP I 1)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.14.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))),
which again simplifies, using linear arithmetic, to two new goals:
Case 2.14.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.14.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.13.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to two new conjectures:
Case 2.13.2.
(IMPLIES (AND (LESSP (SUB1 I) 0)
(LISTP S)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(NOT (LESSP I 0))
(LESSP (SUB1 (DIFFERENCE I 0))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I 0) S))),
which again simplifies, rewriting with SUB1-NNUMBERP, and unfolding the
definition of LESSP, to:
T.
Case 2.13.1.
(IMPLIES (AND (LESSP I 1)
(LISTP S)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 I) 0)
(LENGTH (CDR S))))
(NOT (LESSP I 0))
(LESSP (SUB1 (DIFFERENCE I 0))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I 0) S))).
However this again simplifies, rewriting with SUB1-NNUMBERP, and
expanding the functions NUMBERP, EQUAL, LESSP, DIFFERENCE, and SUB1, to:
T.
Case 2.12.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(EQUAL I N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))).
But this again simplifies, using linear arithmetic, to two new conjectures:
Case 2.12.2.
(IMPLIES (AND (LESSP (SUB1 N) N)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 N) N)
(LENGTH (CDR S))))
(NOT (LESSP N N))
(LESSP (SUB1 (DIFFERENCE N N))
(LENGTH (CDR S)))
(LESSP N (LENGTH L))
(NUMBERP N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE N N) S))),
which again simplifies, rewriting with DIFFERENCE-X-X, and expanding
SUB1, EQUAL, LESSP, and GETNTH, to:
T.
Case 2.12.1.
(IMPLIES (AND (EQUAL N 0)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 N) N)
(LENGTH (CDR S))))
(NOT (LESSP N N))
(LESSP (SUB1 (DIFFERENCE N N))
(LENGTH (CDR S)))
(LESSP N (LENGTH L))
(NUMBERP N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE N N) S))).
However this again simplifies, unfolding the functions NUMBERP, SUB1,
DIFFERENCE, EQUAL, and LESSP, to:
T.
Case 2.11.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to two new goals:
Case 2.11.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, rewriting with the lemma SUB1-NNUMBERP, and
unfolding the definitions of EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 2.11.1.
(IMPLIES (AND (LESSP I 1)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.10.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to two new goals:
Case 2.10.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.10.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP S)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.9.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) 0)
(CDR S)))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I S))),
which again simplifies, using linear arithmetic, applying
SUB1-TYPE-RESTRICTION and DIFFERENCE-SUB1-ARG1, and expanding the
definitions of EQUAL and DIFFERENCE, to:
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(EQUAL (GETNTH I (PUTSEG (CDR S) 1 L))
(GETNTH (SUB1 I) (CDR S)))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I S))),
which again simplifies, applying the lemmas SUB1-TYPE-RESTRICTION,
LENGTH-PUTSEG, and GETNTH-PUTNTH-CASESPLIT, and opening up the definitions
of PUTSEG and GETNTH, to:
T.
Case 2.8.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) 0)
(CDR S)))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(EQUAL I 0))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, using linear arithmetic, rewriting with the lemmas
SUB1-TYPE-RESTRICTION, LISTP-PUTSEG, NON-ZERO-LENGTH-IMPLIES-LISTP, and
CAR-PUTSEG-ZERO, and expanding the definitions of EQUAL, GETNTH, SUB1,
DIFFERENCE, LENGTH, LESSP, and ZEROP, to:
T.
Case 2.7.
(IMPLIES (AND (LISTP S)
(NOT (NUMBERP N))
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) 0)
(CDR S)))
(LESSP (SUB1 I) (LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH 0 S))),
which again simplifies, using linear arithmetic, rewriting with
SUB1-TYPE-RESTRICTION, LISTP-PUTSEG, NON-ZERO-LENGTH-IMPLIES-LISTP,
SUB1-NNUMBERP, and CAR-PUTSEG-ZERO, and opening up the functions GETNTH,
DIFFERENCE, EQUAL, LENGTH, LESSP, and ZEROP, to:
T.
Case 2.6.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(CAR S))).
However this again simplifies, using linear arithmetic, rewriting with
LISTP-PUTSEG, NON-ZERO-LENGTH-IMPLIES-LISTP, and SUB1-NNUMBERP, and
opening up the definitions of GETNTH, EQUAL, DIFFERENCE, and LESSP, to:
T.
Case 2.5.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S))
(CAR S))).
But this again simplifies, using linear arithmetic, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, using linear arithmetic, applying LISTP-PUTSEG,
NON-ZERO-LENGTH-IMPLIES-LISTP, and SUB1-NNUMBERP, and expanding NUMBERP,
GETNTH, DIFFERENCE, EQUAL, LESSP, SUB1, and LENGTH, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(EQUAL I N))
(EQUAL (CAR S)
(GETNTH (DIFFERENCE I N) S))).
But this again simplifies, rewriting with DIFFERENCE-X-X, and opening up
the definitions of SUB1, EQUAL, LESSP, and GETNTH, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (EQUAL 0 N)))
(EQUAL (CAR (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE I N) S))).
This again simplifies, using linear arithmetic, applying LISTP-PUTSEG,
NON-ZERO-LENGTH-IMPLIES-LISTP, and SUB1-NNUMBERP, and unfolding the
functions GETNTH, EQUAL, DIFFERENCE, and LESSP, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH (DIFFERENCE (SUB1 I) N)
(CDR S))
(GETNTH (DIFFERENCE I N) S))).
This again simplifies, using linear arithmetic and rewriting with
DIFFERENCE-SUB1-ARG1, to:
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (SUB1 (DIFFERENCE I N))
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N)))
(EQUAL (GETNTH (SUB1 (DIFFERENCE I N))
(CDR S))
(GETNTH (DIFFERENCE I N) S))),
which again simplifies, opening up GETNTH, to:
(IMPLIES (AND (LISTP S)
(NUMBERP N)
(EQUAL (GETNTH I (PUTSEG (CDR S) (ADD1 N) L))
(GETNTH (SUB1 (DIFFERENCE I N))
(CDR S)))
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NOT (EQUAL I N))
(EQUAL (DIFFERENCE I N) 0))
(EQUAL (GETNTH (SUB1 (DIFFERENCE I N))
(CDR S))
(CAR S))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S))
(LESSP I (LENGTH L)))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH (DIFFERENCE I N) S))),
which simplifies, using linear arithmetic and applying
NON-ZERO-LENGTH-IMPLIES-LISTP, to:
T.
Q.E.D.
[ 0.0 0.2 0.0 ]
GETNTH-PUTSEG-COINCIDENCE
(DISABLE GETNTH-PUTSEG-COINCIDENCE)
[ 0.0 0.0 0.0 ]
GETNTH-PUTSEG-COINCIDENCE-OFF
(PROVE-LEMMA OPEN-PUTNTH-CASESPLIT
(REWRITE)
(EQUAL (PUTNTH V N (CONS A B))
(IF (ZEROP N)
(CONS V B)
(CONS A (PUTNTH V (SUB1 N) B))))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, rewriting with CAR-CONS and CDR-CONS, and opening up
the definitions of PUTNTH and ZEROP, to:
T.
Q.E.D.
[ 0.0 0.0 0.1 ]
OPEN-PUTNTH-CASESPLIT
(DISABLE OPEN-PUTNTH-CASESPLIT)
[ 0.0 0.0 0.0 ]
OPEN-PUTNTH-CASESPLIT-OFF
(PROVE-LEMMA OPEN-UP-PUTNTH1
(REWRITE)
(IMPLIES (NOT (ZEROP N))
(EQUAL (PUTNTH V N (CONS A B))
(CONS A (PUTNTH V (SUB1 N) B))))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0)) (NUMBERP N))
(EQUAL (PUTNTH V N (CONS A B))
(CONS A (PUTNTH V (SUB1 N) B)))).
This simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS, and
expanding the function PUTNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTNTH1
(DISABLE OPEN-UP-PUTNTH1)
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTNTH1-OFF
(PROVE-LEMMA PUTNTH-INTO-NIL
(REWRITE)
(EQUAL (PUTNTH V I 'NIL) 'NIL)
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, opening up the functions LISTP, PUTNTH, and EQUAL,
to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-INTO-NIL
(DISABLE PUTNTH-INTO-NIL)
[ 0.0 0.0 0.0 ]
PUTNTH-INTO-NIL-OFF
(PROVE-LEMMA OPEN-UP-PUTNTH-ON-ZERO
(REWRITE)
(EQUAL (PUTNTH VAL '0 (CONS A B))
(CONS VAL B))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, rewriting with CDR-CONS, and expanding EQUAL and PUTNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTNTH-ON-ZERO
(DISABLE OPEN-UP-PUTNTH-ON-ZERO)
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTNTH-ON-ZERO-OFF
(PROVE-LEMMA PUTNTH-WITH-NON-NUMBER-INDEX
(REWRITE)
(IMPLIES (NOT (NUMBERP I))
(EQUAL (PUTNTH V I L)
(PUTNTH V '0 L)))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, expanding PUTNTH and EQUAL, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-WITH-NON-NUMBER-INDEX
(DISABLE PUTNTH-WITH-NON-NUMBER-INDEX)
[ 0.0 0.0 0.0 ]
PUTNTH-WITH-NON-NUMBER-INDEX-OFF
(PROVE-LEMMA PUTNTH-HAS-NO-EFFECT
(REWRITE)
(IMPLIES (NOT (LESSP N (LENGTH L)))
(EQUAL (PUTNTH V N L) L))
((ENABLE PUTNTH LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. There are four plausible inductions.
However, they merge into one likely candidate induction. We will induct
according to the following scheme:
(AND (IMPLIES (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L))))
(p V N L))
(IMPLIES (AND (NOT (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L)))))
(OR (EQUAL N 0) (NOT (NUMBERP N))))
(p V N L))
(IMPLIES (AND (NOT (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L)))))
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(p V (SUB1 N) (CDR L)))
(p V N L))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT establish that the measure (COUNT N) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for L. The above induction scheme
produces the following four new formulas:
Case 4. (IMPLIES (AND (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L))))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTNTH V N L) L)).
This simplifies, opening up LENGTH, NOT, OR, EQUAL, LESSP, and PUTNTH, to
the following three new formulas:
Case 4.3.
(IMPLIES (AND (EQUAL (ADD1 (LENGTH (CDR L))) 0)
(LISTP L)
(NOT (NUMBERP N)))
(EQUAL (CONS V (CDR L)) L)).
This again simplifies, using linear arithmetic, to:
T.
Case 4.2.
(IMPLIES (AND (EQUAL (ADD1 (LENGTH (CDR L))) 0)
(LISTP L)
(EQUAL N 0))
(EQUAL (CONS V (CDR L)) L)),
which again simplifies, using linear arithmetic, to:
T.
Case 4.1.
(IMPLIES (AND (EQUAL (ADD1 (LENGTH (CDR L))) 0)
(LISTP L)
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (CONS (CAR L)
(PUTNTH V (SUB1 N) (CDR L)))
L)),
which again simplifies, using linear arithmetic, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L)))))
(OR (EQUAL N 0) (NOT (NUMBERP N)))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTNTH V N L) L)),
which simplifies, expanding LENGTH, NOT, OR, EQUAL, and LESSP, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L)))))
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(LESSP (SUB1 N) (LENGTH (CDR L)))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTNTH V N L) L)),
which simplifies, applying SUB1-ADD1, and opening up LENGTH, NOT, OR, and
LESSP, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL (LENGTH L) 0)
(NOT (NUMBERP (LENGTH L)))))
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(EQUAL (PUTNTH V (SUB1 N) (CDR L))
(CDR L))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTNTH V N L) L)).
This simplifies, appealing to the lemmas SUB1-ADD1 and CONS-CAR-CDR, and
unfolding the functions LENGTH, NOT, OR, LESSP, and PUTNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-HAS-NO-EFFECT
(DISABLE PUTNTH-HAS-NO-EFFECT)
[ 0.0 0.0 0.0 ]
PUTNTH-HAS-NO-EFFECT-OFF
(PROVE-LEMMA PUTNTH-CONS1
(REWRITE)
(IMPLIES (ZEROP N)
(EQUAL (PUTNTH V N (CONS A B))
(CONS V B)))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, appealing to the lemma CDR-CONS, and opening up the
definitions of ZEROP, EQUAL, and PUTNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-CONS1
(DISABLE PUTNTH-CONS1)
[ 0.0 0.0 0.0 ]
PUTNTH-CONS1-OFF
(PROVE-LEMMA PUTNTH-CONS2
(REWRITE)
(IMPLIES (NOT (ZEROP N))
(EQUAL (PUTNTH V N (CONS A B))
(CONS A (PUTNTH V (SUB1 N) B))))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0)) (NUMBERP N))
(EQUAL (PUTNTH V N (CONS A B))
(CONS A (PUTNTH V (SUB1 N) B)))).
This simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS, and
expanding the function PUTNTH, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-CONS2
(DISABLE PUTNTH-CONS2)
[ 0.0 0.0 0.0 ]
PUTNTH-CONS2-OFF
(PROVE-LEMMA PUTNTH-SHIFT
(REWRITE)
(IMPLIES (LESSP I (LENGTH L))
(EQUAL (PUTNTH V I L)
(APPEND (FIRSTN I L)
(CONS V (NTHCDR (ADD1 I) L)))))
((ENABLE PUTNTH APPEND FIRSTN NTHCDR LENGTH)
(INDUCT (NUMBER-AND-LIST-INDUCTION I L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new conjectures:
Case 3. (IMPLIES (AND (ZEROP I) (LESSP I (LENGTH L)))
(EQUAL (PUTNTH V I L)
(APPEND (FIRSTN I L)
(CONS V (NTHCDR (ADD1 I) L))))),
which simplifies, applying SUB1-TYPE-RESTRICTION, and expanding the
definitions of ZEROP, EQUAL, LESSP, PUTNTH, FIRSTN, ADD1, LISTP, and APPEND,
to the following four new conjectures:
Case 3.4.
(IMPLIES (AND (EQUAL I 0)
(NOT (EQUAL (LENGTH L) 0))
(NOT (LISTP L)))
(EQUAL L (CONS V (NTHCDR 1 L)))).
However this again simplifies, opening up the definitions of LENGTH and
EQUAL, to:
T.
Case 3.3.
(IMPLIES (AND (EQUAL I 0)
(NOT (EQUAL (LENGTH L) 0))
(LISTP L))
(EQUAL (CONS V (CDR L))
(CONS V (NTHCDR 1 L)))),
which again simplifies, applying CAR-CONS, CDR-CONS, and CONS-EQUAL, to:
(IMPLIES (AND (NOT (EQUAL (LENGTH L) 0))
(LISTP L))
(EQUAL (CDR L) (NTHCDR 1 L))).
Applying the lemma CAR-CDR-ELIM, replace L by (CONS Z X) to eliminate
(CDR L) and (CAR L). We thus obtain:
(IMPLIES (NOT (EQUAL (LENGTH (CONS Z X)) 0))
(EQUAL X (NTHCDR 1 (CONS Z X)))),
which further simplifies, rewriting with CDR-CONS, and expanding the
functions LENGTH, SUB1, NUMBERP, EQUAL, and NTHCDR, to:
T.
Case 3.2.
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LISTP L)))
(EQUAL L (CONS V (NTHCDR 1 L)))).
This again simplifies, opening up the definitions of LENGTH and EQUAL, to:
T.
Case 3.1.
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0))
(LISTP L))
(EQUAL (CONS V (CDR L))
(CONS V (NTHCDR 1 L)))),
which again simplifies, rewriting with the lemmas CAR-CONS, CDR-CONS, and
CONS-EQUAL, to:
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0))
(LISTP L))
(EQUAL (CDR L) (NTHCDR 1 L))).
Appealing to the lemma CAR-CDR-ELIM, we now replace L by (CONS Z X) to
eliminate (CDR L) and (CAR L). The result is:
(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL (LENGTH (CONS Z X)) 0)))
(EQUAL X (NTHCDR 1 (CONS Z X)))).
However this further simplifies, appealing to the lemma CDR-CONS, and
expanding the functions LENGTH, SUB1, NUMBERP, EQUAL, and NTHCDR, to:
T.
Case 2. (IMPLIES
(AND
(NOT (EQUAL I 0))
(NUMBERP I)
(LISTP L)
(IMPLIES (LESSP (SUB1 I) (LENGTH (CDR L)))
(EQUAL (PUTNTH V (SUB1 I) (CDR L))
(APPEND (FIRSTN (SUB1 I) (CDR L))
(CONS V
(NTHCDR (ADD1 (SUB1 I)) (CDR L))))))
(LESSP I (LENGTH L)))
(EQUAL (PUTNTH V I L)
(APPEND (FIRSTN I L)
(CONS V (NTHCDR (ADD1 I) L))))),
which simplifies, rewriting with ADD1-SUB1, SUB1-ADD1, CDR-CONS, and
CAR-CONS, and unfolding the definitions of IMPLIES, LENGTH, LESSP, PUTNTH,
FIRSTN, NTHCDR, and APPEND, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL I 0))
(NUMBERP I)
(NOT (LISTP L))
(LESSP I (LENGTH L)))
(EQUAL (PUTNTH V I L)
(APPEND (FIRSTN I L)
(CONS V (NTHCDR (ADD1 I) L))))).
This simplifies, unfolding the definitions of LENGTH, EQUAL, and LESSP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-SHIFT
(DISABLE PUTNTH-SHIFT)
[ 0.0 0.0 0.0 ]
PUTNTH-SHIFT-OFF
(PROVE-LEMMA PUTNTH-APPEND-CASESPLIT
(REWRITE)
(EQUAL (PUTNTH V N (APPEND A B))
(IF (LESSP N (LENGTH A))
(APPEND (PUTNTH V N A) B)
(APPEND A
(PUTNTH V
(DIFFERENCE N (LENGTH A))
B))))
((ENABLE PUTNTH APPEND LENGTH)
(INDUCT (PUTNTH V N A))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, OR, and
AND, to three new conjectures:
Case 3. (IMPLIES (AND (LISTP A) (ZEROP N))
(EQUAL (PUTNTH V N (APPEND A B))
(IF (LESSP N (LENGTH A))
(APPEND (PUTNTH V N A) B)
(APPEND A
(PUTNTH V
(DIFFERENCE N (LENGTH A))
B))))),
which simplifies, rewriting with the lemmas CDR-CONS and CAR-CONS, and
opening up ZEROP, EQUAL, PUTNTH, LESSP, DIFFERENCE, and APPEND, to ten new
formulas:
Case 3.10.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(NOT (EQUAL (LENGTH A) 0))
(NOT (LISTP (APPEND A B))))
(EQUAL (APPEND A B)
(CONS V (APPEND (CDR A) B)))),
which again simplifies, opening up the definition of APPEND, to:
T.
Case 3.9.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(NOT (EQUAL (LENGTH A) 0))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(CONS V (APPEND (CDR A) B)))),
which again simplifies, rewriting with the lemma CDR-CONS, and expanding
APPEND, to:
T.
Case 3.8.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(LISTP B)
(NOT (LISTP (APPEND A B))))
(EQUAL (APPEND A B)
(APPEND A (CONS V (CDR B))))),
which again simplifies, clearly, to:
T.
Case 3.7.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(LISTP B)
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A (CONS V (CDR B))))).
This again simplifies, applying CAR-CONS, to the new conjecture:
(IMPLIES (AND (LISTP A)
(EQUAL (LENGTH A) 0)
(LISTP B))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A (CONS V (CDR B))))).
Applying the lemma CAR-CDR-ELIM, replace B by (CONS Z X) to eliminate
(CDR B) and (CAR B). We would thus like to prove:
(IMPLIES (AND (LISTP A) (EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))),
which we will name *1.
Case 3.6.
(IMPLIES (AND (LISTP A)
(EQUAL N 0)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
But this again simplifies, applying the lemma CAR-CONS, to:
(IMPLIES (AND (LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
Call the above conjecture *2.
Case 3.5.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH A) 0))
(NOT (LISTP (APPEND A B))))
(EQUAL (APPEND A B)
(CONS V (APPEND (CDR A) B)))).
However this again simplifies, expanding the function APPEND, to:
T.
Case 3.4.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH A) 0))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(CONS V (APPEND (CDR A) B)))),
which again simplifies, rewriting with CDR-CONS, and opening up APPEND, to:
T.
Case 3.3.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B)
(NOT (LISTP (APPEND A B))))
(EQUAL (APPEND A B)
(APPEND A (CONS V (CDR B))))).
This again simplifies, clearly, to:
T.
Case 3.2.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B)
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A (CONS V (CDR B))))).
But this again simplifies, applying CAR-CONS, to:
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(LISTP B))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A (CONS V (CDR B))))).
Applying the lemma CAR-CDR-ELIM, replace B by (CONS Z X) to eliminate
(CDR B) and (CAR B). We would thus like to prove:
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))),
which we will name *3.
Case 3.1.
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
Name the above subgoal *4.
Case 2. (IMPLIES
(AND (LISTP A)
(NOT (EQUAL N 0))
(NUMBERP N)
(EQUAL (PUTNTH V (SUB1 N) (APPEND (CDR A) B))
(IF (LESSP (SUB1 N) (LENGTH (CDR A)))
(APPEND (PUTNTH V (SUB1 N) (CDR A)) B)
(APPEND (CDR A)
(PUTNTH V
(DIFFERENCE (SUB1 N) (LENGTH (CDR A)))
B)))))
(EQUAL (PUTNTH V N (APPEND A B))
(IF (LESSP N (LENGTH A))
(APPEND (PUTNTH V N A) B)
(APPEND A
(PUTNTH V
(DIFFERENCE N (LENGTH A))
B))))).
This simplifies, rewriting with CDR-CONS, CAR-CONS, and SUB1-ADD1, and
opening up APPEND, PUTNTH, LENGTH, LESSP, and DIFFERENCE, to:
T.
Case 1. (IMPLIES (NOT (LISTP A))
(EQUAL (PUTNTH V N (APPEND A B))
(IF (LESSP N (LENGTH A))
(APPEND (PUTNTH V N A) B)
(APPEND A
(PUTNTH V
(DIFFERENCE N (LENGTH A))
B))))),
which simplifies, opening up the definitions of APPEND, LENGTH, EQUAL, LESSP,
and DIFFERENCE, to two new formulas:
Case 1.2.
(IMPLIES (AND (NOT (LISTP A))
(NOT (NUMBERP N)))
(EQUAL (PUTNTH V N B)
(PUTNTH V 0 B))),
which again simplifies, opening up the definitions of PUTNTH and EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (LISTP A)) (EQUAL N 0))
(EQUAL (PUTNTH V N B)
(PUTNTH V 0 B))),
which again simplifies, clearly, to:
T.
So we now return to:
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))),
named *4 above. What luck! This conjecture is subsumed by formula *2 above.
So next consider:
(IMPLIES (AND (LISTP A)
(NOT (NUMBERP N))
(EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))),
named *3 above. Ah ha! This conjecture is subsumed by the subgoal we named
*1 above.
So let us turn our attention to:
(IMPLIES (AND (LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))),
which is formula *2 above. Perhaps we can prove it by induction. Four
inductions are suggested by terms in the conjecture. However, they merge into
one likely candidate induction. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP A) (p V (CDR A) B))
(p V A B))
(IMPLIES (NOT (LISTP A)) (p V A B))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme leads to the following four new
goals:
Case 4. (IMPLIES (AND (NOT (LISTP (CDR A)))
(LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
This simplifies, opening up the function LENGTH, to:
T.
Case 3. (IMPLIES (AND (NOT (EQUAL (LENGTH (CDR A)) 0))
(LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
This simplifies, unfolding the function LENGTH, to:
T.
Case 2. (IMPLIES (AND (NOT (LISTP (APPEND (CDR A) B)))
(LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
This simplifies, unfolding LENGTH, to:
T.
Case 1. (IMPLIES (AND (EQUAL (CONS V (CDR (APPEND (CDR A) B)))
(APPEND (CDR A) B))
(LISTP A)
(EQUAL (LENGTH A) 0)
(NOT (LISTP B))
(LISTP (APPEND A B)))
(EQUAL (CONS V (CDR (APPEND A B)))
(APPEND A B))).
This simplifies, opening up the function LENGTH, to:
T.
That finishes the proof of *2.
So we now return to:
(IMPLIES (AND (LISTP A) (EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))),
named *1 above. Perhaps we can prove it by induction. Three inductions are
suggested by terms in the conjecture. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP A) (p V (CDR A) Z X))
(p V A Z X))
(IMPLIES (NOT (LISTP A))
(p V A Z X))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT A)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. The above induction scheme produces the following three new
goals:
Case 3. (IMPLIES (AND (NOT (LISTP (CDR A)))
(LISTP A)
(EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))).
This simplifies, opening up the function LENGTH, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL (LENGTH (CDR A)) 0))
(LISTP A)
(EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))).
This simplifies, opening up the function LENGTH, to:
T.
Case 1. (IMPLIES (AND (EQUAL (CONS V
(CDR (APPEND (CDR A) (CONS Z X))))
(APPEND (CDR A) (CONS V X)))
(LISTP A)
(EQUAL (LENGTH A) 0))
(EQUAL (CONS V (CDR (APPEND A (CONS Z X))))
(APPEND A (CONS V X)))).
This simplifies, rewriting with CAR-CONS, and opening up LENGTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
PUTNTH-APPEND-CASESPLIT
(DISABLE PUTNTH-APPEND-CASESPLIT)
[ 0.0 0.0 0.0 ]
PUTNTH-APPEND-CASESPLIT-OFF
(PROVE-LEMMA PUTNTH-APPEND-RIGHT
(REWRITE)
(IMPLIES (IF (LESSP N (LENGTH A))
'*1*FALSE
'*1*TRUE)
(EQUAL (PUTNTH V N (APPEND A B))
(APPEND A
(PUTNTH V
(DIFFERENCE N (LENGTH A))
B))))
((ENABLE PUTNTH-APPEND-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, appealing to the lemma PUTNTH-APPEND-CASESPLIT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-APPEND-RIGHT
(DISABLE PUTNTH-APPEND-RIGHT)
[ 0.0 0.0 0.0 ]
PUTNTH-APPEND-RIGHT-OFF
(PROVE-LEMMA PUTNTH-APPEND-LEFT
(REWRITE)
(IMPLIES (LESSP N (LENGTH A))
(EQUAL (PUTNTH V N (APPEND A B))
(APPEND (PUTNTH V N A) B)))
((ENABLE PUTNTH-APPEND-CASESPLIT LENGTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, applying the lemma PUTNTH-APPEND-CASESPLIT, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-APPEND-LEFT
(DISABLE PUTNTH-APPEND-LEFT)
[ 0.0 0.0 0.0 ]
PUTNTH-APPEND-LEFT-OFF
(PROVE-LEMMA PUTNTH-GETNTH-COINCIDENCE
(REWRITE)
(EQUAL (PUTNTH (GETNTH I L) I L) L)
((ENABLE GETNTH PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will try to prove it by induction. The recursive terms in the
conjecture suggest four inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L) (ZEROP I))
(p I L))
(IMPLIES (AND (LISTP L)
(NOT (ZEROP I))
(p (SUB1 I) (CDR L)))
(p I L))
(IMPLIES (NOT (LISTP L)) (p I L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT I) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for L. The above induction scheme
generates the following three new formulas:
Case 3. (IMPLIES (AND (LISTP L) (ZEROP I))
(EQUAL (PUTNTH (GETNTH I L) I L) L)).
This simplifies, applying CONS-CAR-CDR, and expanding the functions ZEROP,
EQUAL, GETNTH, and PUTNTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L)
(NOT (ZEROP I))
(EQUAL (PUTNTH (GETNTH (SUB1 I) (CDR L))
(SUB1 I)
(CDR L))
(CDR L)))
(EQUAL (PUTNTH (GETNTH I L) I L) L)),
which simplifies, appealing to the lemma CONS-CAR-CDR, and unfolding the
functions ZEROP, GETNTH, and PUTNTH, to:
T.
Case 1. (IMPLIES (NOT (LISTP L))
(EQUAL (PUTNTH (GETNTH I L) I L) L)),
which simplifies, unfolding the definitions of GETNTH and PUTNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-GETNTH-COINCIDENCE
(DISABLE PUTNTH-GETNTH-COINCIDENCE)
[ 0.0 0.0 0.0 ]
PUTNTH-GETNTH-COINCIDENCE-OFF
(PROVE-LEMMA PUTNTH-GETNTH-COINCIDENCE1
(REWRITE)
(IMPLIES (EQUAL (GETNTH I L1) (GETNTH I L2))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2))
((ENABLE PUTNTH GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
.
We now use the above equality hypothesis by substituting (GETNTH I L2) for
(GETNTH I L1) and keeping the equality hypothesis. We would thus like to
prove:
(IMPLIES (EQUAL (GETNTH I L1) (GETNTH I L2))
(EQUAL (PUTNTH (GETNTH I L2)
I
(PUTNTH V I L2))
L2)),
which simplifies, obviously, to:
(IMPLIES (EQUAL (GETNTH I L1) (GETNTH I L2))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(IMPLIES (EQUAL (GETNTH I L1) (GETNTH I L2))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)),
named *1. Let us appeal to the induction principle. Nine inductions are
suggested by terms in the conjecture. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP L1) (ZEROP I))
(p I L1 V L2))
(IMPLIES (AND (LISTP L1)
(NOT (ZEROP I))
(p (SUB1 I) (CDR L1) V (CDR L2)))
(p I L1 V L2))
(IMPLIES (NOT (LISTP L1))
(p I L1 V L2))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT I) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instances chosen for L2 and L1. The above induction scheme generates four new
conjectures:
Case 4. (IMPLIES (AND (LISTP L1)
(ZEROP I)
(EQUAL (GETNTH I L1) (GETNTH I L2)))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)),
which simplifies, rewriting with CDR-CONS and CAR-CONS, and unfolding ZEROP,
EQUAL, GETNTH, and PUTNTH, to:
T.
Case 3. (IMPLIES (AND (LISTP L1)
(NOT (ZEROP I))
(NOT (EQUAL (GETNTH (SUB1 I) (CDR L1))
(GETNTH (SUB1 I) (CDR L2))))
(EQUAL (GETNTH I L1) (GETNTH I L2)))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)).
This simplifies, unfolding the definitions of ZEROP, GETNTH, and PUTNTH, to:
T.
Case 2. (IMPLIES (AND (LISTP L1)
(NOT (ZEROP I))
(EQUAL (PUTNTH (GETNTH (SUB1 I) (CDR L1))
(SUB1 I)
(PUTNTH V (SUB1 I) (CDR L2)))
(CDR L2))
(EQUAL (GETNTH I L1) (GETNTH I L2)))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)).
This simplifies, applying CONS-CAR-CDR, CDR-CONS, and CAR-CONS, and opening
up ZEROP, GETNTH, and PUTNTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP L1))
(EQUAL (GETNTH I L1) (GETNTH I L2)))
(EQUAL (PUTNTH (GETNTH I L1)
I
(PUTNTH V I L2))
L2)),
which simplifies, opening up GETNTH, PUTNTH, and EQUAL, to four new
conjectures:
Case 1.4.
(IMPLIES (AND (NOT (LISTP L1))
(NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL 0 (GETNTH (SUB1 I) (CDR L2)))
(NOT (LISTP L2)))
(EQUAL (PUTNTH 0 I L2) L2)),
which again simplifies, expanding the definition of PUTNTH, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (LISTP L1))
(NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL 0 (GETNTH (SUB1 I) (CDR L2)))
(LISTP L2))
(EQUAL (PUTNTH 0 I
(CONS (CAR L2)
(PUTNTH V (SUB1 I) (CDR L2))))
L2)),
which again simplifies, rewriting with CDR-CONS and CAR-CONS, and
unfolding the definition of PUTNTH, to:
(IMPLIES (AND (NOT (LISTP L1))
(NOT (EQUAL I 0))
(NUMBERP I)
(EQUAL 0 (GETNTH (SUB1 I) (CDR L2)))
(LISTP L2))
(EQUAL (CONS (CAR L2)
(PUTNTH 0
(SUB1 I)
(PUTNTH V (SUB1 I) (CDR L2))))
L2)).
Applying the lemma SUB1-ELIM, replace I by (ADD1 X) to eliminate (SUB1 I).
We use the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. We thus obtain:
(IMPLIES (AND (NUMBERP X)
(NOT (LISTP L1))
(NOT (EQUAL (ADD1 X) 0))
(EQUAL 0 (GETNTH X (CDR L2)))
(LISTP L2))
(EQUAL (CONS (CAR L2)
(PUTNTH 0 X (PUTNTH V X (CDR L2))))
L2)),
which further simplifies, rewriting with CAR-CONS and CDR-CONS, to the new
formula:
(IMPLIES (AND (NUMBERP X)
(NOT (LISTP L1))
(EQUAL 0 (GETNTH X (CDR L2)))
(LISTP L2))
(EQUAL (CONS (CAR L2)
(PUTNTH 0 X (PUTNTH V X (CDR L2))))
L2)).
Applying the lemma CAR-CDR-ELIM, replace L2 by (CONS W Z) to eliminate
(CDR L2) and (CAR L2). This produces:
(IMPLIES (AND (NUMBERP X)
(NOT (LISTP L1))
(EQUAL 0 (GETNTH X Z)))
(EQUAL (CONS W (PUTNTH 0 X (PUTNTH V X Z)))
(CONS W Z))),
which further simplifies, rewriting with the lemmas CAR-CONS, CDR-CONS,
and CONS-EQUAL, to:
(IMPLIES (AND (NUMBERP X)
(NOT (LISTP L1))
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)).
Eliminate the irrelevant term. This produces the new goal:
(IMPLIES (AND (NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)),
which we will finally name *1.1.
Case 1.2.
(IMPLIES (AND (NOT (LISTP L1))
(EQUAL I 0)
(EQUAL 0 (CAR L2))
(LISTP L2))
(EQUAL (CONS 0 (CDR (CONS V (CDR L2))))
L2)).
But this again simplifies, applying CDR-CONS and CAR-CONS, and expanding
EQUAL, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (LISTP L1))
(NOT (NUMBERP I))
(EQUAL 0 (CAR L2))
(LISTP L2))
(EQUAL (CONS 0 (CDR (CONS V (CDR L2))))
L2)).
But this again simplifies, rewriting with CDR-CONS and CAR-CONS, and
opening up the definition of EQUAL, to:
T.
So we now return to:
(IMPLIES (AND (NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)),
which we named *1.1 above. Perhaps we can prove it by induction. Five
inductions are suggested by terms in the conjecture. However, they merge into
one likely candidate induction. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP Z) (ZEROP X))
(p X V Z))
(IMPLIES (AND (LISTP Z)
(NOT (ZEROP X))
(p (SUB1 X) V (CDR Z)))
(p X V Z))
(IMPLIES (NOT (LISTP Z)) (p X V Z))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to prove that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for Z. The above induction scheme
generates four new formulas:
Case 4. (IMPLIES (AND (LISTP Z)
(ZEROP X)
(NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)),
which simplifies, rewriting with CDR-CONS and CAR-CONS, and opening up the
functions ZEROP, NUMBERP, EQUAL, GETNTH, and PUTNTH, to:
T.
Case 3. (IMPLIES (AND (LISTP Z)
(NOT (ZEROP X))
(NOT (EQUAL 0 (GETNTH (SUB1 X) (CDR Z))))
(NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)).
This simplifies, unfolding ZEROP and GETNTH, to:
T.
Case 2. (IMPLIES (AND (LISTP Z)
(NOT (ZEROP X))
(EQUAL (PUTNTH 0
(SUB1 X)
(PUTNTH V (SUB1 X) (CDR Z)))
(CDR Z))
(NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)).
This simplifies, applying the lemmas CONS-CAR-CDR, CDR-CONS, and CAR-CONS,
and unfolding ZEROP, GETNTH, and PUTNTH, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP Z))
(NUMBERP X)
(EQUAL 0 (GETNTH X Z)))
(EQUAL (PUTNTH 0 X (PUTNTH V X Z))
Z)).
This simplifies, unfolding the definitions of GETNTH, EQUAL, and PUTNTH, to:
T.
That finishes the proof of *1.1, which, in turn, also finishes the proof
of *1. Q.E.D.
[ 0.0 0.0 0.1 ]
PUTNTH-GETNTH-COINCIDENCE1
(DISABLE PUTNTH-GETNTH-COINCIDENCE1)
[ 0.0 0.0 0.0 ]
PUTNTH-GETNTH-COINCIDENCE1-OFF
(PROVE-LEMMA PUTNTH-PUTNTH-CASESPLIT
(REWRITE)
(IMPLIES (AND (NUMBERP I)
(AND (NUMBERP J)
(IF (LESSP J I)
'*1*FALSE
'*1*TRUE)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L)))))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, obviously, to the following two new goals:
Case 2. (IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(NOT (LESSP J I))
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
Name the above subgoal *1.
Case 1. (IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(NOT (LESSP J I))
(EQUAL I J))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH B I L))).
This again simplifies, clearly, to:
(IMPLIES (AND (NUMBERP J) (NOT (LESSP J J)))
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))),
which we would normally push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we
have previously done, give the name *1 to the original input, and work on it.
So now let us return to:
(IMPLIES (AND (NUMBERP I)
(NUMBERP J)
(IF (LESSP J I) F T))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L))))),
named *1. Let us appeal to the induction principle. There are ten plausible
inductions. However, they merge into one likely candidate induction. We will
induct according to the following scheme:
(AND (IMPLIES (OR (EQUAL I 0) (NOT (NUMBERP I)))
(p B J A I L))
(IMPLIES (AND (NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(OR (EQUAL J 0) (NOT (NUMBERP J))))
(p B J A I L))
(IMPLIES (AND (NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (OR (EQUAL J 0) (NOT (NUMBERP J))))
(p B (SUB1 J) A (SUB1 I) (CDR L)))
(p B J A I L))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT inform us that the measure (COUNT J) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instances chosen for L and I. The above induction
scheme leads to four new formulas:
Case 4. (IMPLIES (AND (OR (EQUAL I 0) (NOT (NUMBERP I)))
(NUMBERP I)
(NUMBERP J)
(IF (LESSP J I) F T))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L))))),
which simplifies, opening up NOT, OR, NUMBERP, EQUAL, LESSP, and PUTNTH, to
three new formulas:
Case 4.3.
(IMPLIES (AND (EQUAL I 0)
(NUMBERP J)
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L) L)),
which again simplifies, opening up PUTNTH, to:
T.
Case 4.2.
(IMPLIES (AND (EQUAL I 0)
(NUMBERP J)
(NOT (EQUAL 0 J))
(LISTP L))
(EQUAL (PUTNTH B J (CONS A (CDR L)))
(CONS A
(CDR (CONS (CAR L)
(PUTNTH B (SUB1 J) (CDR L))))))),
which again simplifies, applying CDR-CONS and CAR-CONS, and expanding the
function PUTNTH, to:
T.
Case 4.1.
(IMPLIES (AND (EQUAL I 0)
(NUMBERP J)
(EQUAL 0 J)
(LISTP L))
(EQUAL (PUTNTH B J (CONS A (CDR L)))
(CONS B (CDR L)))).
But this again simplifies, rewriting with CDR-CONS, and opening up the
functions NUMBERP, EQUAL, and PUTNTH, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(OR (EQUAL J 0) (NOT (NUMBERP J)))
(NUMBERP I)
(NUMBERP J)
(IF (LESSP J I) F T))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L))))).
This simplifies, opening up the functions NOT, OR, NUMBERP, EQUAL, and LESSP,
to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (OR (EQUAL J 0) (NOT (NUMBERP J))))
(NOT (IF (LESSP (SUB1 J) (SUB1 I)) F T))
(NUMBERP I)
(NUMBERP J)
(IF (LESSP J I) F T))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L))))).
This simplifies, unfolding the functions NOT, OR, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (OR (EQUAL J 0) (NOT (NUMBERP J))))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(IF (EQUAL (SUB1 I) (SUB1 J))
(PUTNTH B (SUB1 J) (CDR L))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L)))))
(NUMBERP I)
(NUMBERP J)
(IF (LESSP J I) F T))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(IF (EQUAL I J)
(PUTNTH B J L)
(PUTNTH A I (PUTNTH B J L))))).
This simplifies, unfolding the definitions of NOT, OR, LESSP, and PUTNTH, to
the following eight new formulas:
Case 1.8.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(NOT (EQUAL I J))
(LISTP L))
(EQUAL (PUTNTH B J
(CONS (CAR L)
(PUTNTH A (SUB1 I) (CDR L))))
(PUTNTH A I
(CONS (CAR L)
(PUTNTH B (SUB1 J) (CDR L)))))).
But this again simplifies, rewriting with CDR-CONS and CAR-CONS, and
expanding the definition of PUTNTH, to:
T.
Case 1.7.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(NOT (EQUAL I J))
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L)
(PUTNTH A I L))).
But this again simplifies, opening up the function PUTNTH, to:
T.
Case 1.6.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(EQUAL I J)
(LISTP L))
(EQUAL (PUTNTH B J
(CONS (CAR L)
(PUTNTH A (SUB1 I) (CDR L))))
(CONS (CAR L)
(PUTNTH B (SUB1 I) (CDR L))))),
which again simplifies, obviously, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(NOT (EQUAL (SUB1 I) (SUB1 J)))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(EQUAL I J)
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L) L)).
This again simplifies, trivially, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH B (SUB1 J) (CDR L)))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(NOT (EQUAL I J))
(LISTP L))
(EQUAL (PUTNTH B J
(CONS (CAR L)
(PUTNTH A (SUB1 I) (CDR L))))
(PUTNTH A I
(CONS (CAR L)
(PUTNTH B (SUB1 J) (CDR L)))))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH B (SUB1 J) (CDR L)))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(NOT (EQUAL I J))
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L)
(PUTNTH A I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH B (SUB1 J) (CDR L)))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(EQUAL I J)
(LISTP L))
(EQUAL (PUTNTH B J
(CONS (CAR L)
(PUTNTH A (SUB1 I) (CDR L))))
(CONS (CAR L)
(PUTNTH B (SUB1 I) (CDR L))))),
which again simplifies, applying CDR-CONS and CAR-CONS, and unfolding the
definition of PUTNTH, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL I 0))
(NOT (EQUAL J 0))
(EQUAL (SUB1 I) (SUB1 J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH B (SUB1 J) (CDR L)))
(NUMBERP I)
(NUMBERP J)
(NOT (LESSP (SUB1 J) (SUB1 I)))
(EQUAL I J)
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L) L)).
However this again simplifies, appealing to the lemma CDR-NLISTP, and
expanding the functions LISTP and PUTNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-PUTNTH-CASESPLIT
(DISABLE PUTNTH-PUTNTH-CASESPLIT)
[ 0.0 0.0 0.0 ]
PUTNTH-PUTNTH-CASESPLIT-OFF
(PROVE-LEMMA PUTNTH-COINCIDENCE
(REWRITE)
(IMPLIES (EQUAL (FIX I) (FIX J))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH B J L)))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up the definitions of FIX, PUTNTH, and EQUAL,
to the following four new formulas:
Case 4. (IMPLIES (AND (NUMBERP J)
(NUMBERP I)
(EQUAL I J))
(EQUAL (PUTNTH B I (PUTNTH A I L))
(PUTNTH B I L))).
This again simplifies, obviously, to the new goal:
(IMPLIES (NUMBERP J)
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))),
which we will name *1.
Case 3. (IMPLIES (AND (NOT (NUMBERP I))
(EQUAL 0 J)
(LISTP L))
(EQUAL (CONS B (CDR (CONS A (CDR L))))
(CONS B (CDR L)))).
But this again simplifies, rewriting with the lemma CDR-CONS, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP J))
(EQUAL I 0)
(LISTP L))
(EQUAL (CONS B (CDR (CONS A (CDR L))))
(CONS B (CDR L)))),
which again simplifies, rewriting with the lemma CDR-CONS, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP J))
(NOT (NUMBERP I))
(LISTP L))
(EQUAL (CONS B (CDR (CONS A (CDR L))))
(CONS B (CDR L)))),
which again simplifies, rewriting with CDR-CONS, to:
T.
So next consider:
(IMPLIES (NUMBERP J)
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))),
which is formula *1 above. Perhaps we can prove it by induction. There are
five plausible inductions. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP (PUTNTH A J L)) (ZEROP J))
(p B J A L))
(IMPLIES (AND (LISTP (PUTNTH A J L))
(NOT (ZEROP J))
(p B (SUB1 J) A (CDR L)))
(p B J A L))
(IMPLIES (NOT (LISTP (PUTNTH A J L)))
(p B J A L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT J) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instance chosen for L. The above induction scheme generates the following
three new conjectures:
Case 3. (IMPLIES (AND (LISTP (PUTNTH A J L))
(ZEROP J)
(NUMBERP J))
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))).
This simplifies, appealing to the lemma CDR-CONS, and expanding PUTNTH,
ZEROP, NUMBERP, and EQUAL, to:
T.
Case 2. (IMPLIES (AND (LISTP (PUTNTH A J L))
(NOT (ZEROP J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 J) (CDR L)))
(PUTNTH B (SUB1 J) (CDR L)))
(NUMBERP J))
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))).
This simplifies, applying CDR-CONS and CAR-CONS, and expanding the
definitions of PUTNTH and ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP (PUTNTH A J L)))
(NUMBERP J))
(EQUAL (PUTNTH B J (PUTNTH A J L))
(PUTNTH B J L))),
which simplifies, unfolding PUTNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-COINCIDENCE
(DISABLE PUTNTH-COINCIDENCE)
[ 0.0 0.0 0.0 ]
PUTNTH-COINCIDENCE-OFF
(PROVE-LEMMA PUTNTH-NON-INTERFERENCE NIL
(IMPLIES (NOT (EQUAL (FIX I) (FIX J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L))))
((ENABLE PUTNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up the functions FIX and PUTNTH, to the
following seven new conjectures:
Case 7. (IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(NOT (LISTP L))
(LISTP (PUTNTH A I L)))
(EQUAL (CONS B (CDR (PUTNTH A I L)))
(PUTNTH A I L))).
However this again simplifies, unfolding PUTNTH, to:
T.
Case 6. (IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(LISTP L)
(NOT (LISTP (PUTNTH A I L))))
(EQUAL (PUTNTH A I L)
(PUTNTH A I (CONS B (CDR L))))),
which again simplifies, clearly, to:
T.
Case 5. (IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(LISTP L)
(LISTP (PUTNTH A I L)))
(EQUAL (CONS B (CDR (PUTNTH A I L)))
(PUTNTH A I (CONS B (CDR L))))).
However this again simplifies, applying CDR-CONS, CAR-CONS, and CONS-EQUAL,
and unfolding the function PUTNTH, to:
(IMPLIES (AND (NOT (NUMBERP J))
(NUMBERP I)
(NOT (EQUAL I 0))
(LISTP L))
(EQUAL (CDR (PUTNTH A I L))
(PUTNTH A (SUB1 I) (CDR L)))),
which again simplifies, applying CDR-CONS, and unfolding the function PUTNTH,
to:
T.
Case 4. (IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(NOT (LISTP (PUTNTH B J L)))
(LISTP L))
(EQUAL (PUTNTH B J (CONS A (CDR L)))
(PUTNTH B J L))).
This again simplifies, obviously, to:
T.
Case 3. (IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP (PUTNTH B J L))
(NOT (LISTP L)))
(EQUAL (PUTNTH B J L)
(CONS A (CDR (PUTNTH B J L))))).
This again simplifies, unfolding PUTNTH, to:
T.
Case 2. (IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP (PUTNTH B J L))
(LISTP L))
(EQUAL (PUTNTH B J (CONS A (CDR L)))
(CONS A (CDR (PUTNTH B J L))))),
which again simplifies, applying CDR-CONS, CAR-CONS, and CONS-EQUAL, and
unfolding the definition of PUTNTH, to:
(IMPLIES (AND (NUMBERP J)
(NOT (NUMBERP I))
(NOT (EQUAL 0 J))
(LISTP L))
(EQUAL (PUTNTH B (SUB1 J) (CDR L))
(CDR (PUTNTH B J L)))),
which again simplifies, applying CDR-CONS, and unfolding the definition of
PUTNTH, to:
T.
Case 1. (IMPLIES (AND (NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
Name the above subgoal *1.
We will appeal to induction. Six inductions are suggested by terms in
the conjecture. However, they merge into one likely candidate induction. We
will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP (PUTNTH A I L)) (ZEROP J))
(p B J A I L))
(IMPLIES (AND (LISTP (PUTNTH A I L))
(NOT (ZEROP J))
(p B (SUB1 J) A (SUB1 I) (CDR L)))
(p B J A I L))
(IMPLIES (NOT (LISTP (PUTNTH A I L)))
(p B J A I L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT J) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instances chosen for I and L. The above induction scheme produces the
following four new goals:
Case 4. (IMPLIES (AND (LISTP (PUTNTH A I L))
(ZEROP J)
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
This simplifies, applying the lemmas CDR-CONS and CAR-CONS, and unfolding
the functions PUTNTH, ZEROP, NUMBERP, and EQUAL, to:
T.
Case 3. (IMPLIES (AND (LISTP (PUTNTH A I L))
(NOT (ZEROP J))
(EQUAL (SUB1 I) (SUB1 J))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
This simplifies, using linear arithmetic, to the following two new formulas:
Case 3.2.
(IMPLIES (AND (EQUAL J 0)
(LISTP (PUTNTH A I L))
(NOT (ZEROP J))
(EQUAL (SUB1 I) (SUB1 J))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
This again simplifies, opening up the functions PUTNTH and ZEROP, to:
T.
Case 3.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP (PUTNTH A I L))
(NOT (ZEROP J))
(EQUAL (SUB1 I) (SUB1 J))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))),
which again simplifies, applying the lemmas CDR-CONS, CAR-CONS, and
CONS-EQUAL, and unfolding EQUAL, PUTNTH, ZEROP, SUB1, and NUMBERP, to two
new conjectures:
Case 3.1.2.
(IMPLIES (AND (LISTP L)
(EQUAL 0 (SUB1 J))
(NUMBERP J)
(NOT (EQUAL 0 J))
(NOT (LISTP (CDR L))))
(EQUAL (CDR L)
(PUTNTH B (SUB1 J) (CDR L)))),
which again simplifies, expanding the definition of PUTNTH, to:
T.
Case 3.1.1.
(IMPLIES (AND (LISTP L)
(EQUAL 0 (SUB1 J))
(NUMBERP J)
(NOT (EQUAL 0 J))
(LISTP (CDR L)))
(EQUAL (CONS B (CDDR L))
(PUTNTH B (SUB1 J) (CDR L)))),
which again simplifies, opening up the functions EQUAL and PUTNTH, to:
T.
Case 2. (IMPLIES (AND (LISTP (PUTNTH A I L))
(NOT (ZEROP J))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))),
which simplifies, rewriting with CAR-CONS and CDR-CONS, and unfolding PUTNTH
and ZEROP, to the following two new goals:
Case 2.2.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL J 0))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J))
(NOT (EQUAL I 0)))
(EQUAL (PUTNTH B J
(CONS (CAR L)
(PUTNTH A (SUB1 I) (CDR L))))
(CONS (CAR L)
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L)))))).
However this again simplifies, applying the lemmas CDR-CONS and CAR-CONS,
and unfolding the function PUTNTH, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP L)
(NOT (EQUAL J 0))
(EQUAL (PUTNTH B
(SUB1 J)
(PUTNTH A (SUB1 I) (CDR L)))
(PUTNTH A
(SUB1 I)
(PUTNTH B (SUB1 J) (CDR L))))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J))
(EQUAL I 0))
(EQUAL (PUTNTH B J (CONS A (CDR L)))
(CONS A
(PUTNTH B (SUB1 J) (CDR L))))),
which again simplifies, rewriting with CDR-CONS and CAR-CONS, and
expanding the definitions of SUB1, EQUAL, PUTNTH, and NUMBERP, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP (PUTNTH A I L)))
(NUMBERP J)
(NUMBERP I)
(NOT (EQUAL I J)))
(EQUAL (PUTNTH B J (PUTNTH A I L))
(PUTNTH A I (PUTNTH B J L)))).
This simplifies, unfolding PUTNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
PUTNTH-NON-INTERFERENCE
(PROVE-LEMMA PUTNTH-NON-INTERFERENCE-COROLLARY1
(REWRITE)
(IMPLIES (LESSP (FIX I) (ADD1 J))
(EQUAL (PUTNTH B (ADD1 J) (PUTNTH A I L))
(PUTNTH A I (PUTNTH B (ADD1 J) L))))
((USE (PUTNTH-NON-INTERFERENCE (I I)
(J (ADD1 J))
(A A)
(B B)
(L L)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up FIX, NOT, IMPLIES, and LESSP, to the
conjecture:
(IMPLIES (AND (NUMBERP I)
(EQUAL I (ADD1 J))
(LESSP I I))
(EQUAL (PUTNTH B I (PUTNTH A I L))
(PUTNTH A I (PUTNTH B I L)))).
However this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-NON-INTERFERENCE-COROLLARY1
(DISABLE PUTNTH-NON-INTERFERENCE-COROLLARY1)
[ 0.0 0.0 0.0 ]
PUTNTH-NON-INTERFERENCE-COROLLARY1-OFF
(PROVE-LEMMA PUTNTH-NON-INTERFERENCE-COROLLARY2
(REWRITE)
(IMPLIES (LESSP (FIX I) (PLUS J K))
(EQUAL (PUTNTH B (PLUS J K) (PUTNTH A I L))
(PUTNTH A I (PUTNTH B (PLUS J K) L))))
((USE (PUTNTH-NON-INTERFERENCE (I I)
(J (PLUS J K))
(A A)
(B B)
(L L)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, opening up the definitions of FIX, NOT, IMPLIES, and LESSP,
to:
(IMPLIES (AND (NUMBERP I)
(EQUAL I (PLUS J K))
(LESSP I I))
(EQUAL (PUTNTH B I (PUTNTH A I L))
(PUTNTH A I (PUTNTH B I L)))).
However this again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-NON-INTERFERENCE-COROLLARY2
(DISABLE PUTNTH-NON-INTERFERENCE-COROLLARY2)
[ 0.0 0.0 0.0 ]
PUTNTH-NON-INTERFERENCE-COROLLARY2-OFF
(PROVE-LEMMA PUTNTH-PUTSEG-COINCIDENCE-PROOF
(REWRITE)
(IMPLIES (AND (NUMBERP N)
(AND (NUMBERP I)
(AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(LESSP (DIFFERENCE I N) (LENGTH S)))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L)))
((ENABLE PUTSEG PUTNTH LENGTH DIFFERENCE-X-X DIFFERENCE-SUB1-ARG1
LISTP-PUTSEG NON-ZERO-LENGTH-IMPLIES-LISTP
PUTNTH-PUTNTH-CASESPLIT)
(INDUCT (PUTSEG S N L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations IMPLIES, NOT, OR, and
AND, to the following two new conjectures:
Case 2. (IMPLIES (AND (LISTP S)
(IMPLIES (AND (NUMBERP (ADD1 N))
(NUMBERP I)
(IF (LESSP I (ADD1 N)) F T)
(LESSP (DIFFERENCE I (ADD1 N))
(LENGTH (CDR S))))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE I (ADD1 N))
(CDR S))
(ADD1 N)
L)))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
This simplifies, appealing to the lemmas SUB1-ADD1, PUTNTH-PUTNTH-CASESPLIT,
CDR-CONS, CAR-CONS, and LISTP-PUTSEG, and unfolding the definitions of LESSP,
DIFFERENCE, AND, IMPLIES, LENGTH, PUTSEG, EQUAL, PUTNTH, NUMBERP, and ADD1,
to the following 14 new formulas:
Case 2.14.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE (SUB1 I) N)
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 2.13.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE (SUB1 I) N)
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, clearly, to:
T.
Case 2.12.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE (SUB1 I) N)
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
However this again simplifies, using linear arithmetic and rewriting with
DIFFERENCE-SUB1-ARG1, to:
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(SUB1 (DIFFERENCE I N))
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, unfolding the definition of PUTNTH, to two new
conjectures:
Case 2.12.2.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(SUB1 (DIFFERENCE I N))
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I))
(NOT (EQUAL (DIFFERENCE I N) 0)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (CONS (CAR S)
(PUTNTH V
(SUB1 (DIFFERENCE I N))
(CDR S)))
N L))),
which again simplifies, rewriting with CDR-CONS and CAR-CONS, and
opening up the function PUTSEG, to:
T.
Case 2.12.1.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(SUB1 (DIFFERENCE I N))
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I))
(EQUAL (DIFFERENCE I N) 0))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (CONS V (CDR S)) N L))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.11.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE (SUB1 I) N)
(CDR S))
(ADD1 N)
L))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, applying DIFFERENCE-X-X, CDR-CONS, and CAR-CONS,
and opening up the definitions of SUB1, EQUAL, LESSP, PUTNTH, and PUTSEG,
to:
T.
Case 2.10.
(IMPLIES (AND (LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))).
This again simplifies, using linear arithmetic, to two new formulas:
Case 2.10.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.10.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.9.
(IMPLIES (AND (LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, trivially, to:
T.
Case 2.8.
(IMPLIES (AND (LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
This again simplifies, using linear arithmetic, to two new goals:
Case 2.8.2.
(IMPLIES (AND (LESSP (SUB1 I) N)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.8.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.7.
(IMPLIES (AND (LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S))))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, using linear arithmetic, to two new conjectures:
Case 2.7.2.
(IMPLIES (AND (LESSP (SUB1 I) I)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) I)
(LENGTH (CDR S))))
(NUMBERP I)
(NUMBERP I)
(NOT (LESSP I I))
(LESSP (SUB1 (DIFFERENCE I I))
(LENGTH (CDR S))))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 I) L))
(PUTSEG (PUTNTH V (DIFFERENCE I I) S)
I L))),
which again simplifies, rewriting with DIFFERENCE-X-X, CDR-CONS, and
CAR-CONS, and opening up SUB1, EQUAL, LESSP, PUTNTH, and PUTSEG, to:
T.
Case 2.7.1.
(IMPLIES (AND (EQUAL I 0)
(LISTP S)
(NOT (LESSP (DIFFERENCE (SUB1 I) I)
(LENGTH (CDR S))))
(NUMBERP I)
(NUMBERP I)
(NOT (LESSP I I))
(LESSP (SUB1 (DIFFERENCE I I))
(LENGTH (CDR S))))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 I) L))
(PUTSEG (PUTNTH V (DIFFERENCE I I) S)
I L))).
However this again simplifies, unfolding the functions SUB1, DIFFERENCE,
EQUAL, LESSP, and NUMBERP, to:
T.
Case 2.6.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.5.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(EQUAL (DIFFERENCE I N) 0)
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH V N
(PUTSEG (CDR S) (ADD1 N) L)))),
which again simplifies, clearly, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
This again simplifies, using linear arithmetic, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S)))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, applying DIFFERENCE-X-X, CDR-CONS, and CAR-CONS,
and opening up the functions SUB1, EQUAL, LESSP, PUTNTH, and PUTSEG, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(NUMBERP N)
(EQUAL N 0)
(NOT (LISTP L)))
(EQUAL (PUTSEG S 0 L)
(PUTSEG (CDR S) 1 L))).
This again simplifies, rewriting with LISTP-PUTSEG, and expanding NUMBERP,
PUTNTH, ADD1, and PUTSEG, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP S)
(EQUAL I 0)
(NUMBERP N)
(EQUAL N 0)
(LISTP L))
(EQUAL (CONS V (CDR (PUTSEG S 0 L)))
(CONS V (CDR (PUTSEG (CDR S) 1 L))))).
However this again simplifies, rewriting with the lemma CDR-CONS, and
unfolding the definitions of NUMBERP, PUTNTH, EQUAL, ADD1, and PUTSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NUMBERP N)
(NUMBERP I)
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which simplifies, using linear arithmetic and rewriting with
NON-ZERO-LENGTH-IMPLIES-LISTP, to:
T.
Q.E.D.
[ 0.0 0.2 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE-PROOF
(DISABLE PUTNTH-PUTSEG-COINCIDENCE-PROOF)
[ 0.0 0.0 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE-PROOF-OFF
(PROVE-LEMMA PUTSEG-WITH-NON-NUMBER-INDEX
(REWRITE)
(IMPLIES (NOT (NUMBERP N))
(EQUAL (PUTSEG S N L)
(PUTSEG S '0 L)))
((ENABLE PUTSEG PUTNTH-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (AND (LISTP S) (p (CDR S) (ADD1 N) L))
(p S N L))
(IMPLIES (NOT (LISTP S)) (p S N L))).
Linear arithmetic and the lemma CDR-LESSP can be used to show that the measure
(COUNT S) decreases according to the well-founded relation LESSP in each
induction step of the scheme. Note, however, the inductive instance chosen
for N. The above induction scheme generates the following two new conjectures:
Case 2. (IMPLIES (AND (LISTP S) (NOT (NUMBERP N)))
(EQUAL (PUTSEG S N L)
(PUTSEG S 0 L))).
This simplifies, appealing to the lemma PUTNTH-WITH-NON-NUMBER-INDEX, and
expanding the functions PUTSEG and ADD1, to:
(IMPLIES (AND (LISTP S) (NOT (NUMBERP N)))
(EQUAL (PUTNTH (CAR S)
0
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH (CAR S)
0
(PUTSEG (CDR S) 1 L)))),
which further simplifies, applying SUB1-TYPE-RESTRICTION, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NOT (NUMBERP N)))
(EQUAL (PUTSEG S N L)
(PUTSEG S 0 L))).
This simplifies, opening up the definition of PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-WITH-NON-NUMBER-INDEX
(DISABLE PUTSEG-WITH-NON-NUMBER-INDEX)
[ 0.0 0.0 0.0 ]
PUTSEG-WITH-NON-NUMBER-INDEX-OFF
(PROVE-LEMMA PUTNTH-PUTSEG-COINCIDENCE
(REWRITE)
(IMPLIES (AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L)))
((ENABLE PUTNTH-PUTSEG-COINCIDENCE-PROOF
PUTNTH-WITH-NON-NUMBER-INDEX
PUTSEG-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Perhaps we can prove it by induction. There are six plausible inductions.
However, they merge into one likely candidate induction. We will induct
according to the following scheme:
(AND (IMPLIES (OR (EQUAL N 0) (NOT (NUMBERP N)))
(p V I S N L))
(IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(OR (EQUAL I 0) (NOT (NUMBERP I))))
(p V I S N L))
(IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(p V (SUB1 I) S (SUB1 N) L))
(p V I S N L))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT can be used to prove that the measure (COUNT I) decreases
according to the well-founded relation LESSP in each induction step of the
scheme. Note, however, the inductive instance chosen for N. The above
induction scheme leads to five new goals:
Case 5. (IMPLIES (AND (OR (EQUAL N 0) (NOT (NUMBERP N)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which simplifies, using linear arithmetic, applying the lemmas
PUTNTH-PUTSEG-COINCIDENCE-PROOF, PUTNTH-WITH-NON-NUMBER-INDEX, and
PUTSEG-WITH-NON-NUMBER-INDEX, and expanding NOT, OR, EQUAL, LESSP, and
DIFFERENCE, to four new formulas:
Case 5.4.
(IMPLIES (AND (EQUAL N 0)
(EQUAL I 0)
(LESSP 0 (LENGTH S)))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG (PUTNTH V 0 S) 0 L))),
which again simplifies, using linear arithmetic, applying
PUTNTH-PUTSEG-COINCIDENCE-PROOF, and unfolding EQUAL, LESSP, and
DIFFERENCE, to:
T.
Case 5.3.
(IMPLIES (AND (EQUAL N 0)
(NOT (NUMBERP I))
(LESSP 0 (LENGTH S)))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG (PUTNTH V 0 S) 0 L))).
This again simplifies, using linear arithmetic, applying
PUTNTH-PUTSEG-COINCIDENCE-PROOF, and opening up the definitions of EQUAL,
LESSP, and DIFFERENCE, to:
T.
Case 5.2.
(IMPLIES (AND (NOT (NUMBERP N))
(EQUAL I 0)
(LESSP 0 (LENGTH S)))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG (PUTNTH V 0 S) 0 L))).
But this again simplifies, using linear arithmetic, rewriting with
PUTNTH-PUTSEG-COINCIDENCE-PROOF, and opening up the definitions of EQUAL,
LESSP, and DIFFERENCE, to:
T.
Case 5.1.
(IMPLIES (AND (NOT (NUMBERP N))
(NOT (NUMBERP I))
(LESSP 0 (LENGTH S)))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG (PUTNTH V 0 S) 0 L))).
However this again simplifies, using linear arithmetic, applying
PUTNTH-PUTSEG-COINCIDENCE-PROOF, and unfolding the definitions of EQUAL,
LESSP, and DIFFERENCE, to:
T.
Case 4. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(OR (EQUAL I 0) (NOT (NUMBERP I)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
This simplifies, opening up the functions NOT, OR, EQUAL, and LESSP, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (SUB1 I) (SUB1 N))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
This simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP N 1)
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (SUB1 I) (SUB1 N))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, expanding the definitions of SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which simplifies, using linear arithmetic, to two new goals:
Case 2.2.
(IMPLIES (AND (LESSP (SUB1 I) (SUB1 N))
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, using linear arithmetic, to the goal:
(IMPLIES (AND (LESSP N 1)
(LESSP (SUB1 I) (SUB1 N))
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))).
But this again simplifies, unfolding the functions SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 2.1.
(IMPLIES (AND (LESSP I 1)
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(NOT (LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S)))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which again simplifies, unfolding the functions SUB1, NUMBERP, EQUAL,
LESSP, NOT, and OR, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(EQUAL (PUTNTH V
(SUB1 I)
(PUTSEG S (SUB1 N) L))
(PUTSEG (PUTNTH V
(DIFFERENCE (SUB1 I) (SUB1 N))
S)
(SUB1 N)
L))
(NOT (LESSP I N))
(LESSP (DIFFERENCE I N) (LENGTH S)))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG (PUTNTH V (DIFFERENCE I N) S)
N L))),
which simplifies, using linear arithmetic, applying
PUTNTH-PUTSEG-COINCIDENCE-PROOF, and unfolding the definitions of NOT, OR,
LESSP, and DIFFERENCE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE
(DISABLE PUTNTH-PUTSEG-COINCIDENCE)
[ 0.0 0.0 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE-OFF
(PROVE-LEMMA PUTNTH-PUTSEG-COINCIDENCE-INVERSE
(REWRITE)
(IMPLIES (AND (LESSP I (LENGTH S)) (NUMBERP I))
(EQUAL (PUTSEG (PUTNTH V I S) N L)
(PUTNTH V (PLUS I N) (PUTSEG S N L))))
((USE (PUTNTH-PUTSEG-COINCIDENCE (N N)
(I (PLUS I N))
(V V)
(S S)
(L L)))
(ENABLE DIFFERENCE-PLUS2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture simplifies, rewriting with DIFFERENCE-PLUS2, and unfolding the
definitions of AND and IMPLIES, to the new formula:
(IMPLIES (AND (LESSP (PLUS I N) N)
(LESSP I (LENGTH S))
(NUMBERP I))
(EQUAL (PUTSEG (PUTNTH V I S) N L)
(PUTNTH V
(PLUS I N)
(PUTSEG S N L)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE-INVERSE
(DISABLE PUTNTH-PUTSEG-COINCIDENCE-INVERSE)
[ 0.0 0.0 0.0 ]
PUTNTH-PUTSEG-COINCIDENCE-INVERSE-OFF
(PROVE-LEMMA PUTNTH-AFTER-PUTSEG-PROOF
(REWRITE)
(IMPLIES (AND (NUMBERP I)
(AND (NUMBERP N)
(AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(IF (LESSP (DIFFERENCE I N) (LENGTH S))
'*1*FALSE
'*1*TRUE))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L))))
((ENABLE PUTNTH PUTSEG LENGTH PUTNTH-PUTNTH-CASESPLIT)
(INDUCT (PUTSEG S N L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations IMPLIES, NOT, OR,
and AND, to two new conjectures:
Case 2. (IMPLIES (AND (LISTP S)
(IMPLIES (AND (NUMBERP I)
(NUMBERP (ADD1 N))
(IF (LESSP I (ADD1 N)) F T)
(IF (LESSP (DIFFERENCE I (ADD1 N))
(LENGTH (CDR S)))
F T))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))),
which simplifies, rewriting with the lemmas SUB1-ADD1 and
PUTNTH-PUTNTH-CASESPLIT, and unfolding the definitions of LESSP, DIFFERENCE,
AND, IMPLIES, LENGTH, PUTSEG, NUMBERP, and EQUAL, to five new goals:
Case 2.5.
(IMPLIES (AND (LISTP S)
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.4.
(IMPLIES (AND (LISTP S)
(LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))),
which again simplifies, using linear arithmetic, to the formula:
(IMPLIES (AND (NOT (LESSP N I))
(LISTP S)
(LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))).
However this again simplifies, using linear arithmetic, to:
T.
Case 2.3.
(IMPLIES (AND (LISTP S)
(LESSP (DIFFERENCE (SUB1 I) N)
(LENGTH (CDR S)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))),
which again simplifies, using linear arithmetic, to the conjecture:
(IMPLIES (AND (NOT (LESSP N I))
(LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(NOT (EQUAL N I)))
(EQUAL (PUTNTH (CAR S)
N
(PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))).
But this again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (LISTP S)
(LESSP (SUB1 I) N)
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (EQUAL (DIFFERENCE I N) 0))
(NOT (LESSP (SUB1 (DIFFERENCE I N))
(LENGTH (CDR S))))
(EQUAL N I))
(EQUAL (PUTNTH V I
(PUTSEG (CDR S) (ADD1 N) L))
(PUTNTH (CAR S)
N
(PUTSEG (CDR S)
(ADD1 N)
(PUTNTH V I L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))),
which simplifies, unfolding LENGTH, EQUAL, LESSP, and PUTSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-AFTER-PUTSEG-PROOF
(DISABLE PUTNTH-AFTER-PUTSEG-PROOF)
[ 0.0 0.0 0.0 ]
PUTNTH-AFTER-PUTSEG-PROOF-OFF
(PROVE-LEMMA PUTNTH-AFTER-PUTSEG
(REWRITE)
(IMPLIES (AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(IF (LESSP (DIFFERENCE I N) (LENGTH S))
'*1*FALSE
'*1*TRUE))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L))))
((ENABLE PUTNTH-AFTER-PUTSEG-PROOF PUTNTH-WITH-NON-NUMBER-INDEX
PUTSEG-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Let us appeal to the induction principle. Four inductions are suggested
by terms in the conjecture. However, they merge into one likely candidate
induction. We will induct according to the following scheme:
(AND (IMPLIES (OR (EQUAL N 0) (NOT (NUMBERP N)))
(p V I S N L))
(IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(OR (EQUAL I 0) (NOT (NUMBERP I))))
(p V I S N L))
(IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(p V (SUB1 I) S (SUB1 N) L))
(p V I S N L))).
Linear arithmetic, the lemmas SUB1-LESSEQP and SUB1-LESSP, and the definitions
of OR and NOT can be used to show that the measure (COUNT I) decreases
according to the well-founded relation LESSP in each induction step of the
scheme. Note, however, the inductive instance chosen for N. The above
induction scheme generates the following five new conjectures:
Case 5. (IMPLIES (AND (OR (EQUAL N 0) (NOT (NUMBERP N)))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))).
This simplifies, using linear arithmetic, rewriting with
PUTNTH-AFTER-PUTSEG-PROOF, PUTNTH-WITH-NON-NUMBER-INDEX, and
PUTSEG-WITH-NON-NUMBER-INDEX, and expanding NOT, OR, EQUAL, LESSP, and
DIFFERENCE, to four new goals:
Case 5.4.
(IMPLIES (AND (EQUAL N 0)
(EQUAL I 0)
(NOT (LESSP 0 (LENGTH S))))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG S 0 (PUTNTH V 0 L)))),
which again simplifies, rewriting with PUTNTH-AFTER-PUTSEG-PROOF, and
expanding the functions EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 5.3.
(IMPLIES (AND (EQUAL N 0)
(NOT (NUMBERP I))
(NOT (LESSP 0 (LENGTH S))))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG S 0 (PUTNTH V 0 L)))).
But this again simplifies, applying PUTNTH-AFTER-PUTSEG-PROOF, and
unfolding EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 5.2.
(IMPLIES (AND (NOT (NUMBERP N))
(EQUAL I 0)
(NOT (LESSP 0 (LENGTH S))))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG S 0 (PUTNTH V 0 L)))).
However this again simplifies, applying the lemma
PUTNTH-AFTER-PUTSEG-PROOF, and expanding EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 5.1.
(IMPLIES (AND (NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (LESSP 0 (LENGTH S))))
(EQUAL (PUTNTH V 0 (PUTSEG S 0 L))
(PUTSEG S 0 (PUTNTH V 0 L)))),
which again simplifies, applying PUTNTH-AFTER-PUTSEG-PROOF, and opening up
EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 4. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(OR (EQUAL I 0) (NOT (NUMBERP I)))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))).
This simplifies, expanding NOT, OR, EQUAL, and LESSP, to:
T.
Case 3. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (SUB1 I) (SUB1 N))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))).
This simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP N 1)
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (SUB1 I) (SUB1 N))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))),
which again simplifies, unfolding the functions SUB1, NUMBERP, EQUAL, LESSP,
NOT, and OR, to:
T.
Case 2. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))),
which simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP N 1)
(NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(LESSP (DIFFERENCE (SUB1 I) (SUB1 N))
(LENGTH S))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))).
However this again simplifies, unfolding the definitions of SUB1, NUMBERP,
EQUAL, LESSP, NOT, and OR, to:
T.
Case 1. (IMPLIES (AND (NOT (OR (EQUAL N 0) (NOT (NUMBERP N))))
(NOT (OR (EQUAL I 0) (NOT (NUMBERP I))))
(EQUAL (PUTNTH V
(SUB1 I)
(PUTSEG S (SUB1 N) L))
(PUTSEG S
(SUB1 N)
(PUTNTH V (SUB1 I) L)))
(NOT (LESSP I N))
(NOT (LESSP (DIFFERENCE I N) (LENGTH S))))
(EQUAL (PUTNTH V I (PUTSEG S N L))
(PUTSEG S N (PUTNTH V I L)))),
which simplifies, using linear arithmetic, applying
PUTNTH-AFTER-PUTSEG-PROOF, and opening up the functions NOT, OR, LESSP, and
DIFFERENCE, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTNTH-AFTER-PUTSEG
(DISABLE PUTNTH-AFTER-PUTSEG)
[ 0.0 0.0 0.0 ]
PUTNTH-AFTER-PUTSEG-OFF
(PROVE-LEMMA GETSEG-OF-LENGTH-ZERO
(REWRITE)
(IMPLIES (ZEROP K)
(EQUAL (GETSEG N K L) 'NIL))
((ENABLE GETSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, expanding the functions ZEROP, EQUAL, and GETSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-OF-LENGTH-ZERO
(DISABLE GETSEG-OF-LENGTH-ZERO)
[ 0.0 0.0 0.0 ]
GETSEG-OF-LENGTH-ZERO-OFF
(PROVE-LEMMA GETSEG-ADD1-LENGTH
(REWRITE)
(EQUAL (GETSEG N (ADD1 K) L)
(APPEND (GETSEG N K L)
(CONS (GETNTH (PLUS N K) L) 'NIL)))
((ENABLE APPEND GETSEG PLUS-0 PLUS-RIGHT-ID2
GETNTH-WITH-NON-NUMBER-INDEX PLUS-ADD1)
(INDUCT (GETSEG N K L))
(EXPAND (GETSEG N 1 L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, NOT, OR, and
AND, to the following two new formulas:
Case 2. (IMPLIES (ZEROP K)
(EQUAL (GETSEG N (ADD1 K) L)
(APPEND (GETSEG N K L)
(LIST (GETNTH (PLUS N K) L))))).
This simplifies, applying the lemmas PLUS-0, CAR-CONS, CONS-EQUAL,
SUB1-TYPE-RESTRICTION, and PLUS-RIGHT-ID2, and opening up the functions
ZEROP, ADD1, GETSEG, EQUAL, NUMBERP, SUB1, LISTP, and APPEND, to the
following two new conjectures:
Case 2.2.
(IMPLIES (AND (EQUAL K 0) (NOT (NUMBERP N)))
(EQUAL (GETNTH N L) (GETNTH 0 L))).
But this again simplifies, rewriting with GETNTH-WITH-NON-NUMBER-INDEX, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (NUMBERP K))
(NOT (NUMBERP N)))
(EQUAL (GETNTH N L) (GETNTH 0 L))).
This again simplifies, rewriting with GETNTH-WITH-NON-NUMBER-INDEX, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 N) (ADD1 (SUB1 K)) L)
(APPEND (GETSEG (ADD1 N) (SUB1 K) L)
(LIST (GETNTH (PLUS (ADD1 N) (SUB1 K))
L)))))
(EQUAL (GETSEG N (ADD1 K) L)
(APPEND (GETSEG N K L)
(LIST (GETNTH (PLUS N K) L))))).
This simplifies, applying the lemmas ADD1-SUB1, SUB1-ADD1,
SUB1-TYPE-RESTRICTION, GETNTH-WITH-NON-NUMBER-INDEX, CAR-CONS, CDR-CONS, and
CONS-EQUAL, and opening up the functions PLUS, GETSEG, and APPEND, to the
following two new conjectures:
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG (ADD1 N) K L)
(APPEND (GETSEG (ADD1 N) (SUB1 K) L)
(LIST (GETNTH (ADD1 (PLUS 0 (SUB1 K)))
L)))))
(EQUAL (CONS (GETNTH 0 L) (GETSEG 1 K L))
(APPEND (GETSEG N K L)
(LIST (GETNTH K L))))).
This again simplifies, rewriting with SUB1-TYPE-RESTRICTION, ADD1-SUB1,
and CAR-CONS, and opening up the definitions of EQUAL and PLUS, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG 1 K L)
(APPEND (GETSEG 1 (SUB1 K) L)
(LIST (GETNTH K L)))))
(EQUAL (CONS (GETNTH 0 L) (GETSEG 1 K L))
(APPEND (GETSEG N K L)
(LIST (GETNTH K L))))),
which again simplifies, applying SUB1-TYPE-RESTRICTION,
GETNTH-WITH-NON-NUMBER-INDEX, CDR-CONS, and CAR-CONS, and expanding GETSEG
and APPEND, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP N)
(EQUAL (GETSEG (ADD1 N) K L)
(APPEND (GETSEG (ADD1 N) (SUB1 K) L)
(LIST (GETNTH (ADD1 (PLUS N (SUB1 K)))
L)))))
(EQUAL (GETSEG (ADD1 N) K L)
(APPEND (GETSEG (ADD1 N) (SUB1 K) L)
(LIST (GETNTH (PLUS N K) L))))).
Appealing to the lemma SUB1-ELIM, we now replace K by (ADD1 X) to
eliminate (SUB1 K). We employ the type restriction lemma noted when SUB1
was introduced to constrain the new variable. We must thus prove:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(NUMBERP N)
(EQUAL (GETSEG (ADD1 N) (ADD1 X) L)
(APPEND (GETSEG (ADD1 N) X L)
(LIST (GETNTH (ADD1 (PLUS N X)) L)))))
(EQUAL (GETSEG (ADD1 N) (ADD1 X) L)
(APPEND (GETSEG (ADD1 N) X L)
(LIST (GETNTH (PLUS N (ADD1 X)) L))))).
This further simplifies, rewriting with SUB1-ADD1, CAR-CONS, and PLUS-ADD1,
and opening up the definition of GETSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-LENGTH
(DISABLE GETSEG-ADD1-LENGTH)
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-LENGTH-OFF
(PROVE-LEMMA GETSEG-WITH-NON-NUMBER-INDEX
(REWRITE)
(IMPLIES (NOT (NUMBERP N))
(EQUAL (GETSEG N K L)
(GETSEG '0 K L)))
((ENABLE GETSEG GETNTH-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to show that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for N. The above induction scheme
generates the following two new conjectures:
Case 2. (IMPLIES (AND (ZEROP K) (NOT (NUMBERP N)))
(EQUAL (GETSEG N K L)
(GETSEG 0 K L))).
This simplifies, opening up the functions ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(NOT (NUMBERP N)))
(EQUAL (GETSEG N K L)
(GETSEG 0 K L))).
This simplifies, rewriting with GETNTH-WITH-NON-NUMBER-INDEX, CAR-CONS,
CDR-CONS, and CONS-EQUAL, and opening up the definitions of ZEROP, GETSEG,
and ADD1, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N)))
(EQUAL (GETSEG (ADD1 N) (SUB1 K) L)
(GETSEG 1 (SUB1 K) L))).
However this further simplifies, applying SUB1-TYPE-RESTRICTION, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-WITH-NON-NUMBER-INDEX
(DISABLE GETSEG-WITH-NON-NUMBER-INDEX)
[ 0.0 0.0 0.0 ]
GETSEG-WITH-NON-NUMBER-INDEX-OFF
(PROVE-LEMMA GETSEG-ADD1-CONS
(REWRITE)
(EQUAL (GETSEG (ADD1 N) K (CONS A B))
(GETSEG N K B))
((ENABLE GETSEG GETNTH)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Name the conjecture *1.
Let us appeal to the induction principle. The recursive terms in the
conjecture suggest two inductions. However, they merge into one likely
candidate induction. We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K A B))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) A B))
(p N K A B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to show that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for N. The above induction scheme
leads to the following two new goals:
Case 2. (IMPLIES (ZEROP K)
(EQUAL (GETSEG (ADD1 N) K (CONS A B))
(GETSEG N K B))).
This simplifies, expanding the definitions of ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (GETSEG (ADD1 (ADD1 N))
(SUB1 K)
(CONS A B))
(GETSEG (ADD1 N) (SUB1 K) B)))
(EQUAL (GETSEG (ADD1 N) K (CONS A B))
(GETSEG N K B))).
This simplifies, rewriting with CDR-CONS, SUB1-ADD1, CAR-CONS, and
CONS-EQUAL, and unfolding the functions ZEROP, GETSEG, and GETNTH, to the
conjecture:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 (ADD1 N))
(SUB1 K)
(CONS A B))
(GETSEG (ADD1 N) (SUB1 K) B))
(NOT (NUMBERP N)))
(EQUAL (GETNTH 0 B) (GETNTH N B))).
But this again simplifies, expanding the functions EQUAL and GETNTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-CONS
(DISABLE GETSEG-ADD1-CONS)
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-CONS-OFF
(PROVE-LEMMA GETSEG-LENGTH-1 NIL
(EQUAL (GETSEG N '1 L)
(CONS (GETNTH N L) 'NIL))
((ENABLE GETSEG)
(EXPAND (GETSEG N 1 L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, opening up the functions GETSEG, EQUAL, NUMBERP, and
SUB1, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-LENGTH-1
(PROVE-LEMMA GETSEG-LENGTH-1-RULE
(REWRITE)
(IMPLIES (EQUAL K '1)
(EQUAL (GETSEG N K L)
(CONS (GETNTH N L) 'NIL)))
((USE (GETSEG-LENGTH-1 (N N) (K '1) (L L)))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, clearly, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-LENGTH-1-RULE
(DISABLE GETSEG-LENGTH-1-RULE)
[ 0.0 0.0 0.0 ]
GETSEG-LENGTH-1-RULE-OFF
(PROVE-LEMMA GETSEG-ADD1-LENGTH2
(REWRITE)
(IMPLIES (AND (NUMBERP N)
(IF (LESSP (LENGTH L) (ADD1 N))
'*1*FALSE
'*1*TRUE))
(EQUAL (GETSEG N (ADD1 K) L)
(CONS (GETNTH N L)
(GETSEG (ADD1 N) K L))))
((ENABLE GETNTH GETSEG LENGTH NON-ZERO-LENGTH-IMPLIES-LISTP)
(INDUCT (NUMBER-AND-LIST-INDUCTION N L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new formulas:
Case 3. (IMPLIES (AND (ZEROP N)
(NUMBERP N)
(NOT (LESSP (LENGTH L) (ADD1 N))))
(EQUAL (GETSEG N (ADD1 K) L)
(CONS (GETNTH N L)
(GETSEG (ADD1 N) K L)))),
which simplifies, using linear arithmetic, appealing to the lemmas SUB1-ADD1,
NON-ZERO-LENGTH-IMPLIES-LISTP, CAR-CONS, CDR-CONS, and CONS-EQUAL, and
opening up the functions ZEROP, NUMBERP, ADD1, GETNTH, EQUAL, and GETSEG, to
the formula:
(IMPLIES (AND (EQUAL N 0)
(NOT (LESSP (LENGTH L) 1))
(NOT (NUMBERP K)))
(EQUAL (GETSEG 1 0 L)
(GETSEG 1 K L))).
But this again simplifies, expanding the functions EQUAL and GETSEG, to:
T.
Case 2. (IMPLIES
(AND (NOT (EQUAL N 0))
(NUMBERP N)
(LISTP L)
(IMPLIES (AND (NUMBERP (SUB1 N))
(IF (LESSP (LENGTH (CDR L))
(ADD1 (SUB1 N)))
F T))
(EQUAL (GETSEG (SUB1 N) (ADD1 K) (CDR L))
(CONS (GETNTH (SUB1 N) (CDR L))
(GETSEG (ADD1 (SUB1 N)) K (CDR L)))))
(NOT (LESSP (LENGTH L) (ADD1 N))))
(EQUAL (GETSEG N (ADD1 K) L)
(CONS (GETNTH N L)
(GETSEG (ADD1 N) K L)))),
which simplifies, applying ADD1-SUB1, SUB1-ADD1, CAR-CONS, CDR-CONS, and
CONS-EQUAL, and expanding the functions AND, GETSEG, IMPLIES, LENGTH, LESSP,
and GETNTH, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(LISTP L)
(EQUAL (GETSEG N 0 (CDR L))
(GETSEG N K (CDR L)))
(NOT (LESSP (LENGTH (CDR L)) N))
(NOT (NUMBERP K)))
(EQUAL (GETSEG (ADD1 N) 0 L)
(GETSEG (ADD1 N) K L))),
which again simplifies, unfolding the functions EQUAL and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL N 0))
(NUMBERP N)
(NOT (LISTP L))
(NOT (LESSP (LENGTH L) (ADD1 N))))
(EQUAL (GETSEG N (ADD1 K) L)
(CONS (GETNTH N L)
(GETSEG (ADD1 N) K L)))),
which simplifies, using linear arithmetic and rewriting with
NON-ZERO-LENGTH-IMPLIES-LISTP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-LENGTH2
(DISABLE GETSEG-ADD1-LENGTH2)
[ 0.0 0.0 0.0 ]
GETSEG-ADD1-LENGTH2-OFF
(PROVE-LEMMA GETSEG-APPEND-RIGHT
(REWRITE)
(IMPLIES (IF (LESSP N (LENGTH A))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG (DIFFERENCE N (LENGTH A))
K B)))
((ENABLE GETSEG LENGTH GETNTH-APPEND-RIGHT DIFFERENCE-SUB1-ARG2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
Perhaps we can prove it by induction. Seven inductions are suggested by
terms in the conjecture. They merge into three likely candidate inductions,
two of which are unflawed. So we will choose the one suggested by the largest
number of nonprimitive recursive functions. We will induct according to the
following scheme:
(AND (IMPLIES (ZEROP K) (p N K A B))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) A B))
(p N K A B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT K) decreases according to the well-founded relation
LESSP in each induction step of the scheme. Note, however, the inductive
instance chosen for N. The above induction scheme generates the following
three new goals:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (LESSP N (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG (DIFFERENCE N (LENGTH A))
K B))).
This simplifies, unfolding the functions ZEROP, EQUAL, and GETSEG, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(LESSP (ADD1 N) (LENGTH A))
(NOT (LESSP N (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG (DIFFERENCE N (LENGTH A))
K B))).
This simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (DIFFERENCE (ADD1 N) (LENGTH A))
(SUB1 K)
B))
(NOT (LESSP N (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG (DIFFERENCE N (LENGTH A))
K B))).
This simplifies, rewriting with GETNTH-APPEND-RIGHT, CAR-CONS, CDR-CONS, and
CONS-EQUAL, and unfolding the functions ZEROP and GETSEG, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (DIFFERENCE (ADD1 N) (LENGTH A))
(SUB1 K)
B))
(NOT (LESSP N (LENGTH A))))
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (ADD1 (DIFFERENCE N (LENGTH A)))
(SUB1 K)
B))).
This further simplifies, applying the lemma SUB1-ADD1, and expanding
DIFFERENCE, LESSP, and EQUAL, to three new formulas:
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH A) 0))
(NUMBERP N)
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (DIFFERENCE N (SUB1 (LENGTH A)))
(SUB1 K)
B))
(NOT (LESSP N (LENGTH A))))
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (ADD1 (DIFFERENCE N (LENGTH A)))
(SUB1 K)
B))),
which again simplifies, applying DIFFERENCE-SUB1-ARG2, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (LENGTH A) 0)
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (ADD1 N) (SUB1 K) B))
(NOT (NUMBERP N)))
(EQUAL (GETSEG (ADD1 N) (SUB1 K) B)
(GETSEG 1 (SUB1 K) B))).
However this again simplifies, applying SUB1-TYPE-RESTRICTION, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (LENGTH A) 0)
(EQUAL (GETSEG (ADD1 N)
(SUB1 K)
(APPEND A B))
(GETSEG (ADD1 N) (SUB1 K) B))
(EQUAL N 0))
(EQUAL (GETSEG (ADD1 N) (SUB1 K) B)
(GETSEG 1 (SUB1 K) B))).
This again simplifies, trivially, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-APPEND-RIGHT
(DISABLE GETSEG-APPEND-RIGHT)
[ 0.0 0.0 0.0 ]
GETSEG-APPEND-RIGHT-OFF
(PROVE-LEMMA GETSEG-ACROSS-APPEND
(REWRITE)
(IMPLIES (AND (NUMBERP N)
(AND (IF (LESSP (LENGTH A) N)
'*1*FALSE
'*1*TRUE)
(IF (LESSP (PLUS N K) (LENGTH A))
'*1*FALSE
'*1*TRUE)))
(EQUAL (GETSEG N K (APPEND A B))
(APPEND (GETSEG N (DIFFERENCE (LENGTH A) N) A)
(GETSEG '0
(DIFFERENCE K
(DIFFERENCE (LENGTH A) N))
B))))
((ENABLE GETSEG APPEND GETNTH LENGTH APPEND-NIL-ON-RIGHT
APPEND-NON-LIST-LEFT-COROLLARY DIFFERENCE-X-X
DIFFERENCE-SUB1-ARG2 GETNTH-APPEND-FOR-LENGTH-LEFT
GETNTH-APPEND-LEFT GETSEG-ADD1-CONS GETSEG-APPEND-RIGHT
GETSEG-OF-LENGTH-ZERO PLISTP-GETSEG PLUS-0 PLUS-ADD1
PLUS-RIGHT-ID2 REWRITE-ZERO-DIFFERENCE-AS-EQUALITY)
(INDUCT (NUMBER-AND-LIST-INDUCTION K A))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new goals:
Case 3. (IMPLIES (AND (ZEROP K)
(NUMBERP N)
(NOT (LESSP (LENGTH A) N))
(NOT (LESSP (PLUS N K) (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(APPEND (GETSEG N (DIFFERENCE (LENGTH A) N) A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH A) N))
B)))),
which simplifies, applying PLUS-0, GETSEG-OF-LENGTH-ZERO,
GETSEG-APPEND-RIGHT, PLISTP-GETSEG, APPEND-NIL-ON-RIGHT, and PLUS-RIGHT-ID2,
and opening up ZEROP, EQUAL, and DIFFERENCE, to the following two new
formulas:
Case 3.2.
(IMPLIES (AND (EQUAL K 0)
(NUMBERP N)
(NOT (LESSP (LENGTH A) N))
(NOT (LESSP N (LENGTH A))))
(EQUAL NIL
(GETSEG N
(DIFFERENCE (LENGTH A) N)
A))).
However this again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NUMBERP (LENGTH A))
(NOT (LESSP (LENGTH A) (LENGTH A)))
(NOT (LESSP (LENGTH A) (LENGTH A))))
(EQUAL NIL
(GETSEG (LENGTH A)
(DIFFERENCE (LENGTH A) (LENGTH A))
A))).
But this again simplifies, rewriting with the lemmas DIFFERENCE-X-X and
GETSEG-OF-LENGTH-ZERO, and unfolding ZEROP and EQUAL, to:
T.
Case 3.1.
(IMPLIES (AND (NOT (NUMBERP K))
(NUMBERP N)
(NOT (LESSP (LENGTH A) N))
(NOT (LESSP N (LENGTH A))))
(EQUAL NIL
(GETSEG N
(DIFFERENCE (LENGTH A) N)
A))),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (NOT (NUMBERP K))
(NUMBERP (LENGTH A))
(NOT (LESSP (LENGTH A) (LENGTH A)))
(NOT (LESSP (LENGTH A) (LENGTH A))))
(EQUAL NIL
(GETSEG (LENGTH A)
(DIFFERENCE (LENGTH A) (LENGTH A))
A))).
This again simplifies, rewriting with the lemmas DIFFERENCE-X-X and
GETSEG-OF-LENGTH-ZERO, and unfolding ZEROP and EQUAL, to:
T.
Case 2. (IMPLIES
(AND
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(IMPLIES
(AND (NUMBERP N)
(IF (LESSP (LENGTH (CDR A)) N) F T)
(IF (LESSP (PLUS N (SUB1 K))
(LENGTH (CDR A)))
F T))
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K)
(DIFFERENCE (LENGTH (CDR A)) N))
B))))
(NUMBERP N)
(NOT (LESSP (LENGTH A) N))
(NOT (LESSP (PLUS N K) (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(APPEND (GETSEG N (DIFFERENCE (LENGTH A) N) A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH A) N))
B)))),
which simplifies, rewriting with the lemmas SUB1-ADD1, CDR-CONS, and
CAR-CONS, and opening up AND, IMPLIES, LENGTH, LESSP, EQUAL, PLUS, APPEND,
DIFFERENCE, ADD1, GETNTH, and GETSEG, to nine new conjectures:
Case 2.9.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A)) N)
(NUMBERP N)
(EQUAL N 0)
(NOT (LESSP (SUB1 K) (LENGTH (CDR A)))))
(EQUAL (GETSEG 0 K
(CONS (CAR A) (APPEND (CDR A) B)))
(CONS (CAR A)
(APPEND (GETSEG 1 (LENGTH (CDR A)) A)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.8.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A)) N)
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(NOT (EQUAL N 0)))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH (CDR A))
(SUB1 N)))
B)))),
which again simplifies, using linear arithmetic, to:
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A))
(PLUS 1 (LENGTH (CDR A))))
(NUMBERP (PLUS 1 (LENGTH (CDR A))))
(NOT (LESSP (LENGTH (CDR A))
(SUB1 (PLUS 1 (LENGTH (CDR A))))))
(NOT (EQUAL (PLUS (PLUS 1 (LENGTH (CDR A))) K)
0))
(NOT (LESSP (SUB1 (PLUS (PLUS 1 (LENGTH (CDR A))) K))
(LENGTH (CDR A))))
(NOT (EQUAL (PLUS 1 (LENGTH (CDR A))) 0)))
(EQUAL
(GETSEG (PLUS 1 (LENGTH (CDR A)))
K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND
(GETSEG (PLUS 1 (LENGTH (CDR A)))
(DIFFERENCE (LENGTH (CDR A))
(SUB1 (PLUS 1 (LENGTH (CDR A)))))
A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH (CDR A))
(SUB1 (PLUS 1 (LENGTH (CDR A))))))
B)))).
But this again simplifies, rewriting with the lemmas SUB1-ADD1,
APPEND-NON-LIST-LEFT-COROLLARY, GETSEG-ADD1-CONS, GETSEG-OF-LENGTH-ZERO,
DIFFERENCE-X-X, and GETSEG-APPEND-RIGHT, and opening up the functions SUB1,
NUMBERP, EQUAL, PLUS, LESSP, DIFFERENCE, ZEROP, LENGTH, and LISTP, to:
T.
Case 2.7.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A)) N)
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(EQUAL N 0))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N (ADD1 (LENGTH (CDR A))) A)
(GETSEG 0
(DIFFERENCE K (ADD1 (LENGTH (CDR A))))
B)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.6.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (PLUS N (SUB1 K))
(LENGTH (CDR A)))
(NUMBERP N)
(EQUAL N 0)
(NOT (LESSP (SUB1 K) (LENGTH (CDR A)))))
(EQUAL (GETSEG 0 K
(CONS (CAR A) (APPEND (CDR A) B)))
(CONS (CAR A)
(APPEND (GETSEG 1 (LENGTH (CDR A)) A)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.5.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (PLUS N (SUB1 K))
(LENGTH (CDR A)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(NOT (EQUAL N 0)))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH (CDR A))
(SUB1 N)))
B)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.4.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (PLUS N (SUB1 K))
(LENGTH (CDR A)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(EQUAL N 0))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N (ADD1 (LENGTH (CDR A))) A)
(GETSEG 0
(DIFFERENCE K (ADD1 (LENGTH (CDR A))))
B)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.3.
(IMPLIES
(AND
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K)
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(EQUAL N 0)
(NOT (LESSP (SUB1 K) (LENGTH (CDR A)))))
(EQUAL (GETSEG 0 K
(CONS (CAR A) (APPEND (CDR A) B)))
(CONS (CAR A)
(APPEND (GETSEG 1 (LENGTH (CDR A)) A)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B))))),
which again simplifies, rewriting with APPEND-NON-LIST-LEFT-COROLLARY and
GETSEG-OF-LENGTH-ZERO, and unfolding EQUAL, DIFFERENCE, NUMBERP, LESSP,
ZEROP, LENGTH, and LISTP, to the following three new goals:
Case 2.3.3.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(NOT (EQUAL (LENGTH (CDR A)) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 (LENGTH (CDR A)) (CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B)))
(NOT (LESSP (SUB1 K) (LENGTH (CDR A)))))
(EQUAL
(GETSEG 0 K
(CONS (CAR A) (APPEND (CDR A) B)))
(CONS (CAR A)
(APPEND (GETSEG 1 (LENGTH (CDR A)) A)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B))))).
Appealing to the lemma CAR-CDR-ELIM, we now replace A by (CONS Z X) to
eliminate (CDR A) and (CAR A). The result is the goal:
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B)))
(NOT (LESSP (SUB1 K) (LENGTH X))))
(EQUAL (GETSEG 0 K (CONS Z (APPEND X B)))
(CONS Z
(APPEND (GETSEG 1 (LENGTH X) (CONS Z X))
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B))))).
But this further simplifies, applying GETSEG-ADD1-CONS, to the new goal:
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B)))
(NOT (LESSP (SUB1 K) (LENGTH X))))
(EQUAL (GETSEG 0 K (CONS Z (APPEND X B)))
(CONS Z
(GETSEG 0 (SUB1 K) (APPEND X B))))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 V) to eliminate
(SUB1 K). We employ the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. This produces the new
conjecture:
(IMPLIES (AND (NUMBERP V)
(NOT (EQUAL (ADD1 V) 0))
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 V (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE V (LENGTH X))
B)))
(NOT (LESSP V (LENGTH X))))
(EQUAL (GETSEG 0
(ADD1 V)
(CONS Z (APPEND X B)))
(CONS Z (GETSEG 0 V (APPEND X B))))),
which finally simplifies, rewriting with SUB1-ADD1, CAR-CONS, and
GETSEG-ADD1-CONS, and unfolding ADD1, GETNTH, EQUAL, and GETSEG, to:
T.
Case 2.3.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 0 (CDR A))
(GETSEG 0 (DIFFERENCE (SUB1 K) 0) B)))
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A)
(GETSEG 0 (SUB1 K) B)))).
However this again simplifies, applying APPEND-NON-LIST-LEFT-COROLLARY
and GETSEG-OF-LENGTH-ZERO, and expanding the definitions of ZEROP, EQUAL,
DIFFERENCE, LENGTH, and LISTP, to the new goal:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A)
(GETSEG 0 (SUB1 K) B)))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS Z X) to eliminate
(CDR A) and (CAR A). This produces the new goal:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (LENGTH X) 0)
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS Z B))
(CONS Z (GETSEG 0 (SUB1 K) B)))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 V) to eliminate
(SUB1 K). We rely upon the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. We thus obtain:
(IMPLIES (AND (NUMBERP V)
(NOT (EQUAL (ADD1 V) 0))
(EQUAL (LENGTH X) 0)
(NOT (EQUAL V 0)))
(EQUAL (GETSEG 0 (ADD1 V) (CONS Z B))
(CONS Z (GETSEG 0 V B)))),
which finally simplifies, applying the lemmas SUB1-ADD1, CAR-CONS, and
GETSEG-ADD1-CONS, and opening up the definitions of ADD1, GETNTH, EQUAL,
and GETSEG, to:
T.
Case 2.3.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 0 (CDR A))
(GETSEG 0 (DIFFERENCE (SUB1 K) 0) B)))
(EQUAL (SUB1 K) 0))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A) (GETSEG 0 0 B)))),
which again simplifies, rewriting with APPEND-NON-LIST-LEFT-COROLLARY,
GETSEG-OF-LENGTH-ZERO, and CAR-CONS, and opening up the functions ZEROP,
DIFFERENCE, APPEND, EQUAL, ADD1, GETNTH, and GETSEG, to:
T.
Case 2.2.
(IMPLIES
(AND
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K)
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(NOT (EQUAL N 0)))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH (CDR A))
(SUB1 N)))
B)))).
Appealing to the lemma SUB1-ELIM, we now replace K by (ADD1 X) to
eliminate (SUB1 K). We employ the type restriction lemma noted when SUB1
was introduced to constrain the new variable. The result is:
(IMPLIES
(AND
(NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(LISTP A)
(EQUAL (GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N (ADD1 X)) 0))
(NOT (LESSP (SUB1 (PLUS N (ADD1 X)))
(LENGTH (CDR A))))
(NOT (EQUAL N 0)))
(EQUAL (GETSEG N
(ADD1 X)
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0
(DIFFERENCE (ADD1 X)
(DIFFERENCE (LENGTH (CDR A))
(SUB1 N)))
B)))).
However this further simplifies, appealing to the lemmas PLUS-ADD1,
SUB1-ADD1, CDR-CONS, GETSEG-ADD1-CONS, and
REWRITE-ZERO-DIFFERENCE-AS-EQUALITY, and expanding the definitions of
GETNTH, GETSEG, and DIFFERENCE, to two new goals:
Case 2.2.2.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL
(GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (LESSP (PLUS N X) (LENGTH (CDR A))))
(NOT (EQUAL N 0))
(NOT (EQUAL (LENGTH (CDR A)) (SUB1 N))))
(EQUAL
(CONS (GETNTH (SUB1 N) (APPEND (CDR A) B))
(GETSEG N X (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0
(DIFFERENCE X
(SUB1 (DIFFERENCE (LENGTH (CDR A))
(SUB1 N))))
B)))),
which again simplifies, using linear arithmetic, appealing to the lemmas
GETNTH-APPEND-LEFT, DIFFERENCE-SUB1-ARG2, SUB1-ADD1, CDR-CONS, CAR-CONS,
and CONS-EQUAL, and unfolding the definitions of GETSEG and APPEND, to
two new conjectures:
Case 2.2.2.2.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL
(GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (LESSP (PLUS N X) (LENGTH (CDR A))))
(NOT (EQUAL N 0))
(NOT (EQUAL (LENGTH (CDR A)) (SUB1 N))))
(EQUAL (GETNTH (SUB1 N) (CDR A))
(GETNTH N A))),
which again simplifies, opening up the function GETNTH, to:
T.
Case 2.2.2.1.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL
(GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (LESSP (PLUS N X) (LENGTH (CDR A))))
(NOT (EQUAL N 0))
(NOT (EQUAL (LENGTH (CDR A)) (SUB1 N))))
(EQUAL
(GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG (ADD1 N)
(DIFFERENCE (LENGTH (CDR A)) N)
A)
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS V Z) to eliminate
(CDR A) and (CAR A). This produces:
(IMPLIES
(AND
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(APPEND (GETSEG N (DIFFERENCE (LENGTH Z) N) Z)
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH Z) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH Z) (SUB1 N)))
(NOT (LESSP (PLUS N X) (LENGTH Z)))
(NOT (EQUAL N 0))
(NOT (EQUAL (LENGTH Z) (SUB1 N))))
(EQUAL (GETSEG N X (APPEND Z B))
(APPEND (GETSEG (ADD1 N)
(DIFFERENCE (LENGTH Z) N)
(CONS V Z))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH Z) N))
B)))),
which finally simplifies, rewriting with the lemma GETSEG-ADD1-CONS,
to:
T.
Case 2.2.1.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL
(GETSEG N X (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (LESSP (PLUS N X) (LENGTH (CDR A))))
(NOT (EQUAL N 0))
(EQUAL (LENGTH (CDR A)) (SUB1 N)))
(EQUAL (CONS (GETNTH (SUB1 N) (APPEND (CDR A) B))
(GETSEG N X (APPEND (CDR A) B)))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) (SUB1 N))
A)
(GETSEG 0 (ADD1 X) B)))),
which again simplifies, using linear arithmetic, applying the lemmas
DIFFERENCE-X-X, DIFFERENCE-SUB1-ARG2, GETSEG-APPEND-RIGHT,
GETSEG-OF-LENGTH-ZERO, SUB1-ADD1, APPEND-NON-LIST-LEFT-COROLLARY,
CAR-CONS, and CONS-EQUAL, and expanding the definitions of ADD1, ZEROP,
GETNTH, EQUAL, GETSEG, LENGTH, and LISTP, to two new conjectures:
Case 2.2.1.2.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL (GETSEG 1 X B)
(APPEND (GETSEG N
(DIFFERENCE (SUB1 N) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X (DIFFERENCE (SUB1 N) N))
B)))
(NUMBERP N)
(NOT (LESSP (SUB1 N) (SUB1 N)))
(NOT (LESSP (PLUS N X) (SUB1 N)))
(NOT (EQUAL N 0))
(EQUAL (LENGTH (CDR A)) (SUB1 N))
(NOT (LISTP B)))
(EQUAL (GETNTH (SUB1 N) (APPEND (CDR A) B))
0)).
Applying the lemma SUB1-ELIM, replace N by (ADD1 Z) to eliminate
(SUB1 N). We rely upon the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. We thus obtain the new
formula:
(IMPLIES
(AND
(NUMBERP Z)
(NUMBERP X)
(LISTP A)
(EQUAL (GETSEG 1 X B)
(APPEND (GETSEG (ADD1 Z)
(DIFFERENCE Z (ADD1 Z))
(CDR A))
(GETSEG 0
(DIFFERENCE X (DIFFERENCE Z (ADD1 Z)))
B)))
(NOT (LESSP Z Z))
(NOT (LESSP (PLUS (ADD1 Z) X) Z))
(NOT (EQUAL (ADD1 Z) 0))
(EQUAL (LENGTH (CDR A)) Z)
(NOT (LISTP B)))
(EQUAL (GETNTH Z (APPEND (CDR A) B))
0)),
which finally simplifies, applying the lemmas SUB1-ADD1,
GETNTH-APPEND-FOR-LENGTH-LEFT, and APPEND-NON-LIST-LEFT-COROLLARY, and
opening up DIFFERENCE, PLUS, LESSP, EQUAL, ADD1, and GETNTH, to:
T.
Case 2.2.1.1.
(IMPLIES
(AND
(NUMBERP X)
(LISTP A)
(EQUAL (GETSEG 1 X B)
(APPEND (GETSEG N
(DIFFERENCE (SUB1 N) N)
(CDR A))
(GETSEG 0
(DIFFERENCE X (DIFFERENCE (SUB1 N) N))
B)))
(NUMBERP N)
(NOT (LESSP (SUB1 N) (SUB1 N)))
(NOT (LESSP (PLUS N X) (SUB1 N)))
(NOT (EQUAL N 0))
(EQUAL (LENGTH (CDR A)) (SUB1 N))
(LISTP B))
(EQUAL (GETNTH (SUB1 N) (APPEND (CDR A) B))
(CAR B))).
Applying the lemma SUB1-ELIM, replace N by (ADD1 Z) to eliminate
(SUB1 N). We use the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. This produces:
(IMPLIES
(AND
(NUMBERP Z)
(NUMBERP X)
(LISTP A)
(EQUAL (GETSEG 1 X B)
(APPEND (GETSEG (ADD1 Z)
(DIFFERENCE Z (ADD1 Z))
(CDR A))
(GETSEG 0
(DIFFERENCE X (DIFFERENCE Z (ADD1 Z)))
B)))
(NOT (LESSP Z Z))
(NOT (LESSP (PLUS (ADD1 Z) X) Z))
(NOT (EQUAL (ADD1 Z) 0))
(EQUAL (LENGTH (CDR A)) Z)
(LISTP B))
(EQUAL (GETNTH Z (APPEND (CDR A) B))
(CAR B))),
which finally simplifies, applying SUB1-ADD1,
GETNTH-APPEND-FOR-LENGTH-LEFT, and APPEND-NON-LIST-LEFT-COROLLARY, and
unfolding DIFFERENCE, PLUS, LESSP, ADD1, EQUAL, and GETNTH, to:
T.
Case 2.1.
(IMPLIES
(AND
(NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG N
(DIFFERENCE (LENGTH (CDR A)) N)
(CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K)
(DIFFERENCE (LENGTH (CDR A)) N))
B)))
(NUMBERP N)
(NOT (LESSP (LENGTH (CDR A)) (SUB1 N)))
(NOT (EQUAL (PLUS N K) 0))
(NOT (LESSP (SUB1 (PLUS N K))
(LENGTH (CDR A))))
(EQUAL N 0))
(EQUAL (GETSEG N K
(CONS (CAR A) (APPEND (CDR A) B)))
(APPEND (GETSEG N (ADD1 (LENGTH (CDR A))) A)
(GETSEG 0
(DIFFERENCE K (ADD1 (LENGTH (CDR A))))
B)))).
This again simplifies, applying the lemmas SUB1-ADD1, CDR-CONS, CAR-CONS,
APPEND-NON-LIST-LEFT-COROLLARY, and GETSEG-OF-LENGTH-ZERO, and unfolding
the definitions of EQUAL, DIFFERENCE, NUMBERP, SUB1, LESSP, PLUS, ADD1,
GETNTH, GETSEG, APPEND, ZEROP, LISTP, and LENGTH, to three new goals:
Case 2.1.3.
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(NOT (EQUAL (LENGTH (CDR A)) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 (LENGTH (CDR A)) (CDR A))
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B)))
(NOT (LESSP (SUB1 K) (LENGTH (CDR A)))))
(EQUAL
(GETSEG 0 K
(CONS (CAR A) (APPEND (CDR A) B)))
(CONS (CAR A)
(APPEND (GETSEG 1 (LENGTH (CDR A)) A)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH (CDR A)))
B))))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS Z X) to eliminate
(CDR A) and (CAR A). This produces the new goal:
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B)))
(NOT (LESSP (SUB1 K) (LENGTH X))))
(EQUAL (GETSEG 0 K (CONS Z (APPEND X B)))
(CONS Z
(APPEND (GETSEG 1 (LENGTH X) (CONS Z X))
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B))))),
which further simplifies, rewriting with GETSEG-ADD1-CONS, to:
(IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 (SUB1 K) (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE (SUB1 K) (LENGTH X))
B)))
(NOT (LESSP (SUB1 K) (LENGTH X))))
(EQUAL (GETSEG 0 K (CONS Z (APPEND X B)))
(CONS Z
(GETSEG 0 (SUB1 K) (APPEND X B))))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 V) to eliminate
(SUB1 K). We use the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. We would thus like to prove:
(IMPLIES (AND (NUMBERP V)
(NOT (EQUAL (ADD1 V) 0))
(NOT (EQUAL (LENGTH X) 0))
(EQUAL (GETSEG 0 V (APPEND X B))
(APPEND (GETSEG 0 (LENGTH X) X)
(GETSEG 0
(DIFFERENCE V (LENGTH X))
B)))
(NOT (LESSP V (LENGTH X))))
(EQUAL (GETSEG 0
(ADD1 V)
(CONS Z (APPEND X B)))
(CONS Z (GETSEG 0 V (APPEND X B))))),
which finally simplifies, applying the lemmas SUB1-ADD1, CAR-CONS, and
GETSEG-ADD1-CONS, and expanding ADD1, GETNTH, EQUAL, and GETSEG, to:
T.
Case 2.1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 0 (CDR A))
(GETSEG 0 (DIFFERENCE (SUB1 K) 0) B)))
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A)
(GETSEG 0 (SUB1 K) B)))),
which again simplifies, rewriting with APPEND-NON-LIST-LEFT-COROLLARY
and GETSEG-OF-LENGTH-ZERO, and expanding ZEROP, EQUAL, DIFFERENCE,
LENGTH, and LISTP, to the new formula:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A)
(GETSEG 0 (SUB1 K) B)))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS Z X) to eliminate
(CDR A) and (CAR A). This produces:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (LENGTH X) 0)
(NOT (EQUAL (SUB1 K) 0)))
(EQUAL (GETSEG 0 K (CONS Z B))
(CONS Z (GETSEG 0 (SUB1 K) B)))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 V) to eliminate
(SUB1 K). We use the type restriction lemma noted when SUB1 was
introduced to restrict the new variable. This produces the new formula:
(IMPLIES (AND (NUMBERP V)
(NOT (EQUAL (ADD1 V) 0))
(EQUAL (LENGTH X) 0)
(NOT (EQUAL V 0)))
(EQUAL (GETSEG 0 (ADD1 V) (CONS Z B))
(CONS Z (GETSEG 0 V B)))),
which finally simplifies, rewriting with SUB1-ADD1, CAR-CONS, and
GETSEG-ADD1-CONS, and expanding the definitions of ADD1, GETNTH, EQUAL,
and GETSEG, to:
T.
Case 2.1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (LENGTH (CDR A)) 0)
(EQUAL (GETSEG 0 (SUB1 K) (APPEND (CDR A) B))
(APPEND (GETSEG 0 0 (CDR A))
(GETSEG 0 (DIFFERENCE (SUB1 K) 0) B)))
(EQUAL (SUB1 K) 0))
(EQUAL (GETSEG 0 K (CONS (CAR A) B))
(CONS (CAR A) (GETSEG 0 0 B)))).
However this again simplifies, applying APPEND-NON-LIST-LEFT-COROLLARY,
GETSEG-OF-LENGTH-ZERO, and CAR-CONS, and unfolding ZEROP, DIFFERENCE,
APPEND, EQUAL, ADD1, GETNTH, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (LISTP A))
(NUMBERP N)
(NOT (LESSP (LENGTH A) N))
(NOT (LESSP (PLUS N K) (LENGTH A))))
(EQUAL (GETSEG N K (APPEND A B))
(APPEND (GETSEG N (DIFFERENCE (LENGTH A) N) A)
(GETSEG 0
(DIFFERENCE K
(DIFFERENCE (LENGTH A) N))
B)))).
This simplifies, rewriting with APPEND-NON-LIST-LEFT-COROLLARY and
GETSEG-OF-LENGTH-ZERO, and opening up the functions LENGTH, EQUAL, LESSP,
PLUS, DIFFERENCE, ZEROP, and LISTP, to:
T.
Q.E.D.
[ 0.0 0.5 0.1 ]
GETSEG-ACROSS-APPEND
(DISABLE GETSEG-ACROSS-APPEND)
[ 0.0 0.0 0.0 ]
GETSEG-ACROSS-APPEND-OFF
(PROVE-LEMMA GETSEG-APPEND-LEFT
(REWRITE)
(IMPLIES (IF (LESSP (LENGTH A) (PLUS N K))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A)))
((ENABLE GETSEG LENGTH GETNTH-APPEND-LEFT)
(DISABLE APPEND)
(INDUCT (NUMBER-AND-LIST-INDUCTION K A))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new formulas:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (LESSP (LENGTH A) (PLUS N K))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which simplifies, expanding ZEROP, EQUAL, and GETSEG, to:
T.
Case 2. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(IMPLIES (IF (LESSP (LENGTH (CDR A))
(PLUS N (SUB1 K)))
F T)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(GETSEG N (SUB1 K) (CDR A))))
(NOT (LESSP (LENGTH A) (PLUS N K))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which simplifies, applying the lemma SUB1-ADD1, and opening up the
definitions of IMPLIES, LENGTH, and LESSP, to four new formulas:
Case 2.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A))
(PLUS N (SUB1 K)))
(EQUAL (PLUS N K) 0))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(LESSP (LENGTH (CDR A))
(PLUS N (SUB1 K)))
(NOT (LESSP (LENGTH (CDR A))
(SUB1 (PLUS N K)))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(GETSEG N (SUB1 K) (CDR A)))
(EQUAL (PLUS N K) 0))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP A)
(EQUAL (GETSEG N (SUB1 K) (APPEND (CDR A) B))
(GETSEG N (SUB1 K) (CDR A)))
(NOT (LESSP (LENGTH (CDR A))
(SUB1 (PLUS N K)))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 X) to eliminate (SUB1 K).
We rely upon the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. We would thus like to prove:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(LISTP A)
(EQUAL (GETSEG N X (APPEND (CDR A) B))
(GETSEG N X (CDR A)))
(NOT (LESSP (LENGTH (CDR A))
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG N (ADD1 X) (APPEND A B))
(GETSEG N (ADD1 X) A))),
which further simplifies, using linear arithmetic, applying SUB1-ADD1,
GETNTH-APPEND-LEFT, CAR-CONS, CDR-CONS, and CONS-EQUAL, and expanding the
definitions of LENGTH and GETSEG, to:
(IMPLIES (AND (NUMBERP X)
(LISTP A)
(EQUAL (GETSEG N X (APPEND (CDR A) B))
(GETSEG N X (CDR A)))
(NOT (LESSP (LENGTH (CDR A))
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N) X (APPEND A B))
(GETSEG (ADD1 N) X A))).
Applying the lemma CAR-CDR-ELIM, replace A by (CONS V Z) to eliminate
(CDR A) and (CAR A). We thus obtain:
(IMPLIES (AND (NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which we will name *1.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (LISTP A))
(NOT (LESSP (LENGTH A) (PLUS N K))))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))).
This simplifies, unfolding LENGTH, EQUAL, and LESSP, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (LISTP A))
(EQUAL (PLUS N K) 0))
(EQUAL (GETSEG N K (APPEND A B))
(GETSEG N K A))),
which again simplifies, using linear arithmetic, to:
T.
So we now return to:
(IMPLIES (AND (NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which we named *1 above. We will try to prove it by induction. There are
five plausible inductions. They merge into two likely candidate inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP X) (p N X V Z B))
(IMPLIES (AND (NOT (ZEROP X))
(p (ADD1 N) (SUB1 X) V Z B))
(p N X V Z B))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to show that the measure (COUNT X) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for N. The above induction scheme
produces the following four new conjectures:
Case 4. (IMPLIES (AND (ZEROP X)
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))).
This simplifies, expanding the definitions of ZEROP, NUMBERP, EQUAL, GETSEG,
and ADD1, to:
T.
Case 3. (IMPLIES (AND (NOT (ZEROP X))
(NOT (EQUAL (GETSEG (ADD1 N)
(SUB1 X)
(APPEND Z B))
(GETSEG (ADD1 N) (SUB1 X) Z)))
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))).
This simplifies, applying CAR-CONS and CONS-EQUAL, and expanding ZEROP and
GETSEG, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP X))
(LESSP (LENGTH Z)
(SUB1 (PLUS (ADD1 N) (ADD1 (SUB1 X)))))
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which simplifies, using linear arithmetic, to two new conjectures:
Case 2.2.
(IMPLIES (AND (EQUAL (PLUS (ADD1 N) (ADD1 (SUB1 X)))
0)
(NOT (ZEROP X))
(LESSP (LENGTH Z)
(SUB1 (PLUS (ADD1 N) (ADD1 (SUB1 X)))))
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (EQUAL X 0)
(NOT (ZEROP X))
(LESSP (LENGTH Z)
(SUB1 (PLUS (ADD1 N) (ADD1 (SUB1 X)))))
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which again simplifies, unfolding ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP X))
(EQUAL (GETSEG (ADD1 (ADD1 N))
(SUB1 X)
(APPEND (CONS V Z) B))
(GETSEG (ADD1 (ADD1 N))
(SUB1 X)
(CONS V Z)))
(NUMBERP X)
(EQUAL (GETSEG N X (APPEND Z B))
(GETSEG N X Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETSEG (ADD1 N)
X
(APPEND (CONS V Z) B))
(GETSEG (ADD1 N) X (CONS V Z)))),
which simplifies, rewriting with CAR-CONS and CONS-EQUAL, and unfolding the
definitions of ZEROP and GETSEG, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL X 0))
(EQUAL (GETSEG (ADD1 (ADD1 N))
(SUB1 X)
(APPEND (CONS V Z) B))
(GETSEG (ADD1 (ADD1 N))
(SUB1 X)
(CONS V Z)))
(NUMBERP X)
(EQUAL (GETNTH N (APPEND Z B))
(GETNTH N Z))
(EQUAL (GETSEG (ADD1 N)
(SUB1 X)
(APPEND Z B))
(GETSEG (ADD1 N) (SUB1 X) Z))
(NOT (LESSP (LENGTH Z)
(SUB1 (PLUS N (ADD1 X))))))
(EQUAL (GETNTH (ADD1 N)
(APPEND (CONS V Z) B))
(GETNTH (ADD1 N) (CONS V Z)))),
which again simplifies, using linear arithmetic, applying GETNTH-APPEND-LEFT
and CDR-CONS, and unfolding the function LENGTH, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.0 ]
GETSEG-APPEND-LEFT
(DISABLE GETSEG-APPEND-LEFT)
[ 0.0 0.0 0.0 ]
GETSEG-APPEND-LEFT-OFF
(PROVE-LEMMA GETSEG-AFTER-PUTNTH
(REWRITE)
(IMPLIES (LESSP N I)
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L)))
((ENABLE GETSEG GETNTH-PUTNTH-CASESPLIT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Call the conjecture *1.
We will appeal to induction. There are two plausible inductions.
However, they merge into one likely candidate induction. We will induct
according to the following scheme:
(AND (IMPLIES (ZEROP K) (p I K V N L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 I) (SUB1 K) V N L))
(p I K V N L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP can be
used to establish that the measure (COUNT K) decreases according to the
well-founded relation LESSP in each induction step of the scheme. Note,
however, the inductive instance chosen for I. The above induction scheme
generates three new formulas:
Case 3. (IMPLIES (AND (ZEROP K) (LESSP N I))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which simplifies, expanding the definitions of ZEROP, EQUAL, and GETSEG, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(NOT (LESSP N (ADD1 I)))
(LESSP N I))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(LESSP N I))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which simplifies, rewriting with GETNTH-PUTNTH-CASESPLIT, CAR-CONS, and
CONS-EQUAL, and expanding the functions ZEROP and GETSEG, to the following
four new conjectures:
Case 1.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(LESSP N I)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL V (GETNTH I L))).
However this again simplifies, applying SUB1-TYPE-RESTRICTION, and
expanding the function LESSP, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(LESSP N I)
(LESSP I (LENGTH L))
(NUMBERP I)
(NUMBERP N)
(EQUAL I N))
(EQUAL V (GETNTH I L))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(LESSP N I)
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(LESSP N I)
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (NUMBERP N)))
(EQUAL V (GETNTH I L))),
which again simplifies, opening up LESSP, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-AFTER-PUTNTH
(DISABLE GETSEG-AFTER-PUTNTH)
[ 0.0 0.0 0.0 ]
GETSEG-AFTER-PUTNTH-OFF
(PROVE-LEMMA GETSEG-BEFORE-PUTNTH
(REWRITE)
(IMPLIES (IF (LESSP N (PLUS I K))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L)))
((ENABLE GETSEG GETNTH-PUTNTH-CASESPLIT)
(INDUCT (GETSEG I K L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to two new goals:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which simplifies, expanding ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (IF (LESSP N (PLUS (ADD1 I) (SUB1 K)))
F T)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which simplifies, applying SUB1-ADD1, GETNTH-PUTNTH-CASESPLIT, CAR-CONS, and
CONS-EQUAL, and expanding PLUS, LESSP, IMPLIES, EQUAL, and GETSEG, to the
following 12 new conjectures:
Case 1.12.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL (PLUS I K) 0))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.11.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (PLUS I K) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP I)))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.10.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (PLUS I K) 0)
(LESSP I (LENGTH L))
(EQUAL I 0))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.9.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (PLUS I K) 0))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.8.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 N) (PLUS 0 (SUB1 K)))
(NOT (LESSP N K)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(GETSEG I K L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.7.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) (PLUS I (SUB1 K)))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.6.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) (PLUS I (SUB1 K)))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) (PLUS I (SUB1 K)))
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(EQUAL 0 N))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NUMBERP I)
(NUMBERP N)
(EQUAL I N))
(EQUAL V (GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL V (GETNTH I L))),
which again simplifies, opening up the definitions of EQUAL, PLUS, and
LESSP, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(GETSEG (ADD1 I) (SUB1 K) L))
(NOT (LESSP N (PLUS I K)))
(LESSP I (LENGTH L))
(NOT (NUMBERP I))
(NOT (NUMBERP N)))
(EQUAL V (GETNTH I L))),
which again simplifies, rewriting with the lemma SUB1-TYPE-RESTRICTION,
and opening up the functions PLUS and LESSP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-BEFORE-PUTNTH
(DISABLE GETSEG-BEFORE-PUTNTH)
[ 0.0 0.0 0.0 ]
GETSEG-BEFORE-PUTNTH-OFF
(PROVE-LEMMA GETSEG-PUTNTH-COINCIDENCE
(REWRITE)
(IMPLIES (AND (IF (LESSP N I) '*1*FALSE '*1*TRUE)
(AND (LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V
(DIFFERENCE N I)
(GETSEG I K L))))
((ENABLE GETSEG LENGTH DIFFERENCE-SUB1-ARG1
GETNTH-PUTNTH-CASESPLIT GETSEG-OF-LENGTH-ZERO
GETSEG-AFTER-PUTNTH OPEN-PUTNTH-CASESPLIT
PUTNTH-WITH-NON-NUMBER-INDEX)
(INDUCT (GETSEG I K L))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following two new goals:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V
(DIFFERENCE N I)
(GETSEG I K L)))).
This simplifies, expanding the functions ZEROP, EQUAL, and LESSP, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (AND (IF (LESSP N (ADD1 I)) F T)
(LESSP (DIFFERENCE N (ADD1 I))
(SUB1 K))
(LESSP N (LENGTH L)))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE N (ADD1 I))
(GETSEG (ADD1 I) (SUB1 K) L))))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V
(DIFFERENCE N I)
(GETSEG I K L)))).
This simplifies, rewriting with SUB1-ADD1, PUTNTH-WITH-NON-NUMBER-INDEX,
GETNTH-PUTNTH-CASESPLIT, GETSEG-AFTER-PUTNTH, OPEN-PUTNTH-CASESPLIT, and
CAR-CONS, and opening up the functions LESSP, DIFFERENCE, AND, IMPLIES,
EQUAL, and GETSEG, to 41 new goals:
Case 1.41.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL I 0)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which again simplifies, obviously, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which we will name *1.
Case 1.40.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))).
Call the above conjecture *2.
Case 1.39.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL I 0)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))).
This again simplifies, obviously, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which we will name *3.
Case 1.38.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))).
This again simplifies, clearly, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which we will name *4.
Case 1.37.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 N) 0)
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V N (GETSEG I K L)))).
This again simplifies, using linear arithmetic, to:
T.
Case 1.36.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 N) 0)
(EQUAL N 0)
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, unfolding the functions SUB1 and LESSP, to:
T.
Case 1.35.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 N) 0)
(NOT (NUMBERP N))
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, rewriting with the lemma SUB1-NNUMBERP, and
opening up LESSP, to:
T.
Case 1.34.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.33.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.32.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.31.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL (CONS V (GETSEG (ADD1 I) (SUB1 K) L))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.30.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CONS V (GETSEG (ADD1 I) (SUB1 K) L))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.29.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, applying SUB1-NNUMBERP, and expanding the
functions EQUAL and LESSP, to:
T.
Case 1.28.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.27.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) I)
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.26.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V N (GETSEG I K L)))),
which again simplifies, using linear arithmetic, to:
(IMPLIES (AND (LESSP (SUB1 N) 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V N (GETSEG I K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1.25.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(EQUAL N 0)
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, rewriting with GETSEG-OF-LENGTH-ZERO,
SUB1-TYPE-RESTRICTION, GETNTH-PUTNTH-CASESPLIT, and OPEN-PUTNTH-CASESPLIT,
and expanding the definitions of SUB1, DIFFERENCE, EQUAL, LESSP, ZEROP,
NUMBERP, and GETSEG, to:
T.
Case 1.24.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (NUMBERP N))
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))).
But this again simplifies, appealing to the lemmas SUB1-NNUMBERP,
GETSEG-OF-LENGTH-ZERO, SUB1-TYPE-RESTRICTION, GETNTH-PUTNTH-CASESPLIT, and
OPEN-PUTNTH-CASESPLIT, and expanding the functions DIFFERENCE, EQUAL,
LESSP, ZEROP, NUMBERP, and GETSEG, to:
T.
Case 1.23.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to two new conjectures:
Case 1.23.2.
(IMPLIES (AND (LESSP (SUB1 N) I)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.23.1.
(IMPLIES (AND (LESSP N 1)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.22.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to two new goals:
Case 1.22.2.
(IMPLIES (AND (LESSP (SUB1 N) I)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.22.1.
(IMPLIES (AND (EQUAL N 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.21.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to two new goals:
Case 1.21.2.
(IMPLIES (AND (LESSP (SUB1 N) I)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.21.1.
(IMPLIES (AND (LESSP N 1)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.20.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.19.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to two new goals:
Case 1.19.2.
(IMPLIES (AND (LESSP (SUB1 N) 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (LESSP N 0))
(LESSP (DIFFERENCE N 0) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N 0) 0))
(LESSP 0 (LENGTH L))
(NOT (NUMBERP N)))
(EQUAL (CONS V
(GETSEG 1 (SUB1 K) (PUTNTH V N L)))
(CONS (GETNTH 0 L)
(PUTNTH V
(SUB1 (DIFFERENCE N 0))
(GETSEG 1 (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.19.1.
(IMPLIES (AND (LESSP N 1)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (LESSP N 0))
(LESSP (DIFFERENCE N 0) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N 0) 0))
(LESSP 0 (LENGTH L))
(NOT (NUMBERP N)))
(EQUAL (CONS V
(GETSEG 1 (SUB1 K) (PUTNTH V N L)))
(CONS (GETNTH 0 L)
(PUTNTH V
(SUB1 (DIFFERENCE N 0))
(GETSEG 1 (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.18.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to two new formulas:
Case 1.18.2.
(IMPLIES (AND (LESSP (SUB1 N) I)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, applying the lemma SUB1-NNUMBERP, and opening up
the functions EQUAL, LESSP, and DIFFERENCE, to:
T.
Case 1.18.1.
(IMPLIES (AND (LESSP N 1)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.17.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to two new conjectures:
Case 1.17.2.
(IMPLIES (AND (LESSP (SUB1 N) I)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.17.1.
(IMPLIES (AND (EQUAL N 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.16.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.15.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to two new formulas:
Case 1.15.2.
(IMPLIES (AND (LESSP (SUB1 N) N)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 N) N)
(SUB1 K)))
(NOT (LESSP N N))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N N) 0)
(LESSP N (LENGTH L))
(NUMBERP N))
(EQUAL (CONS V
(GETSEG (ADD1 N)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 N) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, rewriting with the
lemma GETSEG-AFTER-PUTNTH, and opening up the definitions of EQUAL and
LESSP, to:
T.
Case 1.15.1.
(IMPLIES (AND (EQUAL N 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP N)
(NOT (LESSP (DIFFERENCE (SUB1 N) N)
(SUB1 K)))
(NOT (LESSP N N))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N N) 0)
(LESSP N (LENGTH L))
(NUMBERP N))
(EQUAL (CONS V
(GETSEG (ADD1 N)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 N) (SUB1 K) L)))),
which again simplifies, applying GETSEG-OF-LENGTH-ZERO and
GETSEG-AFTER-PUTNTH, and opening up NUMBERP, SUB1, DIFFERENCE, EQUAL,
LESSP, and ZEROP, to:
T.
Case 1.14.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(NOT (LESSP (DIFFERENCE (SUB1 N) I)
(SUB1 K)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))).
But this again simplifies, using linear arithmetic, to two new formulas:
Case 1.14.2.
(IMPLIES (AND (LESSP (SUB1 N) 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (LESSP N 0))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N 0) 0)
(LESSP 0 (LENGTH L))
(NOT (NUMBERP N)))
(EQUAL (CONS V
(GETSEG 1 (SUB1 K) (PUTNTH V N L)))
(CONS V (GETSEG 1 (SUB1 K) L)))),
which again simplifies, rewriting with SUB1-NNUMBERP, and unfolding
LESSP, to:
T.
Case 1.14.1.
(IMPLIES (AND (LESSP N 1)
(NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP 0)
(NOT (LESSP (DIFFERENCE (SUB1 N) 0)
(SUB1 K)))
(NOT (LESSP N 0))
(LESSP 0 K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N 0) 0)
(LESSP 0 (LENGTH L))
(NOT (NUMBERP N)))
(EQUAL (CONS V
(GETSEG 1 (SUB1 K) (PUTNTH V N L)))
(CONS V (GETSEG 1 (SUB1 K) L)))).
This again simplifies, applying SUB1-NNUMBERP,
PUTNTH-WITH-NON-NUMBER-INDEX, GETSEG-OF-LENGTH-ZERO, and
GETSEG-AFTER-PUTNTH, and expanding NUMBERP, EQUAL, LESSP, DIFFERENCE,
and ZEROP, to:
T.
Case 1.13.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) 0)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V N (GETSEG I K L)))).
However this again simplifies, using linear arithmetic, applying
SUB1-TYPE-RESTRICTION and DIFFERENCE-SUB1-ARG1, and opening up EQUAL and
DIFFERENCE, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 K) (PUTNTH V N L))
(PUTNTH V
(SUB1 N)
(GETSEG 1 (SUB1 K) L)))
(NOT (EQUAL N 0))
(NUMBERP N)
(LESSP N K)
(LESSP N (LENGTH L)))
(EQUAL (GETSEG I K (PUTNTH V N L))
(PUTNTH V N (GETSEG I K L)))),
which again simplifies, rewriting with SUB1-TYPE-RESTRICTION,
GETNTH-PUTNTH-CASESPLIT, and OPEN-PUTNTH-CASESPLIT, and unfolding LESSP
and GETSEG, to:
T.
Case 1.12.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) 0)
(GETSEG (ADD1 I) (SUB1 K) L)))
(EQUAL N 0)
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))).
But this again simplifies, rewriting with SUB1-TYPE-RESTRICTION and
GETSEG-AFTER-PUTNTH, and expanding LESSP, SUB1, DIFFERENCE, and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 K) L)
(PUTNTH V 0 (GETSEG 1 (SUB1 K) L)))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, applying SUB1-TYPE-RESTRICTION and
OPEN-PUTNTH-CASESPLIT, and opening up the functions GETSEG and EQUAL, to
the new conjecture:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 K) L)
(PUTNTH V 0 (GETSEG 1 (SUB1 K) L)))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(CONS V (GETSEG 1 (SUB1 K) L)))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 X) to eliminate (SUB1 K).
We employ the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. We thus obtain:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 X L)
(PUTNTH V 0 (GETSEG 1 X L)))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I (ADD1 X) (PUTNTH V 0 L))
(CONS V (GETSEG 1 X L)))),
which further simplifies, applying the lemmas SUB1-ADD1,
SUB1-TYPE-RESTRICTION, GETNTH-PUTNTH-CASESPLIT, and GETSEG-AFTER-PUTNTH,
and expanding EQUAL, NUMBERP, LESSP, and GETSEG, to:
T.
Case 1.11.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) 0)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (NUMBERP N))
(LESSP 0 K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, applying SUB1-TYPE-RESTRICTION,
PUTNTH-WITH-NON-NUMBER-INDEX, GETSEG-AFTER-PUTNTH, and SUB1-NNUMBERP, and
expanding LESSP, DIFFERENCE, and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 K) L)
(PUTNTH V 0 (GETSEG 1 (SUB1 K) L)))
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which again simplifies, rewriting with SUB1-TYPE-RESTRICTION and
OPEN-PUTNTH-CASESPLIT, and expanding GETSEG and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 K) L)
(PUTNTH V 0 (GETSEG 1 (SUB1 K) L)))
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(CONS V (GETSEG 1 (SUB1 K) L)))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 X) to eliminate (SUB1 K).
We rely upon the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. We would thus like to prove:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 X L)
(PUTNTH V 0 (GETSEG 1 X L)))
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I (ADD1 X) (PUTNTH V 0 L))
(CONS V (GETSEG 1 X L)))),
which further simplifies, applying SUB1-ADD1, SUB1-TYPE-RESTRICTION,
GETNTH-PUTNTH-CASESPLIT, and GETSEG-AFTER-PUTNTH, and expanding the
functions EQUAL, NUMBERP, LESSP, and GETSEG, to:
T.
Case 1.10.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))).
However this again simplifies, using linear arithmetic, rewriting with
PUTNTH-WITH-NON-NUMBER-INDEX, GETSEG-AFTER-PUTNTH, and SUB1-NNUMBERP, and
expanding EQUAL, DIFFERENCE, and LESSP, to:
T.
Case 1.9.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))).
However this again simplifies, using linear arithmetic and rewriting with
DIFFERENCE-SUB1-ARG1, to:
T.
Case 1.8.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))).
But this again simplifies, using linear arithmetic, to:
T.
Case 1.7.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.6.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(NOT (EQUAL (DIFFERENCE N I) 0))
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS (GETNTH I L)
(PUTNTH V
(SUB1 (DIFFERENCE N I))
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, rewriting with the lemmas
PUTNTH-WITH-NON-NUMBER-INDEX, GETSEG-AFTER-PUTNTH, and SUB1-NNUMBERP, and
unfolding the definitions of NUMBERP, LESSP, DIFFERENCE, and EQUAL, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (NUMBERP N))
(NOT (EQUAL I 0)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, applying
PUTNTH-WITH-NON-NUMBER-INDEX, GETSEG-AFTER-PUTNTH, and SUB1-NNUMBERP, and
opening up the functions EQUAL, DIFFERENCE, and LESSP, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NUMBERP N)
(NOT (EQUAL I N)))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))).
This again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(NOT (LESSP I (LENGTH L))))
(EQUAL (CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(LESSP I (LENGTH L))
(NUMBERP N)
(EQUAL I N))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))),
which again simplifies, using linear arithmetic, applying
GETSEG-AFTER-PUTNTH, and unfolding the functions EQUAL and LESSP, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L))
(PUTNTH V
(DIFFERENCE (SUB1 N) I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N I))
(LESSP (DIFFERENCE N I) K)
(LESSP N (LENGTH L))
(EQUAL (DIFFERENCE N I) 0)
(LESSP I (LENGTH L))
(NOT (NUMBERP N))
(EQUAL I 0))
(EQUAL (CONS V
(GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V N L)))
(CONS V
(GETSEG (ADD1 I) (SUB1 K) L)))).
This again simplifies, applying PUTNTH-WITH-NON-NUMBER-INDEX,
GETSEG-AFTER-PUTNTH, and SUB1-NNUMBERP, and expanding the definitions of
NUMBERP, LESSP, DIFFERENCE, and EQUAL, to:
T.
So we now return to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which is formula *4 above. This conjecture is subsumed by formula *2 above.
So we now return to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which we named *3 above. We will appeal to induction. There are two
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p K V L))
(IMPLIES (AND (NOT (ZEROP K)) (p (SUB1 K) V L))
(p K V L))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP inform
us that the measure (COUNT K) decreases according to the well-founded relation
LESSP in each induction step of the scheme. The above induction scheme leads
to the following three new goals:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))).
This simplifies, expanding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (SUB1 K) 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))).
This simplifies, applying GETNTH-PUTNTH-CASESPLIT, GETSEG-OF-LENGTH-ZERO,
GETSEG-AFTER-PUTNTH, and OPEN-PUTNTH-CASESPLIT, and expanding the
definitions of ZEROP, GETSEG, EQUAL, LESSP, NUMBERP, and ADD1, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (GETSEG 0 (SUB1 K) (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 (SUB1 K) L)))
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which simplifies, applying the lemmas GETNTH-PUTNTH-CASESPLIT,
GETSEG-AFTER-PUTNTH, and OPEN-PUTNTH-CASESPLIT, and expanding ZEROP, GETSEG,
EQUAL, LESSP, NUMBERP, and ADD1, to:
T.
That finishes the proof of *3.
So next consider:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which we named *2 above. We will try to prove it by induction. Two
inductions are suggested by terms in the conjecture. However, they merge into
one likely candidate induction. We will induct according to the following
scheme:
(AND (IMPLIES (ZEROP K) (p I K V L N))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 I) (SUB1 K) V L N))
(p I K V L N))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each induction step of the scheme. Note, however, the
inductive instance chosen for I. The above induction scheme leads to two new
formulas:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which simplifies, opening up ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG I K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG I K L)))),
which simplifies, applying GETNTH-PUTNTH-CASESPLIT, OPEN-PUTNTH-CASESPLIT,
CAR-CONS, CDR-CONS, and CONS-EQUAL, and unfolding the definitions of ZEROP,
GETSEG, LESSP, NUMBERP, and EQUAL, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTNTH V 0 L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which further simplifies, rewriting with SUB1-TYPE-RESTRICTION and
GETSEG-AFTER-PUTNTH, and opening up LESSP, to:
T.
That finishes the proof of *2.
So let us turn our attention to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
named *1 above. Perhaps we can prove it by induction. There are two
plausible inductions. However, they merge into one likely candidate induction.
We will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p K V L N))
(IMPLIES (AND (NOT (ZEROP K))
(p (SUB1 K) V L N))
(p K V L N))).
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each induction step of the scheme. The above induction
scheme leads to the following three new formulas:
Case 3. (IMPLIES (AND (ZEROP K)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))).
This simplifies, unfolding the definition of ZEROP, to:
T.
Case 2. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (SUB1 K) 0)
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))).
This simplifies, applying GETNTH-PUTNTH-CASESPLIT, GETSEG-OF-LENGTH-ZERO,
GETSEG-AFTER-PUTNTH, and OPEN-PUTNTH-CASESPLIT, and opening up the
definitions of ZEROP, GETSEG, EQUAL, LESSP, NUMBERP, and ADD1, to:
T.
Case 1. (IMPLIES (AND (NOT (ZEROP K))
(EQUAL (GETSEG 0 (SUB1 K) (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 (SUB1 K) L)))
(NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(NOT (EQUAL (LENGTH L) 0)))
(EQUAL (GETSEG 0 K (PUTNTH V 0 L))
(PUTNTH V 0 (GETSEG 0 K L)))),
which simplifies, rewriting with the lemmas GETNTH-PUTNTH-CASESPLIT,
GETSEG-AFTER-PUTNTH, and OPEN-PUTNTH-CASESPLIT, and expanding the
definitions of ZEROP, GETSEG, EQUAL, LESSP, NUMBERP, and ADD1, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.1 0.1 ]
GETSEG-PUTNTH-COINCIDENCE
(DISABLE GETSEG-PUTNTH-COINCIDENCE)
[ 0.0 0.0 0.0 ]
GETSEG-PUTNTH-COINCIDENCE-OFF
(DEFN INTEGER-INDUCTION-INSTANCE
(N K)
(IF (ZEROP K)
'0
(INTEGER-INDUCTION-INSTANCE (ADD1 N)
(SUB1 K)))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each recursive call. Hence, INTEGER-INDUCTION-INSTANCE is
accepted under the principle of definition. Observe that:
(NUMBERP (INTEGER-INDUCTION-INSTANCE N K))
is a theorem.
[ 0.0 0.0 0.0 ]
INTEGER-INDUCTION-INSTANCE
(PROVE-LEMMA GETSEG-GETSEG
(REWRITE)
(IMPLIES (IF (LESSP K (PLUS I J))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG I J (GETSEG N K L))
(GETSEG (PLUS N I) J L)))
((ENABLE GETSEG GETNTH-GETSEG PLUS-ADD1 PLUS-RIGHT-ID2 PLUS-0
GETNTH-WITH-NON-NUMBER-INDEX
GETSEG-WITH-NON-NUMBER-INDEX)
(INDUCT (INTEGER-INDUCTION-INSTANCE I J))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following two new formulas:
Case 2. (IMPLIES (AND (ZEROP J)
(NOT (LESSP K (PLUS I J))))
(EQUAL (GETSEG I J (GETSEG N K L))
(GETSEG (PLUS N I) J L))).
This simplifies, rewriting with PLUS-0, GETSEG-WITH-NON-NUMBER-INDEX, and
PLUS-RIGHT-ID2, and expanding the functions ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(IMPLIES (IF (LESSP K (PLUS (ADD1 I) (SUB1 J)))
F T)
(EQUAL (GETSEG (ADD1 I)
(SUB1 J)
(GETSEG N K L))
(GETSEG (PLUS N (ADD1 I))
(SUB1 J)
L)))
(NOT (LESSP K (PLUS I J))))
(EQUAL (GETSEG I J (GETSEG N K L))
(GETSEG (PLUS N I) J L))),
which simplifies, using linear arithmetic, applying SUB1-ADD1, PLUS-ADD1,
GETSEG-WITH-NON-NUMBER-INDEX, PLUS-RIGHT-ID2, and GETNTH-GETSEG, and
expanding PLUS, LESSP, IMPLIES, EQUAL, and GETSEG, to the following eight
new conjectures:
Case 1.8.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(EQUAL K 0)
(EQUAL (PLUS I J) 0))
(EQUAL (GETSEG I J NIL)
(GETSEG (PLUS N I) J L))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.7.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP K))
(EQUAL (PLUS I J) 0))
(EQUAL (GETSEG I J NIL)
(GETSEG (PLUS N I) J L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.6.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP I))
(LESSP (SUB1 K) (PLUS 0 (SUB1 J)))
(NOT (LESSP K J))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 J (GETSEG N K L))
(GETSEG 0 J L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP I))
(LESSP (SUB1 K) (PLUS 0 (SUB1 J)))
(NOT (LESSP K J))
(NUMBERP N))
(EQUAL (GETSEG 0 J (GETSEG N K L))
(GETSEG N J L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NUMBERP I)
(LESSP (SUB1 K) (PLUS I (SUB1 J)))
(NOT (LESSP K (PLUS I J))))
(EQUAL (CONS (GETNTH (PLUS N I) L)
(GETSEG (ADD1 I)
(SUB1 J)
(GETSEG N K L)))
(GETSEG (PLUS N I) J L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP I))
(EQUAL (GETSEG (ADD1 I)
(SUB1 J)
(GETSEG N K L))
(GETSEG (ADD1 N) (SUB1 J) L))
(NOT (LESSP K J))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 J (GETSEG N K L))
(GETSEG 0 J L))),
which again simplifies, rewriting with the lemmas SUB1-TYPE-RESTRICTION
and GETSEG-WITH-NON-NUMBER-INDEX, to:
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP I))
(EQUAL (GETSEG 1 (SUB1 J) (GETSEG 0 K L))
(GETSEG 1 (SUB1 J) L))
(NOT (LESSP K J))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 J (GETSEG 0 K L))
(GETSEG 0 J L))).
However this again simplifies, using linear arithmetic, rewriting with
GETNTH-GETSEG, and unfolding the definitions of ADD1, PLUS, and GETSEG, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NOT (NUMBERP I))
(EQUAL (GETSEG (ADD1 I)
(SUB1 J)
(GETSEG N K L))
(GETSEG (ADD1 N) (SUB1 J) L))
(NOT (LESSP K J))
(NUMBERP N))
(EQUAL (GETSEG 0 J (GETSEG N K L))
(GETSEG N J L))).
This again simplifies, using linear arithmetic, rewriting with
SUB1-TYPE-RESTRICTION, GETNTH-GETSEG, and PLUS-0, and opening up ADD1 and
GETSEG, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL J 0))
(NUMBERP J)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 J)
(GETSEG N K L))
(GETSEG (ADD1 (PLUS N I)) (SUB1 J) L))
(NOT (LESSP K (PLUS I J))))
(EQUAL (GETSEG I J (GETSEG N K L))
(GETSEG (PLUS N I) J L))).
However this again simplifies, using linear arithmetic, rewriting with
GETNTH-GETSEG, and opening up GETSEG, to:
T.
Q.E.D.
[ 0.0 0.1 0.0 ]
GETSEG-GETSEG
(DISABLE GETSEG-GETSEG)
[ 0.0 0.0 0.0 ]
GETSEG-GETSEG-OFF
(PROVE-LEMMA GETSEG-AFTER-PUTSEG
(REWRITE)
(IMPLIES (IF (LESSP I (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L)))
((ENABLE GETSEG PUTSEG LENGTH PLUS-ADD1 GETNTH-AFTER-PUTSEG)
(INDUCT (INTEGER-INDUCTION-INSTANCE I K))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to two new conjectures:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L))),
which simplifies, opening up ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (IF (LESSP (ADD1 I) (PLUS N (LENGTH S)))
F T)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L))),
which simplifies, applying SUB1-ADD1, GETNTH-AFTER-PUTSEG, CAR-CONS,
CDR-CONS, and CONS-EQUAL, and unfolding the definitions of LESSP, IMPLIES,
and GETSEG, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL (PLUS N (LENGTH S)) 0))
(NUMBERP I)
(LESSP I (SUB1 (PLUS N (LENGTH S))))
(NOT (LESSP I (PLUS N (LENGTH S)))))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-AFTER-PUTSEG
(DISABLE GETSEG-AFTER-PUTSEG)
[ 0.0 0.0 0.0 ]
GETSEG-AFTER-PUTSEG-OFF
(PROVE-LEMMA GETSEG-BEFORE-PUTSEG
(REWRITE)
(IMPLIES (IF (LESSP N (PLUS I K))
'*1*FALSE
'*1*TRUE)
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L)))
((ENABLE GETSEG PUTSEG PLUS-ADD1 GETNTH-BEFORE-PUTSEG)
(INDUCT (INTEGER-INDUCTION-INSTANCE I K))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to two new goals:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L))),
which simplifies, expanding ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (IF (LESSP N (PLUS (ADD1 I) (SUB1 K)))
F T)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) L)))
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L))),
which simplifies, using linear arithmetic, applying SUB1-ADD1, CAR-CONS,
CONS-EQUAL, GETNTH-BEFORE-PUTSEG, and CDR-CONS, and expanding PLUS, LESSP,
IMPLIES, EQUAL, and GETSEG, to the following five new conjectures:
Case 1.5.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL (PLUS I K) 0))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (PLUS I K) 0))
(EQUAL (GETNTH I (PUTSEG S N L))
(GETNTH I L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (PLUS I K) 0))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 N) (PLUS 0 (SUB1 K)))
(NOT (LESSP N K)))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG I K L))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 N) (PLUS I (SUB1 K)))
(NOT (LESSP N (PLUS I K))))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) L))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
GETSEG-BEFORE-PUTSEG
(DISABLE GETSEG-BEFORE-PUTSEG)
[ 0.0 0.0 0.0 ]
GETSEG-BEFORE-PUTSEG-OFF
(PROVE-LEMMA GETSEG-WITHIN-PUTSEG
(REWRITE)
(IMPLIES (AND (IF (LESSP I N) '*1*FALSE '*1*TRUE)
(AND (IF (LESSP (LENGTH L) (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)
(IF (LESSP (PLUS N (LENGTH S)) (PLUS I K))
'*1*FALSE
'*1*TRUE)))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG (DIFFERENCE I N) K S)))
((ENABLE GETSEG PUTSEG LENGTH PLUS-ADD1 GETNTH-PUTSEG-COINCIDENCE
DIFFERENCE-SUB1-ARG1 DIFFERENCE-SUB1-ARG2)
(INDUCT (INTEGER-INDUCTION-INSTANCE I K))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to the following two new conjectures:
Case 2. (IMPLIES (AND (ZEROP K)
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG (DIFFERENCE I N) K S))).
This simplifies, unfolding the definitions of ZEROP, EQUAL, and GETSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(IMPLIES (AND (IF (LESSP (ADD1 I) N) F T)
(IF (LESSP (LENGTH L) (PLUS N (LENGTH S)))
F T)
(IF (LESSP (PLUS N (LENGTH S))
(PLUS (ADD1 I) (SUB1 K)))
F T))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (DIFFERENCE (ADD1 I) N)
(SUB1 K)
S)))
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG (DIFFERENCE I N) K S))).
This simplifies, using linear arithmetic, applying SUB1-ADD1 and
GETNTH-PUTSEG-COINCIDENCE, and unfolding the definitions of LESSP, PLUS, AND,
DIFFERENCE, IMPLIES, GETSEG, and EQUAL, to 12 new formulas:
Case 1.12.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(LESSP I (SUB1 N))
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (CONS (GETNTH (DIFFERENCE I N) S)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L)))
(GETSEG (DIFFERENCE I N) K S))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.11.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (LESSP I N))
(EQUAL (PLUS I K) 0))
(EQUAL (CONS (GETNTH I (PUTSEG S N L))
(GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L)))
(GETSEG (DIFFERENCE I N) K S))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.10.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 (PLUS N (LENGTH S)))
(PLUS 0 (SUB1 K)))
(EQUAL N 0)
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K)))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(GETSEG 0 K S))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.9.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP I))
(LESSP (SUB1 (PLUS N (LENGTH S)))
(PLUS 0 (SUB1 K)))
(NOT (NUMBERP N))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K)))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG 0 K S))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.8.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NUMBERP I)
(LESSP (SUB1 (PLUS N (LENGTH S)))
(PLUS I (SUB1 K)))
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (CONS (GETNTH (DIFFERENCE I N) S)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L)))
(GETSEG (DIFFERENCE I N) K S))),
which again simplifies, using linear arithmetic, to:
T.
Case 1.7.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (DIFFERENCE I (SUB1 N))
(SUB1 K)
S))
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG (DIFFERENCE I N) K S))),
which again simplifies, rewriting with DIFFERENCE-SUB1-ARG2, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (EQUAL N 0))
(NUMBERP N)
(NUMBERP I)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 (DIFFERENCE I N))
(SUB1 K)
S))
(NOT (LESSP I N))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS N (LENGTH S))
(PLUS I K))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(GETSEG (DIFFERENCE I N) K S))),
which again simplifies, using linear arithmetic, applying the lemma
GETNTH-PUTSEG-COINCIDENCE, and expanding the definition of GETSEG, to:
T.
Case 1.6.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(GETSEG I K S))),
which again simplifies, using linear arithmetic, rewriting with
GETNTH-PUTSEG-COINCIDENCE, and opening up the definitions of EQUAL,
DIFFERENCE, and GETSEG, to:
T.
Case 1.5.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(EQUAL I 0))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(GETSEG 0 K S))).
But this again simplifies, opening up the functions EQUAL and PLUS, to the
goal:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG 1 (SUB1 K) (PUTSEG S 0 L))
(GETSEG 1 (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(GETSEG 0 K S))).
This again simplifies, using linear arithmetic, rewriting with
GETNTH-PUTSEG-COINCIDENCE, and unfolding ADD1, LESSP, DIFFERENCE, and
GETSEG, to:
T.
Case 1.4.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL N 0)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(NOT (NUMBERP I)))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(GETSEG 0 K S))).
This again simplifies, applying SUB1-TYPE-RESTRICTION, and expanding the
definition of PLUS, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(EQUAL (GETSEG 1 (SUB1 K) (PUTSEG S 0 L))
(GETSEG 1 (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K))
(NOT (NUMBERP I)))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(GETSEG 0 K S))),
which again simplifies, using linear arithmetic, appealing to the lemmas
SUB1-TYPE-RESTRICTION and GETNTH-PUTSEG-COINCIDENCE, and unfolding the
definitions of DIFFERENCE, GETSEG, and ADD1, to:
T.
Case 1.3.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(NOT (EQUAL I 0))
(NUMBERP I))
(EQUAL (CONS (GETNTH I (PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(GETSEG I K S))),
which again simplifies, using linear arithmetic, rewriting with the lemma
GETNTH-PUTSEG-COINCIDENCE, and unfolding the definitions of DIFFERENCE and
GETSEG, to:
T.
Case 1.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(EQUAL I 0))
(EQUAL (CONS (GETNTH I (PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(GETSEG 0 K S))),
which again simplifies, using linear arithmetic, applying
GETNTH-PUTSEG-COINCIDENCE, and unfolding the definitions of EQUAL, PLUS,
and DIFFERENCE, to the new conjecture:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG 1 (SUB1 K) (PUTSEG S N L))
(GETSEG 1 (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K)))
(EQUAL (CONS (GETNTH 0 S)
(GETSEG 1 (SUB1 K) S))
(GETSEG 0 K S))),
which again simplifies, expanding ADD1 and GETSEG, to:
T.
Case 1.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) (PLUS I K)))
(NOT (NUMBERP I)))
(EQUAL (CONS (GETNTH I (PUTSEG S N L))
(GETSEG (ADD1 I) (SUB1 K) S))
(GETSEG 0 K S))),
which again simplifies, using linear arithmetic, appealing to the lemmas
SUB1-TYPE-RESTRICTION and GETNTH-PUTSEG-COINCIDENCE, and opening up PLUS
and DIFFERENCE, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (NUMBERP N))
(EQUAL (GETSEG 1 (SUB1 K) (PUTSEG S N L))
(GETSEG 1 (SUB1 K) S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(NOT (LESSP (LENGTH S) K))
(NOT (NUMBERP I)))
(EQUAL (CONS (GETNTH 0 S)
(GETSEG 1 (SUB1 K) S))
(GETSEG 0 K S))).
But this again simplifies, opening up ADD1 and GETSEG, to:
T.
Q.E.D.
[ 0.0 0.2 0.0 ]
GETSEG-WITHIN-PUTSEG
(DISABLE GETSEG-WITHIN-PUTSEG)
[ 0.0 0.0 0.0 ]
GETSEG-WITHIN-PUTSEG-OFF
(DEFN GETSEG-PUTSEG-INDUCTION
(I K S N)
(IF (ZEROP K)
'0
(IF (LISTP S)
(GETSEG-PUTSEG-INDUCTION (ADD1 I)
(SUB1 K)
(CDR S)
(ADD1 N))
'0))
NIL)
Linear arithmetic, the lemma COUNT-NUMBERP, and the definition of ZEROP
establish that the measure (COUNT K) decreases according to the well-founded
relation LESSP in each recursive call. Hence, GETSEG-PUTSEG-INDUCTION is
accepted under the principle of definition. The definition of
GETSEG-PUTSEG-INDUCTION can be justified in another way. Linear arithmetic
and the lemma CDR-LESSP inform us that the measure (COUNT S) decreases
according to the well-founded relation LESSP in each recursive call. Observe
that (NUMBERP (GETSEG-PUTSEG-INDUCTION I K S N)) is a theorem.
[ 0.0 0.0 0.0 ]
GETSEG-PUTSEG-INDUCTION
(PROVE-LEMMA PUTSEG-HAS-NO-EFFECT
(REWRITE)
(IMPLIES (NOT (LESSP N (LENGTH L)))
(EQUAL (PUTSEG S N L) L))
((ENABLE PUTSEG LENGTH PUTNTH-HAS-NO-EFFECT)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. There are three plausible inductions.
However, only one is unflawed. We will induct according to the following
scheme:
(AND (IMPLIES (AND (LISTP S) (p (CDR S) (ADD1 N) L))
(p S N L))
(IMPLIES (NOT (LISTP S)) (p S N L))).
Linear arithmetic and the lemma CDR-LESSP establish that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces the following three new formulas:
Case 3. (IMPLIES (AND (LISTP S)
(LESSP (ADD1 N) (LENGTH L))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTSEG S N L) L)).
This simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (PUTSEG (CDR S) (ADD1 N) L) L)
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTSEG S N L) L)).
This simplifies, rewriting with PUTNTH-HAS-NO-EFFECT, and unfolding the
function PUTSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S))
(NOT (LESSP N (LENGTH L))))
(EQUAL (PUTSEG S N L) L)),
which simplifies, expanding the function PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-HAS-NO-EFFECT
(DISABLE PUTSEG-HAS-NO-EFFECT)
[ 0.0 0.0 0.0 ]
PUTSEG-HAS-NO-EFFECT-OFF
(PROVE-LEMMA PUTSEG-CONS2
(REWRITE)
(IMPLIES (NOT (ZEROP N))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B))))
((ENABLE PUTSEG PUTNTH-CONS2)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, NOT, and
IMPLIES, to:
(IMPLIES (AND (NOT (EQUAL N 0)) (NUMBERP N))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B)))).
Appealing to the lemma SUB1-ELIM, we now replace N by (ADD1 X) to eliminate
(SUB1 N). We use the type restriction lemma noted when SUB1 was introduced to
constrain the new variable. The result is the goal:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0)))
(EQUAL (PUTSEG S (ADD1 X) (CONS A B))
(CONS A (PUTSEG S X B)))).
This simplifies, applying the lemma CAR-CONS, to:
(IMPLIES (NUMBERP X)
(EQUAL (PUTSEG S (ADD1 X) (CONS A B))
(CONS A (PUTSEG S X B)))),
which we would usually push and work on later by induction. But if we must
use induction to prove the input conjecture, we prefer to induct on the
original formulation of the problem. Thus we will disregard all that we have
previously done, give the name *1 to the original input, and work on it.
So now let us consider:
(IMPLIES (NOT (ZEROP N))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B)))).
We gave this the name *1 above. Perhaps we can prove it by induction. The
recursive terms in the conjecture suggest two inductions. However, they merge
into one likely candidate induction. We will induct according to the
following scheme:
(AND (IMPLIES (AND (LISTP S)
(p (CDR S) (ADD1 N) A B))
(p S N A B))
(IMPLIES (NOT (LISTP S))
(p S N A B))).
Linear arithmetic and the lemma CDR-LESSP inform us that the measure (COUNT S)
decreases according to the well-founded relation LESSP in each induction step
of the scheme. Note, however, the inductive instance chosen for N. The above
induction scheme produces the following three new conjectures:
Case 3. (IMPLIES (AND (LISTP S)
(ZEROP (ADD1 N))
(NOT (ZEROP N)))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B)))).
This simplifies, expanding the function ZEROP, to:
T.
Case 2. (IMPLIES (AND (LISTP S)
(EQUAL (PUTSEG (CDR S) (ADD1 N) (CONS A B))
(CONS A
(PUTSEG (CDR S) (SUB1 (ADD1 N)) B)))
(NOT (ZEROP N)))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B)))).
This simplifies, applying CAR-CONS and ADD1-SUB1, and opening up ZEROP and
PUTSEG, to:
(IMPLIES (AND (LISTP S)
(EQUAL (PUTSEG (CDR S) (ADD1 N) (CONS A B))
(CONS A
(PUTSEG (CDR S) (SUB1 (ADD1 N)) B)))
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (PUTNTH (CAR S)
N
(PUTSEG (CDR S) (ADD1 N) (CONS A B)))
(CONS A
(PUTNTH (CAR S)
(SUB1 N)
(PUTSEG (CDR S) N B))))).
However this further simplifies, applying SUB1-ADD1, CAR-CONS, and
PUTNTH-CONS2, to:
T.
Case 1. (IMPLIES (AND (NOT (LISTP S)) (NOT (ZEROP N)))
(EQUAL (PUTSEG S N (CONS A B))
(CONS A (PUTSEG S (SUB1 N) B)))).
This simplifies, expanding ZEROP and PUTSEG, to:
T.
That finishes the proof of *1. Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-CONS2
(DISABLE PUTSEG-CONS2)
[ 0.0 0.0 0.0 ]
PUTSEG-CONS2-OFF
(PROVE-LEMMA GETSEG-AROUND-PUTSEG-PROOF
(REWRITE)
(IMPLIES (AND (NUMBERP I)
(AND (NUMBERP N)
(AND (IF (LESSP N I) '*1*FALSE '*1*TRUE)
(AND (IF (LESSP (LENGTH L) (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)
(IF (LESSP (PLUS I K) (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(PUTSEG S
(DIFFERENCE N I)
(GETSEG I K L))))
((ENABLE GETSEG PUTSEG LENGTH GETNTH-BEFORE-PUTSEG
GETSEG-OF-LENGTH-ZERO GETSEG-PUTNTH-COINCIDENCE LENGTH-PUTSEG
PLUS-ADD1 PUTSEG-CONS2 PUTSEG-HAS-NO-EFFECT)
(INDUCT (GETSEG-PUTSEG-INDUCTION I K S N))
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations ZEROP, IMPLIES, NOT,
OR, and AND, to three new formulas:
Case 3. (IMPLIES (AND (ZEROP K)
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS I K)
(PLUS N (LENGTH S)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(PUTSEG S
(DIFFERENCE N I)
(GETSEG I K L)))),
which simplifies, using linear arithmetic, rewriting with
GETSEG-OF-LENGTH-ZERO and PUTSEG-HAS-NO-EFFECT, and unfolding the functions
ZEROP, LENGTH, LISTP, and EQUAL, to:
T.
Case 2. (IMPLIES
(AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP S)
(IMPLIES (AND (NUMBERP (ADD1 I))
(NUMBERP (ADD1 N))
(IF (LESSP (ADD1 N) (ADD1 I)) F T)
(IF (LESSP (LENGTH L)
(PLUS (ADD1 N) (LENGTH (CDR S))))
F T)
(IF (LESSP (PLUS (ADD1 I) (SUB1 K))
(PLUS (ADD1 N) (LENGTH (CDR S))))
F T))
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(DIFFERENCE (ADD1 N) (ADD1 I))
(GETSEG (ADD1 I) (SUB1 K) L))))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS I K)
(PLUS N (LENGTH S)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(PUTSEG S
(DIFFERENCE N I)
(GETSEG I K L)))).
This simplifies, rewriting with SUB1-ADD1 and PLUS-ADD1, and expanding LESSP,
PLUS, AND, DIFFERENCE, IMPLIES, LENGTH, EQUAL, PUTSEG, and GETSEG, to two
new formulas:
Case 2.2.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP S)
(LESSP (PLUS I (SUB1 K))
(PLUS N (LENGTH (CDR S))))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH (CDR S)))))
(NOT (EQUAL (PLUS I K) 0))
(NOT (LESSP (SUB1 (PLUS I K))
(PLUS N (LENGTH (CDR S))))))
(EQUAL (GETSEG I K
(PUTNTH (CAR S)
N
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG S
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, to:
T.
Case 2.1.
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP S)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(DIFFERENCE N I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH (CDR S)))))
(NOT (EQUAL (PLUS I K) 0))
(NOT (LESSP (SUB1 (PLUS I K))
(PLUS N (LENGTH (CDR S))))))
(EQUAL (GETSEG I K
(PUTNTH (CAR S)
N
(PUTSEG (CDR S) (ADD1 N) L)))
(PUTSEG S
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))))),
which again simplifies, using linear arithmetic, rewriting with
LENGTH-PUTSEG, GETNTH-BEFORE-PUTSEG, and GETSEG-PUTNTH-COINCIDENCE, and
expanding the function GETSEG, to:
(IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(LISTP S)
(EQUAL (GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(DIFFERENCE N I)
(GETSEG (ADD1 I) (SUB1 K) L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH (CDR S)))))
(NOT (EQUAL (PLUS I K) 0))
(NOT (LESSP (SUB1 (PLUS I K))
(PLUS N (LENGTH (CDR S))))))
(EQUAL (PUTNTH (CAR S)
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I)
(SUB1 K)
(PUTSEG (CDR S) (ADD1 N) L))))
(PUTSEG S
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) (SUB1 K) L))))).
Applying the lemma SUB1-ELIM, replace K by (ADD1 X) to eliminate (SUB1 K).
We employ the type restriction lemma noted when SUB1 was introduced to
restrict the new variable. This produces:
(IMPLIES (AND (NUMBERP X)
(NOT (EQUAL (ADD1 X) 0))
(LISTP S)
(EQUAL (GETSEG (ADD1 I)
X
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(DIFFERENCE N I)
(GETSEG (ADD1 I) X L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH (CDR S)))))
(NOT (EQUAL (PLUS I (ADD1 X)) 0))
(NOT (LESSP (SUB1 (PLUS I (ADD1 X)))
(PLUS N (LENGTH (CDR S))))))
(EQUAL (PUTNTH (CAR S)
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I)
X
(PUTSEG (CDR S) (ADD1 N) L))))
(PUTSEG S
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) X L))))),
which further simplifies, rewriting with PLUS-ADD1 and SUB1-ADD1, to:
(IMPLIES (AND (NUMBERP X)
(LISTP S)
(EQUAL (GETSEG (ADD1 I)
X
(PUTSEG (CDR S) (ADD1 N) L))
(PUTSEG (CDR S)
(DIFFERENCE N I)
(GETSEG (ADD1 I) X L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH (CDR S)))))
(NOT (LESSP (PLUS I X)
(PLUS N (LENGTH (CDR S))))))
(EQUAL (PUTNTH (CAR S)
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I)
X
(PUTSEG (CDR S) (ADD1 N) L))))
(PUTSEG S
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) X L))))).
Applying the lemma CAR-CDR-ELIM, replace S by (CONS V Z) to eliminate
(CDR S) and (CAR S). We would thus like to prove the new goal:
(IMPLIES (AND (NUMBERP X)
(EQUAL (GETSEG (ADD1 I)
X
(PUTSEG Z (ADD1 N) L))
(PUTSEG Z
(DIFFERENCE N I)
(GETSEG (ADD1 I) X L)))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (EQUAL (LENGTH L) 0))
(NOT (LESSP (SUB1 (LENGTH L))
(PLUS N (LENGTH Z))))
(NOT (LESSP (PLUS I X)
(PLUS N (LENGTH Z)))))
(EQUAL (PUTNTH V
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I)
X
(PUTSEG Z (ADD1 N) L))))
(PUTSEG (CONS V Z)
(DIFFERENCE N I)
(CONS (GETNTH I L)
(GETSEG (ADD1 I) X L))))),
which finally simplifies, rewriting with CDR-CONS, CAR-CONS, SUB1-ADD1,
and PUTSEG-CONS2, and opening up the definition of PUTSEG, to:
T.
Case 1. (IMPLIES (AND (NOT (EQUAL K 0))
(NUMBERP K)
(NOT (LISTP S))
(NUMBERP I)
(NUMBERP N)
(NOT (LESSP N I))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP (PLUS I K)
(PLUS N (LENGTH S)))))
(EQUAL (GETSEG I K (PUTSEG S N L))
(PUTSEG S
(DIFFERENCE N I)
(GETSEG I K L)))).
This simplifies, expanding the definitions of LENGTH and PUTSEG, to:
T.
Q.E.D.
[ 0.0 0.3 0.0 ]
GETSEG-AROUND-PUTSEG-PROOF
(DISABLE GETSEG-AROUND-PUTSEG-PROOF)
[ 0.0 0.0 0.0 ]
GETSEG-AROUND-PUTSEG-PROOF-OFF
(PROVE-LEMMA NUMBERP-CASESPLIT NIL
(OR (NUMBERP A) (NOT (NUMBERP A)))
((ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, obviously, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
NUMBERP-CASESPLIT
(PROVE-LEMMA GETSEG-AROUND-PUTSEG
(REWRITE)
(IMPLIES (AND (IF (LESSP N I) '*1*FALSE '*1*TRUE)
(AND (IF (LESSP (LENGTH L) (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)
(IF (LESSP (PLUS I K) (PLUS N (LENGTH S)))
'*1*FALSE
'*1*TRUE)))
(EQUAL (GETSEG I K (PUTSEG S N L))
(PUTSEG S
(DIFFERENCE N I)
(GETSEG I K L))))
((USE (NUMBERP-CASESPLIT (A I))
(NUMBERP-CASESPLIT (A N))
(GETSEG-AROUND-PUTSEG-PROOF (I I)
(N N)
(K K)
(S S)
(L L))
(GETSEG-AROUND-PUTSEG-PROOF (I '0)
(N N)
(K K)
(S S)
(L L))
(GETSEG-AROUND-PUTSEG-PROOF (I I)
(N '0)
(K K)
(S S)
(L L))
(GETSEG-AROUND-PUTSEG-PROOF (I '0)
(N '0)
(K K)
(S S)
(L L)))
(ENABLE GETSEG-WITH-NON-NUMBER-INDEX
PUTSEG-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This simplifies, applying GETSEG-WITH-NON-NUMBER-INDEX and
PUTSEG-WITH-NON-NUMBER-INDEX, and opening up the definitions of NOT, OR, AND,
IMPLIES, NUMBERP, EQUAL, LESSP, PLUS, and DIFFERENCE, to the following 29 new
formulas:
Case 29.(IMPLIES (AND (NOT (NUMBERP I))
(EQUAL N 0)
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))).
This again simplifies, trivially, to:
T.
Case 28.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (NUMBERP K))
(NOT (LESSP 0 (PLUS N (LENGTH S))))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 27.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (NUMBERP K))
(NOT (LESSP 0 (PLUS N (LENGTH S))))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, obviously, to:
T.
Case 26.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NUMBERP K)
(NOT (LESSP K (PLUS N (LENGTH S))))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
This again simplifies, using linear arithmetic, to:
T.
Case 25.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NUMBERP K)
(NOT (LESSP K (PLUS N (LENGTH S))))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, clearly, to:
T.
Case 24.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 23.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, obviously, to:
T.
Case 22.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(NUMBERP K)
(LESSP K (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP K (PLUS N (LENGTH S))))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
However this again simplifies, using linear arithmetic, to:
T.
Case 21.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(NUMBERP K)
(LESSP K (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (LESSP K (PLUS N (LENGTH S))))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, obviously, to:
T.
Case 20.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (NUMBERP K))
(NOT (LESSP 0 (PLUS N (LENGTH S))))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
But this again simplifies, applying PUTSEG-WITH-NON-NUMBER-INDEX, and
opening up the functions PLUS, EQUAL, and LESSP, to:
T.
Case 19.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NOT (NUMBERP K))
(NOT (LESSP 0 (PLUS N (LENGTH S))))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))).
This again simplifies, obviously, to:
T.
Case 18.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NUMBERP K)
(NOT (LESSP K (PLUS N (LENGTH S))))
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
However this again simplifies, rewriting with PUTSEG-WITH-NON-NUMBER-INDEX,
and unfolding the definition of PLUS, to:
T.
Case 17.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(NUMBERP K)
(NOT (LESSP K (PLUS N (LENGTH S))))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))).
This again simplifies, clearly, to:
T.
Case 16.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 15.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 14.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(LESSP (LENGTH L) (LENGTH S))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 13.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(NOT (EQUAL (LENGTH S) 0))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 12.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(NOT (EQUAL (LENGTH S) 0))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 11.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(NOT (EQUAL (LENGTH S) 0))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 10.(IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (EQUAL N 0))
(NUMBERP N))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S N (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 9. (IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(EQUAL N 0))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, obviously, to:
T.
Case 8. (IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (PLUS N (LENGTH S)))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH S))))
(EQUAL (PLUS N (LENGTH S)) 0)
(NOT (NUMBERP N)))
(EQUAL (GETSEG 0 K (PUTSEG S N L))
(PUTSEG S 0 (GETSEG 0 K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 7. (IMPLIES (AND (NOT (NUMBERP I))
(NOT (NUMBERP N))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 6. (IMPLIES (AND (NOT (NUMBERP N))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG I K L)))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(EQUAL I 0)
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, obviously, to:
T.
Case 5. (IMPLIES (AND (NOT (NUMBERP N))
(EQUAL (GETSEG I K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG I K L)))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (NUMBERP I))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))).
But this again simplifies, using linear arithmetic, to:
T.
Case 4. (IMPLIES (AND (NOT (NUMBERP N))
(LESSP (PLUS I K) (LENGTH S))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(EQUAL I 0)
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 3. (IMPLIES (AND (NOT (NUMBERP N))
(LESSP (PLUS I K) (LENGTH S))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (NUMBERP I))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 2. (IMPLIES (AND (NOT (NUMBERP N))
(NOT (EQUAL I 0))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (NUMBERP I))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP N))
(NOT (NUMBERP I))
(NOT (NUMBERP K))
(LESSP 0 (LENGTH S))
(NOT (LESSP (LENGTH L) (LENGTH S)))
(EQUAL (LENGTH S) 0))
(EQUAL (GETSEG 0 K (PUTSEG S 0 L))
(PUTSEG S 0 (GETSEG 0 K L)))),
which again simplifies, using linear arithmetic, to:
T.
Q.E.D.
[ 0.0 0.1 0.0 ]
GETSEG-AROUND-PUTSEG
(DISABLE GETSEG-AROUND-PUTSEG)
[ 0.0 0.0 0.0 ]
GETSEG-AROUND-PUTSEG-OFF
(PROVE-LEMMA PUTSEG-NIL-SEGMENT
(REWRITE)
(EQUAL (PUTSEG 'NIL N L) L)
((ENABLE PUTSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, unfolding the definitions of LISTP and PUTSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-NIL-SEGMENT
(DISABLE PUTSEG-NIL-SEGMENT)
[ 0.0 0.0 0.0 ]
PUTSEG-NIL-SEGMENT-OFF
(PROVE-LEMMA PUTSEG-NON-LIST-SEGMENT
(REWRITE)
(IMPLIES (NOT (LISTP S))
(EQUAL (PUTSEG S N L) L))
((ENABLE PUTSEG)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, expanding the function PUTSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-NON-LIST-SEGMENT
(DISABLE PUTSEG-NON-LIST-SEGMENT)
[ 0.0 0.0 0.0 ]
PUTSEG-NON-LIST-SEGMENT-OFF
(PROVE-LEMMA OPEN-UP-PUTSEG-ON-SEGMENT-CONS
(REWRITE)
(IMPLIES (AND (NUMBERP N)
(IF (LESSP (LENGTH L)
(PLUS N (LENGTH (CONS A B))))
'*1*FALSE
'*1*TRUE))
(EQUAL (PUTSEG (CONS A B) N L)
(PUTNTH A N
(PUTSEG B (PLUS '1 N) L))))
((ENABLE PUTSEG LENGTH PLUS-ADD1 PLUS-1)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This conjecture can be simplified, using the abbreviations AND, IMPLIES, and
PLUS-1, to:
(IMPLIES (AND (NUMBERP N)
(NOT (LESSP (LENGTH L)
(PLUS N (LENGTH (CONS A B))))))
(EQUAL (PUTSEG (CONS A B) N L)
(PUTNTH A N (PUTSEG B (ADD1 N) L)))).
This simplifies, applying CDR-CONS, PLUS-ADD1, SUB1-ADD1, and CAR-CONS, and
expanding LENGTH, LESSP, and PUTSEG, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTSEG-ON-SEGMENT-CONS
(DISABLE OPEN-UP-PUTSEG-ON-SEGMENT-CONS)
[ 0.0 0.0 0.0 ]
OPEN-UP-PUTSEG-ON-SEGMENT-CONS-OFF
(PROVE-LEMMA PUTSEG-CONS1
(REWRITE)
(IMPLIES (AND (ZEROP N) (LISTP S))
(EQUAL (PUTSEG S N (CONS A B))
(CONS (CAR S) (PUTSEG (CDR S) N B))))
((ENABLE PUTSEG PUTNTH-CONS1 PUTSEG-CONS2
PUTSEG-WITH-NON-NUMBER-INDEX)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
This formula simplifies, appealing to the lemmas CAR-CONS and
PUTSEG-WITH-NON-NUMBER-INDEX, and unfolding the definition of ZEROP, to the
following two new formulas:
Case 2. (IMPLIES (AND (EQUAL N 0) (LISTP S))
(EQUAL (PUTSEG S 0 (CONS A B))
(CONS (CAR S) (PUTSEG (CDR S) 0 B)))).
However this again simplifies, rewriting with CAR-CONS, to:
(IMPLIES (LISTP S)
(EQUAL (PUTSEG S 0 (CONS A B))
(CONS (CAR S) (PUTSEG (CDR S) 0 B)))).
Applying the lemma CAR-CDR-ELIM, replace S by (CONS X Z) to eliminate
(CAR S) and (CDR S). This produces:
(EQUAL (PUTSEG (CONS X Z) 0 (CONS A B))
(CONS X (PUTSEG Z 0 B))),
which further simplifies, rewriting with the lemmas CDR-CONS, CAR-CONS,
PUTSEG-CONS2, and PUTNTH-CONS1, and unfolding ADD1, PUTSEG, EQUAL, SUB1, and
ZEROP, to:
T.
Case 1. (IMPLIES (AND (NOT (NUMBERP N)) (LISTP S))
(EQUAL (PUTSEG S 0 (CONS A B))
(CONS (CAR S) (PUTSEG (CDR S) 0 B)))).
Applying the lemma CAR-CDR-ELIM, replace S by (CONS X Z) to eliminate
(CAR S) and (CDR S). We thus obtain the new goal:
(IMPLIES (NOT (NUMBERP N))
(EQUAL (PUTSEG (CONS X Z) 0 (CONS A B))
(CONS X (PUTSEG Z 0 B)))),
which further simplifies, applying CDR-CONS, CAR-CONS, PUTSEG-CONS2, and
PUTNTH-CONS1, and opening up ADD1, PUTSEG, EQUAL, SUB1, and ZEROP, to:
T.
Q.E.D.
[ 0.0 0.0 0.0 ]
PUTSEG-CONS1
(DISABLE PUTSEG-CONS1)
[ 0.0 0.0 0.0 ]
PUTSEG-CONS1-OFF
(PROVE-LEMMA PUTSEG-GETSEG-COINCIDENCE
(REWRITE)
(IMPLIES (EQUAL I N)
(EQUAL (PUTSEG (GETSEG N K L) I L) L))
((ENABLE PUTSEG GETSEG PUTNTH-GETNTH-COINCIDENCE)
(ENABLE-THEORY GROUND-ZERO)
(DISABLE-THEORY T)))
Give the conjecture the name *1.
We will appeal to induction. There is only one plausible induction. We
will induct according to the following scheme:
(AND (IMPLIES (ZEROP K) (p N K L))
(IMPLIES (AND (NOT (ZEROP K))
(p (ADD1 N) (SUB1 K) L))
(p N K L))).
Linear arithmetic, th