ACL2 !>(defun fib (n)
	 (declare (type (integer 0 *) n))
	 (if (zp n)
	     0
	   (if (eql n 1)
	       1
	     (+ (fib (- n 1))
		(fib (- n 2))))))

For the admission of FIB we will use the relation O< (which is known
to be well-founded on the domain recognized by O-P) and the measure
(ACL2-COUNT N).  The non-trivial part of the measure conjecture is

Goal
(IMPLIES (AND (NOT (ZP N)) (NOT (EQL N 1)))
         (O< (ACL2-COUNT (+ -2 N))
             (ACL2-COUNT N))).
Goal'

Splitter note (see :DOC splitter) for Goal' (2 subgoals).
  if-intro: ((:DEFINITION ACL2-COUNT)
             (:DEFINITION INTEGER-ABS)
             (:DEFINITION O<))

Subgoal 2
Subgoal 1

Q.E.D.

That completes the proof of the measure theorem for FIB.  Thus, we
admit this function under the principle of definition.  We observe
that the type of FIB is described by the theorem 
(AND (INTEGERP (FIB N)) (<= 0 (FIB N))).  We used primitive type reasoning.

Computing the guard conjecture for FIB....

The non-trivial part of the guard conjecture for FIB, given the :compound-
recognizer rule ZP-COMPOUND-RECOGNIZER, the :executable-counterpart
of EQLABLEP, primitive type reasoning and the :type-prescription rule
FIB, is

Goal
(IMPLIES (AND (<= 0 N)
              (INTEGERP N)
              (NOT (ZP N))
              (NOT (EQL N 1)))
         (<= 0 (+ -2 N))).

Q.E.D.

That completes the proof of the guard theorem for FIB.  FIB is compliant
with Common Lisp.

Summary
Form:  ( DEFUN FIB ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION ACL2-COUNT)
        (:DEFINITION EQL)
        (:DEFINITION INTEGER-ABS)
        (:DEFINITION NOT)
        (:DEFINITION O-FINP)
        (:DEFINITION O<)
        (:EXECUTABLE-COUNTERPART EQLABLEP)
        (:EXECUTABLE-COUNTERPART TAU-SYSTEM)
        (:EXECUTABLE-COUNTERPART UNARY--)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:REWRITE DISTRIBUTIVITY-OF-MINUS-OVER-+)
        (:TYPE-PRESCRIPTION FIB))
Splitter rules (see :DOC splitter):
  if-intro: ((:DEFINITION ACL2-COUNT)
             (:DEFINITION INTEGER-ABS)
             (:DEFINITION O<))
Time:  0.02 seconds (prove: 0.00, print: 0.00, other: 0.01)
Prover steps counted:  202
 FIB
ACL2 !>(time$ (fib 40))
; (EV-REC *RETURN-LAST-ARG3* ...) took 
; 1.73 seconds realtime, 1.73 seconds runtime
; (16 bytes allocated).
102334155
ACL2 !>(time$ (fib 40))
; (EV-REC *RETURN-LAST-ARG3* ...) took 
; 1.72 seconds realtime, 1.72 seconds runtime
; (16 bytes allocated).
102334155
ACL2 !>(defun fib-calls (n)
	 (declare (type (integer 0 *) n))
	 (if (zp n)
	     1
	   (if (eql n 1)
	       1
	     (+ (fib-calls (- n 1))
		(fib-calls (- n 2))))))

For the admission of FIB-CALLS we will use the relation O< (which is
known to be well-founded on the domain recognized by O-P) and the measure
(ACL2-COUNT N).  The non-trivial part of the measure conjecture is

Goal
(IMPLIES (AND (NOT (ZP N)) (NOT (EQL N 1)))
         (O< (ACL2-COUNT (+ -2 N))
             (ACL2-COUNT N))).
Goal'

Splitter note (see :DOC splitter) for Goal' (2 subgoals).
  if-intro: ((:DEFINITION ACL2-COUNT)
             (:DEFINITION INTEGER-ABS)
             (:DEFINITION O<))

Subgoal 2
Subgoal 1

Q.E.D.

That completes the proof of the measure theorem for FIB-CALLS.  Thus,
we admit this function under the principle of definition.  We observe
that the type of FIB-CALLS is described by the theorem 
(AND (INTEGERP (FIB-CALLS N)) (< 0 (FIB-CALLS N))).  We used primitive
type reasoning.

Computing the guard conjecture for FIB-CALLS....

The non-trivial part of the guard conjecture for FIB-CALLS, given the
:compound-recognizer rule ZP-COMPOUND-RECOGNIZER, the :executable-
counterpart of EQLABLEP, primitive type reasoning and the :type-prescription
rule FIB-CALLS, is

Goal
(IMPLIES (AND (<= 0 N)
              (INTEGERP N)
              (NOT (ZP N))
              (NOT (EQL N 1)))
         (<= 0 (+ -2 N))).

Q.E.D.

That completes the proof of the guard theorem for FIB-CALLS.  FIB-CALLS
is compliant with Common Lisp.

Summary
Form:  ( DEFUN FIB-CALLS ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION ACL2-COUNT)
        (:DEFINITION EQL)
        (:DEFINITION INTEGER-ABS)
        (:DEFINITION NOT)
        (:DEFINITION O-FINP)
        (:DEFINITION O<)
        (:EXECUTABLE-COUNTERPART EQLABLEP)
        (:EXECUTABLE-COUNTERPART TAU-SYSTEM)
        (:EXECUTABLE-COUNTERPART UNARY--)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:REWRITE DISTRIBUTIVITY-OF-MINUS-OVER-+)
        (:TYPE-PRESCRIPTION FIB-CALLS))
Splitter rules (see :DOC splitter):
  if-intro: ((:DEFINITION ACL2-COUNT)
             (:DEFINITION INTEGER-ABS)
             (:DEFINITION O<))
Time:  0.01 seconds (prove: 0.00, print: 0.00, other: 0.01)
Prover steps counted:  202
 FIB-CALLS
ACL2 !>(thm (implies (natp n)
		     (equal (fib-calls n)
			    (fib (+ 1 n)))))
Goal'

([ A key checkpoint:

Goal'
(IMPLIES (AND (INTEGERP N) (<= 0 N))
         (EQUAL (FIB-CALLS N) (FIB (+ 1 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 (FIB-CALLS N).  This
suggestion was produced using the :induction rule FIB-CALLS.  If we
let (:P N) denote *1 above then the induction scheme we'll use is
(AND (IMPLIES (AND (NOT (ZP N))
                   (NOT (EQL N 1))
                   (:P (+ -1 N))
                   (:P (+ -2 N)))
              (:P N))
     (IMPLIES (AND (NOT (ZP N)) (EQL N 1))
              (:P N))
     (IMPLIES (ZP N) (:P N))).
This induction is justified by the same argument used to admit FIB-CALLS.
When applied to the goal at hand the above induction scheme produces
eleven nontautological subgoals.
Subgoal *1/11
Subgoal *1/11'
Subgoal *1/11''
Subgoal *1/10
Subgoal *1/9
Subgoal *1/8
Subgoal *1/7
Subgoal *1/6
Subgoal *1/5
Subgoal *1/4
Subgoal *1/3
Subgoal *1/2
Subgoal *1/2'
Subgoal *1/1

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

Q.E.D.

Summary
Form:  ( THM ...)
Rules: ((:COMPOUND-RECOGNIZER ZP-COMPOUND-RECOGNIZER)
        (:DEFINITION EQL)
        (:DEFINITION FIB)
        (:DEFINITION FIB-CALLS)
        (:DEFINITION FIX)
        (:DEFINITION NATP)
        (:DEFINITION NOT)
        (:DEFINITION SYNP)
        (:EXECUTABLE-COUNTERPART <)
        (:EXECUTABLE-COUNTERPART BINARY-+)
        (:EXECUTABLE-COUNTERPART EQUAL)
        (:EXECUTABLE-COUNTERPART FIB)
        (:EXECUTABLE-COUNTERPART FIB-CALLS)
        (:EXECUTABLE-COUNTERPART INTEGERP)
        (:EXECUTABLE-COUNTERPART NOT)
        (:EXECUTABLE-COUNTERPART TAU-SYSTEM)
        (:EXECUTABLE-COUNTERPART ZP)
        (:FAKE-RUNE-FOR-LINEAR NIL)
        (:FAKE-RUNE-FOR-TYPE-SET NIL)
        (:INDUCTION FIB-CALLS)
        (:REWRITE COMMUTATIVITY-OF-+)
        (:REWRITE FOLD-CONSTS-IN-+)
        (:REWRITE UNICITY-OF-0))
Time:  0.02 seconds (prove: 0.01, print: 0.00, other: 0.00)
Prover steps counted:  968

Proof succeeded.
ACL2 !>(time$ (fib 41))
; (EV-REC *RETURN-LAST-ARG3* ...) took 
; 2.78 seconds realtime, 2.78 seconds runtime
; (16 bytes allocated).
165580141
ACL2 !>(memoize 'fib)


ACL2 !>>(TABLE
             MEMOIZE-TABLE
             (DEREF-MACRO-NAME 'FIB
                               (MACRO-ALIASES WORLD))
             (LIST* (CONS :CONDITION-FN T)
                    (CONS :INLINE T)
                    (CONS :COMMUTATIVE NIL)
                    (CONS :FORGET NIL)
                    (CONS :MEMO-TABLE-INIT-SIZE (OR NIL *MHT-DEFAULT-SIZE*))
                    (CONS :AOKP 'NIL)
                    (CONS :STATS :DEFAULT)
                    (AND (NOT (EQ ':DEFAULT :DEFAULT))
                         (LIST (CONS :IDEAL-OKP ':DEFAULT)))))

Summary
Form:  ( TABLE MEMOIZE-TABLE ...)
Rules: NIL
Time:  0.01 seconds (prove: 0.00, print: 0.00, other: 0.01)
MEMOIZE-TABLE


ACL2 !>>(VALUE-TRIPLE (DEREF-MACRO-NAME 'FIB
                                        (MACRO-ALIASES (W STATE))))
FIB

Summary
Form:  ( PROGN (TABLE MEMOIZE-TABLE ...) ...)
Rules: NIL
Time:  0.02 seconds (prove: 0.00, print: 0.00, other: 0.02)
 FIB
ACL2 !>(time$ (fib 40))
; (EV-REC *RETURN-LAST-ARG3* ...) took 
; 0.00 seconds realtime, 0.00 seconds runtime
; (1,728 bytes allocated).
102334155
ACL2 !>(time$ (fib 10000))
; (EV-REC *RETURN-LAST-ARG3* ...) took 
; 0.02 seconds realtime, 0.02 seconds runtime
; (5,340,720 bytes allocated).
33644764876431783266621612005107543310302148460680063906564769974680081442166662368155595513633734025582065332680836159373734790483865268263040892463056431887354544369559827491606602099884183933864652731300088830269235673613135117579297437854413752130520504347701602264758318906527890855154366159582987279682987510631200575428783453215515103870818298969791613127856265033195487140214287532698187962046936097879900350962302291026368131493195275630227837628441540360584402572114334961180023091208287046088923962328835461505776583271252546093591128203925285393434620904245248929403901706233888991085841065183173360437470737908552631764325733993712871937587746897479926305837065742830161637408969178426378624212835258112820516370298089332099905707920064367426202389783111470054074998459250360633560933883831923386783056136435351892133279732908133732642652633989763922723407882928177953580570993691049175470808931841056146322338217465637321248226383092103297701648054726243842374862411453093812206564914032751086643394517512161526545361333111314042436854805106765843493523836959653428071768775328348234345557366719731392746273629108210679280784718035329131176778924659089938635459327894523777674406192240337638674004021330343297496902028328145933418826817683893072003634795623117103101291953169794607632737589253530772552375943788434504067715555779056450443016640119462580972216729758615026968443146952034614932291105970676243268515992834709891284706740862008587135016260312071903172086094081298321581077282076353186624611278245537208532365305775956430072517744315051539600905168603220349163222640885248852433158051534849622434848299380905070483482449327453732624567755879089187190803662058009594743150052402532709746995318770724376825907419939632265984147498193609285223945039707165443156421328157688908058783183404917434556270520223564846495196112460268313970975069382648706613264507665074611512677522748621598642530711298441182622661057163515069260029861704945425047491378115154139941550671256271197133252763631939606902895650288268608362241082050562430701794976171121233066073310059947366875
ACL2 !>
