4
;; Functions for extending ACL2 in ways that are potentially unsound
6
;; By Peter C. Dillinger with contributions by Matt Kaufmann
11
(ld ;; Newline to fool dependency scanner
14
(begin-book);$ACL2s-Preamble$|#
16
(in-package "ACL2-HACKER")
21
;=========== some auxiliary definitions ===========
23
; the special progn! support for doing state-global bindings was changed between
24
; 3.2 and 3.2.1. We define progn!-with-bindings to use the right one.
26
(if (earlier-acl2-versionp "ACL2 Version 3.2" (@ acl2-version)) ; >= 3.2.1
28
'(defmacro progn!-with-bindings (bindings &rest rst)
29
`(progn! :state-global-bindings ,bindings . ,rst)))
31
'(defmacro progn!-with-bindings (bindings &rest rst)
32
`(progn! (state-global-let* ,bindings (progn! . ,rst)))))))
34
; read a state global or return a default value (defaulting to nil) if unbound
35
(defmacro @opt (var &optional deflt)
36
`(if (boundp-global ',var state)
37
(f-get-global ',var state)
40
; like common lisp WHEN, but uses ACL2 error triples
41
(defmacro er-when (test form &rest more-forms)
43
(er-progn ,form . ,more-forms)
46
; to enable definition of macros that use keyword arguments at the beginning
47
(defun transpose-keyword-args1 (args-rest kargs-sofar)
48
(if (and (consp args-rest)
49
(keywordp (car args-rest))
50
(consp (cdr args-rest)))
51
(transpose-keyword-args1 (cddr args-rest)
52
(list* (car args-rest)
55
(cons args-rest kargs-sofar)))
57
(defun transpose-keyword-args (args)
58
(transpose-keyword-args1 args nil))
62
;=========== begin touchable stuff ===========
64
; union in the specification language of temp-untouchable-{vars,fns}
65
(defun union-eq-with-top (a b)
66
(if (or (eq a t) (eq b t))
70
; used for temp-touchable specifications
71
(defun add-temp-touchable-aliases (spec sofar fn-p)
72
(declare (xargs :guard (booleanp fn-p)))
75
(let ((sym (if (consp spec) (car spec) spec))
76
(rest (if (consp spec) (cdr spec) nil)))
77
(add-temp-touchable-aliases
84
acl2::*initial-untouchable-fns*
85
acl2::*initial-untouchable-vars*))
91
#|; flawed in terms of undoing
93
; defines a stack of saved untouchables
94
(defun push-temp-touchables (state)
95
(f-put-global 'saved-temp-touchables
96
(cons (cons (@ temp-touchable-vars)
97
(@ temp-touchable-fns))
98
(@opt saved-temp-touchables))
101
(defun pop-temp-touchables (state)
102
(if (and (boundp-global 'saved-temp-touchables state)
103
(consp (@ saved-temp-touchables)))
104
(let ((result (car (@ saved-temp-touchables))))
105
(pprogn (f-put-global 'saved-temp-touchables
106
(cdr (@ saved-temp-touchables))
109
(er soft 'pop-temp-touchables
110
"Stack of temp-touchables is empty.")))
112
(push-untouchable saved-temp-touchables nil)
115
(defmacro push+touchable (&key vars fns)
117
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
118
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
120
; ":Doc-Section hacker
122
; add some fns/vars to those temporarily touchable, remembering previous setting.~/
126
; (push+touchable :fns :all :vars :all) ; like push-all-touchable
127
; (push+touchable :fns set-w :vars :initial)
128
; (push+touchable :vars (foo :initial bar))
131
; This event first pushes the previous temporary touchable settings
132
; (functions and variables) onto a stack (stored in a global variable)
133
; and then adds all those that meet the specification passed in.
135
; ~ilc[pop-touchable] reinstates the previous setting.
137
; An active ttag is required to use this form (~l[defttag]) because it
138
; can render ACL2 unsound (~l[remove-untouchable]).
140
`(progn! (push-temp-touchables state)
141
(set-temp-touchable-vars
142
(add-temp-touchable-aliases ',vars (@ temp-touchable-vars) nil)
144
(set-temp-touchable-fns
145
(add-temp-touchable-aliases ',fns (@ temp-touchable-fns) t)
149
(defmacro push=touchable (&key vars fns)
151
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
152
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
154
; ":Doc-Section hacker
156
; set which fns/vars are temporarily touchable, remembering previous setting.~/
160
; (push=touchable :fns :all :vars :all) ; like push-all-touchable
161
; (push=touchable :fns set-w :vars :initial)
162
; (push=touchable :vars (foo :initial bar)) ;``:fns ()'' default
165
; This event first pushes the previous temporary touchable settings
166
; (functions and variables) onto a stack (stored in a global variable)
167
; and then sets them to the specification passed in.
169
; ~ilc[pop-touchable] reinstates the previous setting.
171
; An active ttag is required to use this form (~l[defttag]) because it
172
; can render ACL2 unsound (~l[remove-untouchable]).
174
`(progn! (push-temp-touchables state)
175
(set-temp-touchable-vars
176
(add-temp-touchable-aliases ',vars nil nil)
178
(set-temp-touchable-fns
179
(add-temp-touchable-aliases ',fns nil t)
183
(defmacro push-all-touchable ()
185
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
186
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
188
; ":Doc-Section hacker
190
; make all fns/vars temporarily touchable, remembering previous setting.~/
194
; (push-all-touchable)
197
; This event first pushes the previous temporary touchable settings
198
; (functions and variables) onto a stack (stored in a global variable)
199
; and then sets them to make everything temporarily touchable.
201
; ~ilc[pop-touchable] reinstates the previous setting. ~ilc[push+touchable]
202
; and ~ilc[push=touchable] allow more more specification of what should be
205
; An active ttag is required to use this form (~l[defttag]) because it
206
; can render ACL2 unsound (~l[remove-untouchable]).
208
`(progn! (push-temp-touchables state)
209
(set-temp-touchable-vars t state)
210
(set-temp-touchable-fns t state)))
213
(defmacro pop-touchable ()
215
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
216
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
218
; ":Doc-Section hacker
220
; revert the effect of a push+touchable, push=touchable, or push-all-touchable.~/
227
; This event pops of the stack of saved temporary touchable settings,
228
; reverting the effect of a ~ilc[push+touchable], ~ilc[push=touchable], or
229
; ~ilc[push-all-touchable].
231
; An active ttag is required to use this form (~l[defttag]) because it
232
; can render ACL2 unsound (~l[remove-untouchable]).
235
((to-restore (pop-temp-touchables state)))
236
(pprogn (set-temp-touchable-vars (car to-restore) state)
237
(set-temp-touchable-fns (cdr to-restore) state)
238
(value ':invisible)))))
241
;helper for progn+touchable and progn=touchable
242
(defmacro progn-touchable-keyword (bangp addp form-lst &key vars fns)
243
(declare (xargs :guard form-lst))
244
`(progn!-with-bindings
245
((temp-touchable-vars
246
(add-temp-touchable-aliases ',vars
248
'(@ temp-touchable-vars)
251
set-temp-touchable-vars)
253
(add-temp-touchable-aliases ',fns
255
'(@ temp-touchable-fns)
258
set-temp-touchable-fns))
261
`((progn . ,form-lst)))))
264
(defmacro progn+touchable (&rest args)
266
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
267
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
269
; ":Doc-Section hacker
271
; execute some events with some additional fns and/or vars made temporarily touchable.~/
275
; (progn+touchable :all ; same as :fns :all :vars :all
278
; (progn+touchable :vars (current-package ld-skip-proofsp)
280
; (progn+touchable :fns :all
282
; (progn+touchable :fns set-w :vars :all
286
; This is like ~ilc[progn] except that it surrounds the events with code to
287
; add certain fns and/or vars to those that are temporarily touchable.
289
; Related to ~ilc[progn=touchable].
291
; An active ttag is required to use this form (~l[defttag]) because it
292
; can render ACL2 unsound (~l[remove-untouchable]).
294
; Note that the syntax for this macro is not quite like traditional
295
; keyword arguments, which would come at the end of the argument list.
297
(declare (xargs :guard (and (consp args)
298
(keywordp (car args)))))
299
(if (not (member-eq (car args) '(:vars :fns)))
300
`(progn-touchable-keyword nil t ,(cdr args)
303
`(progn-touchable-keyword nil t . ,(transpose-keyword-args args))))
305
(defmacro progn=touchable (&rest args)
307
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
308
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
310
; ":Doc-Section hacker
312
; execute some events with only the specified fns and/or vars temporarily touchable.~/
316
; (progn=touchable :all ; same as :fns :all :vars :all
319
; (progn=touchable :vars (current-package ld-skip-proofsp) ; :fns () implied
321
; (progn=touchable :fns :all ; :vars () implied
323
; (progn=touchable :fns set-w :vars :all
327
; This is like ~ilc[progn] except that it surrounds the events with code to
328
; set only certain fns and/or vars as temporarily touchable.
330
; Related to ~ilc[progn+touchable].
332
; An active ttag is required to use this form (~l[defttag]) because it
333
; can render ACL2 unsound (~l[remove-untouchable]).
335
; Note that the syntax for this macro is not quite like traditional
336
; keyword arguments, which would come at the end of the argument list.
338
(declare (xargs :guard (and (consp args)
339
(keywordp (car args)))))
340
(if (not (member-eq (car args) '(:vars :fns)))
341
`(progn-touchable-keyword nil nil ,(cdr args)
344
`(progn-touchable-keyword nil nil . ,(transpose-keyword-args args))))
347
(defmacro progn!+touchable (&rest args)
348
(declare (xargs :guard (and (consp args)
349
(keywordp (car args)))))
350
(if (not (member-eq (car args) '(:vars :fns)))
351
`(progn-touchable-keyword t t ,(cdr args)
354
`(progn-touchable-keyword t t . ,(transpose-keyword-args args))))
357
(defmacro progn!=touchable (&rest args)
358
(declare (xargs :guard (and (consp args)
359
(keywordp (car args)))))
360
(if (not (member-eq (car args) '(:vars :fns)))
361
`(progn-touchable-keyword t nil ,(cdr args)
364
`(progn-touchable-keyword t nil . ,(transpose-keyword-args args))))
367
(defmacro with-touchable (&rest args)
369
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
370
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
372
; ":Doc-Section hacker
374
; execute some events but with certain untouchables removed.
376
; Same as ~c[progn+touchable]. ~l[progn+touchable]."
377
`(progn+touchable . ,args))
381
;=========== begin redef stuff ===========
383
(defun put-ld-redefinition-action (v state)
384
(mv-let (erp v state)
385
(set-ld-redefinition-action v state)
389
(hard-error 'put-ld-redefinition-action
390
"~x0 returned an error."
391
'((#\0 . set-ld-redefinition-action))))
394
(defun expand-redef-action-aliases (spec)
395
(cond ((equal spec t)
396
'(:doit! . :overwrite))
400
(defmacro progn+redef-action (spec &rest form-lst)
401
(declare (xargs :guard form-lst))
402
`(progn!-with-bindings
403
((ld-redefinition-action
404
,(if (eq spec :unspecified)
405
'(@ ld-redefinition-action)
406
`(expand-redef-action-aliases ',spec))
407
put-ld-redefinition-action))
408
(progn . ,form-lst)))
411
(defmacro progn+redef (&rest args)
413
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
414
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
416
; ":Doc-Section hacker
418
; execute some events but with redefinition enabled.~/
421
; Examples (all equivalent):
425
; (progn+redef :action t
427
; (progn+redef :action (:doit! . :overwrite)
431
; This is like ~ilc[progn] except that it sets the
432
; ~ilc[ld-redefinition-action] as (optionally) specified for the
433
; given events. An ~c[:action] of ~c[t] is a shortcut for
434
; ~c[(:doit! . :overwrite)]. ~ilc[make-event] is used to save and restore
435
; the old value of ~ilc[ld-redefinition-action].
437
; An active ttag is required to use this form (~l[defttag]).
439
; Note that the syntax for this macro is not quite like traditional
440
; keyword arguments, which would come at the end of the argument list.
442
(declare (xargs :guard (consp args)))
443
(if (and (equal (car args) :action)
445
`(progn+redef-action ,(cadr args) . ,(cddr args))
446
`(progn+redef-action t . ,args)))
449
(defmacro with-redef-allowed (&rest args)
451
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
452
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
454
; ":Doc-Section hacker
456
; execute some events but with redefinition enabled.
458
; Same as ~c[progn+redef]. ~l[progn+redef]."
459
`(progn+redef . ,args))
462
; this is a wart from an older version of hacker.lisp
463
(defmacro acl2::temporary-redef (&rest forms)
464
(declare (ignore forms))
465
(hard-error 'acl2::temporary-redef "Old implementation of ~x0 was flawed. Adapt solution to use ~x1 (See :DOC ~x1)."
466
'((#\0 . acl2::temporary-redef)
467
(#\1 . progn+redef))))
471
;=========== begin raw mode stuff ===========
474
(defmacro in-raw-mode (&rest form-lst)
476
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
477
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
479
; ":Doc-Section hacker
481
; embed some raw lisp code as an event.~/
486
; (format t \"Preparing to load file...~~%\")
487
; (load \"my-file.lisp\"))~/
490
; (in-raw-mode form1 form2 ... formk)
492
; where each ~c[formi] is processed as though all the forms are preceded by
493
; ~c[:]~ilc[set-raw-mode]~c[ t]. Thus, the forms need not be ~il[events]; they
494
; need not even be legal ACL2 forms. ~l[set-raw-mode] for a discussion of the
495
; so-called ``raw mode'' under which the forms are evaluated ~-[] unless raw
496
; mode is disabled by one of the forms, for example, ~c[(set-raw-mode nil)], in
497
; which case evaluation resumes in non-raw mode.
499
; WARNING: Thus, an ~c[in-raw-mode] form is potentially very dangerous! For
500
; example, you can use it to call the Common Lisp ~c[load] function to load
501
; arbitrary Common Lisp code, perhaps even overwriting definitions of ACL2
502
; system functions! Thus, as with ~ilc[set-raw-mode], ~ilc[in-raw-mode] may
503
; not be evaluated unless there is an active trust tag in effect. ~l[defttag].
505
; Note that the normal undoing mechanism (~pl[ubt]) is not supported when raw
508
`(progn! (with-output :off observation (set-raw-mode-on state))
512
;;acl2-raw-mode-p is restored by progn!-fn
516
(defmacro with-raw-mode (&rest args)
518
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
519
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
521
; ":Doc-Section hacker
523
; embed some raw lisp code as an event.
525
; Same as ~c[in-raw-mode]. ~l[in-raw-mode]."
526
`(in-raw-mode . ,args))
529
;=========== begin program-only stuff ===========
532
(defmacro ensure-program-only-flag (&rest fn-lst)
534
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
535
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
537
; ":Doc-Section hacker
539
; ensure that given function names remain in :PROGRAM mode.~/
543
; (ensure-program-only-flag my-fn your-fn)~/
546
; (ensure-program-only-flag fn1 fn2 ... fnk)
548
; where each ~c[fni] is a literal symbol which should have a ~ilc[program] mode
549
; definition. Each ~c[fni] not already flagged as \"program only\" is flagged
550
; as such. This prevents it from being migrated to ~ilc[logic] mode or being
553
; This is a pseudo-event, meaning it can be used in an event context but does
554
; not (ever) change the world.
556
; Note that the normal undoing mechanism (~pl[ubt]) does not undo the effects
557
; of this pseudo-event.
559
(declare (xargs :guard (and fn-lst
560
(symbol-listp fn-lst))))
561
`(progn!=touchable :vars program-fns-with-raw-code
562
(assign program-fns-with-raw-code
563
(union-eq (@ program-fns-with-raw-code) ',fn-lst))))
565
; test whether a function is in :PROGRAM mode
566
(defun program-mode-p (fn wrld)
568
(getprop fn 'symbol-class nil 'current-acl2-world wrld)))
570
; test whether all functions in a list are in :PROGRAM mode
571
(defun program-mode-p-lst (fn-lst wrld)
573
(and (program-mode-p (car fn-lst) wrld)
574
(program-mode-p-lst (cdr fn-lst) wrld))))
577
(defmacro assert-program-mode (&rest fn-lst)
579
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
580
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
582
; ":Doc-Section hacker
584
; assert that given symbols name :PROGRAM mode functions.~/
588
; (assert-program-mode my-fn your-fn)~/
591
; (assert-program-mode fn1 fn2 ... fnk)
593
; where each ~c[fni] is a literal symbol which should have a ~ilc[program] mode
594
; definition. An error is raised if any ~c[fni] is not a program mode function.
596
; This is a pseudo-event, meaning it can be used in an event context but does
597
; not (ever) change the world.
599
(declare (xargs :guard (and fn-lst
600
(symbol-listp fn-lst))))
602
(program-mode-p-lst ',fn-lst (w state))
603
:msg (msg "Assertion failed. At least one not :program mode:~%~x0"
608
(defmacro ensure-program-only (&rest fn-lst)
610
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
611
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
613
; ":Doc-Section hacker
615
; ensure that named functions are and remain in :PROGRAM mode.~/
619
; (ensure-program-only my-fn your-fn)~/
622
; (ensure-program-only fn1 fn2 ... fnk)
624
; where each ~c[fni] is a literal symbol which should have a ~ilc[program] mode
625
; definition. An error is raised if any ~c[fni] is not a program mode function.
626
; Also, each ~c[fni] not already flagged as \"program only\" is flagged
627
; as such. This prevents it from being migrated to ~ilc[logic] mode or being
630
; This is actually a combination of ~ilc[assert-program-mode] and
631
; ~ilc[ensure-program-only-flag].
633
; This is a pseudo-event, meaning it can be used in an event context but does
634
; not (ever) change the world.
636
; Note that the normal undoing mechanism (~pl[ubt]) does not undo the effects
637
; of this pseudo-event.
639
(declare (xargs :guard (and fn-lst
640
(symbol-listp fn-lst))))
641
`(progn (assert-program-mode . ,fn-lst)
642
(ensure-program-only-flag . ,fn-lst)))
646
;=========== begin special-raw-definition stuff ===========
648
; Here we introduce the notion of a "special raw definition",
649
; which is somewhat related to the notion of "program only" but
650
; importantly different. The intended difference is this:
651
; - A function should be "program only" if bad things could happen as
652
; a result of it migrating to logic mode (with verify-termination)
653
; or by use in macro expansion.
654
; - A function should be considered to have a "special raw definition"
655
; if bad things could happen as a result of replacing its raw
656
; definition with the raw counterpart of its "loop" definition.
659
(defconst *bootstrap-special-raw-definitions*
661
;;-- from axioms.lisp --
662
;;len #|not special, just fast|#
663
;;strip-cars #|not special, just fast|#
664
;;strip-cdrs #|not special, just fast|#
665
acl2::complex-rationalp
672
acl2::intern-in-package-of-symbol
675
acl2::value-triple-fn
678
acl2::acl2-unwind-protect
681
acl2::getprop-default
699
acl2::global-table-cars1
702
acl2::makunbound-global
708
acl2::open-input-channel-p1
709
acl2::open-output-channel-p1
712
acl2::print-object$-ser ; Matt K. change shortly after v4-3
713
acl2::open-input-channel
714
acl2::close-input-channel
715
acl2::open-output-channel
716
acl2::close-output-channel
721
acl2::prin1-with-slashes
722
acl2::may-need-slashes
723
acl2::t-stack-length1
728
acl2::32-bit-integer-stack-length1
729
acl2::extend-32-bit-integer-stack
730
acl2::shrink-32-bit-integer-stack
731
acl2::aref-32-bit-integer-stack
732
acl2::aset-32-bit-integer-stack
733
acl2::f-big-clock-negative-p
734
acl2::f-decrement-big-clock
735
acl2::big-clock-negative-p
736
acl2::decrement-big-clock
737
acl2::list-all-package-names
738
acl2::user-stobj-alist
739
acl2::update-user-stobj-alist
742
acl2::read-acl2-oracle
747
acl2::set-enforce-redundancy
748
acl2::set-verify-guards-eagerness
749
acl2::set-compile-fns
750
acl2::set-measure-function
751
acl2::set-well-founded-relation
754
acl2::set-bogus-mutual-recursion-ok
755
acl2::set-irrelevant-formals-ok
757
acl2::set-inhibit-warnings
758
acl2::set-inhibit-output-lst
760
acl2::set-let*-abstractionp
761
acl2::set-backchain-limit
762
acl2::set-default-backchain-limit
763
acl2::set-rewrite-stack-limit
764
acl2::set-case-split-limitations
765
acl2::set-match-free-default
766
acl2::add-match-free-override
767
acl2::add-include-book-dir
768
acl2::delete-include-book-dir
769
acl2::set-non-linearp
771
acl2::set-default-hints!
772
acl2::add-default-hints!
773
acl2::remove-default-hints!
774
acl2::with-prover-time-limit
775
acl2::catch-time-limit4
776
acl2::time-limit4-reached-p
788
;;-- from translate.lisp --
791
acl2::decrement-big-n
796
acl2::ev-rec-acl2-unwind-protect
802
acl2::untranslate-lst
805
acl2::user-stobj-alist-safe
807
;;-- from history-management.lisp --
808
acl2::start-proof-tree
809
acl2::initialize-summary-accumulators
812
acl2::longest-common-tail-length-rec
815
;;-- from other-events.lisp --
842
acl2::chk-package-reincarnation-import-restrictions
843
acl2::theory-invariant
845
acl2::protected-eval-with-proofs
846
acl2::include-book-fn
847
acl2::write-expansion-file
848
acl2::certify-book-fn
849
acl2::defstobj-field-fns-raw-defs
850
acl2::open-trace-file-fn
851
acl2::close-trace-file-fn
852
acl2::with-error-trace-fn
853
acl2::trace$-fn-general
854
acl2::trace$-fn-simple
856
acl2::break-on-error-fn
859
acl2::ld-print-results
860
acl2::print-newline-for-time$
865
acl2::compile-function
869
acl2::set-debugger-enable-fn
873
acl2::mfc-relieve-hyp
879
#|| Removed by Matt K. after ACL2 Version 3.6.1 in favor of the defmacro just
880
below, because make-event expansion does not take place during (early)
881
loading of compiled files.
882
(make-event ; used here like progn! without a ttag
884
(if (member-eq 'has-special-raw-definition
885
(global-val 'untouchable-vars (w state)))
886
(value nil) ; assume we're already good
887
(assign has-special-raw-definition
888
(union-eq (@opt has-special-raw-definition)
889
*bootstrap-special-raw-definitions*)))
890
(value '(value-triple 'has-special-raw-definition)))
894
(defmacro update-has-special-raw-definition (fn-lst)
895
`(pprogn (if (boundp-global 'has-special-raw-definition state)
897
(f-put-global 'has-special-raw-definition
898
*bootstrap-special-raw-definitions*
900
(assign has-special-raw-definition
901
(union-eq (@ has-special-raw-definition)
904
(push-untouchable has-special-raw-definition nil)
907
(defmacro ensure-special-raw-definition-flag (&rest fn-lst)
909
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
910
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
912
; ":Doc-Section hacker
914
; ensure that named functions are flagged as having special raw definitions.~/
918
; (ensure-special-raw-definition-flag my-fn your-fn)~/
921
; (ensure-special-raw-definition-flag fn1 fn2 ... fnk)
923
; where each ~c[fni] is a literal symbol which should have a function
924
; definition. Each ~c[fni] not already flagged as having a special raw
925
; definition is flagged as such. This idicates to interested parties that
926
; the \"loop\" definition of the function doesn't fully characterize the
927
; effects it has in raw lisp.
929
; This is a pseudo-event, meaning it can be used in an event context but does
930
; not (ever) change the world.
932
; Note that the normal undoing mechanism (~pl[ubt]) does not undo the effects
933
; of this pseudo-event.
935
(declare (xargs :guard (and fn-lst
936
(symbol-listp fn-lst))))
937
`(progn!=touchable :vars has-special-raw-definition
938
(update-has-special-raw-definition ',fn-lst)))
941
(defmacro assert-no-special-raw-definition (&rest fn-lst)
943
;;; This legacy doc string was replaced Nov. 2014 by a corresponding
944
;;; auto-generated defxdoc form in file dillinger-et-al-xdoc.lisp.
946
; ":Doc-Section hacker
948
; assert that given symbols do not have a special raw function definition.~/
952
; (assert-no-special-raw-definition my-fn your-fn)~/
955
; (assert-no-special-raw-definition fn1 fn2 ... fnk)
957
; where each ~c[fni] is a literal symbol. An error is raised if any ~c[fni]
958
; is is flagged as having a special raw definition.
959
; ~l[ensure-special-raw-definition-flag].
961
; This is a pseudo-event, meaning it can be used in an event context but does
962
; not (ever) change the world.
964
(declare (xargs :guard (and fn-lst
965
(symbol-listp fn-lst))))
967
(not (intersectp-eq (@opt has-special-raw-definition)
969
:msg (msg "Assertion failed. Flagged as having special raw definition:~%~x0"
970
(intersection-eq (@opt has-special-raw-definition)
976
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
977
; modify-raw-defun-permanent
979
; for permanently installing some changes (supporting defcode)
983
(defmacro modify-raw-defun-permanent
984
(name name-for-old ll &rest decls-and-body)
985
(declare (xargs :guard (and (symbolp name)
986
(symbolp name-for-old)
988
(consp decls-and-body))))
991
(unless (fboundp ',name-for-old)
992
; if the name-for-old already has a definition, we don't override
993
; it. this provides idempotency for modify-raw-defun-permanent
994
; but means this code doesn't know the first time whether
995
; name-for-old is fresh/unused.
996
(setf (symbol-function ',name-for-old)
997
(symbol-function ',name)))
999
,@ (and ll `((declare (ignorable . ,ll))))
1001
(ensure-special-raw-definition-flag ,name)))
1004
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1007
; for stubbing out ACL2 names
1010
(defun build-deflabels (names)
1013
(cons (list 'deflabel (car names))
1014
(build-deflabels (cdr names)))))
1017
(defmacro deflabels (&rest names)
1019
(with-output :off summary
1020
(progn . ,(build-deflabels names)))
1021
(value-triple ',names)))
1024
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1027
; this should only be used in subsuming hacker stuff, like so:
1032
(progn+all-ttags-allowed
1034
"hacker/all" :ttags ((defcode) (table-guard))))
1035
(subsume-ttags-since-defttag) ; see subsumption.lisp
1038
; this is a work-around for subsuming before progn+subsume-ttags is available.
1042
(defmacro progn+all-ttags-allowed (&rest form-lst)
1043
`(progn!-with-bindings
1044
((temp-touchable-vars (if (eq (@ temp-touchable-vars) t)
1046
(cons 'acl2::ttags-allowed (@ temp-touchable-vars)))
1047
set-temp-touchable-vars))
1048
(progn!-with-bindings
1049
((acl2::ttags-allowed :all))
1050
(progn!-with-bindings
1051
((temp-touchable-vars (if (eq (@ temp-touchable-vars) t)
1053
(cdr (@ temp-touchable-vars)))
1054
set-temp-touchable-vars))
1055
(progn . ,form-lst)))))
1063
(progn+touchable :all
1064
(defun foo (x) (1+ x)))
1065
(progn! (cw "Hi!~%")))
1069
(progn+touchable :all
1070
(defun foo (x) (1+ x)))
1071
(progn! (cw "Hi!~%")))
1075
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1078
; uses a ttag to skip proofs without the ordinary record that
1079
; proofs were skipped.
1082
(defun put-ld-skip-proofsp (v state)
1083
(mv-let (erp v state)
1084
(set-ld-skip-proofsp v state)
1085
(declare (ignore v))
1088
(hard-error 'set-ld-skip-proofsp
1089
"~x0 returned an error."
1090
'((#\0 . set-ld-skip-proofsp))))
1094
(defmacro ttag-skip-proofs (x)
1095
`(progn!-with-bindings
1096
((ld-skip-proofsp 'include-book put-ld-skip-proofsp))
1100
(defmacro progn+ttag-skip-proofs (&rest args)
1101
`(progn!-with-bindings
1102
((ld-skip-proofsp 'include-book put-ld-skip-proofsp))