This file is indexed.

/usr/share/acl2-7.2dfsg/books/make-event/dotimes.lisp is in acl2-books-source 7.2dfsg-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#|

   Dotimes, Version 0.2
   Copyright (C) 2006 by David Rager <ragerdl@cs.utexas.edu>

 License: (An MIT/X11-style license)

   Permission is hereby granted, free of charge, to any person obtaining a
   copy of this software and associated documentation files (the "Software"),
   to deal in the Software without restriction, including without limitation
   the rights to use, copy, modify, merge, publish, distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so, subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
   DEALINGS IN THE SOFTWARE.

 dotimes.lisp

   This file provides a dotimes$ macro for use at the top-level.  I also needed
   a version of dotimes that returned error triples so that I could run events
   multiple times for performance benchmarking.  Dotimes$-with-error-triple
   meets these requirements.  The use of dotimes$-with-error-triple requires an
   active ttag.

   Anyone should feel to cleanup or enhance these macros.

Jared Davis, Matt Kaufmann, and Sandip Ray contributed to this book.
|#

(in-package "ACL2")

(defmacro dotimes$ (var-limit-form form &key (name 'dotimes-default-name-foo))
  (declare (xargs :guard (and (true-listp var-limit-form)
                              (equal (length var-limit-form) 2))))

  (let ((var (car var-limit-form))
        (limit (cadr var-limit-form)))

    `(make-event
      (with-output
       :off summary
       (progn
         (with-output
          :off :all
          (defun ,name (,var)
            (declare (xargs :measure (acl2-count ,var)))
            (if (zp ,var)
                (cw "Done with dotimes~%")
              (prog2$ ,form
                      (,name (1- ,var))))))
         (value-triple (,name ,limit))
         (value-triple '(value-triple :invisible)

; The following keyword :on-skip-proofs t was added by Matt K. after v4-3.
; Without it, value-triple returns (mv nil :skipped state) when skipping
; proofs, as is done during the Expand/Port step of provisional certification
; (see :DOC provisional-certification).

                       :on-skip-proofs t))))))

(defmacro dotimes$-with-error-triple
  (var-limit-form form &key (name 'dotimes-default-name-foo))
  (declare (xargs :guard (and (true-listp var-limit-form)
                              (equal (length var-limit-form) 2))))

  (let ((var (car var-limit-form))
        (limit (cadr var-limit-form)))

    `(make-event
      (with-output
       :off summary
       (progn!
         (with-output
          :off :all
          (progn
            (set-state-ok t)
            (defun ,name (,var state)
              (declare (xargs :measure (acl2-count ,var)
                              :mode :program))
              (if (zp ,var)
                  (mv nil (cw "Done with dotimes~%") state)
                (mv-let (erp val state)
                  ,form
; I don't have a need to recognize errors right now.  Someone else can feel
; free to implement such a feature if they like.
                  (declare (ignore erp val))
                  (,name (1- ,var) state))))
            (set-state-ok nil)))
         (,name ,limit state)
         (value-triple '(value-triple :invisible)
; See comment about addition of :on-skip-proofs t in the definition of
; dotimes$.
                       :on-skip-proofs t))))))

; A test:
(local
 (encapsulate
  ()

  (defun fib (x)
    (declare (xargs :guard (natp x)))
    (cond ((mbe :logic (or (zp x) (<= x 0))
                :exec (<= x 0))
           0)
          ((= x 1)
           1)

          (t
           (let ((a (fib (- x 1)))
                 (b (fib (- x 2))))

             (+ a b)))))

  (dotimes$ (i 4) (time$ (fib 25)) :name dotimes-foo)))

#|
; The following examples work, but I have disabled them so that people can
; include this book without needing an active ttag.  Note that the use of
; dotimes$-with-error-triple does require an active ttag.

(defttag t)

(local
 (encapsulate
  ()
  (dotimes$-with-error-triple
   (i 4)
   (time$ (thm (equal 3 3))))))

(dotimes$-with-error-triple
 (i 100)
 (thm (equal (append x (append y z))
             (append (append x y) z)))
 :name dotimes-thmm)

|#