1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3
;;; Section 4: Definition of m-correspondence
5
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
8
;;; Definition of mapping-induced correspondence:
10
;;; In order for a Gem memory and and Rtm memory to be m-correspondent via m,
11
;;; the following conditions must hold:
13
;;; - Correctness w.r.t. the types of the variables appearing into the memories:
14
;;; I.e., m must map boolean Gem variables into single Rtm variables, and integer Gem
15
;;; variables into tuples of |*rns*| Rtm variables;
17
;;; - Correctness w.r.t. the values and attributes of the variables appearing into the memories:
18
;;; for each entry of the mapping,
19
;;; the values obtained by direct application of rns to the gem variable of the entry must
20
;;; match those of the rtm variables, and
21
;;; the attributes of the rtm variables must match that of the rtm variable.
23
;;; - A mapping must have every Gem variable within the range of the Gem memory it references
25
;;; - A mapping must contain every variable of the Gem memory it references
28
;;; Similar properties to the least two will be needed for the Rtm memories (e.g., every Rtm
29
;;; variable should be in the range of the Rtm memory), when proving properties about
30
;;; programs. We will insert them then.
37
(include-book "CRTcorollaries")
39
(in-theory (current-theory 'ground-zero))
41
(include-book "Mapping")
47
;;; Memories must be correspondent via m in terms of types
52
(defun correct-wrt-arity (m gem-typed-mem)
56
(correct-type (type-0 m))
59
(var-type (get-cell (gemvar-0 m) gem-typed-mem)))
60
(correct-wrt-arity (cdr m) gem-typed-mem))))
62
(defthm correct-arity-all-i-need
66
(correct-wrt-arity m gem-typed-mem))
68
(correct-type (type-0 m))
71
(var-type (get-cell (gemvar-0 m) gem-typed-mem)))
72
(not (null (var-attributes (rtmintvars-0 m) rtm-typed-mem)))
73
(correct-wrt-arity (cdr m) gem-typed-mem))))
80
;; Every entry of the mapping must point to a coherent set of rtm variables, i.e. to a set of of rtm
81
;; variables which share the same attribute.
84
(defun get-common-value (l)
85
(if (equal-elements (car l) (cdr l))
89
(defthm if-every-element-matches-val-then-get-common-value-amounts-to-val
95
(equal (get-common-value l) v)))
97
(in-theory (disable if-every-element-matches-val-then-get-common-value-amounts-to-val))
100
(defun m-entries-point-to-good-rtm-var-sets (m rtm-typed-mem)
104
(not (endp (rtmintvars-0 m)))
105
(true-listp (rtmintvars-0 m))
106
(not (equal 'error-value (get-common-value (var-attributes (rtmintvars-0 m) rtm-typed-mem))))
107
(m-entries-point-to-good-rtm-var-sets (cdr m) rtm-typed-mem))))
109
(in-theory (disable m-entries-point-to-good-rtm-var-sets))
116
;;; Values and attributes must be correspondent via the mapping.
118
;;; In order to allow this definition, we first provide
119
;;; definitions of transformations of gem values into tuples of rtm values (by *rns*) and
120
;;; viceversa (by inverse application of *rns*).
122
;;; Notice that these transformations are actually just ``stubs'', since we provide a
123
;;; simplified form of axiomatization of the chinese remainder inversion theorem.
124
;;; Additional hypothesis (e.g., boundedness of Gem and Rtm integers, and relations between such
125
;;; bounds) shall (and will) be added and taken into account when proving properties of programs.
126
;;; In the cureent state of the proof, however, we can limit ourselves to consider 'generic'
127
;;; transformations of Gem vars into tuples of Rtm vars, and their corresponding generic inverse.
129
;;; However, since memories could contain nil cells, we have to lift our transformations, and
130
;;; the 'simplified axiomatization of CRT', to deal with nils.
132
;;; We extend transformations so that nils transform into sequences of nils and viceversa.
133
;;; We lift the simplified CRT axiomatization to such extended version.
140
(defun make-null-list (l)
143
(cons nil (make-null-list (cdr l)))))
145
(defthm make-null-list-is-invariant-on-value-slicing (equal (make-null-list rtmvars) (make-null-list (var-values rtmvars rm))))
147
(in-theory (disable make-null-list-is-invariant-on-value-slicing))
149
(defun equal-values (val-list-1 val-list-2)
150
(equal val-list-1 val-list-2))
152
(defun build-values-by-rns (gem-value rns)
155
(cons (mod gem-value (car rns))
156
(build-values-by-rns gem-value (cdr rns)))))
158
(in-theory (enable build-values-by-rns))
160
(defun mod-extended-for-nil (val1 val2)
165
(defun build-values-by-rns-extended-for-nil (gem-value rns)
168
(cons (mod-extended-for-nil gem-value (car rns))
169
(build-values-by-rns-extended-for-nil gem-value (cdr rns)))))
171
(defthm build-values-by-rns-extended-behaves-standardly-on-non-nils
173
(not (null gem-value))
175
(build-values-by-rns-extended-for-nil gem-value rns)
176
(build-values-by-rns gem-value rns))))
178
(defthm build-values-by-rns-extended-for-nils-provides-integers-from-integer
185
(not (null (build-values-by-rns-extended-for-nil val rns)))
186
(integer-listp (build-values-by-rns-extended-for-nil val rns)))))
191
(defun build-value-by-inverse-rns (rtm-values rns)
192
(crtmod rtm-values rns))
195
(defun build-value-by-inverse-rns-extended-for-nil (rtm-values rns)
197
(integer-listp rtm-values)
198
(crtmod rtm-values rns)
202
(defthm build-value-by-inverse-rns-extended-for-nils-behaves-standardly-on-integer-lists
204
(integer-listp rtm-values)
206
(build-value-by-inverse-rns-extended-for-nil rtm-values rns)
207
(build-value-by-inverse-rns rtm-values rns))))
212
(defthm crt-inversion-inst
215
(rel-prime-moduli rns)
217
(< gem-value (prod rns)))
219
(build-value-by-inverse-rns (build-values-by-rns gem-value rns) rns)
221
:hints (("Goal" :in-theory (enable crt-inversion))))
224
(in-theory (enable natp))
227
(defthm crt-inversion-extended-to-nils-in-integer-case
230
(rel-prime-moduli rns)
231
(< gem-value (prod rns))
236
(build-value-by-inverse-rns-extended-for-nil (build-values-by-rns-extended-for-nil gem-value rns) rns)
241
build-values-by-rns-extended-behaves-standardly-on-non-nils
242
(:instance build-value-by-inverse-rns-extended-for-nils-behaves-standardly-on-integer-lists
243
(rtm-values (build-values-by-rns gem-value rns)))
244
(:instance build-values-by-rns-extended-for-nils-provides-integers-from-integer
247
(defthm crt-inversion-extended-to-nils-in-nil-case
250
(rel-prime-moduli rns)
255
(build-value-by-inverse-rns-extended-for-nil (build-values-by-rns-extended-for-nil gem-value rns) rns)
258
(defthm crt-inversion-extended-to-nils
261
(rel-prime-moduli rns)
268
(< gem-value (prod rns)))))
270
(build-value-by-inverse-rns-extended-for-nil (build-values-by-rns-extended-for-nil gem-value rns) rns)
274
(and (not (null gem-value)) (not (and (natp gem-value) (< gem-value (prod rns)))))
276
(and (natp gem-value) (< gem-value (prod rns)))))
277
("Subgoal 2" :use crt-inversion-extended-to-nils-in-nil-case)
278
("subgoal 1" :use (:instance crt-inversion-extended-to-nils-in-integer-case))))
281
(in-theory (disable build-values-by-rns-extended-for-nil
283
build-value-by-inverse-rns-extended-for-nil
284
build-value-by-inverse-rns
285
build-values-by-rns-extended-behaves-standardly-on-non-nils
286
build-values-by-rns-extended-for-nils-provides-integers-from-integer
287
build-value-by-inverse-rns-extended-for-nils-behaves-standardly-on-integer-lists
288
crt-inversion-extended-to-nils-in-integer-case
289
crt-inversion-extended-to-nils-in-nil-case))
298
;; m-correspondence definition w.r.t. values and attributes of memories
304
(defun apply-direct-rns-to-value-according-to-type (gem-cell type)
307
(list (var-value gem-cell)))
309
(build-values-by-rns-extended-for-nil (var-value gem-cell) *rns*))
314
(defun apply-invers-rns-to-values-according-to-type (vals type)
319
(build-value-by-inverse-rns-extended-for-nil vals *rns*))
325
(defun invert-cell (rtmvars rtm-typed-mem type)
328
(var-values rtmvars rtm-typed-mem)
329
(make-null-list rtmvars))
330
(apply-invers-rns-to-values-according-to-type
331
(var-values rtmvars rtm-typed-mem)
334
(apply-invers-rns-to-values-according-to-type
335
(var-values rtmvars rtm-typed-mem)
337
(get-common-value (var-attributes rtmvars rtm-typed-mem))
340
(defun equal-values-and-attributes (gem-cell rtmvars rtm-typed-mem type)
343
(var-values rtmvars rtm-typed-mem)
344
(apply-direct-rns-to-value-according-to-type gem-cell type))
346
(var-attribute gem-cell)
347
(var-attributes rtmvars rtm-typed-mem))))
351
(defthm apply-direct-rns-unfolding-for-integer-case
355
(apply-direct-rns-to-value-according-to-type gem-cell type)
356
(build-values-by-rns-extended-for-nil (var-value gem-cell) *rns*))))
358
(defthm apply-direct-rns-unfolding-for-boolean-case
362
(apply-direct-rns-to-value-according-to-type gem-cell type)
363
(list (var-value gem-cell)))))
367
(defthm apply-inverse-rns-unfolding-for-integer-case
370
(equal (apply-invers-rns-to-values-according-to-type values type)
371
(build-value-by-inverse-rns-extended-for-nil values *rns*))))
374
(defthm apply-inverse-direct-retrieves-same-value-for-typed-cells
377
(rel-prime-moduli *rns*)
378
(integer-listp *rns*)
385
(natp (var-value gem-cell))
386
(< (var-value gem-cell) (prod *rns*)))
387
(null (var-value gem-cell))))
389
(apply-invers-rns-to-values-according-to-type
390
(apply-direct-rns-to-value-according-to-type gem-cell type) type)
391
(var-value gem-cell)))
392
:hints (("goal" :cases ( (equal type 'bool)
395
:in-theory (disable null
396
apply-inverse-rns-unfolding-for-integer-case
397
crt-inversion-extended-to-nils
398
apply-direct-rns-unfolding-for-integer-case
399
apply-direct-rns-to-value-according-to-type
401
apply-invers-rns-to-values-according-to-type
402
build-value-by-inverse-rns-extended-for-nil
403
build-values-by-rns-extended-for-nil)
404
:use ((:instance apply-direct-rns-unfolding-for-integer-case)
405
(:instance apply-inverse-rns-unfolding-for-integer-case (values (build-values-by-rns-extended-for-nil (var-value gem-cell) *rns*)))
406
(:instance crt-inversion-extended-to-nils (rns *rns*) (gem-value (var-value gem-cell)))))))
411
(defthm inversion-for-empty-cell
415
(equal-values (var-values rtmvars rm) (apply-direct-rns-to-value-according-to-type cell type))
418
(equal-values (var-values rtmvars rm) (make-null-list rtmvars))
419
(equal (apply-invers-rns-to-values-according-to-type (var-values rtmvars rm) type) cell)))
421
:in-theory (enable make-null-list-is-invariant-on-value-slicing)
422
:cases ( (equal type 'bool) (equal type 'int)))))
425
(in-theory (disable make-cell))
428
(defthm ad-hoc-2-for-inversion-of-one-nonempty-cell-by-decode
430
(and (not (null bui)) (integer-listp bui))
431
(not (equal (make-null-list l) bui))))
434
(defthm ad-hoc-3-for-inversion-of-one-nonempty-cell-by-decode
436
(integerp (var-value cell))
437
(not (equal (make-null-list l) (build-values-by-rns-extended-for-nil (var-value cell) *rns*))))
438
:hints (("goal" :use ((:instance build-values-by-rns-extended-for-nils-provides-integers-from-integer
439
(val (var-value cell)) (rns *rns*))
440
(:instance ad-hoc-2-for-inversion-of-one-nonempty-cell-by-decode
442
(bui (build-values-by-rns-extended-for-nil (var-value cell) *rns*)))))))
444
(defthm nonempty-cell-is-not-mapped-into-nils-by-rns
447
(true-listp (var-attributes rtmvars rm))
448
(not (null (var-attributes rtmvars rm)))
451
(equal-values (var-values rtmvars rm) (apply-direct-rns-to-value-according-to-type cell type))
452
(equal-elements (var-attribute cell) (var-attributes rtmvars rm))
453
(equal type (var-type cell)))
454
(not (equal-values (var-values rtmvars rm) (make-null-list rtmvars))))
455
:hints (("goal" :cases ( (equal type 'bool) (equal type 'int)))))
459
(in-theory (disable my-or-2 my-or-3))
462
(IMPLIES (AND (TRUE-LISTP CELL6)
463
(EQUAL (+ 3 (LEN CELL6)) 3))
467
(defthm reconstruction-of-cell
476
:hints (("Subgoal 1.1" :use silly00)
477
("Subgoal 2.1" :use silly00)
480
(union-theories (current-theory 'ground-zero)
481
'((:definition is-mem-cell-p)
482
(:definition make-cell)
483
(:definition var-type)
484
(:definition var-value)
485
(:definition var-attribute)))))
490
(defthm nonempty-rtm-vars-which-correspond-to-gem-var-by-values-and-atributes-map-back-to-gem-var
493
(rel-prime-moduli *rns*)
494
(integer-listp *rns*)
496
(true-listp (var-attributes rtmvars rm))
497
(not (null (var-attributes rtmvars rm)))
500
(natp (var-value cell))
501
(< (var-value cell) (prod *rns*))
502
(equal-values (var-values rtmvars rm) (apply-direct-rns-to-value-according-to-type cell type))
503
(equal-elements (var-attribute cell) (var-attributes rtmvars rm))
504
(equal type (var-type cell)))
507
(apply-invers-rns-to-values-according-to-type (var-values rtmvars rm) type)
508
(get-common-value (var-attributes rtmvars rm))
511
:hints (("goal" :in-theory '((:definition my-or-2)
512
(:definition is-mem-cell-p)
514
(:definition equal-values)
515
(:definition is-mem-cell-p))
516
:use (reconstruction-of-cell
517
(:instance if-every-element-matches-val-then-get-common-value-amounts-to-val
518
(l (var-attributes rtmvars rm)) (v (var-attribute cell)))
519
(:instance apply-inverse-direct-retrieves-same-value-for-typed-cells
520
(type type) (gem-cell cell))))))
531
(defthm decode-inversion-for-nonempty-gem-cell
534
(rel-prime-moduli *rns*)
535
(integer-listp *rns*)
537
(true-listp (var-attributes rtmvars rm))
538
(not (null (var-attributes rtmvars rm)))
541
(natp (var-value cell))
542
(< (var-value cell) (prod *rns*))
543
(equal-values (var-values rtmvars rm) (apply-direct-rns-to-value-according-to-type cell type))
544
(equal-elements (var-attribute cell) (var-attributes rtmvars rm))
545
(equal type (var-type cell)))
547
(not (equal-values (var-values rtmvars rm) (make-null-list rtmvars)))
550
(apply-invers-rns-to-values-according-to-type (var-values rtmvars rm) type)
551
(get-common-value (var-attributes rtmvars rm))
554
:hints (("goal" :use (nonempty-cell-is-not-mapped-into-nils-by-rns
555
nonempty-rtm-vars-which-correspond-to-gem-var-by-values-and-atributes-map-back-to-gem-var))))
562
(defthm var-attributes-always-true-listp
563
(true-listp (var-attributes rtmvars rtm-typed-mem)))
565
(defun bounded-value (cell)
568
(and (natp (var-value cell)) (< (var-value cell) (prod *rns*)))))
570
(defthm invert-cell-inverts-for-m-correspondents
573
(rel-prime-moduli *rns*)
574
(integer-listp *rns*)
576
(not (null (var-attributes rtmvars rtm-typed-mem)))
577
(equal type (var-type gem-cell))
579
(or (null gem-cell) (is-mem-cell-p gem-cell))
580
(bounded-value gem-cell)
581
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
583
(invert-cell rtmvars rtm-typed-mem type)
586
:in-theory (disable equal-values)
587
:use ( var-attributes-always-true-listp
588
(:instance decode-inversion-for-nonempty-gem-cell
591
(:instance inversion-for-empty-cell
593
(rm rtm-typed-mem))))))
596
(defun is-typed-amem-p (mem)
601
(is-mem-cell-p (cdr (car mem)))
602
(is-typed-amem-p (cdr mem)))))
604
(in-theory (enable get-cell))
606
(defthm any-cell-of-a-typed-mem-is-nil-or-a-typed-cell
608
(is-typed-amem-p gem-typed-mem)
611
(null (assoc-equal v gem-typed-mem))
612
(null (get-cell v gem-typed-mem)))
613
(is-mem-cell-p (get-cell v gem-typed-mem))))
623
(defun m-correspondent-values-p (m gem-typed-mem rtm-typed-mem)
629
(equal-values-and-attributes
630
(get-cell (gemvar-0 m) gem-typed-mem)
632
rtm-typed-mem (type-0 m))
633
(m-correspondent-values-p (cdr m) gem-typed-mem rtm-typed-mem)))))
635
(defun decode (m rtm-typed-mem)
641
(invert-cell (rtmintvars-0 m) rtm-typed-mem (type-0 m))
642
(decode (cdr m) rtm-typed-mem))))
646
(equal (caar m) (gemvar-0 m)))
648
(in-theory (disable silly1))
652
(correct-wrt-arity m gem-typed-mem)
653
(correct-wrt-arity (cdr m) gem-typed-mem)))
655
(in-theory (disable silly1 silly2))
657
(defun bounded-amem-p (mem)
661
(and (bounded-value (cdr (car mem)))
662
(bounded-amem-p (cdr mem)))))
664
(defthm any-cell-of-bounded-mem-is-bounded
666
(bounded-amem-p gem-typed-mem)
667
(bounded-value (get-cell v gem-typed-mem)))
670
(defthm decode-equals-retrieve-vars
673
(rel-prime-moduli *rns*)
674
(integer-listp *rns*)
676
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem)
677
(is-typed-amem-p gem-typed-mem)
678
(bounded-amem-p gem-typed-mem)
679
(correct-wrt-arity m gem-typed-mem))
681
(decode m rtm-typed-mem)
682
(retrieve-vars m gem-typed-mem)))
683
:hints (("Goal" :induct (len m))
689
(:instance retrieve-vars (vars m) (mem gem-typed-mem))
690
m-correspondent-values-p
691
(:instance any-cell-of-a-typed-mem-is-nil-or-a-typed-cell (v (gemvar-0 m)))
692
(:instance any-cell-of-bounded-mem-is-bounded (v (gemvar-0 m)))
693
correct-arity-all-i-need
694
(:instance invert-cell-inverts-for-m-correspondents
695
(rtmvars (rtmintvars-0 m))
696
(gem-cell (get-cell (gemvar-0 m) gem-typed-mem))
697
(type (type-0 m)))))))
700
(defthm decode-retrieves-gem-memory
703
(rel-prime-moduli *rns*)
704
(integer-listp *rns*)
706
(vars-inclusion gem-typed-mem m)
707
(vars-inclusion m gem-typed-mem)
708
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem)
709
(is-typed-amem-p gem-typed-mem)
710
(bounded-amem-p gem-typed-mem)
711
(correct-wrt-arity m gem-typed-mem))
712
(equal-memories (decode m rtm-typed-mem) gem-typed-mem))
713
:hints (("Goal" :in-theory (enable retrieving-keeps-equality))))
716
(defun projectiocell (cell attr)
719
(if (equal (var-attribute cell) attr)
723
(defun projectio (mem attr)
727
(projectiocell (cdr (car mem)) attr)
728
(projectio (cdr mem) attr))))
732
(defthm cell-of-projected-mem-is-projected-cell
734
(get-cell cell (projectio mem attr))
735
(projectiocell (get-cell cell mem) attr)))
740
(defthm projection-of-null-list-is-null-list
742
(equal-values (var-values l rtm-typed-mem) (make-null-list l))
743
(equal-values (var-values l (projectio rtm-typed-mem attr)) (make-null-list l))))
746
(defthm null-cell-corresponds-to-null-lists-of-values
750
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
751
(equal-values (var-values rtmvars rtm-typed-mem) (make-null-list rtmvars)))
752
:hints (("Goal" :in-theory (disable get-cell var-value var-attribute ))))
756
(defthm project-invert-commute-for-empty-cell
760
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
761
(equal (projectiocell (invert-cell rtmvars rtm-typed-mem type) attr)
762
(invert-cell rtmvars (projectio rtm-typed-mem attr) type)))
763
:hints (("Goal" :use (null-cell-corresponds-to-null-lists-of-values
764
(:instance projection-of-null-list-is-null-list (l rtmvars))))))
768
(defthm rtmvars-correspondent-to-nonemptycell-is-not-emptylist
771
(not (null (var-attributes rtmvars rtm-typed-mem)))
772
(equal type (var-type gem-cell))
774
(not (null gem-cell))
775
(equal (var-attribute gem-cell) attr)
776
(is-mem-cell-p gem-cell)
777
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
780
(var-values rtmvars rtm-typed-mem)
781
(make-null-list rtmvars)))))
786
(defthm values-remain-the-same-if-correspondent-attrs
789
(not (null (var-attributes rtmvars rtm-typed-mem)))
790
(equal type (var-type gem-cell))
792
(not (null gem-cell))
793
(equal (var-attribute gem-cell) attr)
794
(is-mem-cell-p gem-cell)
795
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
797
(var-values rtmvars (projectio rtm-typed-mem attr))
798
(var-values rtmvars rtm-typed-mem)))
799
:hints (("Goal" :do-not '(generalize))))
803
(defthm attributes-same-1
805
(equal-elements attr (var-attributes rtmvars rtm-typed-mem))
807
(var-attributes rtmvars (projectio rtm-typed-mem attr))
808
(var-attributes rtmvars rtm-typed-mem))))
813
(defthm inversion-2-for-nonempty-projected-on-same-attr
816
(not (null (var-attributes rtmvars rtm-typed-mem)))
817
(equal type (var-type gem-cell))
819
(not (null gem-cell))
820
(equal (var-attribute gem-cell) attr)
821
(is-mem-cell-p gem-cell)
822
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
823
(equal (invert-cell rtmvars (projectio rtm-typed-mem attr) type)
824
(invert-cell rtmvars rtm-typed-mem type)))
825
:hints (("Goal" :in-theory nil
826
;; modified for Version 2.7 fertilization
828
(:instance invert-cell (rtm-typed-mem (projectio rtm-typed-mem attr)))
830
equal-values-and-attributes
831
(:instance attributes-same-1 (attr (var-attribute gem-cell)))
832
rtmvars-correspondent-to-nonemptycell-is-not-emptylist
833
values-remain-the-same-if-correspondent-attrs)
834
:expand ((:free (x) (hide x))))))
837
(defthm inversion-1-for-nonempty-projected-on-different-attr
840
(not (null (var-attributes rtmvars rtm-typed-mem)))
841
(equal type (var-type gem-cell))
843
(not (null gem-cell))
844
(not (equal (var-attribute gem-cell) attr))
845
(is-mem-cell-p gem-cell)
846
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
847
(equal (projectiocell (invert-cell rtmvars rtm-typed-mem type) attr)
851
(defthm projecting-on-different-attr-gets-nils
854
(not (equal (var-attribute gem-cell) attr))
855
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
857
(var-values rtmvars (projectio rtm-typed-mem attr))
858
(make-null-list rtmvars))))
862
(defthm decode-one-entry-of-null-list-is-nil
867
(equal-values (var-values l rtm-typed-mem) (make-null-list l)))
868
(equal (apply-invers-rns-to-values-according-to-type (var-values l rtm-typed-mem) ty) nil))
869
:hints(("goal" :in-theory (enable build-value-by-inverse-rns-extended-for-nil))))
872
(defthm inversion-2-for-nonempty-projected-on-different-attr
877
(not (equal (var-attribute gem-cell) attr))
878
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
879
(equal (invert-cell rtmvars (projectio rtm-typed-mem attr) type)
882
((:instance decode-one-entry-of-null-list-is-nil
884
(rtm-typed-mem (projectio rtm-typed-mem attr))
886
(:instance invert-cell (rtm-typed-mem (projectio rtm-typed-mem attr)))
887
projecting-on-different-attr-gets-nils))))
892
(defthm inversion-for-nonempty-projected-on-different-attr
897
(not (null (var-attributes rtmvars rtm-typed-mem)))
898
(equal type (var-type gem-cell))
900
(not (null gem-cell))
901
(not (equal (var-attribute gem-cell) attr))
902
(is-mem-cell-p gem-cell)
903
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
904
(equal (projectiocell (invert-cell rtmvars rtm-typed-mem type) attr)
905
(invert-cell rtmvars (projectio rtm-typed-mem attr) type)))
909
(inversion-1-for-nonempty-projected-on-different-attr
910
inversion-2-for-nonempty-projected-on-different-attr))))
916
(defthm project-invert-commuting
921
(not (null (var-attributes rtmvars rtm-typed-mem)))
924
(equal type (var-type gem-cell)))
926
(or (null gem-cell) (is-mem-cell-p gem-cell))
927
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
928
(equal (projectiocell (invert-cell rtmvars rtm-typed-mem type) attr)
929
(invert-cell rtmvars (projectio rtm-typed-mem attr) type)))
930
:hints (("Goal" :cases
931
( (and (not (null gem-cell)) (not (equal (var-attribute gem-cell) attr)))
932
(and (not (null gem-cell)) (equal (var-attribute gem-cell) attr))))
933
("Subgoal 3" :use project-invert-commute-for-empty-cell)
934
("Subgoal 2" :use inversion-for-nonempty-projected-on-different-attr)))
940
(not (null rtmvars)))
941
(not (null (var-attributes rtmvars rtm-typed-mem)))))
944
(defthm project-invert-commuting-better
951
(equal type (var-type gem-cell)))
953
(or (null gem-cell) (is-mem-cell-p gem-cell))
954
(equal-values-and-attributes gem-cell rtmvars rtm-typed-mem type))
955
(equal (projectiocell (invert-cell rtmvars rtm-typed-mem type) attr)
956
(invert-cell rtmvars (projectio rtm-typed-mem attr) type)))
957
:hints (("Goal" :use (letssimplify project-invert-commuting))))
962
m-entries-point-to-good-rtm-var-sets
963
m-correspondent-values-p))
965
(in-theory (disable gemvar-0 rtmintvars-0))
971
(is-typed-amem-p gem-typed-mem)
972
(correct-wrt-arity m gem-typed-mem)
973
(m-entries-point-to-good-rtm-var-sets m rtm-typed-mem)
974
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem))
977
(null (get-cell (gemvar-0 m) gem-typed-mem))
978
(is-mem-cell-p (get-cell (gemvar-0 m) gem-typed-mem)))
979
(true-listp (rtmintvars-0 m))
980
(not (null (rtmintvars-0 m)))
981
(correct-type (type-0 m))
983
(null (get-cell (gemvar-0 m) gem-typed-mem))
984
(equal (type-0 m) (var-type (get-cell (gemvar-0 m) gem-typed-mem))))
985
(equal-values-and-attributes
986
(get-cell (gemvar-0 m) gem-typed-mem)
990
(correct-wrt-arity (cdr m) gem-typed-mem)
991
(m-entries-point-to-good-rtm-var-sets (cdr m) rtm-typed-mem)
992
(m-correspondent-values-p (cdr m) gem-typed-mem rtm-typed-mem)))
993
:hints (("Goal" :use (:instance any-cell-of-a-typed-mem-is-nil-or-a-typed-cell
999
(defun decode-projection (m rtm-typed-mem attr)
1002
(put-cell (gemvar-0 m)
1009
(decode-projection (cdr m) rtm-typed-mem attr))))
1012
(in-theory (enable m-entries-point-to-good-rtm-var-sets))
1014
(defthm project-of-decode-is-decode-projection
1016
(projectio (decode m rtm-typed-mem) attr)
1017
(decode-projection m rtm-typed-mem attr)))
1020
(defthm decode-projection-is-decode-of-projection
1023
(is-typed-amem-p gem-typed-mem)
1024
(correct-wrt-arity m gem-typed-mem)
1025
(m-entries-point-to-good-rtm-var-sets m rtm-typed-mem)
1026
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem))
1028
(decode-projection m rtm-typed-mem attr)
1029
(decode m (projectio rtm-typed-mem attr))))
1030
:hints (("Goal" :induct (len m))
1031
("Subgoal *1/1" :in-theory nil
1033
(:instance decode (rtm-typed-mem (projectio rtm-typed-mem attr)))
1035
(:instance project-invert-commuting-better
1037
(gem-cell (get-cell (gemvar-0 m) gem-typed-mem))
1038
(rtmvars (rtmintvars-0 m)))))))
1042
(defthm decode-project-commuting
1045
(is-typed-amem-p gem-typed-mem)
1046
(correct-wrt-arity m gem-typed-mem)
1047
(m-entries-point-to-good-rtm-var-sets m rtm-typed-mem)
1048
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem))
1050
(projectio (decode m rtm-typed-mem) attr)
1051
(decode m (projectio rtm-typed-mem attr)))))
1055
(in-theory (disable get-cell put-cell))
1057
(defthm equalwrt-holds-on-project
1059
(equal-wrt-vars m0 m1 m2)
1060
(equal-wrt-vars m0 (projectio m1 attr) (projectio m2 attr))))
1062
(defthm projectio-keeps-caars
1063
(same-caars-p m0 (projectio m0 attr))
1064
:hints (("Goal" :in-theory (enable put-cell))))
1067
(defthm equalwrt-holds-on-project-all
1069
(equal-wrt-vars m0 m1 m2)
1070
(equal-wrt-vars (projectio m0 attr) m1 m2))
1071
:hints (("Goal" :use (:instance if-same-caars-same-equality-wrt-vars
1073
(vars2 (projectio m0 attr))
1077
(defthm equalwrt-holds-on-project-all-all
1079
(equal-wrt-vars m0 m1 m2)
1080
(equal-wrt-vars (projectio m0 attr) (projectio m1 attr) (projectio m2 attr)))
1081
:hints (("Goal" :use (:instance if-same-caars-same-equality-wrt-vars
1083
(vars2 (projectio m0 attr))
1087
(defthm equal-memories-holds-by-projection
1089
(equal-memories m1 m2)
1090
(equal-memories (projectio m1 attr) (projectio m2 attr))))
1095
(defthm equalities-on-io
1098
(rel-prime-moduli *rns*)
1099
(integer-listp *rns*)
1101
(m-entries-point-to-good-rtm-var-sets m rtm-typed-mem)
1102
(vars-inclusion gem-typed-mem m)
1103
(vars-inclusion m gem-typed-mem)
1104
(m-correspondent-values-p m gem-typed-mem rtm-typed-mem)
1105
(is-typed-amem-p gem-typed-mem)
1106
(bounded-amem-p gem-typed-mem)
1107
(correct-wrt-arity m gem-typed-mem))
1108
(equal-memories (decode m (projectio rtm-typed-mem attr)) (projectio gem-typed-mem attr)))
1111
equal-memories-commutative
1112
retrieving-keeps-equality
1113
decode-equals-retrieve-vars
1114
equal-wrt-vars-reflexive
1115
equal-wrt-vars-transitive
1116
equalwrt-holds-on-project-all)
1117
:use ( (:instance equal-memories-holds-by-projection
1118
(m1 (decode m rtm-typed-mem))
1119
(m2 gem-typed-mem))))))
1122
(defthm fact-bout-rns-v0
1124
(integer-listp *rns*)
1125
(rel-prime-moduli *rns*)
1130
:hints (("Goal" :in-theory (enable prod posp rel-prime-moduli rel-prime-all rel-prime g-c-d
1132
(:executable-counterpart nonneg-int-gcd))))
1135
(defun append-lists (list-of-lists)
1136
(if (endp list-of-lists)
1138
(append (car list-of-lists)
1139
(append-lists (cdr list-of-lists)))))
1141
(defun retrieve-gemvars (m)
1145
(cons (gemvar-0 m) (retrieve-gemvars (cdr m)))))
1147
(defun retrieve-rtmvars (m)
1151
(retrieve-rtmvars (cdr m)))))
1153
(defun gem-variables (m) (retrieve-gemvars m))
1154
(defun rtm-variables (m) (append-lists (retrieve-rtmvars m)))
1156
(defun same-vars (m1 m2)
1158
(vars-inclusion m1 m2)
1159
(vars-inclusion m2 m1)))
1161
(defun member-equal-bool (el l)
1162
(declare (xargs :guard (true-listp l)))
1163
(cond ((endp l) nil)
1164
((equal el (car l)) t)
1165
(t (member-equal-bool el (cdr l)))))
1167
(defun no-tmp-into-mapping (m)
1171
(not (member-equal-bool 'tmp (rtmintvars-0 m)))
1172
(no-tmp-into-mapping (cdr m)))))
1174
(defun no-duplicates-p (l)
1177
(and (not (member-equal-bool (car l) (cdr l)))
1178
(no-duplicates-p (cdr l)))))
1181
(defun apply-direct-rns-to-value-depending-on-type (gemvalue type)
1182
(cond ( (equal type 'bool) (list gemvalue) )
1183
( (equal type 'int) (build-values-by-rns-extended-for-nil gemvalue *rns*) )
1186
(defun represent-same-values-p (gemvalue rtmvalues type)
1189
(apply-direct-rns-to-value-depending-on-type gemvalue type)))
1192
(defun m-correspondent-vals-p (m gem-typed-mem rtm-typed-mem)
1198
(represent-same-values-p
1199
(var-value (get-cell (gemvar-0 m) gem-typed-mem))
1200
(var-values (rtmintvars-0 m) rtm-typed-mem)
1202
(m-correspondent-vals-p (cdr m) gem-typed-mem rtm-typed-mem)))))
1205
(defun attributes-correspondence (m gem-typed-mem rtm-typed-mem)
1209
(not (endp (rtmintvars-0 m)))
1210
(true-listp (rtmintvars-0 m))
1211
(not (equal 'error-value (get-common-value (var-attributes (rtmintvars-0 m) rtm-typed-mem))))
1213
(var-attribute (get-cell (gemvar-0 m) gem-typed-mem))
1214
(var-attributes (rtmintvars-0 m) rtm-typed-mem))
1215
(attributes-correspondence (cdr m) gem-typed-mem rtm-typed-mem))))
1218
(defthm redefinition-of-m-corr
1221
(m-entries-point-to-good-rtm-var-sets m rtm-vars)
1222
(m-correspondent-values-p m gem-vars rtm-vars))
1224
(attributes-correspondence m gem-vars rtm-vars)
1225
(m-correspondent-vals-p m gem-vars rtm-vars)))
1230
(defun is-variable-mapping (m gem-vars rtm-vars)
1233
(no-tmp-into-mapping m)
1234
(no-duplicates-p (gem-variables m))
1235
(no-duplicates-p (rtm-variables m))
1236
(correct-wrt-arity m gem-vars)
1237
(same-vars gem-vars m)
1238
(attributes-correspondence m gem-vars rtm-vars)
1239
(m-correspondent-vals-p m gem-vars rtm-vars)))
1241
(defun output (mem) (projectio mem 'Output))
1243
(defun is-gem-mem-p (mem)
1244
(and (is-typed-amem-p mem)
1245
(bounded-amem-p mem)))
1247
(defthm mapping-correspondence-implies-same-outputs
1250
(is-variable-mapping m gem-mem rtm-mem)
1251
(is-gem-mem-p gem-mem))
1254
(decode m (output rtm-mem))))
1255
:hints (("Goal" :use
1257
(:instance redefinition-of-m-corr
1260
(:instance equalities-on-io
1261
(gem-typed-mem gem-mem)
1262
(rtm-typed-mem rtm-mem))
1263
(:instance equal-memories-commutative
1264
(mem1 (output gem-mem))
1265
(mem2 (decode m (output rtm-mem)))))))
1270
(in-theory (disable correct-arity-all-i-need
1271
if-every-element-matches-val-then-get-common-value-amounts-to-val
1272
make-null-list-is-invariant-on-value-slicing
1273
build-values-by-rns-extended-for-nils-provides-integers-from-integer
1274
build-value-by-inverse-rns-extended-for-nils-behaves-standardly-on-integer-lists
1275
crt-inversion-extended-to-nils-in-integer-case
1276
apply-direct-rns-unfolding-for-integer-case
1277
apply-direct-rns-unfolding-for-boolean-case
1278
apply-inverse-direct-retrieves-same-value-for-typed-cells
1279
inversion-for-empty-cell
1280
ad-hoc-2-for-inversion-of-one-nonempty-cell-by-decode
1281
ad-hoc-3-for-inversion-of-one-nonempty-cell-by-decode
1282
nonempty-cell-is-not-mapped-into-nils-by-rns
1283
nonempty-rtm-vars-which-correspond-to-gem-var-by-values-and-atributes-map-back-to-gem-var
1284
decode-inversion-for-nonempty-gem-cell
1285
invert-cell-inverts-for-m-correspondents
1286
;any-cell-of-a-typed-mem-is-nil-or-a-typed-cell
1289
decode-equals-retrieve-vars
1290
decode-retrieves-gem-memory
1291
cell-of-projected-mem-is-projected-cell
1292
projection-of-null-list-is-null-list
1293
null-cell-corresponds-to-null-lists-of-values
1294
project-invert-commute-for-empty-cell
1295
rtmvars-correspondent-to-nonemptycell-is-not-emptylist
1296
values-remain-the-same-if-correspondent-attrs
1298
inversion-2-for-nonempty-projected-on-different-attr
1299
inversion-1-for-nonempty-projected-on-different-attr
1300
projecting-on-different-attr-gets-nils
1301
decode-one-entry-of-null-list-is-nil
1302
inversion-2-for-nonempty-projected-on-different-attr
1303
inversion-for-nonempty-projected-on-different-attr
1304
project-invert-commuting
1306
project-invert-commuting-better
1307
decode-projection-is-decode-of-projection
1308
decode-project-commuting
1309
equalwrt-holds-on-project-all
1310
equalwrt-holds-on-project-all-all
1311
equal-memories-holds-by-projection
b'\\ No newline at end of file'