5
(set-match-free-default :all)
9
We define the common boolean operations (and a few other common useful notions)
10
on sets canonicalized as ordered lists using Pete's total ordering of all ACL2
11
objects. Further, the functions have been defined with a normalization of all
12
ACL2 objects as appropriate sets (we define a 1-1 function which maps any ACL2
13
object to a corresponding well-formed set) and using this normal (and its
14
inverse), we can prove properties about normalized set operations which use
15
equal-ity instead of set-equality and require no backtracking to relieve
16
well-formed set hypotheses.
18
EXPORTED logic functions:
20
(in e x) -- set membership predicate, is element e a member of set x
21
(subset x y) -- subset predicate, is set x a subset of set y
22
(isect x y) -- the set intersection of set x and set y
23
(unite x y) -- the set union of set x and set y
24
(sdiff x y) -- the set of elements in set x but not in set y
25
(card x) -- returns the number of objects in the set x
26
(s1 e) -- the singleton set consisting only of the element e
27
(scar x) -- the least (by <<) element in the set x, nil if x is empty
28
() -- NIL is unique representative value for empty set,
29
so use NULL or NOT to test a set for emptiness
30
(c1 x) -- test which returns true if x is a singleton set
32
EXPORTED theorems provided at the end of this file.
34
I have removed all of the subgoal hints except for those introduced by the
35
macro defthm-ternary-sets. These subgoal hints are reasonable since they are
36
introduced in the context of a provided induction scheme and they help speed
37
the proofs through considerably by avoiding the problem in ACL2 of
38
free-variable matching in the application of <<-transitive.
42
(include-book "total-order")
44
;; i needed to add the following forward-chaining rule to make better use
45
;; of <<-trichotomy from the included order book.
48
(defthm <<-trichotomy-forward-chain1
49
(implies (and (not (<< x y))
52
:rule-classes :forward-chaining))
59
(<< (first x) (second x))))))
61
(defun ifsp (x) ;; ill-formed setp
68
(if (ifsp x) (list x) x))
71
(if (ifsp x) (first x) x))
75
(or (equal e (first x))
77
(in-aux e (rest x))))))
80
(in-aux e (norm->set x)))
82
(defun subset-aux (x y)
85
(cond ((equal (first x) (first y))
86
(subset-aux (rest x) (rest y)))
87
((<< (first y) (first x))
88
(subset-aux x (rest y)))
92
(subset-aux (norm->set x) (norm->set y)))
94
(defun isect-aux (x y)
95
(declare (xargs :measure (+ (acl2-count x)
99
((equal (first x) (first y))
101
(isect-aux (rest x) (rest y))))
102
((<< (first x) (first y))
103
(isect-aux (rest x) y))
105
(isect-aux x (rest y)))))
108
(set->norm (isect-aux (norm->set x) (norm->set y))))
110
(defun unite-aux (x y)
111
(declare (xargs :measure (+ (acl2-count x)
115
((equal (first x) (first y))
117
(unite-aux (rest x) (rest y))))
118
((<< (first x) (first y))
120
(unite-aux (rest x) y)))
123
(unite-aux x (rest y))))))
126
(set->norm (unite-aux (norm->set x) (norm->set y))))
128
(defun sdiff-aux (x y)
129
(declare (xargs :measure (+ (acl2-count x)
133
((equal (first x) (first y))
134
(sdiff-aux (rest x) (rest y)))
135
((<< (first x) (first y))
137
(sdiff-aux (rest x) y)))
139
(sdiff-aux x (rest y)))))
142
(set->norm (sdiff-aux (norm->set x) (norm->set y))))
145
(set->norm (list e)))
151
(if (ifsp x) x (first x)))
153
(defmacro empty-set ()
157
(let ((x (norm->set x))) (and (consp x) (not (cdr x)))))
161
;;; some useful auxiliary macros which could be removed if
162
;;; needed (e.g. if the names conflict with existing fns)
167
(defmacro sdrop (e x)
171
`(sdrop (scar ,x) ,x))
176
(defmacro common (x y)
177
`(not (satom (isect ,x ,y))))
180
;;;; properties of setp ;;;;
183
(defthm setp-implies-true-listp
186
:rule-classes (:forward-chaining
190
;;;; properties of norm->set and set->norm ;;;;
193
(defthm norm->set-set->norm-of-setp
195
(equal (norm->set (set->norm x))
199
(defthm norm->set-of-wf-setp
200
(implies (not (ifsp x))
201
(equal (norm->set x) x))))
204
(defthm norm->set-of-if-setp
206
(equal (norm->set x) (list x)))))
209
(defthm norm->set-returns-setp
210
(setp (norm->set x))))
213
(defthm norm->set-preserves-equality
214
(iff (equal (norm->set x) (norm->set y))
218
(defthm set->norm-norm->set-inverse
219
(equal (set->norm (norm->set x)) x)))
222
(defthm set->norm-nil-iff-passed-nil
224
(iff (set->norm x) x))))
227
(defthm norm->set-of-x-is-consp-or-not-x
228
(iff (consp (norm->set x)) x)
232
(defthm norm->set-is-true-listp
233
(true-listp (norm->set x))
234
:rule-classes :type-prescription))
236
(in-theory (disable set->norm norm->set))
239
;;;; bounded properties ;;;;
242
(defthm unite-aux-bounded-<<
243
(implies (and (<< a (first x))
245
(<< a (first (unite-aux x y))))))
248
(defthm isect-aux-bounded-<<
249
(implies (and (or (<< a (first x))
252
(<< a (first (isect-aux x y))))))
255
(defthm sdiff-aux-bounded-<<
256
(implies (and (setp x)
259
(<< a (first (sdiff-aux x y))))))
262
;;;; type-correctness properties ;;;;
265
(defthm unite-aux-preserves-setp
266
(implies (and (setp x) (setp y))
267
(setp (unite-aux x y)))
268
:rule-classes ((:forward-chaining
269
:trigger-terms ((unite-aux x y)))
273
(defthm isect-aux-preserves-setp
274
(implies (and (setp x) (setp y))
275
(setp (isect-aux x y)))
276
:rule-classes ((:forward-chaining
277
:trigger-terms ((isect-aux x y)))
281
(defthm sdiff-aux-preserves-setp
283
(setp (sdiff-aux x y)))
284
:rule-classes ((:forward-chaining
285
:trigger-terms ((sdiff-aux x y)))
289
;;;; properties of membership-aux ;;;;
292
(defthm in-aux-isect-aux-reduce
293
(equal (in-aux e (isect-aux x y))
294
(and (in-aux e x) (in-aux e y)))))
297
(defthm in-aux-unite-aux-reduce
298
(equal (in-aux e (unite-aux x y))
299
(or (in-aux e x) (in-aux e y)))))
302
(defthm in-aux-implies-bounded
303
(implies (and (setp x)
305
(not (in-aux a x)))))
308
(defthm in-aux-sdiff-aux-reduce
310
(equal (in-aux e (sdiff-aux x y))
311
(and (in-aux e x) (not (in-aux e y)))))))
314
(defthm in-aux-subset-aux-transits
315
(implies (and (in-aux e x)
320
;;;; ternary variable induction scheme and strategy ;;;;
322
;; the following function defines an induction scheme used in theorems
323
;; involving three free variables (like associativity proofs).
326
(defun ternary-induct (x y z)
327
(declare (xargs :measure (+ (acl2-count x)
333
; The following was changed to avoid SBCL warning, "Asserted type NUMBER
334
; conflicts with derived type (VALUES LIST &OPTIONAL)."
336
(cond ((<< (first x) (first y))
337
(cond ((<< (first x) (first z))
338
(ternary-induct (rest x) y z))
339
((equal (first x) (first z))
340
(ternary-induct (rest x) y (rest z)))
341
((and (<< (first z) (first x))
342
(<< (first z) (first y)))
343
(ternary-induct x y (rest z)))))
344
((equal (first x) (first y))
345
(cond ((<< (first x) (first z))
346
(ternary-induct (rest x) (rest y) z))
347
((equal (first x) (first z))
348
(ternary-induct (rest x) (rest y) (rest z)))
349
((<< (first z) (first x))
350
(ternary-induct x y (rest z)))))
351
((<< (first y) (first x))
352
(cond ((<< (first y) (first z))
353
(ternary-induct x (rest y) z))
354
((equal (first y) (first z))
355
(ternary-induct x (rest y) (rest z)))
356
((and (<< (first z) (first y))
357
(<< (first z) (first x)))
358
(ternary-induct x y (rest z)))))))))
360
;; the following macro defines an effective strategy for inducting based on the
361
;; scheme ternary-induct.
363
(defmacro defthm-ternary-sets (name body)
366
:induct (ternary-induct x y z)
367
:in-theory (disable <<-transitive))
369
:in-theory (enable <<-transitive))
371
:in-theory (enable <<-transitive)))))
374
;;;; properties of subset-aux ;;;;
377
(defthm unite-aux-x<y-expansion
378
(implies (and (consp x)
380
(<< (car x) (car y)))
381
(equal (unite-aux x y)
383
(unite-aux (cdr x) y))))))
386
(defthm subset-aux-x<y-reduces-nil
387
(implies (and (consp x)
389
(<< (car x) (car y)))
390
(equal (subset-aux x y)
394
(defthm atom-unite-aux-implies-atom-params
395
(implies (not (consp (unite-aux x y)))
400
(defthm-ternary-sets subset-aux-unite-aux-reduction
401
(equal (subset-aux (unite-aux x y) z)
402
(and (subset-aux x z)
406
(in-theory (disable unite-aux-x<y-expansion)))
409
(defthm subset-aux-is-reflexive
413
(defthm subset-aux-unite-aux-property
415
(subset-aux x (unite-aux x y)))))
418
(defthm <<-irreflexive-rewrite
423
(defthm-ternary-sets subset-aux-isect-aux-reduction
424
(equal (subset-aux x (isect-aux y z))
425
(and (subset-aux x y)
429
(defthm subset-aux-isect-aux-property
431
(subset-aux (isect-aux x y) x))))
434
(defthm subset-aux-sdiff-aux-property
436
(subset-aux (sdiff-aux x y) x))))
439
(defthm-ternary-sets subset-aux-is-transitive
440
(implies (and (subset-aux x y)
445
(defthm subset-aux-is-total-on-sets
446
(implies (and (setp x) (setp y)
448
(equal (subset-aux y x)
452
(defthm subset-length-property
453
(implies (and (setp x)
456
(<= (len x) (len y)))))
459
(defthm len<-reduce-when-subset
460
(implies (and (setp x)
463
(equal (< (len x) (len y))
464
(not (equal x y))))))
467
;;;; properties of unite-aux ;;;;
470
(defthm unite-aux-implied-by-and
471
(implies (and (setp x)
477
(defthm unite-aux-reflexes
479
(equal (unite-aux x x) x))))
482
(defthm unite-aux-commutes
483
(implies (and (setp x) (setp y))
484
(equal (unite-aux x y)
488
(defthm unite-aux-x<y-expansion-flip
489
(implies (and (consp x)
491
(<< (car x) (car y)))
492
(equal (unite-aux y x)
494
(unite-aux y (cdr x)))))))
497
(in-theory (enable unite-aux-x<y-expansion)))
500
(defthm-ternary-sets unite-aux-associates
501
(implies (and (setp x) (setp y) (setp z))
502
(equal (unite-aux (unite-aux x y) z)
503
(unite-aux x (unite-aux y z))))))
506
(in-theory (disable unite-aux-x<y-expansion-flip
507
unite-aux-x<y-expansion)))
510
(defthm unite-aux-subset-aux-property
511
(equal (equal (unite-aux x y) y)
515
(defthm length-of-unite-aux-property
516
(implies (and (setp x) (setp y))
517
(equal (len (unite-aux x y))
519
(len (sdiff-aux y x)))))))
522
(defthm set-norm-equality-transfer
524
(equal (equal (set->norm x) y)
525
(equal x (norm->set y))))))
528
;;;; properties of isect-aux ;;;;
531
(defthm isect-aux-reflexes
533
(equal (isect-aux x x) x))))
536
(defthm isect-aux-commutes
537
(implies (and (setp x) (setp y))
538
(equal (isect-aux x y) (isect-aux y x)))))
541
(defthm isect-aux-x<y-expansion
542
(implies (and (consp x)
544
(<< (car x) (car y)))
545
(equal (isect-aux y x)
546
(isect-aux y (cdr x))))))
549
(defthm-ternary-sets isect-aux-associates
550
(implies (and (setp x) (setp y) (setp z))
551
(equal (isect-aux (isect-aux x y) z)
552
(isect-aux x (isect-aux y z))))))
555
(in-theory (disable isect-aux-commutes
556
unite-aux-commutes)))
559
(defthm isect-aux-bounded-then-not-equal
560
(implies (and (consp z)
561
(or (<< (car z) (car x))
562
(<< (car z) (car y))))
563
(not (equal (isect-aux x y) z)))))
566
(defthm isect-aux-subset-aux-property
567
(implies (and (setp x) (setp y))
568
(equal (equal (isect-aux x y) x)
572
(defthm <<-irreflexive-rewrite-flip
577
(defthm-ternary-sets isect-aux-unite-aux-distributes
578
(implies (and (setp x) (setp y) (setp z))
579
(equal (isect-aux (unite-aux x y) z)
580
(unite-aux (isect-aux x z)
584
(defthm-ternary-sets isect-aux-sdiff-aux-distributes
585
(implies (and (setp x) (setp y) (setp z))
586
(equal (isect-aux (sdiff-aux x y) z)
587
(sdiff-aux (isect-aux x z) y)))))
590
;;;; properties of sdiff-aux ;;;;
593
(defthm sdiff-aux-subset-aux-property
594
(implies (and (setp x) (setp y))
596
(not (subset-aux x y))))))
599
(defthm length-of-sdiff-aux-property
600
(implies (and (setp x) (setp y))
601
(equal (len (sdiff-aux x y))
603
(len (isect-aux x y)))))))
606
(defthm-ternary-sets sdiff-aux-unite-aux-distributes
607
(implies (and (setp x) (setp y) (setp z))
608
(equal (sdiff-aux (unite-aux x y) z)
609
(unite-aux (sdiff-aux x z)
613
(defthm-ternary-sets sdiff-aux-unite-aux-reduction
614
(implies (and (setp x) (setp y) (setp z))
615
(equal (sdiff-aux x (unite-aux y z))
616
(sdiff-aux (sdiff-aux x y) z)))))
619
(defthm sdiff-aux-reduce-no-isect-aux
620
(implies (and (setp x) (setp y) (not (isect-aux x y)))
621
(equal (sdiff-aux x y) x))))
624
;;;; properties of s1-aux -- i.e. list ;;;;
627
(defthm subset-aux-reduces-to-membership
629
(equal (subset-aux (list e) x)
633
(defthm subset-aux-of-singleton
634
(implies (and (setp x) x
635
(subset-aux x (list e)))
636
(equal (equal x (list e)) t))))
639
(defthm isect-aux-of-singleton
641
(equal (isect-aux (list e) x)
642
(if (in-aux e x) (list e) ())))))
645
(defthm sdiff-aux-of-singleton
647
(equal (sdiff-aux (list e) x)
648
(if (in-aux e x) () (list e))))))
651
;;;; EXPORTED THEOREMS ;;;;
652
;; Note, the order of the these theorems below is relevant for the
653
;; order in which ACL2 applies them (later ones first). This is why
654
;; the associativity and commutativity theorems are first since
655
;; restructuring unite and isect can have the detrimental effect of
656
;; disabling the application of other rules.
659
(in-theory (enable unite-aux-commutes
660
isect-aux-commutes)))
663
;;;; EXPORTED associative and commutative properties ;;;;
665
(defthm unite-implied-by-and
669
(defthm unite-reflexes
670
(equal (unite x x) x))
672
(defthm unite-commutes
676
(defthm unite-associates
677
(equal (unite (unite x y) z)
678
(unite x (unite y z))))
680
(defthm unite-associate-2
681
(equal (unite x (unite y z))
682
(unite y (unite x z)))
684
:in-theory (disable unite-commutes)
685
:use ((:instance unite-commutes
686
(x x) (y (unite y z)))
687
(:instance unite-commutes
690
(defthm isect-reflexes
691
(equal (isect x x) x))
693
(defthm isect-commutes
697
(defthm isect-associates
698
(equal (isect (isect x y) z)
699
(isect x (isect y z))))
701
(defthm isect-associate-2
702
(equal (isect x (isect y z))
703
(isect y (isect x z)))
705
:in-theory (disable isect-commutes)
706
:use ((:instance isect-commutes
707
(x x) (y (isect y z)))
708
(:instance isect-commutes
711
;;;; EXPORTED properties of membership ;;;;
713
(defthm in-isect-reduce
714
(equal (in e (isect x y))
715
(and (in e x) (in e y))))
717
(defthm in-unite-reduce
718
(equal (in e (unite x y))
719
(or (in e x) (in e y))))
721
(defthm in-sdiff-reduce
722
(equal (in e (sdiff x y))
723
(and (in e x) (not (in e y)))))
725
(defthm in-subset-transits
726
(implies (and (in e x)
731
;;;; EXPORTED properties of susbet ;;;;
733
(defthm subset-unite-reduction
734
(equal (subset (unite x y) z)
738
(defthm subset-unite-property
739
(subset x (unite x y)))
741
(defthm subset-isect-reduction
742
(equal (subset x (isect y z))
746
(defthm subset-isect-property
747
(subset (isect x y) x))
749
(defthm subset-sdiff-property
750
(subset (sdiff x y) x))
752
(defthm subset-is-reflexive
755
(defthm subset-is-transitive
756
(implies (and (subset x y)
760
(defthm subset-is-total-order
761
(implies (subset x y)
765
(defthm subset-card-property
766
(implies (subset x y)
767
(<= (card x) (card y))))
769
(defthm card<-reduce-when-subset
770
(implies (subset x y)
771
(equal (< (card x) (card y))
775
;;;; EXPORTED reductions of unite ;;;;
777
(defthm unite-subset-property
778
(equal (equal (unite x y) y)
781
(defthm unite-subset-property-2
782
(equal (equal (unite y x) y)
785
(defthm unite-card-property
786
(equal (card (unite x y))
788
(card (sdiff y x)))))
791
;;;; EXPORTED reductions of isect ;;;;
793
(defthm isect-subset-property
794
(equal (equal (isect x y) x)
797
(defthm isect-unite-distributes-1
798
(equal (isect (unite x y) z)
802
(defthm isect-unite-distributes-2
803
(equal (isect z (unite x y))
806
:hints (("Goal" :in-theory (disable isect-aux-commutes)
807
:use (:instance isect-aux-commutes
809
(y (unite-aux (norm->set x)
812
(defthm isect-sdiff-distributes-1
813
(equal (isect (sdiff x y) z)
814
(sdiff (isect x z) y)))
816
(defthm isect-sdiff-distributes-2
817
(equal (isect z (sdiff x y))
818
(sdiff (isect x z) y))
819
:hints (("Goal" :in-theory (disable isect-aux-commutes)
820
:use (:instance isect-aux-commutes
822
(y (sdiff-aux (norm->set x)
826
;;;; EXPORTED reductions of sdiff ;;;;
828
(defthm sdiff-subset-property
832
(defthm sdiff-card-property
833
(equal (card (sdiff x y))
835
(card (isect x y)))))
837
(defthm sdiff-unite-distributes
838
(equal (sdiff (unite x y) z)
842
(defthm sdiff-unite-reduction
843
(equal (sdiff x (unite y z))
844
(sdiff (sdiff x y) z)))
846
(defthm sdiff-reduce-no-isect
847
(implies (not (isect x y))
848
(equal (sdiff x y) x)))
851
;;;; EXPORTED reductions of s1 ;;;;
853
(defthm s1-membership-property
857
(defthm s1-subset-property-1
858
(equal (subset (s1 e) x)
861
(defthm s1-subset-property-2
862
(implies (and (subset x (s1 e)) x)
865
(:instance norm->set-of-x-is-consp-or-not-x)))
866
:rule-classes :forward-chaining)
868
(defthm s1-isect-property-1
869
(equal (isect (s1 e) x)
870
(if (in e x) (s1 e) ())))
872
(defthm s1-isect-property-2
873
(equal (isect x (s1 e))
874
(if (in e x) (s1 e) ()))
875
:hints (("Goal" :in-theory (disable isect-aux-commutes)
876
:use (:instance isect-aux-commutes
880
(defthm s1-sdiff-property
881
(equal (sdiff (s1 e) x)
882
(if (in e x) () (s1 e))))
884
(defthm s1-card-property
885
(equal (card (s1 e)) 1))
887
(defthm s1-iff-t (iff (s1 e) t))
890
(equal (equal (s1 e) nil) nil))
892
(defthm subset-s1-redux
893
(equal (subset a (s1 e))
894
(if a (equal a (s1 e)) t)))
898
;;;; EXPORTED properties of empty-set ;;;;
900
(defthm membership-empty-set
901
(not (in e (empty-set))))
903
(defthm empty-set-is-subset
904
(subset (empty-set) x))
906
(defthm empty-set-is-only-superset-self
907
(equal (subset x (empty-set))
910
(defthm unite-empty-set-property-1
911
(equal (unite x (empty-set)) x))
913
(defthm unite-empty-set-property-2
914
(equal (unite (empty-set) x) x))
916
(defthm isect-empty-set-property-1
917
(equal (isect (empty-set) x) (empty-set)))
919
(defthm isect-empty-set-property-2
920
(equal (isect x (empty-set)) (empty-set)))
922
(defthm sdiff-of-empty-set-1
923
(equal (sdiff (empty-set) x) (empty-set)))
925
(defthm sdiff-of-empty-set-2
926
(equal (sdiff x (empty-set)) x))
928
(defthm s1-is-not-empty-set
930
:hints (("Goal" :in-theory (enable set->norm)))
931
:rule-classes :type-prescription)
933
(defthm card-of-empty-set
936
:hints (("Goal" :in-theory (enable norm->set)))
937
:rule-classes :type-prescription)
940
;;;; EXPORTED properties of scar ;;;;
942
(defthm scar-membership-property
943
(iff (in (scar x) x) x))
945
(defthm scar-is-least-member
946
(implies (and (in e x)
947
(not (equal e (scar x))))
950
(defthm scar-returns-nil-for-empty-set
951
(equal (scar (empty-set)) nil))
954
(equal (scar (s1 e)) e)
955
:hints (("Goal" :in-theory (enable set->norm))))
957
(defthm scar-of-unite
959
(equal (scar (unite x y))
960
(if (<< (scar x) (scar y)) (scar x) (scar y))))
961
:hints (("Goal" :in-theory (enable norm->set set->norm))))
963
(defthm scar-of-sdiff
964
(implies (<< (scar x) (scar y))
965
(equal (scar (sdiff x y)) (scar x)))
966
:hints (("Goal" :in-theory (enable norm->set set->norm))))
969
;;;; EXPORTED properties of c1 ;;;;
972
(equal (c1 (s1 e)) t))
978
(equal (c1 (unite x y))
979
(if (c1 x) (implies y (equal x y)) (and (not x) (c1 y))))
980
:hints (("Goal" :in-theory (enable norm->set set->norm)
981
:expand ((unite-aux (list x) y) (unite-aux x y)))))
983
(defthm isect-aux-sdiff-aux-prop1
984
(implies (and (setp x) x
985
(not (isect-aux x y)))
988
(defthm isect-aux-sdiff-aux-prop2
989
(implies (and (consp x)
991
(not (isect-aux x y))
992
(not (cdr (sdiff-aux x y))))
996
(implies (not (isect x y))
997
(equal (c1 (sdiff x y)) (c1 x)))
998
:hints (("Goal" :in-theory (enable norm->set set->norm)
999
:expand ((:free (x) (sdiff-aux (list x) y))
1000
(:free (x z) (sdiff-aux (list x z) y))
1001
(:free (x a b) (sdiff-aux (list* x a b) y))))))
1003
(defthm c1-not-sdiff
1004
(implies (and (isect x y) (c1 x))
1006
:hints (("Goal" :in-theory (enable norm->set set->norm)
1007
:expand (:free (x) (sdiff-aux (list x) y)))))
1010
;; we now disable the top-level functions to keep their
1011
;; definitions from being expanded
1013
(in-theory (disable in subset isect unite sdiff card s1 scar c1))
1015
;; the following macro will enable/disable the executable-counterparts
1017
(defmacro ec-sets (x)
1018
`(in-theory (,(if x 'enable 'disable)
1019
(in) (subset) (isect) (unite)
1020
(sdiff) (card) (s1) (scar) (c1))))
1022
;; we will begin with the executable-counterparts disabled
1026
;; the following macro is a convenient way to define constants, it is similar
1027
;; to the 'list macro
1029
(defmacro make-set (&rest elems)
1030
(if (endp elems) '(emptyset)
1031
`(sadd ,(first elems) (make-set ,@(rest elems)))))
1035
;; we conclude with a few corollaries
1037
(defthm unite-iff-or
1038
(iff (unite x y) (or x y))
1039
:hints (("Goal" :cases ((not x) (not y)))))
1041
(defthm unite-x-absorption
1042
(equal (unite x (unite x y)) (unite x y)))
1045
(equal (c1 (sadd e x)) (if (c1 x) (equal x (s1 e)) (not x))))
1047
(defthm equal-s1-redux
1048
(equal (equal (s1 a) (s1 b)) (equal a b))
1049
:hints (("Goal" :in-theory (enable s1))))
1051
(defthm wrap-up-s1-equal-to-c1
1052
(equal (equal (s1 (scar s)) s) (c1 s))
1053
:hints (("Goal" :in-theory (enable s1 scar c1))))
1055
(defthm c1-in-redux-scar
1056
(implies (c1 s) (equal (in e s) (equal e (scar s))))
1057
:hints (("Goal" :in-theory (enable in c1 scar))))
1060
(defthm setp-cons-redux
1061
(equal (setp (cons x y))
1062
(and (setp y) (implies y (<< x (car y)))))))
1064
(defthm equal-sadd-s1-redux
1065
(equal (equal (sadd e x) (s1 a))
1066
(and (equal e a) (implies x (equal x (s1 e)))))
1067
:hints (("Goal" :in-theory (enable s1 unite norm->set set->norm)
1068
:expand ((unite-aux (list e) x)))))
1077
> I propose the following additions to the sets book:
1080
> (equal (sdiff x x)
1083
The following rule subsumes yours and I think would be
1086
(defthm sdiff-superset
1087
(implies (subset x y)
1091
> ;(add similar lemmas about other functions than unite
1093
> (defthm unite-reflexes-2
1094
> (equal (unite x (unite x y))
1097
> ;and can you prove this one for me?
1098
> (defthm sdiff-sdiff
1099
> (equal (sdiff (sdiff x y) y)
1103
absorption rules for unite, isect, and sdiff (on the right)
1104
would be good. I have no idea why I had not considered adding
1105
these before. I will probably generalize them to have subset
1108
> BTW, what's the status of the sets book? Will it be
1109
> released with ACL2?
1111
It is in one of the workshops, although I am uncertain if it
1112
is updated. I will probably get Matt to add it to the misc
1113
directory (especially with some of the recent additions to
1114
the records book which make use of the sets book).
1118
> (defthm unite-sdiff-hack
1119
> (equal (unite x (sdiff y x))
1122
Hmmm. I am uncertain if this is a proper reduction. Intuitively,
1123
while the lhs is a bigger term, it is smaller in terms of
1124
cardinality. I will need to think about this case, but offhand,
1125
I don't see this as an obviously good addition to the sets book.
1127
> (BTW, I'm assuming its okay to ask you to prove these
1128
> since they'd make good additions to the sets book,
1129
> which you are developing. If you'd rather not be
1130
> bothered with this, let me know.)
1132
Please feel free to make suggestions (just don't expect that I
1133
will always be quick in handling the suggestions). I like using
1134
the sets book and would like to see others use it as well. (I am
1135
generally an advocate of having books with rewrite rules which
1136
are "context-free" -- well as context-free as possible).
1141
> i talked with Matt (the other "old-timer") and we
1143
> in tacit agreement that we should change
1145
> to "maps.lisp" (the new version with all of the
1147
> improvements and which includes the sets book). But,
1148
> I want to wait ask about this at the next ACL2
1150
> to get an idea of how many people (if any) are using
1156
My sense is that people aren't using the records/maps
1157
book enough (and that, in general, people don't
1158
appreciate the importance of the tricks done to make
1159
the records book clean). Did anyone ever give a talk
1160
on records/maps at the ACL2 seminar?
1162
I'm changing my copy of the "M5" JVM model to use
1163
records, and I think this is clearly the way to go.
1164
(There are some subtleties, but I now have a fairly
1165
clean algebra for the heap.) If J's folks keep
1166
hearing about this from enough people, maybe they'll
1167
use records for M6. Hanbing seems to be in charge of
1170
> > BTW, are there easy proofs for either of the
1172
> > (which I've left as axioms in order to get on with
1174
> > JVM proofs)? I'm not terribly familiar with the
1176
> > book, and I didn't find an easy proof for these.
1178
> > (defaxiom sdiff-sdiff
1179
> > (equal (ACL2::SDIFF (ACL2::SDIFF Z X) X)
1180
> > (ACL2::SDIFF Z X)))
1182
> > (defaxiom unite-hack
1183
> > (equal (acl2::unite x (acl2::sdiff z x))
1184
> > (acl2::unite x z)))
1186
> I believe these are provable, but not easily proven
1188
> terms of the existing rules.
1190
> I am planning on doing some work with the records (I
1192
> "maps") and sets books this weekend. The updates
1194
> cover these theorems (and many others). I will send
1198
That would be great! Thanks. I've been spending a
1199
lot of time making changes to M5 and thinking about
1200
sets, maps, and other implementation details, instead
1201
of actually doing the proofs I'm supposed to be doing
1202
(about java.util.linkedlist). Even so, Dill seems
1203
satisfied with my progress. Once we get the JVM model
1204
(and the sets and maps books) stabilized, I should be
1205
much more productive and should be able to totally
1212
__________________________________________________
1214
Yahoo! Tax Center - forms, calculators, tips, more
1215
http://taxes.yahoo.com/