ACL2 !>(defun sum-to-n (n)
         (if (zp n)
             0
           (+ n (sum-to-n (- n 1)))))

The admission of SUM-TO-N is trivial, using the relation O< (which
is known to be well-founded on the domain recognized by O-P) and the
measure (ACL2-COUNT N).  We observe that the type of SUM-TO-N is described
by the theorem (AND (INTEGERP (SUM-TO-N N)) (<= 0 (SUM-TO-N N))). 
We used the :compound-recognizer rule ZP-COMPOUND-RECOGNIZER and primitive
type reasoning.

Summary
Form:  ( DEFUN SUM-TO-N ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:FAKE-RUNE-FOR-TYPE-SET NIL))
Time:  0.00 seconds (prove: 0.00, print: 0.00, other: 0.00)
 SUM-TO-N
ACL2 !>(thm ; fails
        (implies (natp n)
                 (equal (sum-to-n n)
                        (/ (* n (+ n 1))
                           2))))
Goal'
Goal''

([ A key checkpoint:

Goal''
(IMPLIES (AND (INTEGERP N) (<= 0 N))
         (EQUAL (SUM-TO-N N)
                (+ (* 1/2 N) (* N 1/2 N))))

*1 (Goal'') is pushed for proof by induction.

])

Perhaps we can prove *1 by induction.  One induction scheme is suggested
by this conjecture.  

We will induct according to a scheme suggested by (SUM-TO-N N).  This
suggestion was produced using the :induction rule SUM-TO-N.  If we
let (:P N) denote *1 above then the induction scheme we'll use is
(AND (IMPLIES (AND (NOT (ZP N)) (:P (+ -1 N)))
              (:P N))
     (IMPLIES (ZP N) (:P N))).
This induction is justified by the same argument used to admit SUM-TO-N.
When applied to the goal at hand the above induction scheme produces
four nontautological subgoals.
Subgoal *1/4
Subgoal *1/4'
Subgoal *1/4''
Subgoal *1/4'''
Subgoal *1/4'4'
Subgoal *1/4'5'
Subgoal *1/4'6'

([ A key checkpoint while proving *1 (descended from Goal''):

Subgoal *1/4'
(IMPLIES (AND (NOT (ZP N))
              (EQUAL (SUM-TO-N (+ -1 N))
                     (+ (* 1/2 N)
                        (* -1/2 N)
                        (* (+ -1 N) 1/2 N)))
              (<= 0 N))
         (EQUAL (+ N (SUM-TO-N (+ -1 N)))
                (+ (* 1/2 N) (* N 1/2 N))))

*1.1 (Subgoal *1/4'6') is pushed for proof by induction.

])
Subgoal *1/3
Subgoal *1/2
Subgoal *1/1

So we now return to *1.1, which is

(IMPLIES (AND (RATIONALP S)
              (< 0 S)
              (RATIONALP R)
              (< 0 R)
              (NOT (ZP N))
              (<= 0 N))
         (EQUAL (+ N R S (* -1 R) (* -1/2 N))
                (+ R S))).

No induction schemes are suggested by *1.1.  Consequently, the proof
attempt has failed.

Summary
Form:  ( THM ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION FIX)
        (:DEFINITION NATP)
        (:DEFINITION SUM-TO-N)
        (:DEFINITION SYNP)
        (:EXECUTABLE-COUNTERPART <)
        (:EXECUTABLE-COUNTERPART BINARY-*)
        (:EXECUTABLE-COUNTERPART BINARY-+)
        (:EXECUTABLE-COUNTERPART EQUAL)
        (:EXECUTABLE-COUNTERPART INTEGERP)
        (:EXECUTABLE-COUNTERPART NOT)
        (:EXECUTABLE-COUNTERPART SUM-TO-N)
        (:EXECUTABLE-COUNTERPART ZP)
        (:FAKE-RUNE-FOR-LINEAR NIL)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:INDUCTION SUM-TO-N)
        (:REWRITE ASSOCIATIVITY-OF-*)
        (:REWRITE ASSOCIATIVITY-OF-+)
        (:REWRITE COMMUTATIVITY-2-OF-+)
        (:REWRITE COMMUTATIVITY-OF-*)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE DISTRIBUTIVITY)
        (:REWRITE FOLD-CONSTS-IN-+)
        (:REWRITE UNICITY-OF-0))
Time:  0.02 seconds (prove: 0.02, print: 0.00, other: 0.00)
Prover steps counted:  1252

---
The key checkpoint goals, below, may help you to debug this failure.
See :DOC failure and see :DOC set-checkpoint-summary-limit.
---

*** Key checkpoint at the top level: ***

Goal''
(IMPLIES (AND (INTEGERP N) (<= 0 N))
         (EQUAL (SUM-TO-N N)
                (+ (* 1/2 N) (* N 1/2 N))))

*** Key checkpoint under a top-level induction ***

Subgoal *1/4'
(IMPLIES (AND (NOT (ZP N))
              (EQUAL (SUM-TO-N (+ -1 N))
                     (+ (* 1/2 N)
                        (* -1/2 N)
                        (* (+ -1 N) 1/2 N)))
              (<= 0 N))
         (EQUAL (+ N (SUM-TO-N (+ -1 N)))
                (+ (* 1/2 N) (* N 1/2 N))))

ACL2 Error in ( THM ...):  See :DOC failure.

******** FAILED ********
ACL2 !>(include-book "arithmetic/top" :dir :system) ; include an arithmetic book

Summary
Form:  ( INCLUDE-BOOK "arithmetic/top" ...)
Rules: NIL
Time:  0.29 seconds (prove: 0.00, print: 0.00, other: 0.29)
 "/v/filer4b/v8q001/acl2/v7-0-hons/books/arithmetic/top.lisp"
ACL2 !>(thm ; succeeds
        (implies (natp n)
                 (equal (sum-to-n n)
                        (/ (* n (+ n 1))
                           2))))
Goal'
Goal''

([ A key checkpoint:

Goal''
(IMPLIES (NATP N)
         (EQUAL (SUM-TO-N N)
                (+ (* 1/2 N) (* 1/2 N N))))

*1 (Goal'') is pushed for proof by induction.

])

Perhaps we can prove *1 by induction.  One induction scheme is suggested
by this conjecture.  

We will induct according to a scheme suggested by (SUM-TO-N N).  This
suggestion was produced using the :induction rule SUM-TO-N.  If we
let (:P N) denote *1 above then the induction scheme we'll use is
(AND (IMPLIES (AND (NOT (ZP N)) (:P (+ -1 N)))
              (:P N))
     (IMPLIES (ZP N) (:P N))).
This induction is justified by the same argument used to admit SUM-TO-N.
When applied to the goal at hand the above induction scheme produces
three nontautological subgoals.
Subgoal *1/3
Subgoal *1/3'
Subgoal *1/2
Subgoal *1/1

*1 is COMPLETED!
Thus key checkpoint Goal'' is COMPLETED!

Q.E.D.

Summary
Form:  ( THM ...)
Rules: ((:COMPOUND-RECOGNIZER NATP-COMPOUND-RECOGNIZER)
        (:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION FIX)
        (:DEFINITION NOT)
        (:DEFINITION SUM-TO-N)
        (:EXECUTABLE-COUNTERPART BINARY-*)
        (:EXECUTABLE-COUNTERPART BINARY-+)
        (:EXECUTABLE-COUNTERPART EQUAL)
        (:EXECUTABLE-COUNTERPART NATP)
        (:EXECUTABLE-COUNTERPART NOT)
        (:EXECUTABLE-COUNTERPART SUM-TO-N)
        (:EXECUTABLE-COUNTERPART TAU-SYSTEM)
        (:EXECUTABLE-COUNTERPART UNARY--)
        (:EXECUTABLE-COUNTERPART ZP)
        (:FAKE-RUNE-FOR-LINEAR NIL)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:FORWARD-CHAINING NATP-FC-1)
        (:INDUCTION SUM-TO-N)
        (:REWRITE ASSOCIATIVITY-OF-*)
        (:REWRITE ASSOCIATIVITY-OF-+)
        (:REWRITE COMMUTATIVITY-2-OF-*)
        (:REWRITE COMMUTATIVITY-2-OF-+)
        (:REWRITE COMMUTATIVITY-OF-*)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE DISTRIBUTIVITY)
        (:REWRITE DISTRIBUTIVITY-OF-MINUS-OVER-+)
        (:REWRITE FUNCTIONAL-COMMUTATIVITY-OF-MINUS-*-RIGHT)
        (:REWRITE MINUS-CANCELLATION-ON-LEFT)
        (:REWRITE UNICITY-OF-1)
        (:TYPE-PRESCRIPTION NONNEGATIVE-PRODUCT))
Time:  0.01 seconds (prove: 0.01, print: 0.00, other: 0.00)
Prover steps counted:  569

Proof succeeded.
ACL2 !>(thm ; fails
        (implies (natp k)
                 (equal (sum-to-n (* 2 k))
                        (* k (+ (* 2 k) 1)))))
Goal'

([ A key checkpoint:

Goal'
(IMPLIES (NATP K)
         (EQUAL (SUM-TO-N (* 2 K))
                (+ K (* 2 K K))))

*1 (Goal') is pushed for proof by induction.

])

No induction schemes are suggested by *1.  Consequently, the proof
attempt has failed.

Summary
Form:  ( THM ...)
Rules: ((:COMPOUND-RECOGNIZER NATP-COMPOUND-RECOGNIZER)
        (:DEFINITION FIX)
        (:REWRITE COMMUTATIVITY-2-OF-*)
        (:REWRITE COMMUTATIVITY-OF-*)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE DISTRIBUTIVITY)
        (:REWRITE UNICITY-OF-1))
Time:  0.00 seconds (prove: 0.00, print: 0.00, other: 0.00)
Prover steps counted:  319

---
The key checkpoint goal, below, may help you to debug this failure.
See :DOC failure and see :DOC set-checkpoint-summary-limit.
---

*** Key checkpoint at the top level: ***

Goal'
(IMPLIES (NATP K)
         (EQUAL (SUM-TO-N (* 2 K))
                (+ K (* 2 K K))))

ACL2 Error in ( THM ...):  See :DOC failure.

******** FAILED ********
ACL2 !>(defthm sum-to-n-rewrite ; create a rewrite rule
	 (implies (natp n)
		  (equal (sum-to-n n)
			 (/ (* n (+ n 1))
			    2))))
Goal'
Goal''

([ A key checkpoint:

Goal''
(IMPLIES (NATP N)
         (EQUAL (SUM-TO-N N)
                (+ (* 1/2 N) (* 1/2 N N))))

*1 (Goal'') is pushed for proof by induction.

])

Perhaps we can prove *1 by induction.  One induction scheme is suggested
by this conjecture.  

We will induct according to a scheme suggested by (SUM-TO-N N).  This
suggestion was produced using the :induction rule SUM-TO-N.  If we
let (:P N) denote *1 above then the induction scheme we'll use is
(AND (IMPLIES (AND (NOT (ZP N)) (:P (+ -1 N)))
              (:P N))
     (IMPLIES (ZP N) (:P N))).
This induction is justified by the same argument used to admit SUM-TO-N.
When applied to the goal at hand the above induction scheme produces
three nontautological subgoals.
Subgoal *1/3
Subgoal *1/3'
Subgoal *1/2
Subgoal *1/1

*1 is COMPLETED!
Thus key checkpoint Goal'' is COMPLETED!

Q.E.D.

Summary
Form:  ( DEFTHM SUM-TO-N-REWRITE ...)
Rules: ((:COMPOUND-RECOGNIZER NATP-COMPOUND-RECOGNIZER)
        (:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION FIX)
        (:DEFINITION NOT)
        (:DEFINITION SUM-TO-N)
        (:EXECUTABLE-COUNTERPART BINARY-*)
        (:EXECUTABLE-COUNTERPART BINARY-+)
        (:EXECUTABLE-COUNTERPART EQUAL)
        (:EXECUTABLE-COUNTERPART NATP)
        (:EXECUTABLE-COUNTERPART NOT)
        (:EXECUTABLE-COUNTERPART SUM-TO-N)
        (:EXECUTABLE-COUNTERPART TAU-SYSTEM)
        (:EXECUTABLE-COUNTERPART UNARY--)
        (:EXECUTABLE-COUNTERPART ZP)
        (:FAKE-RUNE-FOR-LINEAR NIL)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:FORWARD-CHAINING NATP-FC-1)
        (:INDUCTION SUM-TO-N)
        (:REWRITE ASSOCIATIVITY-OF-*)
        (:REWRITE ASSOCIATIVITY-OF-+)
        (:REWRITE COMMUTATIVITY-2-OF-*)
        (:REWRITE COMMUTATIVITY-2-OF-+)
        (:REWRITE COMMUTATIVITY-OF-*)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE DISTRIBUTIVITY)
        (:REWRITE DISTRIBUTIVITY-OF-MINUS-OVER-+)
        (:REWRITE FUNCTIONAL-COMMUTATIVITY-OF-MINUS-*-RIGHT)
        (:REWRITE MINUS-CANCELLATION-ON-LEFT)
        (:REWRITE UNICITY-OF-1)
        (:TYPE-PRESCRIPTION NONNEGATIVE-PRODUCT))
Time:  0.01 seconds (prove: 0.01, print: 0.00, other: 0.00)
Prover steps counted:  569
 SUM-TO-N-REWRITE
ACL2 !>(thm ; now, succeeds immediately
        (implies (natp k)
                 (equal (sum-to-n (* 2 k))
                        (* k (+ (* 2 k) 1)))))

Q.E.D.

Summary
Form:  ( THM ...)
Rules: ((:COMPOUND-RECOGNIZER NATP-COMPOUND-RECOGNIZER)
        (:DEFINITION FIX)
        (:DEFINITION SYNP)
        (:EXECUTABLE-COUNTERPART BINARY-*)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:REWRITE COMMUTATIVITY-2-OF-*)
        (:REWRITE COMMUTATIVITY-OF-*)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE DISTRIBUTIVITY)
        (:REWRITE FOLD-CONSTS-IN-*)
        (:REWRITE SUM-TO-N-REWRITE)
        (:REWRITE UNICITY-OF-1))
Time:  0.00 seconds (prove: 0.00, print: 0.00, other: 0.00)
Prover steps counted:  156

Proof succeeded.
ACL2 !>
