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
|
;; Copyright (C) 2017, Regents of the University of Texas
;; Written by Cuong Chau
;; License: A 3-clause BSD license. See the LICENSE file distributed with
;; ACL2.
;; Cuong Chau <ckcuong@cs.utexas.edu>
;; May 2019
(in-package "ADE")
(include-book "comp-gcd")
(include-book "../fifo/queue10")
(local (include-book "arithmetic-3/top" :dir :system))
(local (in-theory (disable nth)))
;; ======================================================================
;;; Table of Contents:
;;;
;;; 1. DE Module Generator of Q10-COMP-GCD
;;; 2. Multi-Step State Lemma
;;; 3. Single-Step-Update Property
;;; 4. Relationship Between the Input and Output Sequences
;; ======================================================================
;; 1. DE Module Generator of Q10-COMP-GCD
;;
;; Construct a DE module generator that concatenates Q10 with COMP-GCD via a
;; link. Prove the value and state lemmas for this module generator.
(defconst *q10-comp-gcd$go-num* (+ *queue10$go-num*
*comp-gcd$go-num*))
(defun q10-comp-gcd$data-ins-len (data-size)
(declare (xargs :guard (natp data-size)))
(+ 2 (* 2 (mbe :logic (nfix data-size)
:exec data-size))))
(defun q10-comp-gcd$ins-len (data-size)
(declare (xargs :guard (natp data-size)))
(+ (q10-comp-gcd$data-ins-len data-size)
*q10-comp-gcd$go-num*))
;; DE module generator of Q10-COMP-GCD
(module-generator
q10-comp-gcd* (data-size)
(si 'q10-comp-gcd data-size)
(list* 'full-in 'empty-out- (append (sis 'data-in 0 (* 2 data-size))
(sis 'go 0 *q10-comp-gcd$go-num*)))
(list* 'in-act 'out-act
(sis 'data-out 0 data-size))
'(l q10 comp-gcd)
(list
;; LINK
;; L
(list 'l
(list* 'l-status (sis 'd-out 0 (* 2 data-size)))
(si 'link (* 2 data-size))
(list* 'q10-out-act 'comp-gcd-in-act
(sis 'q10-data-out 0 (* 2 data-size))))
;; JOINTS
;; Q10
(list 'q10
(list* 'in-act 'q10-out-act
(sis 'q10-data-out 0 (* 2 data-size)))
(si 'queue10 (* 2 data-size))
(list* 'full-in 'l-status
(append (sis 'data-in 0 (* 2 data-size))
(sis 'go 0 *queue10$go-num*))))
;; COMP-GCD
(list 'comp-gcd
(list* 'comp-gcd-in-act 'out-act
(sis 'data-out 0 data-size))
(si 'comp-gcd data-size)
(list* 'l-status 'empty-out-
(append (sis 'd-out 0 (* 2 data-size))
(sis 'go
*queue10$go-num*
*comp-gcd$go-num*)))))
(declare (xargs :guard (natp data-size))))
(make-event
`(progn
,@(state-accessors-gen 'q10-comp-gcd '(l q10 comp-gcd) 0)))
;; DE netlist generator. A generated netlist will contain an instance of
;; Q10-COMP-GCD.
(defund q10-comp-gcd$netlist (data-size)
(declare (xargs :guard (and (natp data-size)
(<= 2 data-size))))
(cons (q10-comp-gcd* data-size)
(union$ (queue10$netlist (* 2 data-size))
(comp-gcd$netlist data-size)
:test 'equal)))
;; Recognizer for Q10-COMP-GCD
(defund q10-comp-gcd& (netlist data-size)
(declare (xargs :guard (and (alistp netlist)
(natp data-size)
(<= 2 data-size))))
(b* ((subnetlist (delete-to-eq (si 'q10-comp-gcd data-size)
netlist)))
(and (equal (assoc (si 'q10-comp-gcd data-size) netlist)
(q10-comp-gcd* data-size))
(link& subnetlist (* 2 data-size))
(queue10& subnetlist (* 2 data-size))
(comp-gcd& subnetlist data-size))))
;; Sanity check
(local
(defthmd check-q10-comp-gcd$netlist-64
(and (net-syntax-okp (q10-comp-gcd$netlist 64))
(net-arity-okp (q10-comp-gcd$netlist 64))
(q10-comp-gcd& (q10-comp-gcd$netlist 64) 64))))
;; Constraints on the state of Q10-COMP-GCD
(defund q10-comp-gcd$st-format (st data-size)
(b* ((l (nth *q10-comp-gcd$l* st))
(q10 (nth *q10-comp-gcd$q10* st))
(comp-gcd (nth *q10-comp-gcd$comp-gcd* st)))
(and (link$st-format l (* 2 data-size))
(queue10$st-format q10 (* 2 data-size))
(comp-gcd$st-format comp-gcd data-size))))
(defthm q10-comp-gcd$st-format=>constraint
(implies (q10-comp-gcd$st-format st data-size)
(and (natp data-size)
(<= 3 data-size)))
:hints (("Goal"
:in-theory (enable q10-comp-gcd$st-format)))
:rule-classes :forward-chaining)
(defund q10-comp-gcd$valid-st (st data-size)
(b* ((l (nth *q10-comp-gcd$l* st))
(q10 (nth *q10-comp-gcd$q10* st))
(comp-gcd (nth *q10-comp-gcd$comp-gcd* st)))
(and (link$valid-st l (* 2 data-size))
(queue10$valid-st q10 (* 2 data-size))
(comp-gcd$valid-st comp-gcd data-size))))
(defthmd q10-comp-gcd$valid-st=>constraint
(implies (q10-comp-gcd$valid-st st data-size)
(and (natp data-size)
(<= 3 data-size)))
:hints (("Goal"
:in-theory (enable comp-gcd$valid-st=>constraint
q10-comp-gcd$valid-st)))
:rule-classes :forward-chaining)
(defthmd q10-comp-gcd$valid-st=>st-format
(implies (q10-comp-gcd$valid-st st data-size)
(q10-comp-gcd$st-format st data-size))
:hints (("Goal" :in-theory (e/d (queue10$valid-st=>st-format
comp-gcd$valid-st=>st-format
q10-comp-gcd$st-format
q10-comp-gcd$valid-st)
(link$st-format)))))
;; Extract the input and output signals for Q10-COMP-GCD
(progn
;; Extract the input data
(defun q10-comp-gcd$data-in (inputs data-size)
(declare (xargs :guard (and (true-listp inputs)
(natp data-size))))
(take (* 2 (mbe :logic (nfix data-size)
:exec data-size))
(nthcdr 2 inputs)))
(defthm len-q10-comp-gcd$data-in
(equal (len (q10-comp-gcd$data-in inputs data-size))
(* 2 (nfix data-size))))
(in-theory (disable q10-comp-gcd$data-in))
;; Extract the inputs for the Q10 joint
(defund q10-comp-gcd$q10-inputs (inputs st data-size)
(b* ((full-in (nth 0 inputs))
(data-in (q10-comp-gcd$data-in inputs data-size))
(go-signals (nthcdr (q10-comp-gcd$data-ins-len data-size)
inputs))
(q10-go-signals (take *queue10$go-num* go-signals))
(l (nth *q10-comp-gcd$l* st))
(l.s (nth *link$s* l)))
(list* full-in (f-buf (car l.s))
(append data-in q10-go-signals))))
;; Extract the inputs for the COMP-GCD joint
(defund q10-comp-gcd$comp-gcd-inputs (inputs st data-size)
(b* ((empty-out- (nth 1 inputs))
(go-signals (nthcdr (q10-comp-gcd$data-ins-len data-size)
inputs))
(comp-gcd-go-signals (take *comp-gcd$go-num*
(nthcdr *queue10$go-num* go-signals)))
(l (nth *q10-comp-gcd$l* st))
(l.s (nth *link$s* l))
(l.d (nth *link$d* l)))
(list* (f-buf (car l.s)) empty-out-
(append (v-threefix (strip-cars l.d))
comp-gcd-go-signals))))
;; Extract the "in-act" signal
(defund q10-comp-gcd$in-act (inputs st data-size)
(queue10$in-act (q10-comp-gcd$q10-inputs inputs st data-size)
(nth *q10-comp-gcd$q10* st)
(* 2 data-size)))
(defthm q10-comp-gcd$in-act-inactive
(implies (not (nth 0 inputs))
(not (q10-comp-gcd$in-act inputs st data-size)))
:hints (("Goal" :in-theory (enable q10-comp-gcd$q10-inputs
q10-comp-gcd$in-act))))
;; Extract the "out-act" signal
(defund q10-comp-gcd$out-act (inputs st data-size)
(comp-gcd$out-act (q10-comp-gcd$comp-gcd-inputs inputs st data-size)
(nth *q10-comp-gcd$comp-gcd* st)
data-size))
(defthm q10-comp-gcd$out-act-inactive
(implies (equal (nth 1 inputs) t)
(not (q10-comp-gcd$out-act inputs st data-size)))
:hints (("Goal" :in-theory (enable q10-comp-gcd$comp-gcd-inputs
q10-comp-gcd$out-act))))
;; Extract the output data
(defund q10-comp-gcd$data-out (inputs st data-size)
(comp-gcd$data-out (q10-comp-gcd$comp-gcd-inputs inputs st data-size)
(nth *q10-comp-gcd$comp-gcd* st)
data-size))
(defthm len-q10-comp-gcd$data-out-1
(implies (q10-comp-gcd$st-format st data-size)
(equal (len (q10-comp-gcd$data-out inputs st data-size))
data-size))
:hints (("Goal" :in-theory (enable q10-comp-gcd$st-format
q10-comp-gcd$data-out))))
(defthm len-q10-comp-gcd$data-out-2
(implies (q10-comp-gcd$valid-st st data-size)
(equal (len (q10-comp-gcd$data-out inputs st data-size))
data-size))
:hints (("Goal" :in-theory (enable q10-comp-gcd$valid-st
q10-comp-gcd$data-out))))
(defthm bvp-q10-comp-gcd$data-out
(implies (and (q10-comp-gcd$valid-st st data-size)
(q10-comp-gcd$out-act inputs st data-size))
(bvp (q10-comp-gcd$data-out inputs st data-size)))
:hints (("Goal" :in-theory (enable q10-comp-gcd$valid-st
q10-comp-gcd$out-act
q10-comp-gcd$data-out))))
(defun q10-comp-gcd$outputs (inputs st data-size)
(list* (q10-comp-gcd$in-act inputs st data-size)
(q10-comp-gcd$out-act inputs st data-size)
(q10-comp-gcd$data-out inputs st data-size)))
)
;; The value lemma for Q10-COMP-GCD
(defthm q10-comp-gcd$value
(b* ((inputs (list* full-in empty-out- (append data-in go-signals))))
(implies
(and (q10-comp-gcd& netlist data-size)
(true-listp data-in)
(equal (len data-in) (* 2 data-size))
(true-listp go-signals)
(equal (len go-signals) *q10-comp-gcd$go-num*)
(q10-comp-gcd$st-format st data-size))
(equal (se (si 'q10-comp-gcd data-size) inputs st netlist)
(q10-comp-gcd$outputs inputs st data-size))))
:hints (("Goal"
:do-not-induct t
:expand (:free (inputs data-size)
(se (si 'q10-comp-gcd data-size)
inputs st netlist))
:in-theory (e/d (de-rules
q10-comp-gcd&
q10-comp-gcd*$destructure
q10-comp-gcd$data-in
q10-comp-gcd$st-format
q10-comp-gcd$in-act
q10-comp-gcd$out-act
q10-comp-gcd$data-out
q10-comp-gcd$q10-inputs
q10-comp-gcd$comp-gcd-inputs)
(de-module-disabled-rules)))))
;; This function specifies the next state of Q10-COMP-GCD.
(defun q10-comp-gcd$step (inputs st data-size)
(b* ((l (nth *q10-comp-gcd$l* st))
(q10 (nth *q10-comp-gcd$q10* st))
(comp-gcd (nth *q10-comp-gcd$comp-gcd* st))
(q10-inputs (q10-comp-gcd$q10-inputs inputs st data-size))
(comp-gcd-inputs (q10-comp-gcd$comp-gcd-inputs
inputs st data-size))
(d-in (queue10$data-out q10))
(q10-out-act (queue10$out-act q10-inputs q10 (* 2 data-size)))
(comp-gcd-in-act (comp-gcd$in-act comp-gcd-inputs
comp-gcd data-size))
(l-inputs (list* q10-out-act comp-gcd-in-act d-in)))
(list
;; L
(link$step l-inputs l (* 2 data-size))
;; Joint Q10
(queue10$step q10-inputs q10 (* 2 data-size))
;; Joint COMP-GCD
(comp-gcd$step comp-gcd-inputs comp-gcd data-size))))
;; The state lemma for Q10-COMP-GCD
(defthm q10-comp-gcd$state
(b* ((inputs (list* full-in empty-out- (append data-in go-signals))))
(implies
(and (q10-comp-gcd& netlist data-size)
(true-listp data-in)
(equal (len data-in) (* 2 data-size))
(true-listp go-signals)
(equal (len go-signals) *q10-comp-gcd$go-num*)
(q10-comp-gcd$st-format st data-size))
(equal (de (si 'q10-comp-gcd data-size) inputs st netlist)
(q10-comp-gcd$step inputs st data-size))))
:hints (("Goal"
:do-not-induct t
:expand (:free (inputs data-size)
(de (si 'q10-comp-gcd data-size)
inputs st netlist))
:in-theory (e/d (de-rules
q10-comp-gcd&
q10-comp-gcd*$destructure
q10-comp-gcd$st-format
q10-comp-gcd$data-in
q10-comp-gcd$data-out
q10-comp-gcd$q10-inputs
q10-comp-gcd$comp-gcd-inputs)
(de-module-disabled-rules)))))
(in-theory (disable q10-comp-gcd$step))
;; ======================================================================
;; 2. Multi-Step State Lemma
;; Conditions on the inputs
(defund q10-comp-gcd$input-format (inputs data-size)
(declare (xargs :guard (and (true-listp inputs)
(natp data-size))))
(b* ((full-in (nth 0 inputs))
(empty-out- (nth 1 inputs))
(data-in (q10-comp-gcd$data-in inputs data-size))
(go-signals (nthcdr (q10-comp-gcd$data-ins-len data-size)
inputs)))
(and
(booleanp full-in)
(booleanp empty-out-)
(or (not full-in) (bvp data-in))
(true-listp go-signals)
(= (len go-signals) *q10-comp-gcd$go-num*)
(equal inputs
(list* full-in empty-out- (append data-in go-signals))))))
(local
(defthm q10-comp-gcd$input-format=>q10$input-format
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size))
(queue10$input-format
(q10-comp-gcd$q10-inputs inputs st data-size)
(* 2 data-size)))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$input-format
comp-gcd$valid-st=>constraint
queue10$input-format
queue10$data-in
q10-comp-gcd$valid-st
q10-comp-gcd$q10-inputs)
())))))
(local
(defthm q10-comp-gcd$input-format=>comp-gcd$input-format
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size))
(comp-gcd$input-format
(q10-comp-gcd$comp-gcd-inputs inputs st data-size)
data-size))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$input-format
comp-gcd$valid-st=>constraint
comp-gcd$input-format
comp-gcd$data-in
q10-comp-gcd$valid-st
q10-comp-gcd$st-format
q10-comp-gcd$comp-gcd-inputs)
())))))
(defthm booleanp-q10-comp-gcd$in-act
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size))
(booleanp (q10-comp-gcd$in-act inputs st data-size)))
:hints (("Goal"
:in-theory (enable q10-comp-gcd$valid-st
q10-comp-gcd$in-act)))
:rule-classes (:rewrite :type-prescription))
(defthm booleanp-q10-comp-gcd$out-act
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size))
(booleanp (q10-comp-gcd$out-act inputs st data-size)))
:hints (("Goal"
:in-theory (enable q10-comp-gcd$valid-st
q10-comp-gcd$out-act)))
:rule-classes (:rewrite :type-prescription))
(simulate-lemma q10-comp-gcd)
;; ======================================================================
;; 3. Single-Step-Update Property
;; The extraction function for Q10-COMP-GCD that extracts the future output
;; sequence from the current state.
(defund q10-comp-gcd$extract (st)
(b* ((l (nth *q10-comp-gcd$l* st))
(q10 (nth *q10-comp-gcd$q10* st))
(comp-gcd (nth *q10-comp-gcd$comp-gcd* st)))
(append
(gcd$op-map
(append (queue10$extract q10)
(extract-valid-data (list l))))
(comp-gcd$extract comp-gcd))))
(defthm q10-comp-gcd$extract-not-empty
(implies (and (q10-comp-gcd$out-act inputs st data-size)
(q10-comp-gcd$valid-st st data-size))
(< 0 (len (q10-comp-gcd$extract st))))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$valid-st
q10-comp-gcd$extract
q10-comp-gcd$out-act)
())))
:rule-classes :linear)
;; Specify and prove a state invariant
(progn
(defund q10-comp-gcd$inv (st)
(b* ((comp-gcd (nth *q10-comp-gcd$comp-gcd* st)))
(comp-gcd$inv comp-gcd)))
(defthm q10-comp-gcd$inv-preserved
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size)
(q10-comp-gcd$inv st))
(q10-comp-gcd$inv
(q10-comp-gcd$step inputs st data-size)))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$valid-st
q10-comp-gcd$inv
q10-comp-gcd$step)
()))))
)
;; The extracted next-state function for Q10-COMP-GCD. Note that this
;; function avoids exploring the internal computation of Q10-COMP-GCD.
(defund q10-comp-gcd$extracted-step (inputs st data-size)
(b* ((data (gcd$op (q10-comp-gcd$data-in inputs data-size)))
(extracted-st (q10-comp-gcd$extract st))
(n (1- (len extracted-st))))
(cond
((equal (q10-comp-gcd$out-act inputs st data-size) t)
(cond
((equal (q10-comp-gcd$in-act inputs st data-size) t)
(cons data (take n extracted-st)))
(t (take n extracted-st))))
(t (cond
((equal (q10-comp-gcd$in-act inputs st data-size) t)
(cons data extracted-st))
(t extracted-st))))))
;; The single-step-update property
(progn
(local
(defthm q10-comp-gcd$q10-out-act-inactive
(implies (equal (nth *link$s*
(nth *q10-comp-gcd$l* st))
'(t))
(not (queue10$out-act
(q10-comp-gcd$q10-inputs inputs st data-size)
(nth *q10-comp-gcd$q10* st)
(* 2 data-size))))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$q10-inputs)
())))))
(local
(defthm q10-comp-gcd$comp-gcd-in-act-inactive
(implies (equal (nth *link$s*
(nth *q10-comp-gcd$l* st))
'(nil))
(not (comp-gcd$in-act
(q10-comp-gcd$comp-gcd-inputs inputs st data-size)
(nth *q10-comp-gcd$comp-gcd* st)
data-size)))
:hints (("Goal"
:in-theory (e/d (q10-comp-gcd$comp-gcd-inputs)
())))))
(local
(defthm q10-comp-gcd-aux-1
(b* ((q10-inputs (q10-comp-gcd$q10-inputs inputs st data-size)))
(implies (natp data-size)
(equal (queue10$data-in q10-inputs (* 2 data-size))
(take (* 2 data-size)
(nthcdr 2 inputs)))))
:hints (("Goal" :in-theory (enable q10-comp-gcd$q10-inputs
q10-comp-gcd$data-in
queue10$data-in)))))
(local
(defthm q10-comp-gcd-aux-2
(b* ((comp-gcd-inputs (q10-comp-gcd$comp-gcd-inputs
inputs st data-size))
(l (nth *q10-comp-gcd$l* st))
(l.d (nth *link$d* l)))
(implies (and (natp data-size)
(equal (len l.d) (* 2 data-size))
(bvp (strip-cars l.d)))
(equal (comp-gcd$data-in comp-gcd-inputs data-size)
(strip-cars l.d))))
:hints (("Goal" :in-theory (enable q10-comp-gcd$comp-gcd-inputs
comp-gcd$data-in)))))
(local
(defthm gcd$op-map-of-append-instance
(equal (gcd$op-map (append x (list (strip-cars d))))
(append (gcd$op-map x)
(gcd$op-map (list (strip-cars d)))))))
(defthm q10-comp-gcd$extracted-step-correct
(b* ((next-st (q10-comp-gcd$step inputs st data-size)))
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size)
(q10-comp-gcd$inv st))
(equal (q10-comp-gcd$extract next-st)
(q10-comp-gcd$extracted-step inputs st data-size))))
:hints
(("Goal"
:use (q10-comp-gcd$input-format=>q10$input-format
q10-comp-gcd$input-format=>comp-gcd$input-format)
:in-theory (e/d (f-sr
comp-gcd$valid-st=>constraint
queue10$extracted-step
comp-gcd$extracted-step
q10-comp-gcd$extracted-step
q10-comp-gcd$valid-st
q10-comp-gcd$inv
q10-comp-gcd$step
q10-comp-gcd$data-in
q10-comp-gcd$in-act
q10-comp-gcd$out-act
q10-comp-gcd$data-out
q10-comp-gcd$extract)
(q10-comp-gcd$input-format=>q10$input-format
q10-comp-gcd$input-format=>comp-gcd$input-format
gcd$op-map-of-append
nfix)))))
)
;; ======================================================================
;; 4. Relationship Between the Input and Output Sequences
;; Prove that q10-comp-gcd$valid-st is an invariant.
(defthm q10-comp-gcd$valid-st-preserved
(implies (and (q10-comp-gcd$input-format inputs data-size)
(q10-comp-gcd$valid-st st data-size))
(q10-comp-gcd$valid-st
(q10-comp-gcd$step inputs st data-size)
data-size))
:hints
(("Goal"
:use (q10-comp-gcd$input-format=>q10$input-format
q10-comp-gcd$input-format=>comp-gcd$input-format)
:in-theory (e/d (f-sr
q10-comp-gcd$valid-st
q10-comp-gcd$step)
(q10-comp-gcd$input-format=>q10$input-format
q10-comp-gcd$input-format=>comp-gcd$input-format)))))
(defthm q10-comp-gcd$extract-lemma
(implies (and (q10-comp-gcd$valid-st st data-size)
(q10-comp-gcd$inv st)
(q10-comp-gcd$out-act inputs st data-size))
(equal (list (q10-comp-gcd$data-out inputs st data-size))
(nthcdr (1- (len (q10-comp-gcd$extract st)))
(q10-comp-gcd$extract st))))
:hints (("Goal"
:do-not-induct t
:in-theory (e/d (q10-comp-gcd$valid-st
q10-comp-gcd$inv
q10-comp-gcd$extract
q10-comp-gcd$out-act
q10-comp-gcd$data-out)
()))))
;; Extract the accepted input sequence
(seq-gen q10-comp-gcd in in-act 0
(q10-comp-gcd$data-in inputs data-size))
;; Extract the valid output sequence
(seq-gen q10-comp-gcd out out-act 1
(q10-comp-gcd$data-out inputs st data-size)
:netlist-data (nthcdr 2 outputs))
;; The multi-step input-output relationship
(in-out-stream-lemma q10-comp-gcd :op gcd$op :inv t)
|