File: rp-then-fgl.lisp

package info (click to toggle)
acl2 8.6%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: trixie
  • size: 1,111,420 kB
  • sloc: lisp: 17,818,294; java: 125,359; python: 28,122; javascript: 23,458; cpp: 18,851; ansic: 11,569; perl: 7,678; xml: 5,591; sh: 3,976; makefile: 3,833; ruby: 2,633; yacc: 1,126; ml: 763; awk: 295; csh: 233; lex: 197; php: 178; tcl: 49; asm: 23; haskell: 17
file content (217 lines) | stat: -rw-r--r-- 7,463 bytes parent folder | download | duplicates (2)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
; Use Rp-rewriter, then FGL as clause-processors (and some other things in between)
;
; Copyright (C) 2021 Centaur Technology
;
; 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.
;
; Original author: Mertcan Temel <mert@centtech.com>

(in-package "RP")

(include-book "top")
(include-book "centaur/fgl/portcullis" :dir :system)
(include-book "centaur/meta/let-abs" :dir :system)

;; (local
;;  (include-book "centaur/gl/bfr-satlink" :dir :system))

;; (local
;;  (value-triple (acl2::tshell-ensure)))


(defevaluator letabs-ev2 letabs-ev2-list
  ((if a b c)
   (implies a b)
   (not a))
  :namedp t)

(defthm letabs-ev2-of-let-abstract-term
  (equal (letabs-ev2 (cmr::let-abstract-term cmr::x cmr::base-var) acl2::a)
         (letabs-ev2 cmr::x acl2::a))
  :hints (("goal" :use ((:functional-instance cmr::letabs-ev-of-let-abstract-term
                                              (cmr::letabs-ev letabs-ev2)
                                              (cmr::letabs-ev-list letabs-ev2-list )))
           :in-theory (enable letabs-ev2-of-fncall-args
                              letabs-ev2-of-bad-fncall
                              letabs-ev2-of-nonsymbol-atom))))

(define cmr::let-abstract-full-clause-proc-exclude-hyps
  ((clause pseudo-term-listp)
   var)
  (b* (((unless (acl2::pseudo-var-p var)) (list clause))
       (term (acl2::disjoin clause)))
    (case-match term
      (('implies p q)
       (let* ((p (cmr::let-abstract-term p var))
              (q (cmr::let-abstract-term q var)))
         (list (list `(implies ,p ,q)))))
      (&
       (list (list (cmr::let-abstract-term term var))))))
  ///

  (defthm cmr::let-abstract-full-clause-proc-exclude-hyps-correct
    (implies (and (pseudo-term-listp clause)
                  (alistp a)
                  (letabs-ev2
                   (acl2::conjoin-clauses
                    (cmr::let-abstract-full-clause-proc-exclude-hyps clause
                                                                     var))
                   a))
             (letabs-ev2 (acl2::disjoin clause) a))
    :rule-classes :clause-processor
    :hints (("Goal"
             :do-not-induct t
             :in-theory (e/d (ACL2::DISJOIN) ())))))

(defmacro defthmrp-then-fgl (name term &rest args)
  `(make-event
    (b* ((name ',name)
         (term ',term)
         (args ',args)
         (__FUNCTION__ 'defthmrp-then-fgl)
         ((std::extract-keyword-args
           :allowed-keys #!keyword'(rule-classes
                                    new-synps
                                    vacuity-check
                                    disable-meta-rules
                                    enable-meta-rules
                                    enable-rules
                                    disable-rules
                                    runes runes-outside-in cases
                                    lambda-opt disabled
                                    disabled-for-rp
                                    disabled-for-ACL2
                                    rw-direction
                                    supress-warnings
                                    add-rp-rule
                                    ruleset)
           (new-synps 'nil)
           (runes 'nil)
           (runes-outside-in 'nil)
           (cases 'nil))
          args)
         (world (w state))
         ((acl2::er cases)
          (translate-lst cases t t nil 'defthmrp-then-fgl world state))
         ((acl2::er new-synps-vals) ;; new-synps is an alist...
          (translate-lst (strip-cdrs new-synps) t t nil 'defthmrp-then-fgl world state))
         (new-synps (pairlis$ (strip-cars new-synps) new-synps-vals))
       
         (override-hints `(:hints
                           ('(:clause-processor
                              (rp-cl :runes ,runes
                                     :runes-outside-in ,runes-outside-in
                                     :new-synps ,new-synps
                                     :cases ,cases
                                     :suppress-not-simplified-error t))
                            '(:clause-processor (cmr::let-abstract-full-clause-proc-exclude-hyps
                                                 clause 'var))
                            '(:clause-processor fgl::expand-an-implies-cp)
                            '(:clause-processor (fgl::fgl-interp-cp clause (fgl::default-fgl-config)
                                                                    fgl::interp-st
                                                                    state))
                            ))))
      (value
       `(defthmrp ,name ,term
          :override-cl-hints ,override-hints)))))

#|(defmacro defthmrp-then-fgl (name term
&key
(rule-classes ':rewrite)
;; (use-opener-error-rules 't)
(new-synps 'nil)
(disable-meta-rules 'nil)
(enable-meta-rules 'nil)
(enable-rules 'nil)
(disable-rules 'nil)
(runes 'nil)
(runes-outside-in 'nil) ;; when nil, runes will be read from
;; rp-rules table
(cases 'nil)
)
`(encapsulate
nil
(make-event
(b* ((- (check-if-clause-processor-up-to-date (w state)))
;;(?old-not-simplified-action (not-simplified-action rp-state))

(body `(with-output
:stack :pop
:on (acl2::summary acl2::event acl2::error)
:gag-mode :goals
:summary-off (:other-than acl2::time acl2::rules)
(def-rp-rule ,',name ,',term
:rule-classes ,',rule-classes
:hints
('(:clause-processor
(rp-cl :runes ,,runes
:runes-outside-in ,,runes-outside-in
:new-synps ,',new-synps
:cases ,',cases
:suppress-not-simplified-error t))
'(:clause-processor (cmr::let-abstract-full-clause-proc-exclude-hyps
clause 'var))
'(:clause-processor fgl::expand-an-implies-cp)
'(:clause-processor (fgl::fgl-interp-cp clause (fgl::default-fgl-config)
fgl::interp-st
state))
)

)))
(event
,(if (or disable-meta-rules
enable-meta-rules
enable-rules
disable-rules)
``(with-output
:off :all
:stack :push
(encapsulate
nil

,@(if ',enable-meta-rules
`((local
(enable-meta-rules ,@',enable-meta-rules)))
'nil)

,@(if ',disable-meta-rules
`((local
(disable-meta-rules ,@',disable-meta-rules)))
'nil)

,@(if ',enable-rules
`((local
(enable-rules ,',enable-rules)))
'nil)

,@(if ',disable-rules
`((local
(disable-rules ,',disable-rules)))
'nil)
,body))
`body)))
(mv nil event state rp-state)))

#|(make-event
(b* ((rp-state (update-not-simplified-action :error rp-state)))
(mv nil `(value-triple :none) state rp-state)))|#

))|#