/usr/share/acl2-6.5/books/cgen/acl2s-parameter.lisp is in acl2-books-source 6.5-2.
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 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 | #|$ACL2s-Preamble$;
(ld ;; Newline to fool ACL2/cert.pl dependency scanner
"portcullis.lsp")
(acl2::begin-book t :ttags :all);$ACL2s-Preamble$|#
(in-package "ACL2")
(include-book "utilities")
;;; Keep the following defconst synced with all the acl2s parameters
(defconst *acl2s-parameters* '(num-trials
verbosity-level
num-counterexamples
num-witnesses
;show-top-level-counterexample
sampling-method
backtrack-limit
search-strategy
testing-enabled
stopping-condition
subgoal-timeout
))
;All user-defined parameters are stored here
(table acl2s-defaults-table)
(defrec acl2s-param-info% (value guard setter) NIL)
(defmacro add-acl2s-parameter (name default
&key
(setter 'nil)
(doc-string 'nil)
(guard 't))
"Add a new user-defined parameter.
Put it in the acl2s-defaults-table as a key,
using the value of :default.
:guard is a term that checks for legal values of the
parameter (It uses symbol 'value for variable capture).
getter and setter specify macro names that will be used by
the actual getter/setter mechanism to delegate its function.
Note that setter should be a macro that expands to a state changing
embedded event form, this this is called from inside an make-event.
You have to see the code in acl2s-defaults to understand whats going
on with getter and setter, the situation is assymmetric and I am
being lazy about documentation.
:doc-string is a string that is used to specify the defdoc.
For internal flags dont use a doc-string"
(b* (((unless (symbolp name))
(er hard 'add-acl2s-parameter
"Name must be a symbol, but is ~x0." name))
;; ((unless (pseudo-termp guard))
;; (er hard 'add-acl2s-parameter
;; ":guard must be a term, but is ~x0." guard))
);*b
`(progn
(table acl2s-defaults-table
',name
',(acl2::make acl2s-param-info%
:guard guard ;store guard too
:value default
:setter setter)
:put)
,@(and doc-string
`((defdoc ,name ,doc-string))))))
(defdoc ACL2::TESTING
":Doc-Section ACL2::TESTING
A counterexample generation framework for ACL2 ~/
Test formulas before and during a proof attempt, to find
counterexamples and witnesses potentially saving time and
effort and providing more intuition into the conjecture under
scrutiny. The testing framework is tightly coupled with the
data definition (See ~ilc[DATA-DEFINITIONS]) framework.
~t[test?] guarantees printing counterexamples in
terms of the top goals variables. See ~ilc[test?]
for more details and examples.
The framework can be configured via a bunch of parameters
whose documention you will find below. In particular, see
~ilc[num-trials], ~ilc[verbosity-level], ~ilc[testing-enabled].~/
To understand more about how testing works,
please refer to the following paper
~url[http://www.ccs.neu.edu/home/harshrc/ITaITP.pdf]
")
(defdoc ACL2::acl2s-defaults
":Doc-Section ACL2::acl2-sedan
Getting and setting defaults for various parameters in ACL2 Sedan~/
~/
")
(add-acl2s-parameter
num-trials 1000
:doc-string
":Doc-Section ACL2::TESTING
Max number of tries to find counterexamples~/~/
Maximum number of tries (attempts) to construct
counterexamples and witnesses.
By default this parameter is set to 1000. Can be set to
any natural number ~t[n]. If set to 0, it has the same
effect as setting testing-enabled parameter to ~t[nil].
~bv[]
Usage:
(acl2s-defaults :set num-trials 1000)
(acl2s-defaults :get num-trials)
:doc num-trials
~ev[]"
:guard (and (natp value)
(< value 1000000000)))
(add-acl2s-parameter
verbosity-level 1
:doc-string
":Doc-Section ACL2::TESTING
Control verbosity of Testing~/~/
Control amount of output printed by random-testing
Currently 3 verbosity levels are implemented:
0 - All testing output is turned off
1 - Normal verbosity level (default)
2 - More verbose.
3 - For Debug by normal users
4 and above - System level debug by developers
~bv[]
Usage:
(acl2s-defaults :set verbosity-level 1)
(acl2s-defaults :get verbosity-level)
:doc verbosity-level
~ev[]"
:guard (natp value))
(add-acl2s-parameter
num-counterexamples 3
:doc-string
":Doc-Section ACL2::TESTING
Number of Counterexamples to be shown~/~/
Set the number of counterexamples desired to be shown
By default this parameter is set to 3. Can be set to
any natural number n. Setting this number to 0 implies
the user is not interested in seeing counterexamples, and
thus none will be printed in the testing output.
~bv[]
Usage:
(acl2s-defaults :set num-counterexamples 3)
(acl2s-defaults :get num-counterexamples)
:doc num-counterexamples
~ev[]"
:guard (natp value))
(add-acl2s-parameter
num-witnesses 3
:doc-string
":Doc-Section ACL2::TESTING
Number of Witnesses to be shown~/~/
Set the number of witnesses desired to be shown
By default this parameter is set to 3. Can be set to
any natural number. Setting this number to 0 implies
the user is not interested in seeing witnesses, and
thus none will be printed in the testing output.
~bv[]
Usage:
(acl2s-defaults :set num-witnesses 3)
(acl2s-defaults :get num-witnesses)
:doc num-witnesses
~ev[]"
:guard (natp value))
;DEPRECATED
;; (add-acl2s-parameter
;; show-top-level-counterexample t
;; :doc-string ":Doc-Section ACL2::TESTING
;; Show Counterexamples to the top-level <i>goal</i>"
;; Show Counterexamples to the top-level <i>goal</i>
;; instead of to the <i>subgoals</i>.
;; By default this parameter is set to <tt>t</tt>.
;; If set to <tt>nil</tt>, then counterexamples are simply
;; instances falsifying the respective subgoals.
;; ~bv[]
;; Usage:
;; (acl2s-defaults :set show-top-level-counterexample t)
;; (acl2s-defaults :get show-top-level-counterexample)
;; :doc show-top-level-counterexample
;; ~ev[]
;; "
;; :guard (booleanp value))
;; use test enumerator for user-level controlled testing
(defconst *default-rt-use-test-enum* t)
(defmacro set-acl2s-random-testing-use-test-enumerator (v)
;:Doc-Section RANDOM-TESTING
"Set the flag to use test-enumerator if it exists~/
By default this parameter is set to nil.
~bv[]
Usage:
(set-acl2s-random-testing-use-test-enumerator nil)
~ev[]~/
"
`(assign acl2s-rt-use-test-enum ,v))
(defun get-acl2s-random-testing-use-test-enumerator-fn (state)
(declare (xargs :stobjs (state)))
(let ((nt (f-boundp-global 'acl2s-rt-use-test-enum state)))
(if nt
(f-get-global 'acl2s-rt-use-test-enum state)
*default-rt-use-test-enum*)))
(defmacro get-acl2s-random-testing-use-test-enumerator ()
;:Doc-Section RANDOM-TESTING
"Get the current setting for use of test-enumerator~/
~bv[]
Usage:
(get-acl2s-random-testing-use-test-enumerator)
~ev[]~/
"
'(get-acl2s-random-testing-use-test-enumerator-fn state))
(add-acl2s-parameter
search-strategy :simple
:doc-string
":Doc-Section ACL2::TESTING
Specify the search strategy to be used ~/~/
Specify which of the following strategies to
use for instantiating free variables of the conjecture
under test: ~t[:simple] or ~t[:incremental]
or ~t[:hybrid] (untested).
~t[:incremental] uses a dpll-like algorithm to search
for counterexamples.
By default this parameter is set to the symbol ~t[:simple].
~bv[]
Usage:
(acl2s-defaults :set search-strategy :simple)
(acl2s-defaults :get search-strategy)
:doc search-strategy
~ev[]
"
:guard (member-eq value '(:simple :incremental :hybrid)))
;; Use natural seeds or random tree of natural numbers
(add-acl2s-parameter
sampling-method :random
:doc-string
":Doc-Section ACL2::TESTING
Specify sampling method to be used to instantiate variables ~/~/
Specify which of the following methods to
use for instantiating free variables of the conjecture
under test: ~t[:be] or ~t[:random] or ~t[:uniform-random] or ~t[:mixed]
By default this parameter is set to the symbol ~t[:random]
~bv[]
Usage:
(acl2s-defaults :set sampling-method :random)
(acl2s-defaults :get sampling-method)
:doc sampling-method
~ev[]
"
:guard (member-eq value '(:be :uniform-random :random :mixed)))
;; (add-acl2s-parameter
;; flatten-defdata nil
;; :doc-string ":Doc-Section ACL2::TESTING
;; Flatten defdata instances during sampling"
;; Flatten defdata enumerator expressions which stand for
;; instances of the particular defdata type. Basically if you
;; have a type triple <tt>(defdata triple (list pos pos pos))</tt>,
;; then an instance of triple is generated (sampled) by a call to the
;; enumerator expression <tt>(nth-triple n)</tt>, where <tt>n</tt>
;; is some natural number. Alternatively we could flatten the
;; defdata instance by representing it with the enumerator
;; expression <tt>(list (nth-pos n1) (nth-pos n2) (nth-pos n3))</tt>
;; which consists purely of instances of primitive and custom types.
;; This has the nice property of distribution invariance,
;; i.e. a field of a particular type has the same distribution,
;; regardless of its position in the body of a complex defdata type.
;; By default the value of parameter is <tt>nil</tt>.
;; ~bv[]
;; Usage:
;; (acl2s-defaults :set flatten-defdata-instance nil)
;; (acl2s-defaults :get flatten-defdata-instance)
;; :doc flatten-defdata-instance
;; ~ev[]
;; "
;; :guard (booleanp value))
(add-acl2s-parameter
backtrack-limit 3
:doc-string
":Doc-Section ACL2::TESTING
Maximum number of backtracks allowed (per variable)~/~/
Maximum number of backtracks allowed by a variable.
The default backtrack limit is set to 3. Setting this
parameter to 0, means that backtracking is disabled.
~bv[]
Usage:
(acl2s-defaults :set backtrack-limit 3)
(acl2s-defaults :get backtrack-limit)
:doc backtrack-limit
~ev[]
"
:guard (natp value))
(add-acl2s-parameter
subgoal-timeout 10
:doc-string
":Doc-Section ACL2::TESTING
Testing timeout (in seconds) per subgoal~/~/
Maximum allowed time (in seconds) to test any
subgoal or top-level form.
The default timeout limit is set to 10 sec.
Setting this parameter to 0 amounts to disabling
the timeout mechanism, i.e. its a no-op.
~bv[]
Usage:
(acl2s-defaults :set subgoal-timeout 10)
(acl2s-defaults :get subgoal-timeout)
:doc subgoal-timeout
~ev[]
"
:guard (natp value))
(add-acl2s-parameter
testing-enabled :naive
:doc-string
":Doc-Section ACL2::TESTING
Testing enable/disable flag~/~/
Testing can be enabled or disabled
using this parameter.
The default value is ~t[:naive] (unless you are in
the usual ACL2 Sedan session modes, where default is ~t[t]).
Setting this parameter to ~t[nil] amounts to disabling
the testing mechanism. Setting this parameter
to ~t[:naive] leads to top-level testing without any
theorem prover support.
~bv[]
Usage:
(acl2s-defaults :set testing-enabled :naive)
(acl2s-defaults :get testing-enabled)
:doc testing-enabled
~ev[]
"
:guard (member-eq value '(T NIL :naive))
:setter set-acl2s-random-testing-enabled)
(defun mem-tree (x tree)
(declare (xargs :guard (symbolp x)))
(if (atom tree)
(eq x tree)
(or (mem-tree x (car tree))
(mem-tree x (cdr tree)))))
(defun get-acl2s-random-testing-hints-flag-fn ( state)
(declare (xargs :mode :program
:stobjs (state)))
;; bugfix 30 April '12: I had changed the name of test-each-checkpoint
;; to test-checkpoint and forgot the update the fact here. Bad bad bad!
(and (mem-tree 'TEST-CHECKPOINT ;check if random testing is enabled
(override-hints (w state)))
T))
(defdoc get-acl2s-random-testing-hints-enabled
":Doc-Section ACL2::TESTING
Get current setting for random-testing-hints-enabled~/~/
Get current setting for random-testing-hints-enabled.
Returns ~t[nil] if ~t[thm] and ~t[defthm] do not make use of random-testing
in their proof attempts, and ~t[t] otherwise.
~bv[]
Usage:
(get-acl2s-random-testing-hints-enabled)
~ev[]
")
;top-level exported macro to know wether random testing is enabled or not
(defmacro get-acl2s-random-testing-hints-enabled ()
`(get-acl2s-random-testing-hints-flag-fn state))
(defun set-acl2s-random-testing-flag-fn (flg mode state)
(declare (xargs :mode :program
:stobjs (state)))
;check if random testing is enabled by searching for the testing hint
(let ((flg (if (eq flg :naive) NIL flg)))
(if (get-acl2s-random-testing-hints-enabled)
;;; TESTING hint is currently ENABLED
(if flg ;if enabled and user wants to set it then no-op
'(value-triple :REDUNDANT)
;if enabled and user wants to turn it off
(if (eq mode :program)
'(progn ; Feb 13 2012 bug. Testing-hint cant be disabled
;; in program mode. Found by Pete while using defunc.
;; Reason: local forms are ignored in program mode.
(logic)
(disable-acl2s-random-testing)
(program))
'(disable-acl2s-random-testing)))
;;; TESTING hint is currently disabled
(if flg ;if disabled and user wants to set it to t
(if (eq mode :program)
'(progn
(logic)
(enable-acl2s-random-testing)
(program))
'(enable-acl2s-random-testing))
;if testing-hint is disabled and user wants to turn it off its no-op
'(value-triple :REDUNDANT)))))
;top-level exported macro to know enable random testing
(defmacro set-acl2s-random-testing-enabled (v forms)
(declare (xargs :guard (member-eq v '(T NIL :naive))))
`(make-event
(let ((mode (cdr (assoc-eq :defun-mode
(table-alist
'acl2::acl2-defaults-table
(w state))))))
(let ((forms ',forms))
(value `(progn
,(set-acl2s-random-testing-flag-fn ,v mode state)
,@forms))))))
(defmacro acl2s-defaults (&rest rst)
(b* (((unless (consp (cdr rst)));atleast 2 elems
(er hard 'acl2s-defaults
"~|At least 2 arguments, but given ~x0~%" rst))
(param (second rst))
(op (car rst))
((unless (or (eq :get op)
(and (eq :set op)
(consp (cddr rst));value
)))
(er hard 'acl2s-defaults;TODO be more informative
"~|Invalid arguments supplied, given ~x0~%" rst)))
(if (eq :get op)
;get the value at the point of call (runtime)
`(b* ((param-rec-pair
(assoc-eq ',param
(table-alist 'acl2s-defaults-table
(w state))))
((unless (consp param-rec-pair))
(er hard 'acl2s-defaults
"~|Parameter ~x0 not found in acl2s-defaults!~%"
',param))
(r (cdr param-rec-pair))
(val (access acl2s-param-info% r :value)))
val)
;get the guard and value at the runtime
;since we need access to state
;and set the new value v
`(with-output
:off summary
(make-event
(b* ((param-rec-pair
(assoc-eq ',param
(table-alist
'acl2s-defaults-table (w state))))
((unless (consp param-rec-pair))
(er hard 'acl2s-defaults
"~|Parameter ~x0 not found in acl2s-defaults!~%"
',param))
;guard is fixed once it is initialized INVARIANT
(r (cdr param-rec-pair))
(guard (access acl2s-param-info% r :guard))
(setter (access acl2s-param-info% r :setter))
(v (third ',rst)))
`(make-event ;state changing event
(if (not ,(subst v 'value guard))
(er soft 'acl2s-defaults-table
"Guard ~x0 for ~x1 in table failed for VALUE ~x2"
',guard ',',param ',v)
(if ',setter
(let ((table-update-form
`(table acl2s-defaults-table
',',',param
',(change acl2s-param-info% ',r :value ',v))))
;;; setter is a macro, so dont quote the args to it whereas the above
;;; table macro needs quoted args because its 3rd parameter is &rest rst
(value `(,',setter ,',v (,table-update-form));embedded event
))
(value `(progn
(table acl2s-defaults-table
',',',param
',(change acl2s-param-info% ',r :value ',v))
(value-triple ',',v))))))))))))
;;; copied from main.lisp, since these functions are only called by
;;; set-acl2s-random-testing-enabled, which is defined here
;;; add no-op override hints that test each checkpoint. The reason
;;; why we need backtrack hint is not that we need clause-list
;;; (children goals of clause), but because we need to do testing only
;;; on checkpoints, and only backtrack hints have access to processor,
;;; if this were not the case, we could have used ":no-op
;;; '(test-each-goal ...)" as an override hint which has no effect but
;;; to test each goal. Another reason is that because computed-hints
;;; with :COMPUTED-HINT-REPLACEMENT t is not additive like
;;; override-hints it can cause a hint to be not selected otherwise.
(defmacro enable-acl2s-random-testing ()
;; this has to be a makevent because enable-acl2s-random-testing is the
;; expansion result of the make-event in set-acl2s-random-testing-enabled
`(make-event
'(progn
(acl2::add-override-hints
'((list* :backtrack
;take parent pspv and hist, not the ones returned by clause-processor
`(test-checkpoint acl2::id
acl2::clause
acl2::clause-list
acl2::processor
;TODO:ask Matt about sending parent pspv and hist
',acl2::pspv
',acl2::hist
acl2::ctx
state
)
;; `(mv-let (erp tval state)
;; (trans-eval
;; `(test-each-checkpoint ',acl2::id
;; ',acl2::clause
;; ',acl2::processor
;; ',',acl2::pspv
;; ',',acl2::hist state
;; ts$)
;; 'acl2s-testing ; ctx
;; state
;; t ; aok
;; )
;; (declare (ignorable erp))
;; (mv (cadr tval) (caddr tval) state))
;`(test-each-checkpoint acl2::id acl2::clause acl2::processor ',acl2::pspv ',acl2::hist state)
acl2::keyword-alist)))
)))
(defmacro disable-acl2s-random-testing ()
`(make-event
'(progn
(acl2::remove-override-hints
'((list* :backtrack
`(test-checkpoint acl2::id
acl2::clause
acl2::clause-list
acl2::processor
',acl2::pspv
',acl2::hist
acl2::ctx
state
)
;take parent pspv and hist, not the ones returned by clause-processor
;; `(mv-let (erp tval state)
;; (trans-eval
;; `(test-each-checkpoint ',acl2::id
;; ',acl2::clause
;; ',acl2::processor
;; ',',acl2::pspv
;; ',',acl2::hist state
;; ts$)
;; 'acl2s-testing ; ctx
;; state
;; t ; aok
;; )
;; (declare (ignorable erp))
;; (mv (cadr tval) (caddr tval) state))
;`(test-each-checkpoint acl2::id acl2::clause acl2::processor ',acl2::pspv ',acl2::hist state)
acl2::keyword-alist)))
)))
; Internal flags
(add-acl2s-parameter
;show pts at the end of subgoal?
acl2s-pts-subgoalp NIL
:guard (booleanp value))
#|ACL2s-ToDo-Line|#
|