This file is indexed.

/usr/share/acl2-6.3/books/tools/case-splitting-rules.lisp is in acl2-books-source 6.3-5.

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
; case-splitting-rules -- figure out which rules caused case splits
; Copyright (C) 2012 Centaur Technology
;
; Contact:
;   Centaur Technology Formal Verification Group
;   7600-C N. Capital of Texas Highway, Suite 300, Austin, TX 78731, USA.
;   http://www.centtech.com/
;
; This program is free software; you can redistribute it and/or modify it under
; the terms of the GNU General Public License as published by the Free Software
; Foundation; either version 2 of the License, or (at your option) any later
; version.  This program is distributed in the hope that it will be useful but
; WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
; FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
; more details.  You should have received a copy of the GNU General Public
; License along with this program; if not, write to the Free Software
; Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
;
; Original authors: Sol Swords and Jared Davis
;                   {sswords,jared}@centtech.com

(in-package "ACL2")
(include-book "bstar")

; This is something you can use to figure out which rewrite rules led to case
; splits in a proof.  The interface is terrible:
;
; First, do:
;     (set-raw-proof-format t)
;
; Then, try your proof and find the goal that is case splitting on you.  The
; proof log will then have a big list of rules:
;
;    ((:rewrite ...) (:definition ...))
;
; Copy this s-expression, and then submit the form:
;
;    (case-splitting-rules ((:rewrite ...) (:definition ...)))
;
; This will print out just the rewrite rules with IF on their right-hand side.
;
; Known Limits:
;  - Does not show you non-rewrite rules (e.g., :definition rules)
;  - Does not show you rules with (case-split ...) in their hyps

(defun not-pr-body (wrld-segment numes wrld state)
  (declare (xargs :stobjs state :mode :program))
  (info-for-rules (actual-props wrld-segment nil nil)
                  numes
                  (ens state)
                  wrld))

(defun not-pr-fn (name state)
  (declare (xargs :stobjs state :mode :program))
  (cond ((and (symbolp name)
              (not (keywordp name)))
         (let* ((wrld (w state))
                (name (deref-macro-name name (macro-aliases wrld)))
                (numes (strip-cars (getprop name 'runic-mapping-pairs nil
                                            'current-acl2-world wrld)))
                (wrld-segment (world-to-next-event
                               (cdr (decode-logical-name name wrld)))))
           (not-pr-body wrld-segment numes wrld state)))
        (t (er hard? 'not-pr
               "The argument to NOT-PR must be a non-keyword symbol."))))

(defun not-pr-fn-list (names state)
  (declare (xargs :stobjs state :mode :program))
  (if (atom names)
      nil
    (append (not-pr-fn (car names) state)
            (not-pr-fn-list (cdr names) state))))

(defun easy-translate
  (term  ; the term you want to translate (i.e., macro-expand)
   ctx   ; a "context" for error messages
   state)
  "Returns (MV ER VAL STATE)"
  (declare (xargs :mode :program :stobjs state))
  (translate term ;; term to translate
             t ;; we're translating for logical use
             t ;; logic mode
             t ;; known stobjs, t means "all stobjs in world"
             ctx
             (w state)
             state))

(mutual-recursion
 (defun has-callp (fn x)
   (cond ((atom x)
          nil)
         ((quotep x)
          nil)
         ((equal (car x) fn)
          t)
         ((atom (car x))
          (has-callp-list fn (cdr x)))
         (t ;; ((lambda formals body) args)
          (or (has-callp fn (third (first x)))
              (has-callp-list fn (cdr x))))))
 (defun has-callp-list (fn x)
   (if (atom x)
       nil
     (or (has-callp fn (car x))
         (has-callp-list fn (cdr x))))))

(defun collect-case-splits (info-list state)
  (declare (xargs :mode :program :stobjs state))
  (b* (((when (atom info-list))
        (mv nil state))
       (rhs-values (cdr (assoc :rhs (car info-list))))
       ((unless rhs-values)
        (collect-case-splits (cdr info-list) state))
       ((mv er val state)
        (easy-translate (car rhs-values) 'collect-case-splits state))
       ((when er)
        (er hard? 'collect-case-splits "something bad happened: ~@0" er)
        (mv nil state))
       ((mv rest state) (collect-case-splits (cdr info-list) state))
       ((when (has-callp 'if val))
        (mv (cons (car info-list) rest) state)))
    (mv rest state)))

(defun collect-rewrites (info-list)
  (if (atom info-list)
      nil
    (if (eq (caadr (assoc :rune (car info-list))) :rewrite)
        (cons (car info-list) (collect-rewrites (cdr info-list)))
      (collect-rewrites (cdr info-list)))))

(defmacro case-splitting-rules (x)
  `(b* ((info (not-pr-fn-list (acl2::strip-cadrs ',x) state))
        (rewrites (collect-rewrites info))
        ((mv splits state)
         (collect-case-splits rewrites state)))
     (print-info-for-rules splits (standard-co state) state)))