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 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210
|
;; This is really a continuation of the proof of the ADD1 program proof.
(in-package "M6")
(include-book "../M6/m6-start-jvm")
(include-book "ordinals/e0-ordinal" :dir :system)
(set-well-founded-relation e0-ord-<)
(include-book "ADD1-program-correct.improved")
;-- Initial State -----------------------------------------------------
;; (acl2::set-guard-checking nil)
;; (defconst *s2* (setup-initial-state "Second" '() *s*))
;; (thread-table (round-robin-run *s2* 101))
;; (defun init-state2 ()
;; (round-robin-run *s2* 10))
;; (acl2::set-guard-checking t)
(include-book "factorial-program-init-state")
;
; Properties of init-state
;
(defthm no-pending-exception-init-state2
(not (acl2::g 'pending-exception (aux (init-state2))))
:hints (("Goal" :in-theory (enable init-state2))))
(defthm no-fatal-error?-init-state2
(no-fatal-error? (init-state2))
:hints (("Goal" :in-theory (enable init-state2))))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
(defun inst-equiv (i2 i1)
(equal (inst-inst i2) (inst-inst i1)))
(defequiv inst-equiv)
(defcong inst-equiv equal (inst-opcode inst) 1
:hints (("Goal" :in-theory (enable inst-opcode))))
(defcong inst-equiv equal (inst-inst inst) 1)
(defcong inst-equiv equal (execute-invokestatic inst s) 1
:hints (("Goal" :in-theory (disable CALL_STATIC_METHOD
RESOLVEMETHODREFERENCE))))
; need to simplify the execute-invokestatic
;
;;; (defun execute-invokestatic (inst s)
;;; (let* ((methodCP (arg inst))
;;; (method-ptr (methodCP-to-method-ptr methodCP)))
;;; (mv-let (method-rep new-s)
;;; (resolveMethodReference method-ptr t s) ;; we know class is loaded
;;; (if (pending-exception s)
;;; (raise-exception (pending-exception s) s)
;;; (if method-rep
;;; (let* ((class-rep (static-method-class-rep method-rep new-s))
;;; (mclassname (classname class-rep))
;;; (class-ref (class-ref class-rep)))
;;; (if (class-rep-in-error-state? class-rep)
;;; (fatalError "expected initialized class" new-s)
;;; (if (not (class-initialized? mclassname new-s))
;;; (prog2$ (acl2::debug-print "hereXXX")
;;; (reschedule (initializeClass mclassname new-s)))
;;; ;; re-execute the same instruction.
;;; (call_static_method class-ref method-rep new-s))))
;;; (fatalSlotError methodCP new-s))))))
;
;
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; Sun Jan 11 21:57:30 2004
(defun state-equiv-class-table-equal (s2 s1)
(and (equal (class-table s2) (class-table s1))
(equal (env s2) (env s1))
(equal (heap s2) (heap s1))
(equal (error-flag s2) (error-flag s1))
(equal (acl2::g 'pending-exception (aux s2))
(acl2::g 'pending-exception (aux s1)))))
;; properties of state-equiv-class-table-equal
(defequiv state-equiv-class-table-equal)
(defcong state-equiv-class-table-equal equal (class-table s) 1)
(defcong state-equiv-class-table-equal equal (heap s) 1)
(defcong state-equiv-class-table-equal equal (env s) 1)
(defcong state-equiv-class-table-equal equal (error-flag s) 1)
(defcong state-equiv-class-table-equal equal (instance-class-table s) 1
:hints (("Goal" :in-theory (enable instance-class-table))))
(defcong state-equiv-class-table-equal equal (array-class-table s) 1
:hints (("Goal" :in-theory (enable array-class-table))))
(defcong state-equiv-class-table-equal equal (class-loaded? cn s) 2
:hints (("Goal" :in-theory (cons 'class-loaded? (disable state-equiv-class-table-equal)))))
(defcong state-equiv-class-table-equal equal (no-fatal-error? s) 1
:hints (("Goal" :in-theory (enable no-fatal-error?))))
(defthm state-equiv-class-table-equal-make-state
(state-equiv-class-table-equal (make-state (pc s)
(current-thread s)
(heap s)
(thread-table s)
(class-table s)
(env s)
(error-flag s)
(aux s))
s))
(defthm implies-state-equiv-class-table-equal
(implies (and (equal (heap s2) (heap s1))
(equal (class-table s2) (class-table s1))
(equal (env s2) (env s1))
(equal (error-flag s2) (error-flag s1))
(equal (acl2::g 'pending-exception (aux s2))
(acl2::g 'pending-exception (aux s1))))
(equal (state-equiv-class-table-equal s2 s1) t)))
;; should disable this soon.
(in-theory (disable state-equiv-class-table-equal))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; init-state property again
(defconst *second-method*
'(METHOD
"Second" "fact" (PARAMETERS INT)
(RETURNTYPE . INT)
(ACCESSFLAGS *CLASS* *PUBLIC* *STATIC*)
(CODE (MAX_STACK . 3)
(MAX_LOCAL . 1)
(CODE_LENGTH . 15)
(PARSEDCODE (0 (ILOAD_0))
(1 (IFGT 6))
(4 (ICONST_1))
(5 (IRETURN))
(6 (ILOAD_0))
(7 (ILOAD_0))
(8 (ICONST_1))
(9 (ISUB))
(10 (INVOKESTATIC (METHODCP "fact" "Second" (INT) INT)))
(13 (IMUL))
(14 (IRETURN))
(ENDOFCODE 15))
(EXCEPTIONS)
(STACKMAP))))
(defconst *fact-ptr*
'(METHOD-PTR "Second" "fact" (INT) INT))
(defthm second-method-code
(equal (code-instrs (METHOD-CODE *second-method*))
'((0 (ILOAD_0))
(1 (IFGT 6))
(4 (ICONST_1))
(5 (IRETURN))
(6 (ILOAD_0))
(7 (ILOAD_0))
(8 (ICONST_1))
(9 (ISUB))
(10 (INVOKESTATIC (METHODCP "fact" "Second" (INT) INT)))
(13 (IMUL))
(14 (IRETURN))
(ENDOFCODE 15))))
(defthm deref-method-fact-ptr
(equal (DEREF-METHOD *FACT-PTR*
(INSTANCE-CLASS-TABLE (INIT-STATE2)))
*second-method*))
(in-theory (disable init-state2 (init-state2)))
(in-theory (disable code-instrs))
(defthm inst-is
(implies (state-equiv-class-table-equal s (init-state2))
(equal (INST-BY-OFFSET1
ip
(CODE-INSTRS
(METHOD-CODE
(DEREF-METHOD *fact-ptr*
(INSTANCE-CLASS-TABLE S)))))
(inst-by-offset1
ip
(code-instrs (method-code *second-method*))))))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; definition of poised for execution!
;
;; don't care about heap
(defun poised-for-execute-fact (s)
(and (inst-equiv (next-inst s)
'(any (invokestatic (METHODCP "fact" "Second" (INT) INT))))
(current-thread-exists? s)
;; (wff-state-regular s)
;; (wff-thread-table-regular (thread-table s))
(unique-id-thread-table (thread-table s))
(state-equiv-class-table-equal s (init-state2))))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; Call opener: deal with the method invocation
;
;; Start dealing with dynamic class loading primitives that in term incurs that
;; we need to talk about creating object in the heap
;; (defthm state-equiv-class-table-equal-mv-state-equiv-class-table-equal-1
;; (implies (state-equiv-class-table-equal s2 s1))
;; (equal (car (build-a-java-visible-instance-data classnames s2))
;; (car (build-a-java-visible-instance-data classnames s1)))))
;;;
;;; this cause loops in v28
;;;
(defthm state-equiv-class-table-equal-mv-state-equiv-class-table-equal-1
(implies (and (state-equiv-class-table-equal s2 s1)
(not (equal s2 s1)))
(equal (car (build-a-java-visible-instance-data classnames s2))
(car (build-a-java-visible-instance-data classnames s1)))))
(defthm state-equiv-class-table-equal-mv-state-equiv-class-table-equal-2
(implies (and (state-equiv-class-table-equal s2 s1)
(not (equal s2 s1)))
(state-equiv-class-table-equal
(mv-nth 1 (build-a-java-visible-instance-data classnames s2))
(mv-nth 1 (build-a-java-visible-instance-data classnames s1)))))
(in-theory (disable build-a-java-visible-instance-data))
;; (i-am-here) ;; Tue Jul 4 22:24:07 2006
(defthm state-equiv-class-table-equal-build-an-instance-1
(implies (and (state-equiv-class-table-equal s2 s1)
(not (equal s2 s1)))
(equal (car (build-an-instance classnames s2))
(car (build-an-instance classnames s1))))
:hints (("Goal" :restrict
((STATE-EQUIV-CLASS-TABLE-EQUAL-MV-STATE-EQUIV-CLASS-TABLE-EQUAL-1
((s1 s1) (s2 s2)))))))
;; :hints (("Goal" :use ((:instance
;; state-equiv-class-table-equal-mv-state-equiv-class-table-equal-1
;; (s2 s1) (s1 s1)
;; (classnames (collect-superclass-list1 classnames
;; (instance-class-table s1) ni))))
;; :in-theory (disable
;; state-equiv-class-table-equal-mv-state-equiv-class-table-equal-1))))
(defthm state-equiv-class-table-equal-build-an-instance-2
(implies (state-equiv-class-table-equal s2 s1)
(state-equiv-class-table-equal
(mv-nth 1 (build-an-instance classnames s2))
(mv-nth 1 (build-an-instance classnames s1)))))
;;; I know those rules are bad!! Thu Apr 1 09:41:26 2004
(defthm state-equiv-class-table-equal-build-an-instanceClass-1
(implies (state-equiv-class-table-equal s2 s1)
(equal (car (build-an-instanceClass classnames s2))
(car (build-an-instanceClass classnames s1)))))
(defthm state-equiv-class-table-equal-build-an-instanceClass-2
(implies (state-equiv-class-table-equal s2 s1)
(state-equiv-class-table-equal
(mv-nth 1 (build-an-instanceClass classnames s2))
(mv-nth 1 (build-an-instanceClass classnames s1)))))
(defthm state-equiv-class-table-equal-set-trace
(state-equiv-class-table-equal
(state-set-aux (aux-set-trace any (aux s)) s) s)
:hints (("Goal" :in-theory (enable aux-set-trace
state-equiv-class-table-equal))))
(defthm get-exception-aux-set-trace
(equal (acl2::g 'pending-exception (aux-set-trace any aux))
(acl2::g 'pending-exception aux))
:hints (("Goal" :in-theory (enable aux-set-trace))))
(in-theory (disable aux-set-trace ))
(in-theory (disable add-obj-th-count))
(defthm state-equiv-class-table-equal-load_cp_entry-1
(implies (state-equiv-class-table-equal s2 s1)
(state-equiv-class-table-equal
(mv-nth 1 (load_cp_entry cp s2))
(mv-nth 1 (load_cp_entry cp s1))))
:hints (("Goal" :in-theory (e/d (load_cp_entry state-equiv-class-table-equal)
(build-an-instance)))))
(defthm state-equiv-class-table-equal-load_cp_entry-2
(implies (state-equiv-class-table-equal s2 s1)
(equal
(car (load_cp_entry cp s2))
(car (load_cp_entry cp s1))))
:hints (("Goal" :in-theory (enable load_cp_entry))))
(in-theory (disable load_cp_entry))
(defthm state-equiv-class-table-equal-load_cp_entries
(and (implies (state-equiv-class-table-equal s2 s1)
(state-equiv-class-table-equal
(mv-nth 1 (load_cp_entries cps s2))
(mv-nth 1 (load_cp_entries cps s1))))
(implies (state-equiv-class-table-equal s2 s1)
(equal (car (load_cp_entries cps s2))
(car (load_cp_entries cps s1)))))
:hints (("Goal" :restrict ((STATE-EQUIV-CLASS-TABLE-EQUAL-LOAD_CP_ENTRY-2
((s1 s1) (s2 s2)))
(state-equiv-class-table-equal-load_cp_entry-1
((s1 s1) (s2 s2)))))))
(defthm state-equiv-class-table-equal-implies-get-pending-equal
(implies (state-equiv-class-table-equal s2 s1)
(equal (acl2::g 'pending-exception (aux s2))
(acl2::g 'pending-exception (aux s1))))
:hints (("Goal" :in-theory (enable state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-implies-get-pending-equal-specific
(implies (state-equiv-class-table-equal s2 s1)
(equal (acl2::g 'pending-exception (aux (mv-nth 1 (load_cp_entries
cps s2))))
(acl2::g 'pending-exception (aux (mv-nth 1 (load_cp_entries
cps s1))))))
:hints (("Goal" :restrict ((STATE-EQUIV-CLASS-TABLE-EQUAL-LOAD_CP_ENTRY-2
((s1 s1) (s2 s2)))
(state-equiv-class-table-equal-load_cp_entry-1
((s1 s1) (s2 s2)))
(STATE-EQUIV-CLASS-TABLE-EQUAL-IMPLIES-GET-PENDING-EQUAL
((s1 s1) (s2 s2)))))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(load_class2 classname s) 2
:hints (("Goal" :in-theory (e/d (load_class2) ())
:restrict ((STATE-EQUIV-CLASS-TABLE-EQUAL-LOAD_CP_ENTRY-2
((s1 s) (s2 s-equiv)))
(state-equiv-class-table-equal-load_cp_entry-1
((s1 s) (s2 s-equiv)))
(state-equiv-class-table-equal-load_cp_entries
((s1 s) (s2 s-equiv)))
(STATE-EQUIV-CLASS-TABLE-EQUAL-IMPLIES-GET-PENDING-EQUAL-SPECIFIC
((s1 s) (s2 s-equiv)))
(STATE-EQUIV-CLASS-TABLE-EQUAL-IMPLIES-GET-PENDING-EQUAL
((s1 s) (s2 s-equiv)))))))
(in-theory (disable state-equiv-class-table-equal-implies-get-pending-equal-specific))
(defun load_class_x_induct (p s seen mode s-equiv)
(declare (xargs :measure (induct-measure p s seen mode)))
(let ((classname p)
(interfaces p))
(cond ((and (equal mode 3)
(or (class-loaded? classname s)
(mem classname seen)
(mv-let (def-found class-desc)
(class-by-name-s classname
(external-class-table s))
(declare (ignore class-desc))
(not def-found))))
(list p s seen mode))
((and (equal mode 3)
(or (not (trivial-inv-env-do-not-change
(load_class_x classname s seen 2) s))
(not (no-fatal-error? (load_class_x classname s seen 2)))))
(load_class_x_induct classname s seen 2 s-equiv))
((equal mode 3)
(list (load_class_x_induct classname s seen 2 s-equiv)
(load_class_x_induct classname
(load_class_x classname s seen 2) seen 1
(load_class_x classname s-equiv seen 2))))
((and (equal mode 2)
(not (load_class_1-inv classname s seen))
(list p seen mode)))
((equal mode 2)
(mv-let (def-found class-desc)
(class-by-name-s classname (external-class-table s))
(declare (ignore def-found))
(let* ((supername (super-s class-desc)))
(load_class_x_induct supername s (cons classname seen)
3 s-equiv))))
((and (equal mode 1)
(not (load_class_2-inv classname s seen)))
(list p seen mode))
((equal mode 1)
(mv-let (def-found class-desc)
(class-by-name-s classname (external-class-table s))
(declare (ignore def-found))
(let* ((interfaces (interfaces-s class-desc)))
(load_class_x_induct interfaces s (cons classname seen) 0 s-equiv))))
((and (equal mode 0)
(or (endp interfaces)
(not (no-fatal-error? s))
(mem (car interfaces) seen))
(list p seen s mode)))
((and (equal mode 0)
(class-loaded? (car interfaces) s)
(let ((class-rep (class-by-name (car interfaces)
(instance-class-table s))))
(not (isInterface class-rep))))
(list p seen s mode))
((and (equal mode 0)
(class-loaded? (car interfaces) s))
(load_class_x_induct (cdr interfaces) s seen 0 s-equiv))
((and (equal mode 0)
(let* ((new-s (load_class_x (car interfaces) s seen 3))
(class-rep (class-by-name (car interfaces)
(instance-class-table
new-s))))
(or (not (trivial-inv-env-do-not-change new-s s))
(not (no-fatal-error? new-s))
(not (isInterface class-rep)))))
(load_class_x_induct (car interfaces) s seen 3 s-equiv))
((equal mode 0)
(let* ((new-s (load_class_x (car interfaces) s seen 3)))
(list (load_class_x_induct (car interfaces) s seen 3 s-equiv)
(load_class_x_induct (cdr interfaces) new-s seen 0
(load_class_x (car interfaces) s-equiv seen 3)))))
(t (list p s seen mode s-equiv)))))
(in-theory (disable load_class2))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(fatalerror any s) 2
:hints (("Goal" :in-theory (enable fatalerror
state-equiv-class-table-equal))))
(in-theory (disable fatalError
STATE-EQUIV-CLASS-TABLE-EQUAL-IMPLIES-GET-PENDING-EQUAL))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(load_class_x classname s anySeen anyMode) 2
:hints (("Goal" :do-not '(generalize)
:induct (load_class_x_induct classname s anySeen anyMode
s-equiv))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(load_array_class2 basetype s) 2
:hints (("Goal" :in-theory (enable load_array_class2
array-class-table
state-equiv-class-table-equal
instance-class-table))))
(in-theory (disable load_array_class2 load_class_x state-equiv-class-table-equal))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(state-set-current-thread cid s) 2
:hints (("Goal" :in-theory (enable state-set-current-thread
state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-set-cid
(state-equiv-class-table-equal
(state-set-current-thread cid s)
s)
:hints (("Goal" :in-theory (enable state-set-current-thread
state-equiv-class-table-equal))))
(in-theory (disable state-set-current-thread))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(load_class classname s) 2
:hints (("Goal" :in-theory (enable load_class))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(load_array_class basetype s) 2
:hints (("Goal" :in-theory (enable load_array_class load_class))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(resolveClassReference classname s) 2
:hints (("Goal" :in-theory (enable resolveClassReference))))
;
; Finally, we proved the needed congruence rule.
;
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; To prove the following, we do not need above proof at all!!
;
(defthm resolveClassReference-loaded-class-no-change
(implies (and (class-loaded? classname s)
(not (array-type? classname)))
(equal (resolveClassReference classname s)
s))
:hints (("Goal" :in-theory (enable resolveClassReference))))
(defthm poised-execute-next-inst-is
(implies (and (inst-equiv (next-inst s) '(any (invokestatic (METHODCP "fact"
"Second" (INT) INT))))
(no-fatal-error? s))
(equal (m6step s) (execute-invokestatic (next-inst s) s)))
:hints (("Goal" :in-theory (e/d (m6step) (execute-invokestatic next-inst inst-equiv)))))
(defthm call-opener-execute-invokestatic-Fact-equal-call-static
(implies (and (poised-for-execute-fact s)
(inst-equiv inst '(any (invokestatic (METHODCP "fact" "Second" (INT) INT)))))
(equal (execute-invokestatic inst s)
(call_static_method 55 *second-method* s)))
:hints (("Goal" :in-theory (e/d ((init-state2)
STATE-EQUIV-CLASS-TABLE-EQUAL-IMPLIES-GET-PENDING-EQUAL)
(call_static_method)))))
(defthm call-opener-execute-invoke
(implies (poised-for-execute-fact s)
(equal (m6step s)
(call_static_method 55 *second-method* s))))
(in-theory (disable call-opener-execute-invokestatic-Fact-equal-call-static poised-execute-next-inst-is))
;
; We know how to do invoke from a state equiv to initial-state!!
;
;----------------------------------------------------------------------
;;
;; just use executable counterpart.
;;
;
;----------------------------------------------------------------------
;
; Regular opener for doing recusive funcation call and looping
;
;; (defun natp (x)
;; (and (integerp x)
;; (<= 0 x)))
(defun c+ (i j)
(if (zp i)
(nfix j)
(+ 1 (c+ (- i 1) j))))
(defun fact-clock (n)
(if (zp n)
5
(c+ 7 (c+ (fact-clock (- n 1)) 2))))
(defun fact (n)
(if (zp n)
1
(* n (fact (- n 1)))))
(defun fact-induct (n s)
(if (zp n)
(list n s)
(fact-induct (- n 1) (simple-run s 7))))
#|
(defthm c+-revealed
(equal (c+ i j) (+ (nfix i) (nfix j))))
(in-theory (disable c+-revealed))
|#
(defthm simple-run-+
(implies (and (natp i) (natp j))
(equal (simple-run s (+ i j))
(simple-run (simple-run s i) j))))
(defthm simple-run-c+
(implies (and (natp i) (natp j))
(equal (simple-run s (c+ i j))
(simple-run (simple-run s i) j))))
(defthm simple-run-opener-J
(and (equal (simple-run s 0) s)
(implies (natp i)
(equal (simple-run s (+ 1 i))
(simple-run (m6step s) i)))))
(in-theory (disable simple-run-opener simple-run))
;----------------------------------------------------------------------
;
; Statement of the theorem
;
(in-theory (disable implies-state-equiv-class-table-equal))
;; (defthm wff-state-regular-implies-equal
;; (implies (poised-for-execute-fact s)
;; (EQUAL (MAKE-STATE (PC S)
;; (CURRENT-THREAD S)
;; (HEAP (INIT-STATE2))
;; (THREAD-TABLE S)
;; (CLASS-TABLE (INIT-STATE2))
;; (ENV (INIT-STATE2))
;; (ERROR-FLAG (INIT-STATE2))
;; (AUX S))
;; S)))
;; (in-theory (disable pushFrame0))
;; (defthm second-is-correct-lemma
;; (implies (and (poised-for-execute-fact s)
;; ;; (wff-state-regular s)
;; ;; (wff-thread-table-regular (thread-table s))
;; ;; (EQUAL (MAKE-STATE (PC S)
;; ;; (CURRENT-THREAD S)
;; ;; (HEAP (INIT-STATE2))
;; ;; (THREAD-TABLE S)
;; ;; (CLASS-TABLE (INIT-STATE2))
;; ;; (ENV (INIT-STATE2))
;; ;; (ERROR-FLAG (INIT-STATE2))
;; ;; (AUX S))
;; ;; s)
;; (no-fatal-error? s)
;; (integerp n)
;; (<= 0 n)
;; (intp n)
;; (equal n (topStack s)))
;; (equal (simple-run s (fact-clock n))
;; (state-set-pc (+ 3 (pc s))
;; (pushStack (int-fix (fact n))
;; (popStack s)))))
;; :hints (("Goal" :do-not '(generalize fertilize)
;; :induct (fact-induct n s))
;; ("Subgoal *1/2"
;; :cases ((inst-equiv (next-inst s)
;; '(any (invokestatic (METHODCP "fact" "Second" (INT) INT))))))))
;----------------------------------------------------------------------
(defun intp (n)
(and (integerp n)
(<= (- (expt 2 31)) n)
(< n (expt 2 31))))
(defthm intp-int-fix
(implies (intp n)
(equal (int-fix n) n))
:hints (("Goal" :in-theory (enable int-fix))))
;; (skip-proofs
;; (defthm int-fix-int-fix
;; (equal (int-fix (* x (int-fix y)))
;; (int-fix (* x y)))))
;----------------------------------------------------------------------
(in-theory (enable next-inst))
;; (defthm second-is-correct
;; (implies (and (poised-for-execute-fact s)
;; (wff-state-regular s)
;; (wff-thread-table-regular (thread-table s))
;; (no-fatal-error? s)
;; (integerp n)
;; (<= 0 n)
;; (intp n)
;; (equal n (topStack s)))
;; (equal (simple-run s (fact-clock n))
;; (state-set-pc (+ 3 (pc s))
;; (pushStack (int-fix (fact n))
;; (popStack s)))))
;; :hints (("Goal" :do-not '(generalize fertilize preprocess)
;; :induct (fact-induct n s))
;; ("Subgoal *1/2"
;; :cases ((inst-equiv (next-inst s)
;; '(any (invokestatic (METHODCP "fact" "Second" (INT) INT))))))))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
;
; These are used for simplifying the term to get the next instruction.
;
;
(defthm pushFrame0-current-frame
(implies (and (wff-thread-table (thread-table s))
(current-thread-exists? s))
(equal (current-frame (pushFrame0 new-frame s))
new-frame))
:hints (("Goal" :in-theory (enable current-frame pushFrame0
current-thread-exists?))))
;; (defcong equiv-frame equal (method-ptr frame) 1)
(defthm current-method-ptr-popStackN
(equal (current-method-ptr (popStackN n s))
(current-method-ptr s)))
(defthm current-method-ptr-state-set-pc
(equal (current-method-ptr (state-set-pc pc s))
(current-method-ptr s)))
(defthm current-method-ptr-popStack
(equal (current-method-ptr (popStack s))
(current-method-ptr s)))
(defthm current-method-ptr-pushStack
(equal (current-method-ptr (pushStack v s))
(current-method-ptr s)))
(defthm current-method-ptr-pushFrame0
(implies (and (wff-thread-table (thread-table s))
(current-thread-exists? s))
(equal (current-method-ptr
(pushFrame0 new-frame s))
(method-ptr new-frame)))
:hints (("Goal" :in-theory (enable current-method-ptr
current-frame
pushFrame0
thread-exists?
current-thread-exists?))))
(defthm pc-pushFrame0
(equal (pc (pushFrame0 new-frame s)) 0)
:hints (("Goal" :in-theory (enable pushFrame0))))
(defthm pc-popFrame
(equal (pc (popFrame s))
(return-pc (current-frame s)))
:hints (("Goal" :in-theory (enable popFrame current-frame))))
(defthm instance-class-table-pushFrame0
(equal (instance-class-table (pushFrame0 new-frame s))
(instance-class-table s))
:hints (("Goal" :in-theory (enable pushFrame0))))
(in-theory (enable wff-thread-table-regular))
(defthm current-thread-exists?-popStackN
(implies (current-thread-exists? s)
(current-thread-exists? (popStackN n s))))
(defthm current-thread-exists?-popStack
(implies (current-thread-exists? s)
(current-thread-exists? (popStack s))))
(defthm current-thread-exists?-state-set-pc
(implies (current-thread-exists? s)
(current-thread-exists? (state-set-pc n s))))
(defthm current-thread-exists?-pushFrame
(implies (current-thread-exists? s)
(current-thread-exists? (pushFrame0 frame s)))
:hints (("Goal" :in-theory (enable current-thread-exists? pushFrame0 thread-exists?))))
(defthm instance-class-table-popStack
(equal (instance-class-table (popStack s))
(instance-class-table s)))
(defthm instance-class-table-popStackN
(equal (instance-class-table (popStackN n s))
(instance-class-table s)))
(defthm wff-thread-table-regular-popStackN
(implies (and (wff-thread-table-regular (thread-table s))
(current-thread-exists? s))
(wff-thread-table-regular (thread-table (popStackN n s)))))
;----------------------------------------------------------------------
;
; These should deal with no-fatal-error?
;
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(pushFrame0 frame s) 2
:hints (("Goal" :in-theory (enable pushFrame0
state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-pushFrame
(state-equiv-class-table-equal (pushFrame0 frame s) s)
:hints (("Goal" :in-theory (enable pushFrame0 state-equiv-class-table-equal))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(popStack s) 1
:hints (("Goal" :in-theory (enable popStack
state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-popStack
(state-equiv-class-table-equal (popStack s) s)
:hints (("Goal" :in-theory (enable popStack state-equiv-class-table-equal))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(pushStack v s) 2
:hints (("Goal" :in-theory (enable pushStack
state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-pushStack
(state-equiv-class-table-equal (pushStack v s) s)
:hints (("Goal" :in-theory (enable pushStack
state-equiv-class-table-equal))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(state-set-local-at i v s) 3
:hints (("Goal" :in-theory (enable state-set-local-at
state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-state-set-local-at
(state-equiv-class-table-equal (state-set-local-at i v s) s)
:hints (("Goal" :in-theory (enable state-set-local-at state-equiv-class-table-equal))))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(popStackN n s) 2)
(defthm state-equiv-class-table-equal-popStackN
(state-equiv-class-table-equal (popStackN n s) s))
(defcong state-equiv-class-table-equal state-equiv-class-table-equal
(state-set-pc pc s) 2
:hints (("Goal" :in-theory (enable state-set-pc state-equiv-class-table-equal))))
(defthm state-equiv-class-table-equal-state-set-pc
(state-equiv-class-table-equal (state-set-pc pc s) s)
:hints (("Goal" :in-theory (enable state-set-pc state-equiv-class-table-equal))))
;; ??? WHY? those do not apply automatically?
(defthm no-fatal-error-pushFrame0
(equal (no-fatal-error? (pushFrame0 frame s))
(no-fatal-error? s)))
(defthm no-fatal-error-state-set-pc
(equal (no-fatal-error? (state-set-pc pc s))
(no-fatal-error? s)))
(defthm no-fatal-error-popStack
(equal (no-fatal-error? (popStack s))
(no-fatal-error? s)))
(defthm pushStack-no-change-instance-class-table
(equal (instance-class-table (pushStack v s))
(instance-class-table s)))
(defthm no-fatal-error-popStackN
(equal (no-fatal-error? (popStackN n s))
(no-fatal-error? s)))
;; (in-theory (disable pushFrame0 (init-state2) code-instrs inst-inst))
;; (in-theory (disable execute-invokestatic))
;----------------------------------------------------------------------
(in-theory (enable local-at))
(defthm car-operand-stack-current-frame-is-topStack
(equal (car (operand-stack (current-frame s)))
(topStack s))
:hints (("Goal" :in-theory (enable topStack))))
;----------------------------------------------------------------------
;
; Next deal with popStack-pushStack!!! w
;
; we need
(defthm wff-state-regular-pushFrame
(implies (wff-state-regular s)
(wff-state-regular (pushFrame0 frame s)))
:hints (("Goal" :in-theory (enable pushFrame0 wff-state state-set-pc
make-state pc current-thread thread-table
class-table env aux heap error-flag))))
(defthm wff-state-regular-popStackN
(implies (wff-state-regular s)
(wff-state-regular (popStackN n s))))
;; (defthm wff-state-regular-pushStack
;; (implies (wff-state-regular s)
;; (wff-state-regular (pushStack v s))))
(defthm wff-thread-table-regular-pushFrame0
(implies (and (current-thread-exists? s)
(wff-thread-table-regular (thread-table s)))
(wff-thread-table-regular (thread-table (pushFrame0 frame s))))
:hints (("Goal" :in-theory (enable pushFrame0))))
;; (defthm wff-thread-table-regular-popStackN
;; (implies (and (current-thread-exists? s)
;; (wff-thread-table-regular (thread-table s)))
;; (wff-thread-table-regular (thread-table (popStackN n s)))))
(defthm wff-state-regular-integerp-pc
(implies (wff-state-regular s)
(integerp (pc s)))
:hints (("Goal" :in-theory (enable wff-state-regular)))
:rule-classes :forward-chaining)
(defthm wff-state-regular-state-set-pc
(implies (and (wff-state-regular s)
(integerp pc))
(wff-state-regular (state-set-pc pc s)))
:hints (("Goal" :in-theory (enable state-set-pc wff-state state-set-pc
make-state pc current-thread thread-table
class-table env aux heap error-flag))))
(in-theory (disable wff-state-regular))
(defthm unique-id-thread-table-pushFrame0
(implies (and (current-thread-exists? s)
(unique-id-thread-table (thread-table s)))
(unique-id-thread-table (thread-table (pushFrame0 frame s))))
:hints (("Goal" :in-theory (enable pushFrame0))))
(defthm unique-id-thread-table-popStackN
(implies (and (current-thread-exists? s)
(unique-id-thread-table (thread-table s)))
(unique-id-thread-table (thread-table (popStackN n s)))))
(defthm wff-call-frame-regular-make-frame
(implies (and (wff-method-ptr mptr)
(true-listp locals)
(true-listp ops))
(wff-call-frame-regular (MAKE-FRAME rpc
ops
locals
mptr
sync
resume-pc
aux)))
:hints (("Goal" :in-theory (enable wff-call-frame-regular wff-call-frame
make-frame locals operand-stack return-pc
method-ptr sync-obj-ref))))
(defthm wff-call-frame-regular-locals-truelistp
(implies (wff-call-frame-regular frame)
(true-listp (locals frame)))
:hints (("Goal" :in-theory (enable wff-call-frame
wff-call-frame-regular locals))))
(defthm wff-call-frame-regular-opstack-truelistp
(implies (wff-call-frame-regular frame)
(true-listp (operand-stack frame)))
:hints (("Goal" :in-theory (enable wff-call-frame
wff-call-frame-regular operand-stack))))
;;
;; this is not provable anymore after we updatd to wff-call-frame to assert
;; a lot of properties about the frame.
;;
;; To prove the same theorem. we need add a lot of more hypthoesis
;----------------------------------------------------------------------
;
(defthm current-thread-pushFrame
(equal (current-thread (pushFrame0 frame s))
(current-thread s))
:hints (("Goal" :in-theory (enable pushFrame0))))
(defthm current-thread-popStackN
(equal (current-thread (popStackN n s))
(current-thread s)))
;----------------------------------------------------------------------
;----------------------------------------------------------------------
;
; About popFrame
(defthm popFrame-opstack-primitves
(and (implies (and (current-thread-exists? s)
(wff-state-regular s)
(unique-id-thread-table (thread-table s))
(wff-thread-table-regular (thread-table s)))
(equal (popFrame (popStack s))
(popFrame s)))
(implies (and (current-thread-exists? s)
(unique-id-thread-table (thread-table s))
(wff-thread-table-regular (thread-table s))
(wff-state-regular s))
(equal (popFrame (pushStack v s))
(popFrame s)))
(implies (and (current-thread-exists? s)
(unique-id-thread-table (thread-table s))
(wff-thread-table-regular (thread-table s))
(wff-state-regular s))
(equal (popFrame (state-set-pc pc s))
(popFrame s)))
(implies (and (current-thread-exists? s)
(unique-id-thread-table (thread-table s))
(wff-thread-table-regular (thread-table s))
(wff-state-regular s))
(equal (popFrame (state-set-local-at i v s))
(popFrame s))))
:hints (("Goal" :in-theory (enable popFrame current-thread-exists?
state-set-local-at thread-exists?
popStack pushStack state-set-pc))))
;
; Interaction between popFrame and opStack
;
;----------------------------------------------------------------------
(defthm bind-wff-thread-regular-implies
(implies (and (thread-by-id id tt)
(wff-thread-table-regular tt))
(wff-thread-regular (thread-by-id id tt))))
(defthm wff-thread-regular-make-thread-equal
(implies (wff-thread-regular (thread-by-id (current-thread s)
(thread-table s)))
(equal (MAKE-THREAD (CURRENT-THREAD S)
(THREAD-SAVED-PC (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE S)))
(THREAD-CALL-STACK (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE S)))
(THREAD-STATE (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE S)))
(THREAD-MREF (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE S)))
(THREAD-MDEPTH (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE S)))
(THREAD-REF (THREAD-BY-ID (CURRENT-THREAD S)
(THREAD-TABLE s))))
(thread-by-id (current-thread s) (thread-table s)))))
(defthm state-set-pc-state-set-thread-table-normalize
(equal (state-set-thread-table th (state-set-pc pc s))
(state-set-pc pc (state-set-thread-table th s)))
:hints (("Goal" :in-theory (enable state-set-thread-table state-set-pc))))
(defthm state-set-thread-table-set-thread-table-normalize
(equal (state-set-thread-table th1 (state-set-thread-table th2 s))
(state-set-thread-table th1 s))
:hints (("Goal" :in-theory (enable state-set-thread-table))))
;; (defthm thread-primitives-state-set-pc
;; (and (equal (popStack (state-set-pc npc s))
;; (state-set-pc npc (popStack s)))
;; (equal (pushStack v (state-set-pc npc s))
;; (state-set-pc npc (pushStack v s)))
;; (equal (state-set-local-at i v (state-set-pc npc s))
;; (state-set-pc npc (state-set-local-at i v s))))
;; :hints (("Goal" :in-theory (enable state-set-pc popStack pushStack
;; state-set-local-at
;; state-set-thread-table))))
(defthm popStackN-state-set-pc-normalize
(equal (popStackN n (state-set-pc pc s))
(state-set-pc pc (popStackN n s))))
(defthm wff-state-regular-state-set-thread-table
(implies (wff-state-regular s)
(equal (state-set-thread-table (thread-table s) s)
s))
:hints (("Goal" :in-theory (enable wff-state-regular state-set-thread-table))))
(defthm popFrame-pushFrame0-is
(implies (and (current-thread-exists? s)
(wff-state-regular s)
(wff-thread-table-regular (thread-table s))
(unique-id-thread-table (thread-table s)))
(equal (popFrame (pushFrame0 frame s))
(state-set-pc (return-pc frame) s)))
:hints (("Goal" :in-theory (enable popFrame pushFrame0 current-thread-exists?
thread-exists?))))
(in-theory (disable popFrame pushFrame0))
;----------------------------------------------------------------------
(defthm second-is-correct
(implies (and (poised-for-execute-fact s)
(wff-state-regular s)
(wff-thread-table-regular (thread-table s))
(no-fatal-error? s)
(integerp n)
(<= 0 n)
(intp n)
(equal n (topStack s)))
(equal (simple-run s (fact-clock n))
(state-set-pc (+ 3 (pc s))
(pushStack (int-fix (fact n))
(popStack s)))))
:hints (("Goal" :do-not '(generalize fertilize)
:induct (fact-induct n s))))
|