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 623 624 625 626 627 628 629 630 631 632 633 634
|
; Milawa - A Reflective Theorem Prover
; Copyright (C) 2005-2009 Kookamara LLC
;
; Contact:
;
; Kookamara LLC
; 11410 Windermere Meadows
; Austin, TX 78759, USA
; http://www.kookamara.com/
;
; 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: Jared Davis <jared@kookamara.com>
(in-package "MILAWA")
(include-book "worldp")
(set-verify-guards-eagerness 2)
(set-case-split-limitations nil)
(set-well-founded-relation ord<)
(set-measure-function rank)
(defund tactic.slow-world-arities (x)
(declare (xargs :guard (tactic.worldp x)))
(let* ((res (rw.slow-theory-map-arities (tactic.world->theories x)))
(res (app (rw.slow-rule-list-arities (tactic.world->allrules x)) res))
(res (app (logic.slow-formula-list-arities (tactic.world->defs x)) res)))
res))
(defund tactic.world-arities (x acc)
(declare (xargs :guard (and (tactic.worldp x)
(true-listp acc))))
(let* ((acc (rw.theory-map-arities (tactic.world->theories x) acc))
(acc (rw.rule-list-arities (tactic.world->allrules x) acc)))
(logic.formula-list-arities (tactic.world->defs x) acc)))
(defthm true-listp-of-tactic.world-arities
(implies (force (true-listp acc))
(equal (true-listp (tactic.world-arities x acc))
t))
:hints(("Goal" :in-theory (enable tactic.world-arities))))
(defthm tactic.world-arities-removal
(implies (force (true-listp acc))
(equal (tactic.world-arities x acc)
(app (tactic.slow-world-arities x) acc)))
:hints(("Goal" :in-theory (enable tactic.world-arities
tactic.slow-world-arities))))
(defthm tactic.slow-world-arities-correct
(implies (force (tactic.worldp x))
(equal (logic.arities-okp (tactic.slow-world-arities x) atbl)
(tactic.world-atblp x atbl)))
:hints(("Goal"
:expand ((tactic.slow-world-arities x)
(tactic.world-atblp x atbl))
:in-theory (disable rw.rule-list-atblp-of-tactic.world->allrules
logic.formula-list-atblp-of-tactic.world->defs
rw.theory-list-atblp-of-range-of-tactic.world->theories))))
(defund tactic.slow-world-list-arities (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
;; Reverse order gives us a tail call in the fast version
(app (tactic.slow-world-list-arities (cdr x))
(tactic.slow-world-arities (car x)))
nil))
(defund tactic.world-list-arities (x acc)
(declare (xargs :guard (and (tactic.world-listp x)
(true-listp acc))))
(if (consp x)
(tactic.world-list-arities (cdr x)
(tactic.world-arities (car x) acc))
acc))
(defthm true-listp-of-tactic.world-list-arities
(implies (force (true-listp acc))
(equal (true-listp (tactic.world-list-arities x acc))
t))
:hints(("Goal" :in-theory (enable tactic.world-list-arities))))
(defthm tactic.world-list-arities-removal
(implies (force (true-listp acc))
(equal (tactic.world-list-arities x acc)
(app (tactic.slow-world-list-arities x) acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-arities
tactic.slow-world-list-arities))))
(defthm tactic.slow-world-list-arities-correct
(implies (force (tactic.world-listp x))
(equal (logic.arities-okp (tactic.slow-world-list-arities x) atbl)
(tactic.world-list-atblp x atbl)))
:hints(("Goal"
:induct (cdr-induction x)
:expand ((tactic.world-list-atblp x atbl)
(tactic.slow-world-list-arities x)))))
;; One final twist is that if we are checking a list of worlds, it is most
;; common for the allrules and defs to be the same throughout all of the
;; worlds. Rather than repeatedly collect from them, we see this situation and
;; avoid the redundant gathering.
(defund tactic.slow-world-partial-arities (x)
(declare (xargs :guard (tactic.worldp x)))
(rw.slow-theory-map-arities (tactic.world->theories x)))
(defund tactic.world-partial-arities (x acc)
(declare (xargs :guard (and (tactic.worldp x)
(true-listp acc))))
(rw.theory-map-arities (tactic.world->theories x) acc))
(defthm true-listp-of-tactic.world-partial-arities
(implies (force (true-listp acc))
(equal (true-listp (tactic.world-partial-arities x acc))
t))
:hints(("Goal" :in-theory (enable tactic.world-partial-arities))))
(defthm tactic.world-partial-arities-removal
(implies (force (true-listp acc))
(equal (tactic.world-partial-arities x acc)
(app (tactic.slow-world-partial-arities x) acc)))
:hints(("Goal" :in-theory (enable tactic.world-partial-arities
tactic.slow-world-partial-arities))))
(defthm tactic.slow-world-partial-arities-correct
(implies (force (and (tactic.worldp x)
(rw.rule-list-atblp (tactic.world->allrules x) atbl)
(logic.formula-list-atblp (tactic.world->defs x) atbl)))
(equal (logic.arities-okp (tactic.slow-world-partial-arities x) atbl)
(tactic.world-atblp x atbl)))
:hints(("Goal"
:expand ((tactic.slow-world-partial-arities x)
(tactic.world-atblp x atbl))
:in-theory (disable rw.rule-list-atblp-of-tactic.world->allrules
logic.formula-list-atblp-of-tactic.world->defs
rw.theory-list-atblp-of-range-of-tactic.world->theories))))
(defund tactic.slow-world-list-partial-arities (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
;; Reverse order gives us a tail call in the fast version
(app (tactic.slow-world-list-partial-arities (cdr x))
(tactic.slow-world-partial-arities (car x)))
nil))
(defund tactic.world-list-partial-arities (x acc)
(declare (xargs :guard (and (tactic.world-listp x)
(true-listp acc))))
(if (consp x)
(tactic.world-list-partial-arities (cdr x)
(tactic.world-partial-arities (car x) acc))
acc))
(defthm true-listp-of-tactic.world-list-partial-arities
(implies (force (true-listp acc))
(equal (true-listp (tactic.world-list-partial-arities x acc))
t))
:hints(("Goal" :in-theory (enable tactic.world-list-partial-arities))))
(defthm tactic.world-list-partial-arities-removal
(implies (force (true-listp acc))
(equal (tactic.world-list-partial-arities x acc)
(app (tactic.slow-world-list-partial-arities x) acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-partial-arities
tactic.slow-world-list-partial-arities))))
(defund tactic.world-list-compatiblep-hack (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
(if (consp (cdr x))
(and (equal (tactic.world->allrules (first x))
(tactic.world->allrules (second x)))
(equal (tactic.world->defs (first x))
(tactic.world->defs (second x)))
(tactic.world-list-compatiblep-hack (cdr x)))
t)
t))
(defthm tactic.slow-world-list-partial-arities-correct
(implies (force (and (tactic.world-listp x)
(tactic.world-list-compatiblep-hack x)
(consp x)
(rw.rule-list-atblp (tactic.world->allrules (car x)) atbl)
(logic.formula-list-atblp (tactic.world->defs (car x)) atbl)))
(equal (logic.arities-okp (tactic.slow-world-list-partial-arities x) atbl)
(tactic.world-list-atblp x atbl)))
:hints(("Goal"
:induct (cdr-induction x)
:in-theory (e/d (tactic.world-list-compatiblep-hack
tactic.slow-world-list-partial-arities)
(LOGIC.FORMULA-LIST-ATBLP-OF-TACTIC.WORLD->DEFS
RW.RULE-LIST-ATBLP-OF-TACTIC.WORLD->ALLRULES)))))
;; All of this culminates in tactic.fast-world-list-atblp, which is pretty damn
;; wonderful.
(defund tactic.fast-world-list-atblp (x atbl)
(declare (xargs :guard (and (tactic.world-listp x)
(logic.arity-tablep atbl))))
(if (and (consp x)
(tactic.world-list-compatiblep-hack x))
(let* ((acc (rw.rule-list-arities (tactic.world->allrules (car x)) nil))
(acc (logic.formula-list-arities (tactic.world->defs (car x)) acc))
(acc (tactic.world-list-partial-arities x acc)))
(logic.fast-arities-okp acc atbl))
(ACL2::prog2$
(ACL2::cw "Performance note: fast-world-atblp cannot use compatibility hack.~%")
(logic.fast-arities-okp (tactic.world-list-arities x nil) atbl))))
(defthm tactic.fast-world-list-atblp-is-tactic.world-list-atblp
(implies (force (and (tactic.world-listp x)
(mapp atbl)))
(equal (tactic.fast-world-list-atblp x atbl)
(tactic.world-list-atblp x atbl)))
:hints(("Goal"
:in-theory (e/d (tactic.fast-world-list-atblp)
((:executable-counterpart acl2::force))))))
;; Here are some performance comparisons, using level9/symmetry.
;; (defun tactic.world-list-atblp-wrapper (x atbl) ;; to avoid guards
;; (declare (xargs :mode :program))
;; (tactic.world-list-atblp x atbl))
;; (defun tactic.fast-world-list-atblp-wrapper (x atbl) ;; to avoid guards
;; (declare (xargs :mode :program))
;; (tactic.fast-world-list-atblp x atbl))
;; (acl2::time$
;; ;; 7.3 seconds, 28 KB allocated
;; (tactic.world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 1)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; (acl2::time$
;; ;; 20.7 seconds, 86 KB allocated
;; (tactic.world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 3)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; (acl2::time$
;; ;; .36 seconds, 62 MB allocated
;; (tactic.fast-world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 1)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; (acl2::time$
;; ;; .6 seconds, 105 MB allocated
;; (tactic.fast-world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 3)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; (acl2::time$
;; ;; .74 seconds, 127 MB allocated
;; (tactic.fast-world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 4)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; (acl2::time$
;; ;; 2.1 seconds, 376 MB allocated
;; (tactic.fast-world-list-atblp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 15)
;; (tactic.harness->atbl (acl2::w acl2::state))))
;; We now turn our attention to developing fast checks for the env-okp
;; functions. Our approach is pretty much the same as for the arity table,
;; except it's a little easier because we don't need to develop any analogue of
;; logic.arities-okp or anything; it's just a matter of harvesting lists of
;; formulas and putting them into lists, which we'll then mergesort and do an
;; ordered comparison against to make sure they're all axioms and/or theorems.
;; We start with the rewrite rules. We need to show that every rule in the
;; list of allrules and that all of the rules throughout our theories are
;; members of *thms*. As with our atbl checks, we just accumulate the theorems
;; for all the rules.
;; We found it useful to break up tactic.world-env-okp into two functions,
;; one to check the axioms and one to check the theorems.
(defund tactic.world-thms-okp (x thms)
(declare (xargs :guard (and (tactic.worldp x)
(logic.formula-listp thms))))
(and (rw.theory-list-env-okp-of-range (tactic.world->theories x) thms)
(rw.rule-list-env-okp (tactic.world->allrules x) thms)))
(defund tactic.world-axioms-okp (x axioms)
(declare (xargs :guard (and (tactic.worldp x)
(logic.formula-listp axioms))))
(subsetp (tactic.world->defs x) axioms))
(defthm booleanp-of-tactic.world-thms-okp
(equal (booleanp (tactic.world-thms-okp x thms))
t)
:hints(("Goal" :in-theory (enable tactic.world-thms-okp))))
(defthm booleanp-of-tactic.world-axioms-okp
(equal (booleanp (tactic.world-axioms-okp x thms))
t)
:hints(("Goal" :in-theory (enable tactic.world-axioms-okp))))
(deflist tactic.world-list-thms-okp (x thms)
(tactic.world-thms-okp x thms)
:guard (and (tactic.world-listp x)
(logic.formula-listp thms)))
(deflist tactic.world-list-axioms-okp (x axioms)
(tactic.world-axioms-okp x axioms)
:guard (and (tactic.world-listp x)
(logic.formula-listp axioms)))
(defthmd tactic.world-env-okp-redefinition
(equal (tactic.world-env-okp x axioms thms)
(and (tactic.world-thms-okp x thms)
(tactic.world-axioms-okp x axioms)))
:hints(("Goal" :in-theory (enable tactic.world-env-okp
tactic.world-thms-okp
tactic.world-axioms-okp))))
(defthmd tactic.world-list-env-okp-redefinition
(equal (tactic.world-list-env-okp x axioms thms)
(and (tactic.world-list-thms-okp x thms)
(tactic.world-list-axioms-okp x axioms)))
:hints(("Goal"
:induct (cdr-induction x)
:in-theory (enable tactic.world-env-okp-redefinition))))
(defund tactic.slow-world-thms (x)
(declare (xargs :guard (tactic.worldp x)))
(app (rw.slow-theory-map-thms (tactic.world->theories x))
(rw.slow-rule-list-thms (tactic.world->allrules x))))
(defund tactic.world-thms (x acc)
(declare (xargs :guard (and (tactic.worldp x)
(true-listp acc))))
(let ((acc (rw.rule-list-thms (tactic.world->allrules x) acc)))
(rw.theory-map-thms (tactic.world->theories x) acc)))
(defthm true-listp-of-tactic.world-thms
(implies (force (true-listp acc))
(true-listp (tactic.world-thms x acc)))
:hints(("Goal" :in-theory (enable tactic.world-thms))))
(defthm tactic.world-thms-removal
(implies (force (true-listp acc))
(equal (tactic.world-thms x acc)
(app (tactic.slow-world-thms x)
acc)))
:hints(("Goal" :in-theory (enable tactic.world-thms
tactic.slow-world-thms))))
(defthm tactic.slow-world-thms-correct
(equal (subsetp (tactic.slow-world-thms x) thms)
(tactic.world-thms-okp x thms))
:hints(("Goal"
:in-theory (e/d (tactic.slow-world-thms
tactic.world-thms-okp)))))
(defund tactic.slow-world-list-thms (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
(app (tactic.slow-world-list-thms (cdr x))
(tactic.slow-world-thms (car x)))
nil))
(defund tactic.world-list-thms (x acc)
(declare (xargs :guard (and (tactic.world-listp x)
(true-listp acc))))
(if (consp x)
(tactic.world-list-thms (cdr x)
(tactic.world-thms (car x) acc))
acc))
(defthm true-listp-of-tactic.world-list-thms
(implies (force (true-listp acc))
(true-listp (tactic.world-list-thms x acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-thms))))
(defthm tactic.world-list-thms-removal
(implies (force (true-listp acc))
(equal (tactic.world-list-thms x acc)
(app (tactic.slow-world-list-thms x)
acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-thms
tactic.slow-world-list-thms))))
(defthm tactic.slow-world-list-thms-correct
(equal (subsetp (tactic.slow-world-list-thms x) thms)
(tactic.world-list-thms-okp x thms))
:hints(("Goal"
:in-theory (e/d (tactic.slow-world-list-thms
tactic.world-list-thms-okp)))))
(defund tactic.slow-world-partial-thms (x)
(declare (xargs :guard (tactic.worldp x)))
(rw.slow-theory-map-thms (tactic.world->theories x)))
(defund tactic.world-partial-thms (x acc)
(declare (xargs :guard (and (tactic.worldp x)
(true-listp acc))))
(rw.theory-map-thms (tactic.world->theories x) acc))
(defthm true-listp-of-tactic.world-partial-thms
(implies (force (true-listp acc))
(true-listp (tactic.world-partial-thms x acc)))
:hints(("Goal" :in-theory (enable tactic.world-partial-thms))))
(defthm tactic.world-partial-thms-removal
(implies (force (true-listp acc))
(equal (tactic.world-partial-thms x acc)
(app (tactic.slow-world-partial-thms x)
acc)))
:hints(("Goal" :in-theory (enable tactic.world-partial-thms
tactic.slow-world-partial-thms))))
(defthm tactic.slow-world-partial-thms-correct
(implies (subsetp (tactic.slow-world-partial-thms x) thms)
(equal (tactic.world-thms-okp x thms)
(rw.rule-list-env-okp (tactic.world->allrules x) thms)))
:hints(("Goal"
:in-theory (e/d (tactic.slow-world-partial-thms
tactic.world-thms-okp)))))
(defund tactic.slow-world-list-partial-thms (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
(app (tactic.slow-world-list-partial-thms (cdr x))
(tactic.slow-world-partial-thms (car x)))
nil))
(defund tactic.world-list-partial-thms (x acc)
(declare (xargs :guard (and (tactic.world-listp x)
(true-listp acc))))
(if (consp x)
(tactic.world-list-partial-thms (cdr x)
(tactic.world-partial-thms (car x) acc))
acc))
(defthm true-listp-of-tactic.world-list-partial-thms
(implies (force (true-listp acc))
(true-listp (tactic.world-list-partial-thms x acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-partial-thms))))
(defthm tactic.world-list-partial-thms-removal
(implies (force (true-listp acc))
(equal (tactic.world-list-partial-thms x acc)
(app (tactic.slow-world-list-partial-thms x)
acc)))
:hints(("Goal" :in-theory (enable tactic.world-list-partial-thms
tactic.slow-world-list-partial-thms))))
(defthm tactic.slow-world-list-partial-thms-correct
(implies (and (subsetp (tactic.slow-world-list-partial-thms x) thms)
(force (tactic.world-list-compatiblep-hack x))
(force (consp x)))
(equal (tactic.world-list-thms-okp x thms)
(rw.rule-list-env-okp (tactic.world->allrules (car x)) thms)))
:hints(("Goal"
:in-theory (e/d (tactic.world-list-compatiblep-hack
tactic.slow-world-list-partial-thms
tactic.world-list-thms-okp)))))
(defund tactic.world-list-defs (x)
(declare (xargs :guard (tactic.world-listp x)))
(if (consp x)
(revappend (tactic.world->defs (car x))
(tactic.world-list-defs (cdr x)))
nil))
(defthm true-listp-of-tactic.world-list-defs
(true-listp (tactic.world-list-defs x))
:hints(("Goal" :in-theory (enable tactic.world-list-defs))))
(defthm tactic.world-list-defs-correct
(equal (subsetp (tactic.world-list-defs x) axioms)
(tactic.world-list-axioms-okp x axioms))
:hints(("Goal"
:in-theory (enable tactic.world-list-defs
tactic.world-list-axioms-okp
tactic.world-axioms-okp))))
(defthm tactic.world-list-partial-defs-correct
(implies (and (tactic.world-list-compatiblep-hack x)
(consp x))
(equal (subsetp (tactic.world->defs (car x)) axioms)
(tactic.world-list-axioms-okp x axioms)))
:hints(("Goal" :in-theory (enable tactic.world-axioms-okp
tactic.world-list-axioms-okp
tactic.world-list-compatiblep-hack))))
(defund tactic.fast-world-list-env-okp (x axioms thms)
(declare (xargs :guard (and (tactic.world-listp x)
(logic.formula-listp axioms)
(logic.formula-listp thms))))
(if (and (consp x)
(tactic.world-list-compatiblep-hack x))
(let* ((my-thms (tactic.world-list-partial-thms x nil))
(my-thms (rw.rule-list-thms (tactic.world->allrules (car x)) my-thms))
(my-defs (tactic.world->defs (car x))))
(and (ordered-list-subsetp (mergesort my-thms) (mergesort thms))
(ordered-list-subsetp (mergesort my-defs) (mergesort axioms))))
(ACL2::prog2$
(ACL2::cw "Performance note: fast-world-list-env-okp can't use compatibility hack.~%")
(let* ((my-thms (tactic.world-list-thms x nil))
(my-defs (tactic.world-list-defs x)))
(and (ordered-list-subsetp (mergesort my-thms) (mergesort thms))
(ordered-list-subsetp (mergesort my-defs) (mergesort axioms)))))))
(defthmd lemma-1-for-tactic.fast-world-list-env-okp-lemma
(implies (TACTIC.WORLD-LIST-THMS-OKP X THMS)
(SUBSETP (TACTIC.SLOW-WORLD-LIST-PARTIAL-THMS X) THMS))
:hints(("Goal"
:in-theory (enable tactic.world-list-thms-okp
tactic.world-thms-okp
TACTIC.SLOW-WORLD-LIST-PARTIAL-THMS
tactic.slow-world-partial-thms))))
(defthmd lemma-2-for-tactic.fast-world-list-env-okp-lemma
(implies (tactic.world-list-thms-okp x thms)
(rw.rule-list-env-okp (tactic.world->allrules (first x)) thms))
:hints(("Goal"
:in-theory (enable tactic.world-list-thms-okp
tactic.world-thms-okp))))
(defthmd tactic.fast-world-list-env-okp-lemma
(equal (tactic.fast-world-list-env-okp x axioms thms)
(and (tactic.world-list-axioms-okp x axioms)
(tactic.world-list-thms-okp x thms)))
:hints(("Goal"
:in-theory (e/d (tactic.fast-world-list-env-okp
lemma-1-for-tactic.fast-world-list-env-okp-lemma
lemma-2-for-tactic.fast-world-list-env-okp-lemma
)))))
(defthm tactic.fast-world-list-env-okp-correct
(equal (tactic.fast-world-list-env-okp x axioms thms)
(tactic.world-list-env-okp x axioms thms))
:hints(("Goal" :in-theory (enable tactic.fast-world-list-env-okp-lemma
tactic.world-list-env-okp-redefinition))))
;; Here are some performance comparisons, using level9/symmetry.
;;
;; (defun tactic.world-list-env-okp-wrapper (x axioms thms) ;; to avoid guards
;; (declare (xargs :mode :program))
;; (tactic.world-list-env-okp x axioms thms))
;;
;; (defun tactic.fast-world-list-env-okp-wrapper (x axioms thms) ;; to avoid guards
;; (declare (xargs :mode :program))
;; (tactic.fast-world-list-env-okp x axioms thms))
;;
;; (acl2::time$
;; ;; 41.3 seconds, 10 MB
;; (tactic.world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 1)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
;;
;; (acl2::time$
;; ;; 124 seconds, 30 MB
;; (tactic.world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 3)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
;;
;; (acl2::time$
;; ;; .41 seconds, 20 MB
;; (tactic.fast-world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 1)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
;;
;; (acl2::time$
;; ;; .68 seconds, 36 MB
;; (tactic.fast-world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 3)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
;;
;; (acl2::time$
;; ;; .81 seconds, 44 MB
;; (tactic.fast-world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 4)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
;;
;; (acl2::time$
;; ;; 2.2 seconds, 133 MB
;; (tactic.fast-world-list-env-okp-wrapper (repeat (tactic.harness->world (acl2::w acl2::state)) 15)
;; (tactic.harness->axioms (acl2::w acl2::state))
;; (tactic.harness->thms (acl2::w acl2::state))))
|