~ubuntu-branches/ubuntu/wily/acl2/wily

« back to all changes in this revision

Viewing changes to books/workshops/2009/fraij-roach/support/theorems.lisp

  • Committer: Package Import Robot
  • Author(s): Camm Maguire
  • Date: 2015-01-16 10:35:45 UTC
  • mfrom: (3.3.26 sid)
  • Revision ID: package-import@ubuntu.com-20150116103545-prehe9thgo79o8w8
Tags: 7.0-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
(in-package "ACL2")
 
2
#|
 
3
 
 
4
(ld ;; Newline to fool dependency scanner
 
5
  "theorems.lisp" :ld-pre-eval-print t)
 
6
 
 
7
 
 
8
theorems.lisp
 
9
 ------------------------------
 
10
Author------------------: Fares Fraij
 
11
Email-------------------: fares@ahu.edu.jo
 
12
Date of last revision---: July 25, 2008
 
13
The used version of ACL2: 2.9.2 (under WindowsXP)
 
14
 
 
15
 Objective:
 
16
 ---------
 
17
The goal of this book is to provide some proofs in directed acyclic graph 
 
18
(DAG) theory. First, we prove that given an acyclic directed graph, the 
 
19
replacement of any node within the graph with its siblings will NOT 
 
20
introduce cycles (i.e., the acyclicity of the graph is maintained). Second,
 
21
we prove that dereferencing a certain index, within such a graph, and 
 
22
dereferencing the same index after replacing an index with its sibling will
 
23
yield the same value.
 
24
 
 
25
 Background:
 
26
 ----------
 
27
The acyclic directed graph is modeled by a list. Each entry of the list
 
28
has two components: a node, which is a natural number referred to as index
 
29
henceforth, and a data object represents the nodes' direct siblings. 
 
30
This object may be an index, a string, or a structure consisting of 
 
31
indexes, strings, or a combination of both. The graph is assumed to have 
 
32
indexes as internal nodes and terminals (i.e., strings) as leafs.
 
33
 
 
34
This work proofs that applying certain substitutions (on the form of rules) 
 
35
to an acyclic graph maintains certain properties. A rule is a tuple 
 
36
consisting of two components: an index, which represents a node in the 
 
37
graph, and a data object which represents the nodes' direct siblings (or 
 
38
the transitive closure of the nodes' direct siblings). One of the properties 
 
39
that we are interested in is that applying such a rule to an acyclic graph
 
40
will maintain acyclicity. We are also interested in proving that dereferencing 
 
41
a certain index in the graph, before and after applying sucha rule, is the same.
 
42
 
 
43
|#
 
44
 
 
45
(include-book "./functions")
 
46
;; Lemma: assoc-replaceValue
 
47
;; This lemma describes the relation between the functions assoc and replaceValue.
 
48
(defthm assoc-replaceValue
 
49
  (implies (uniqueNodeIDp cp)
 
50
           (equal (assoc p (replaceValue i v cp))
 
51
                  (if (assoc i cp)
 
52
                      (if (equal p i) (cons p v) (assoc p cp))
 
53
                    (assoc p cp)))))
 
54
 
 
55
 
 
56
;; Lemma: uniqueNodeIDp-replaceValue
 
57
;; This lemma states that replaceValue preserves uniqueNodeIDp
 
58
(defthm uniqueNodeIDp-replaceValue
 
59
  (implies (uniqueNodeIDp cp)
 
60
           (uniqueNodeIDp (replaceValue i v cp))))
 
61
 
 
62
;; Lemma: acyclicp1-perm-congruence
 
63
;; This lemma states that given to lists, seen1 and seen2,
 
64
;; which are permutations of each others, then chasing 
 
65
;; an object in both of them leads to the same result. 
 
66
(defthm acyclicp1-perm-congruence
 
67
  (implies (perm seen1 seen2)
 
68
           (equal (acyclicp1 p cp seen1) (acyclicp1 p cp seen2)))
 
69
  :rule-classes :congruence)
 
70
 
 
71
;; Lemma: valueOf-replaceValue
 
72
;; This lemma describes the relation between the functions valueOf and replaceValue.
 
73
(defthm valueOf-replaceValue
 
74
  (implies (and (uniqueNodeIDp cp)
 
75
                (natp p))
 
76
           (equal (valueOf p (replaceValue i q cp))
 
77
                  (if (assoc i cp)
 
78
                      (if (equal p i)
 
79
                          q
 
80
                        (valueOf p cp))
 
81
                    (valueOf p cp))))
 
82
  :hints (("Goal" :in-theory (enable valueOf))))
 
83
 
 
84
;; Lemma: car-assoc
 
85
;; This lemma states that given the index x that exists as the car 
 
86
;; of an entry in the constant pool cp, then the car of that entry 
 
87
;; is x itself. 
 
88
(defthm car-assoc
 
89
  (implies (assoc x cp)
 
90
           (equal (car (assoc x cp)) x)))
 
91
 
 
92
 
 
93
;; Lemma: cdr-assoc
 
94
;; This lemma states that given a rule that belongs to the constant pool
 
95
;; cp, then the cdr of the result of looking up the car of rule in cp is
 
96
;; the cdr of rule itself.
 
97
(defthm cdr-assoc
 
98
  (implies (and (uniqueNodeIDp cp)
 
99
                (member-equal rule cp))
 
100
           (equal (cdr (assoc (car rule) cp)) (cdr rule))))
 
101
 
 
102
;; Lemma: assoc-natp
 
103
;; This lemma states that given an index i, which ocuurs as 
 
104
;; the car of an entry in cp and cp is well formed, then i is 
 
105
;; a natural number.
 
106
(defthm assoc-natp
 
107
  (implies (and (assoc i cp)
 
108
                (uniqueNodeIDp cp))
 
109
           (natp i))
 
110
  :rule-classes :forward-chaining)
 
111
 
 
112
;; Lemma: no-immediate-loops
 
113
;; This lemma states that given that the natural number index i and
 
114
;; that the object obj is acyclic in cp and the list that results
 
115
;; from adding i to seen, then there is no match between obj and
 
116
;; any entry that has i as its car. 
 
117
(defthm no-immediate-loops
 
118
  (implies (and (natp i)
 
119
                (acyclicp1 obj cp (cons i seen)))
 
120
           (not (matchValueRulep obj (cons i x))))
 
121
  :rule-classes nil)
 
122
 
 
123
;; Lemma: no-immediate-loops-useful
 
124
;; This lemma is a good rewrite rule version of the above lemma, 
 
125
;; namely no-immediate-loops since it does not contain free variables.
 
126
(defthm no-immediate-loops-useful
 
127
  (implies (and (uniqueNodeIDp cp)
 
128
                (assoc (car rule) cp) ;;
 
129
                (acyclicp1 (cdr rule)
 
130
                           cp (cons (car rule) seen)))
 
131
           (not (matchValueRulep (cdr rule)
 
132
                           rule)))
 
133
  :hints (("Goal" :use (:instance no-immediate-loops
 
134
                                  (i (car rule))
 
135
                                  (obj (cdr rule))
 
136
                                  (x (cdr rule))))))
 
137
 
 
138
(in-theory (enable acyclicp))
 
139
 
 
140
;; Lemma: acyclicp-car
 
141
;; This lemma states that given the acyclic object p in cp
 
142
;; and p is a cons, then the car of p is acyclic in cp.
 
143
(defthm acyclicp-car
 
144
  (implies (and (consp p)
 
145
                (acyclicp p cp))
 
146
           (acyclicp (car p) cp)))
 
147
 
 
148
;; Lemma: acyclicp-cdr
 
149
;; This lemma states that given the acyclic object p in cp
 
150
;; and p is a cons, then the cdr of p is acyclic in cp.
 
151
(defthm acyclicp-cdr
 
152
  (implies (and (consp p)
 
153
                (acyclicp p cp))
 
154
           (acyclicp (cdr p) cp)))
 
155
 
 
156
;; Lemma: acyclicp-valueOf
 
157
;; This next proof is a little more interesting: If p is 
 
158
;; acyclic, then (valueOf p c) is acyclic1 with respect to 
 
159
;; seen = (cons p nil).  But then by the acyclic1-cons theorem, 
 
160
;; (valueOf p c) is acyclic1 with respect to seen = nil, which means 
 
161
;; it is acyclic.
 
162
(defthm acyclicp-valueOf
 
163
  (implies (and (natp p)
 
164
                (acyclicp p cp))
 
165
           (acyclicp (valueOf p cp) cp))
 
166
  :hints
 
167
  (("Goal'" :expand (acyclicp1 p cp nil))))
 
168
 
 
169
;; Now I turn it back off...
 
170
(in-theory (disable acyclicp))
 
171
 
 
172
;; Lemma:  valueOf-apply-rule-to-entry-1
 
173
;; This lemma descibes the behavior of the functions valueOf and
 
174
;; apply-rule-to-entry-1: (valueOf p (apply-rule-to-entry-1 rule i c)).
 
175
(defthm valueOf-apply-rule-to-entry-1
 
176
  (implies (and (uniqueNodeIDp cp)
 
177
                (assoc i cp))
 
178
           (equal (valueOf p (apply-rule-to-entry-1 rule i cp))
 
179
                  (if (equal p i)
 
180
                      (if (matchValueRulep (valueOf p cp) rule)
 
181
                          (applySubstitution (valueOf p cp) rule)
 
182
                        (valueOf p cp))
 
183
                    (valueOf p cp))))
 
184
  :hints (("Goal" :in-theory (enable valueOf))))
 
185
 
 
186
;; Lemma: valueOf-apply-rule-to-entry
 
187
;; I prove a similar lemma of the above that describes the behavior of
 
188
;; the functions valueOf and apply-rule-entry: 
 
189
;; (valueOf p (apply-rule-to-entry rule i c)).
 
190
(defthm valueOf-apply-rule-to-entry
 
191
  (implies (and (uniqueNodeIDp cp)
 
192
                (assoc i cp))
 
193
           (equal (valueOf p (apply-rule-to-entry rule i cp))
 
194
                  (if (ok-rulep rule cp)
 
195
                      (valueOf p (apply-rule-to-entry-1 rule i cp))
 
196
                    (valueOf p cp))))
 
197
  :hints (("Goal" :in-theory (disable apply-rule-to-entry-1))))
 
198
 
 
199
;; Lemma: natp-car-assoc-i-c
 
200
;; This lemma states that if the car of looking up the index i in cp
 
201
;; is a natural number, then i exists as the car of an enry in cp. 
 
202
(defthm natp-car-assoc-i-c
 
203
  (implies (natp (car (assoc i cp)))
 
204
           (assoc i cp)))
 
205
 
 
206
 
 
207
;; The following Lemmas are two types:
 
208
;; (1) The first types states that given an index p that exists
 
209
;; as the car of an entry in cp, then this index also exists 
 
210
;; in cp after applying the following functions to it: 
 
211
;; apply-rule-to-entry-1, apply-rule-to-entry,  
 
212
;; apply-rule-list-to-entry, and once_tdl.
 
213
;; (2) The second types states that given a well formed cp,
 
214
;; then the cp will also be well fomed after applying 
 
215
;; apply-rule-to-entry-1, apply-rule-to-entry, 
 
216
;; apply-rule-list-to-entry, and once_tdl.
 
217
 
 
218
(defthm assoc-p-apply-rule-to-entry-1
 
219
  (implies (assoc p cp)
 
220
           (assoc p
 
221
                  (apply-rule-to-entry-1 rule i cp)))
 
222
  :hints (("Goal" :in-theory (enable valueOf))))
 
223
 
 
224
(defthm assoc-p-apply-rule-to-entry
 
225
  (implies (assoc p cp)
 
226
           (assoc p
 
227
                  (apply-rule-to-entry rule i cp)))
 
228
  :hints (("Goal" :in-theory (disable apply-rule-to-entry-1))))
 
229
 
 
230
 
 
231
(defthm uniqueNodeIDp-apply-rule-to-entry
 
232
  (implies (uniqueNodeIDp cp)
 
233
           (uniqueNodeIDp (apply-rule-to-entry rule 
 
234
                                                   i
 
235
                                                   cp))))
 
236
 
 
237
;; Theorem: acyclicp1-applySubstitution
 
238
;; This theorem states that given the well formed constant pool cp,
 
239
;; the object p, which is acyclic in cp given seen, and a rule that
 
240
;; has an acyclic cdr, then the object that results from replacing 
 
241
;; the occurences of (car rule) in p with (cdr rule) is also acyclic
 
242
;; in cp given the same seen.
 
243
(defthm acyclicp1-applySubstitution
 
244
  (implies (and (uniqueNodeIDp cp)
 
245
                (acyclicp1 p cp seen)
 
246
                (acyclicp1 (cdr rule) cp seen))
 
247
           (acyclicp1 (applySubstitution p rule) cp seen)))
 
248
 
 
249
;; Theorem: acyclicp-applySubstitution
 
250
;; This theorem states that given the well formed constant pool cp,
 
251
;; the object p, which is acyclic in cp, and a well fomed  rule in cp,
 
252
;; then the object that results from replacing the occurences of 
 
253
;; (car rule) in p with (cdr rule) is also acyclic in cp. Note that
 
254
;; this theorem serves as a wrapper for the previous theorem, namely
 
255
;; acyclicp1-applySubstitution
 
256
;; Main 1 
 
257
(defthm acyclicp-applySubstitution
 
258
  (implies (and (uniqueNodeIDp cp)
 
259
                (acyclicp p cp)
 
260
                (acyclicp (cdr rule) cp))
 
261
           (acyclicp (applySubstitution p rule) cp))
 
262
  :hints (("Goal" :in-theory (enable acyclicp))))
 
263
 
 
264
;; Lemma: acyclicp-assoc
 
265
;; This lemma states that given the natural number p that
 
266
;; is acyclic in cp, then p exists as the car of one of the
 
267
;; entries of cp.
 
268
(defthm acyclicp-assoc
 
269
  (implies (and (natp p)
 
270
                (acyclicp p cp))
 
271
           (assoc p cp))
 
272
  :hints (("Goal" :expand (acyclicp p cp))))
 
273
 
 
274
;; Lemma: assoc-acyclicp1-seen-acyclicp1-nil
 
275
;; This lemma states that given that natural number p
 
276
;; which occur as the car of one of the entries of cp and
 
277
;; the value bounded to p in cp is acyclic in cp given the
 
278
;; list (cons p seen), then p is acyclic in cp given the 
 
279
;; empty list, nil. 
 
280
(defthm assoc-acyclicp1-seen-acyclicp1-nil
 
281
  (implies (and (natp p)
 
282
                (assoc p cp)
 
283
                (acyclicp1 (valueOf p cp) cp (cons p seen)))
 
284
           (acyclicp1 p cp nil))
 
285
  :hints (("goal" :expand (acyclicp1 p cp nil)
 
286
           :use (:instance subsetp-acyclicp1
 
287
                           (p (valueOf p cp))
 
288
                           (visited1 (list p))
 
289
                           (visited2 (cons p seen))))))
 
290
 
 
291
 
 
292
;; Lemma: acyclicp1-seen-acyclicp1-nil
 
293
;; This lemma states that if the index p is acyclic
 
294
;; in cp given the list seen, the p is also acyclic
 
295
;; in cp given the empty list, nil.
 
296
(defthm acyclicp1-seen-acyclicp1-nil
 
297
  (implies (acyclicp1 p cp seen)
 
298
           (acyclicp1 p cp nil)))
 
299
 
 
300
;; Lemma: acyclicp1-p-acyclicp1-valueOf
 
301
;; This lemma states that if the index p is acyclic
 
302
;; in cp given the list seen, the (valueOf p cp) is also acyclic
 
303
;; in cp given seen = (cons p seen)
 
304
(defthm acyclicp1-seen-acyclicp1-valueOf-seen
 
305
  (implies (and (acyclicp1 p cp seen)
 
306
                (natp p))
 
307
           (acyclicp1 (valueOf p cp) cp seen))
 
308
  :rule-classes :forward-chaining)
 
309
 
 
310
;; Theorem: dref-applySubstitution
 
311
;; This theorem states that given the well formed cp, the well formed
 
312
;; rule in cp, and the acyclic object p in cp, then the result of dereferencing
 
313
;; p in cp is the same as dereferencing the modified p in cp. P is modified by 
 
314
;; replacing every ocuurence of the (car rule) in p with (cdr rule).
 
315
;; Main 2
 
316
(defthm dref-applySubstitution
 
317
  (implies (and (uniqueNodeIDp cp)
 
318
                (acyclicp p cp)
 
319
                (acyclicp (cdr rule) cp)
 
320
                (equal (dref (car rule) cp)
 
321
                       (dref (cdr rule) cp))) ;;
 
322
           (equal (dref (applySubstitution p rule) cp)
 
323
                  (dref p cp)))
 
324
  :hints (("Goal" :in-theory (enable acyclicp))))
 
325
; (i-am-here)
 
326
;; Lemma: subsetp-union-equal-or
 
327
;; This lemma states that if x is a subset of y
 
328
;; and a is a subset of x union y, then either 
 
329
;; a is subset of x or a is subset of y.
 
330
(defthm subsetp-union-equal-or
 
331
  (implies  (and (subsetp x y)
 
332
                 (subsetp a (union-equal x y)))
 
333
            (or (subsetp a x)
 
334
                (subsetp a y)))
 
335
  :rule-classes :forward-chaining)
 
336
 
 
337
#||
 
338
; [Removed by Matt K. to handle changes to member, assoc, etc. after ACL2 4.2.]
 
339
 
 
340
;; Lemma: member-is-member-equal
 
341
;; This I developed since I wanted to 
 
342
;; consentarate on the use of member-equal 
 
343
;; instead of member. These two predicates are 
 
344
;; equivalent in the logic mode; however,
 
345
;; they are different in the programming mode. 
 
346
(defthm member-is-member-equal
 
347
  (equal (member i seen)
 
348
         (member-equal i seen)))
 
349
||#
 
350
 
 
351
;; Lemma(s): The following set of lemmas are general 
 
352
;; facts about set theory operations.
 
353
;; Begin of set general set theory lemmas
 
354
(defthm member-equal-intersectp
 
355
  (implies (member-equal i x)
 
356
           (intersectp-equal x (cons i seen))))
 
357
 
 
358
(defthm intersectp-equal-x-y-seen
 
359
  (iff (intersectp-equal (union-equal x
 
360
                                      y)
 
361
                         seen)
 
362
       (or (intersectp-equal x seen)
 
363
           (intersectp-equal y seen))))
 
364
 
 
365
;; Lemma-1 
 
366
(defthm intersectp-equal-not-acyclicp1
 
367
  (implies (intersectp-equal (all-indexes-in-obj obj) seen)
 
368
           (not (acyclicp1 obj
 
369
                           cp seen))))
 
370
;; lemma-2
 
371
(defthm not-acyclicp-cons-any
 
372
  (implies (not (acyclicp1 obj cp seen))
 
373
           (not (acyclicp1 obj cp (cons any seen)))))
 
374
 
 
375
;; Lemma-3: needs Lemma-1 + Lemma-2
 
376
(defthm intersectp-equal-indexes-acyclicp1
 
377
  (implies (intersectp-equal (indexes-from-obj i cp)
 
378
                             seen)
 
379
           (equal (acyclicp1 i cp seen) nil)))
 
380
 
 
381
(defthm member-intersectp-equal
 
382
  (implies (and (member-equal e x)
 
383
                (member-equal e y))
 
384
           (intersectp-equal x y)))
 
385
 
 
386
(defthm member-equal-union-equal
 
387
  (iff  (member-equal i (union-equal y z))
 
388
        (or (member-equal i z)
 
389
            (member-equal i y))))
 
390
;; End of set general set theory lemmas
 
391
;;--------------------------------------------------
 
392
 
 
393
;;--------------------------------------------------
 
394
;; Lemma: transitivity-of-member-equal
 
395
;; In this lemma I start to use the function 
 
396
;; indexes-from-obj, which takes as inputs the object p 
 
397
;; and a cp and returns all the indexes on the paths starting
 
398
;; from p.
 
399
;; This lemma states that given that the index i is member 
 
400
;; on the set of all indexes in cp strating from p and 
 
401
;; j is a member on the set of all indexes in cp starting 
 
402
;; from i, then j is a member on the set of all indexes in 
 
403
;; cp starting from p.
 
404
;; Another way to express the idea of this lemma is that:
 
405
;; if the index i is within the subtree of the indexes strating
 
406
;; from p and the index j is within the subtree of indexes 
 
407
;; starting from i, then j is within the subtree of indexes 
 
408
;; starting from p.
 
409
 
 
410
;; Lemma-1
 
411
(defthm  acyclicp-member-equal-all-indexes
 
412
  (implies (and (acyclicp obj cp)
 
413
                (member-equal i (all-indexes-in-obj obj))
 
414
                (member-equal j (indexes-from-obj i cp)))
 
415
           (member-equal j (indexes-from-obj obj cp))))
 
416
 
 
417
;; Lemma-2 needs Lemma-1
 
418
(defthm transitivity-of-member-equal
 
419
  (implies (and (member-equal i (indexes-from-obj p cp))
 
420
                (member-equal j (indexes-from-obj i cp)))
 
421
           (member-equal j (indexes-from-obj p cp))))
 
422
 
 
423
 
 
424
;;------------------------------------------------------------
 
425
;; Lemma: member-equal-subset-index-from-obj
 
426
;; This lemma states that if the index i is within the 
 
427
;; the subtree starting from p, then the set of indexes 
 
428
;; starting from i in cp is a subset from the set of
 
429
;; indexes strating from p in cp.
 
430
(defthm acyclicp-member-equal-all-indexes-from
 
431
  (implies (and (acyclicp obj cp)
 
432
                (member-equal i (all-indexes-in-obj obj)))
 
433
           (subsetp (indexes-from-obj i cp)
 
434
                    (indexes-from-obj obj cp))))
 
435
 
 
436
(defthm member-equal-subset-index-from-obj
 
437
  (implies (member-equal i (indexes-from-obj p cp))
 
438
           (subsetp (indexes-from-obj i cp)
 
439
                    (indexes-from-obj p cp))))
 
440
 
 
441
 
 
442
;;------------------------------------------------------------
 
443
;; Lemma: subsetp-member-equal-i-subsetp-cons-i
 
444
;; This lemma states that given the set of indexes
 
445
;; starting from i in cp is a subset from the set
 
446
;; of indexes strating from p in cp and i is 
 
447
;; within the subtree starting from p, then 
 
448
;; the set that results from adding the index i to 
 
449
;; the set of indexes starting from the index 
 
450
;; associated with i in cp is a subset from the set
 
451
;; of indexes strating from p.
 
452
;; The following lemmas are about the relation between 
 
453
;; subset, indexes-from-obj, and member.
 
454
;;---------------------------------------------------
 
455
;; Begin of lemmas that are about the relation between 
 
456
;; subset, indexes-from-obj, and member.
 
457
(defthm acyclicp-member-equal-all-indexes-fron-valueOf
 
458
  (implies (and (acyclicp obj cp)
 
459
                (member-equal i (all-indexes-in-obj obj)))
 
460
           (subsetp (indexes-from-obj (valueOf i cp) cp)
 
461
                    (indexes-from-obj obj cp))))
 
462
 
 
463
(defthm subsetp-member-equal-i-subsetp-cons-i
 
464
  (implies (and (subsetp (indexes-from-obj i cp) 
 
465
                         (indexes-from-obj p cp))
 
466
                (member-equal i (indexes-from-obj p cp)))
 
467
           (subsetp (cons i (indexes-from-obj (valueOf i cp) cp))
 
468
                    (indexes-from-obj p cp)))
 
469
  :rule-classes :forward-chaining)
 
470
 
 
471
(defthm subsetp-member-equal-i-subsetp-cons-i-1
 
472
  (implies (and (subsetp (indexes-from-obj i cp) 
 
473
                         (indexes-from-obj p cp))
 
474
                (member-equal i (indexes-from-obj p cp)))
 
475
           (subsetp (indexes-from-obj (valueOf i cp) cp)
 
476
                    (indexes-from-obj p cp)))
 
477
  :rule-classes :forward-chaining)
 
478
 
 
479
(defthm not-subsetp-pfo-valueOf-not-member-equal-pfo
 
480
  (implies (not (subsetp (indexes-from-obj (valueOf i cp) cp)
 
481
                         (indexes-from-obj p1 cp)))
 
482
           (not (member-equal i (indexes-from-obj p1 cp))))
 
483
  :rule-classes :forward-chaining)
 
484
 
 
485
(defthm not-subsetp-cons-pfo-valueOf-not-member-equal-pfo
 
486
  (implies (not (subsetp (cons i (indexes-from-obj (valueOf i cp) cp))
 
487
                         (indexes-from-obj p1 cp)))
 
488
           (not (member-equal i (indexes-from-obj p1 cp))))
 
489
  :rule-classes :forward-chaining)
 
490
;;---------------------------------------------------
 
491
;; End of lemmas that are about the relation between 
 
492
;; subset, indexes-from-obj, and member.
 
493
;;----------------------------------------------------
 
494
 
 
495
;; Lemma acyclicp1-car-cdr states that given an object p
 
496
;; in which its first and its second components are acyclic
 
497
;; in the constant pool cp, Then the object p itself is 
 
498
;; acyclic in cp.
 
499
 
 
500
(defthm acyclicp1-car-cdr
 
501
  (implies (and (consp p)
 
502
                (acyclicp1 (car p) cp seen)
 
503
                (acyclicp1 (cdr p) cp seen))
 
504
           (acyclicp p cp))
 
505
  :hints (("Goal" :in-theory (enable acyclicp))))
 
506
 
 
507
;; Lemma acyclicp1-valueOf-p-c-assoc-p-c states that given 
 
508
;; a natural number p for which the object associated 
 
509
;; with in cp is acyclic in cp with respect to list of 
 
510
;; encountered indexes so far, namely seen, then p 
 
511
;; itself is acyclic in cp with respect to seen.
 
512
 
 
513
(defthm acyclicp1-valueOf-p-c-assoc-p-c
 
514
  (implies (and (natp p)
 
515
                (acyclicp1 (valueOf p cp) cp (cons p seen)))
 
516
           (assoc p cp))
 
517
  :hints (("Goal" :in-theory (enable valueOf acyclicp))))
 
518
 
 
519
;; Lemma acyclicp1-valueOf-p-c-acyclicp1-p is a more
 
520
;; restricted version of the Lemma 
 
521
;; acyclicp1-valueOf-p-c-assoc-p-c (above).
 
522
 
 
523
(defthm acyclicp1-valueOf-p-c-acyclicp1-p
 
524
  (implies (and (natp p)
 
525
                (acyclicp1 (valueOf p cp) cp (cons p seen)))
 
526
           (acyclicp p cp))
 
527
  :hints (("Goal" :in-theory (enable acyclicp))))
 
528
 
 
529
;; Lemma assoc-p-c-assoc-p-replaceValue-i-x-c states that if 
 
530
;; an index is associated with a cp, then it is also 
 
531
;; associated with the cp that results from inserting
 
532
;; an index i in original cp.
 
533
(defthm assoc-p-c-assoc-p-replaceValue-i-x-c
 
534
  (implies (assoc p cp)
 
535
           (assoc p (replaceValue i x cp))))
 
536
           
 
537
;; Lemma acyclicp1-a-replaceValue-i-x-c-seen-1 states that given
 
538
;; an ok constant pool, an acyclic pointer, p, in the cp
 
539
;; wrt seen, and i is not reachable from p, then p is 
 
540
;; also acyclic wrt seen in the result of inserting 
 
541
;; an index i associated with object x in the original cp.
 
542
  
 
543
(encapsulate ()
 
544
             (local (in-theory (disable 
 
545
                                intersectp-equal-indexes-acyclicp1
 
546
                                natp-car-assoc-i-c
 
547
                                assoc
 
548
                                union-equal
 
549
                                intersectp-equal)))
 
550
 
 
551
             (defthm acyclicp1-a-replaceValue-i-x-c-seen-1
 
552
               (implies (and (uniqueNodeIDp cp)
 
553
                             (acyclicp1 p cp seen)
 
554
                             (or (and (consp p)
 
555
                                      (not (member-equal 
 
556
                                            i 
 
557
                                            (all-indexes-in-obj p))))
 
558
                                 (and (natp p)
 
559
                                      (not (equal p i))))
 
560
                             (not (member-equal i (indexes-from-obj p cp))))
 
561
                        (acyclicp1 p (replaceValue i x cp) seen))))
 
562
 
 
563
 
 
564
;; Lemma acyclicp-applySubstitution-replaceValue-1 is a more restricted 
 
565
;; version of Lemma acyclicp1-a-replaceValue-i-x-c-seen-1 (above)
 
566
 
 
567
(defthm acyclicp-applySubstitution-replaceValue-1
 
568
  (implies (and (uniqueNodeIDp cp)
 
569
                (acyclicp p cp)
 
570
                (or (and (consp p)
 
571
                         (not (member-equal i (all-indexes-in-obj p))))
 
572
                    (and (natp p)
 
573
                         (not (equal p i))))
 
574
                (not (member-equal i (indexes-from-obj p cp))))
 
575
           (acyclicp p
 
576
                    (replaceValue i any cp)))
 
577
  :hints (("Goal" :in-theory (enable acyclicp))))
 
578
 
 
579
;; Lemma not-subsetp-not-member-equal-1 states that given
 
580
;; that the set of indexes starting from i in cp is not a subset 
 
581
;; of that from x in cp, then i does not belong to the set
 
582
;; of indexes from x in cp.
 
583
 
 
584
(defthm not-subsetp-not-member-equal-1
 
585
  (implies (not (subsetp (indexes-from-obj i cp)
 
586
                         (indexes-from-obj x cp)))
 
587
           (not (member-equal i (indexes-from-obj x cp)))))
 
588
 
 
589
;; Lemma acyclicp1-subsetp-pfo-valueOf-pfo states that given an ok 
 
590
;; constant pool, cp, the index i is associated with an entry in cp, 
 
591
;; and i is acyclic in cp wrt seen, then the set of indexes 
 
592
;; starting from the object associated with i in cp is a subset 
 
593
;; of that from i in cp.
 
594
 
 
595
(defthm acyclicp1-subsetp-pfo-valueOf-pfo
 
596
  (implies (and (assoc i cp)
 
597
                (uniqueNodeIDp cp)
 
598
                (acyclicp1 i cp seen))
 
599
           (subsetp (indexes-from-obj (valueOf i cp) cp)
 
600
                    (indexes-from-obj i cp)))
 
601
  :rule-classes :forward-chaining)
 
602
 
 
603
;; Lemma acyclicp-subsetp-pfo-valueOf-pfo is a more restrictive 
 
604
;; version of Lemma acyclicp1-subsetp-pfo-valueOf-pfo (above).
 
605
(defthm acyclicp-subsetp-pfo-valueOf-pfo
 
606
  (implies (and (assoc i cp)
 
607
                (uniqueNodeIDp cp)
 
608
                (acyclicp i cp))
 
609
           (subsetp (indexes-from-obj (valueOf i cp) cp)
 
610
                    (indexes-from-obj i cp)))
 
611
  :rule-classes :forward-chaining)
 
612
 
 
613
;; Lemma acyclicp1-not-member-equal-pfo states that given an ok 
 
614
;; constant pool, cp, the index i is associated with an entry in cp, 
 
615
;; and i is acyclic in cp wrt seen, then i does not belong to 
 
616
;; the set of indexes starting from the object assocted with 
 
617
;; i in cp.
 
618
 
 
619
(defthm acyclicp1-not-member-equal-pfo
 
620
  (implies (and (assoc i cp)
 
621
                (uniqueNodeIDp cp)
 
622
                (acyclicp1 i cp seen))
 
623
           (not (member-equal i (indexes-from-obj (valueOf i cp) cp))))
 
624
  :rule-classes (:rewrite :forward-chaining))
 
625
 
 
626
;; Lemma acyclicp-not-member-equal-pfo is a more restrictive 
 
627
;; version of Lemma acyclicp1-not-member-equal-pfo (above).
 
628
(defthm acyclicp-not-member-equal-pfo
 
629
  (implies (and (assoc i cp)
 
630
                (uniqueNodeIDp cp)
 
631
                (acyclicp i cp))
 
632
           (not (member-equal i (indexes-from-obj (valueOf i cp) cp))))
 
633
  :hints (("Goal" :in-theory (enable acyclicp)))
 
634
  :rule-classes (:rewrite :forward-chaining))
 
635
 
 
636
;; Lemma subsetp-not-subsetp-member-equal states that
 
637
;; if x is subset of the list that results from adding 
 
638
;; the element i to y, and x is not a subset of y,
 
639
;; then i is equal to x.
 
640
(defthm subsetp-not-subsetp-member-equal
 
641
  (implies (and (subsetp x
 
642
                         (cons i y))
 
643
                (not (subsetp x
 
644
                              y)))
 
645
           (member-equal i x))
 
646
  :rule-classes :forward-chaining)
 
647
 
 
648
;; Lemma perm-list-1 states that given the acyclic object (valueOf i cp), which represents
 
649
;; the object associated with i in cp, wrt to the list that consists of adding
 
650
;; i and p to seen, then the object (valueOf i cp) is also acyclic in cp wrt the
 
651
;; list that consists of adding p and i to seen. 
 
652
(defthm perm-list-1
 
653
  (implies (acyclicp1 (valueOf i cp) cp (list* p i seen))
 
654
           (acyclicp1 (valueOf i cp) cp (list* i p seen)))
 
655
  :rule-classes :forward-chaining)
 
656
 
 
657
;; Lemma member-equal-subsetp-member-equal states that 
 
658
;; if the element i is member in the list x, and x is a subset 
 
659
;; of the list y, then i is belongs to y.
 
660
(defthm member-equal-subsetp-member-equal
 
661
  (implies (and (member-equal i x)
 
662
                (subsetp x y))
 
663
           (member-equal i y)))
 
664
 
 
665
;; Lemma matchValueRulep-valueOf-rule-implies-member-objp-r1-valueOf states that 
 
666
;; if there is a match between the object valueOf and rule, then 
 
667
;; the first component of the rule belongs to valueOf.
 
668
 
 
669
(defthm matchValueRulep-valueOf-rule-implies-member-objp-r1-valueOf
 
670
  (implies (matchValueRulep valueOf rule)
 
671
           (member-objp (car rule) valueOf)))
 
672
;;[x]
 
673
 
 
674
;; Lemma acyclicp1-obj-member-objp-i-acyclicp1-i states that given 
 
675
;; an acyclic object valueOf in cp wrt seen and the element i belongs to valueOf,
 
676
;; then i is also acyclic in cp wrt seen.
 
677
 
 
678
(defthm acyclicp1-obj-member-objp-i-acyclicp1-i
 
679
  (implies (and (acyclicp1 valueOf cp seen)
 
680
                (member-objp i valueOf))
 
681
           (acyclicp1 i cp seen)))
 
682
;;[x]
 
683
 
 
684
;; Lemma acyclicp1-obj-member-objp-i-acyclicp1-i-1 is a restricted
 
685
;; version of Lemma acyclicp1-obj-member-objp-i-acyclicp1-i (above).
 
686
 
 
687
(defthm acyclicp1-obj-member-objp-i-acyclicp1-i-1
 
688
  (implies (and (acyclicp valueOf cp)
 
689
                (member-objp i valueOf))
 
690
           (acyclicp i cp)))
 
691
;;[x]
 
692
 
 
693
(defthm matchValueRulep-member-i-valueOf-subsetp-pfo-i
 
694
  (implies (and (matchValueRulep valueOf rule)
 
695
                (acyclicp1 valueOf cp seen))
 
696
           (subsetp (indexes-from-obj (car rule) cp)
 
697
                    (indexes-from-obj valueOf cp))))
 
698
;;[x]
 
699
                    
 
700
;; Lemma i-not-member-valueOf-subsetp-pfo-r1-valueOf states that
 
701
;; given that the index i is not reachable from the object valueOf in cp, 
 
702
;; there is a match between the index i and rule, and valueOf is acyclic
 
703
;; in cp wrt seen, then i is not reachable from the first 
 
704
;; component of rule. 
 
705
(defthm i-not-member-valueOf-subsetp-pfo-r1-valueOf
 
706
  (implies (and (not (member-equal i (indexes-from-obj valueOf cp)))
 
707
                (matchValueRulep valueOf rule)
 
708
                (acyclicp1 valueOf cp seen))
 
709
           (not (member-equal i (indexes-from-obj (car rule) cp)))))
 
710
;;[x]
 
711
 
 
712
;; Lemma not-member-i-pfo-valueOf-matchValueRulep-valueOf-rule-not-member-i-pfo-cdr-rule
 
713
;; states that given that the index i is not reachable from object valueOf 
 
714
;; in cp, there is a match between valueOf and rule, valueOf is acyclic in cp 
 
715
;; wrt seen, and the set of indexes accumulated from the second 
 
716
;; component of rule in cp is a subset of that accumulated from the 
 
717
;; first component of rule in cp, then the index i is not reachable
 
718
;; from the second component of rule in cp.
 
719
(defthm not-member-i-pfo-valueOf-matchValueRulep-valueOf-rule-not-member-i-pfo-cdr-rule
 
720
  (implies (and (not (member-equal i (indexes-from-obj valueOf cp)))
 
721
                (matchValueRulep valueOf rule)
 
722
                (acyclicp1 valueOf cp seen)
 
723
                (subsetp (indexes-from-obj (cdr rule) cp)
 
724
                         (indexes-from-obj (car rule) cp)))
 
725
           (not (member-equal i (indexes-from-obj (cdr rule) cp)))))
 
726
;;[x]
 
727
 
 
728
(encapsulate ()
 
729
             (local (in-theory (disable 
 
730
                                member-equal
 
731
                                intersectp-equal-not-acyclicp1
 
732
                                union-equal
 
733
                                intersectp-equal-indexes-acyclicp1
 
734
                                natp-car-assoc-i-c
 
735
                                intersectp-equal
 
736
                                assoc
 
737
                                member-objp
 
738
                                all-indexes-in-obj
 
739
                                not-subsetp-not-member-equal-1
 
740
                                not-acyclicp-cons-any
 
741
                                acyclicp1-obj-member-objp-i-acyclicp1-i-1
 
742
                                acyclicp-assoc
 
743
                                acyclicp-member-equal-all-indexes
 
744
                                uniqueNodeIDp)))
 
745
 
 
746
             ;; Lemma acyclicp1-not-member-equal-pfo-applySubstitution
 
747
             ;; states that given a rule that represent a cons, the first 
 
748
             ;; component of the rule appears as the first component of 
 
749
             ;; an entry in cp, an ok constant pool, cp, the set of indexes 
 
750
             ;; accumulated from the second component of rule in cp is 
 
751
             ;; a subset of that accumulated from the first component of 
 
752
             ;; rule in cp, the second component of the rule is acyclic 
 
753
             ;; in cp wrt seen, the object x is acyclic in cp wrt seen, 
 
754
             ;; and the index i is not reachable from object x in cp, 
 
755
             ;; then the index i is not reachable from the object that 
 
756
             ;; results from replacing every occurence of the rhs of 
 
757
             ;; the rule in x with the lhs of the rule. 
 
758
 
 
759
             (defthm acyclicp1-not-member-equal-pfo-applySubstitution
 
760
               (implies (and (consp rule)
 
761
                             (uniqueNodeIDp cp)
 
762
                             (assoc (car rule) cp)
 
763
                             (subsetp (indexes-from-obj (cdr rule) cp)
 
764
                                      (indexes-from-obj (car rule) cp))
 
765
                             (acyclicp1 (cdr rule) cp seen)
 
766
                             (acyclicp1 x cp seen)
 
767
                             (not (member-equal i (indexes-from-obj x cp))))
 
768
                        (not (member-equal i 
 
769
                                           (indexes-from-obj 
 
770
                                            (applySubstitution x rule) 
 
771
                                            cp))))))
 
772
;;[x]
 
773
 
 
774
;; Lemma not-assoc-i-cp-replaceValue-i-cp-is-cp states that 
 
775
;; given the ok constant pool cp and the index i 
 
776
;; does not belong to the domain of cp, then 
 
777
;; the result of inserting the object that associates 
 
778
;; the index i with the object any is actually cp itself. 
 
779
(defthm not-assoc-i-cp-replaceValue-i-cp-is-cp
 
780
  (implies (and (uniqueNodeIDp cp)
 
781
                (not (assoc i cp)))
 
782
           (equal (replaceValue i any cp)
 
783
                  cp)))
 
784
;;[x]
 
785
 
 
786
(encapsulate ()
 
787
             (local (in-theory (disable 
 
788
                                intersectp-equal-not-acyclicp1
 
789
                                union-equal
 
790
                                intersectp-equal-indexes-acyclicp1
 
791
                                natp-car-assoc-i-c
 
792
                                intersectp-equal
 
793
                                assoc
 
794
                                member-objp)))
 
795
 
 
796
             ;; Lemma acyclicp1-applySubstitution-replaceValue-1 states that
 
797
             ;; given an ok constant pool, cp, the index i is 
 
798
             ;; acyclic in cp wrt seen, the object p is acyclic 
 
799
             ;; in cp wrt seen, the index i is not reachable 
 
800
             ;; from the object p in cp, then the object p is 
 
801
             ;; acyclic in the new cp, which results from associating 
 
802
             ;; the index i with the bject any in the orignal cp,
 
803
             ;; wrt seen.
 
804
             (defthm acyclicp1-applySubstitution-replaceValue-1
 
805
               (implies (and (uniqueNodeIDp cp)
 
806
                             (acyclicp1 i cp seen)
 
807
                             (acyclicp1 p cp seen)
 
808
                             (not (member-equal i (all-indexes-in-obj p)))
 
809
                             (not (member-equal i (indexes-from-obj p cp))))
 
810
                        (acyclicp1 p
 
811
                                   (replaceValue i any cp)
 
812
                                   seen)))
 
813
             ;;[x]
 
814
             ;; Lemma acyclicp1-not-member-equal-pfo-acyclicp1
 
815
             ;; states that given an acyclic index, i, in cp
 
816
             ;; wrt seen and i is not reachable from the index p, 
 
817
             ;; i is not reachable from the index p, 
 
818
             ;; then the index i is acyclic in cp wrt to the new 
 
819
             ;; list that results from adding p to seen.
 
820
             (defthm acyclicp1-not-member-equal-pfo-acyclicp1
 
821
               (implies (and (acyclicp1 i cp seen)
 
822
                             (not (member-equal p (all-indexes-in-obj i)))
 
823
                             (not (member-equal p (indexes-from-obj i cp))))
 
824
                        (acyclicp1 i cp (cons p seen))))
 
825
             ;;[x]
 
826
             )
 
827
 
 
828
;; Lemma acyclicp1-assoc-acyclicp1-valueOf states that given
 
829
;; an ok constant pool, cp, an acyclic index i in cp 
 
830
;; wrt seen, and i appears as the first component of 
 
831
;; of an entry in cp, then the object associated with 
 
832
;; i in cp is also acyclic wrt seen.
 
833
 
 
834
(defthm acyclicp1-assoc-acyclicp1-valueOf 
 
835
  (implies (and (uniqueNodeIDp cp)
 
836
                (acyclicp1 i cp seen)
 
837
                (assoc i cp))
 
838
           (acyclicp1 (valueOf i cp) cp seen))
 
839
  :rule-classes :forward-chaining)
 
840
;;[x]
 
841
 
 
842
;; Lemma acyclicp-assoc-acyclicp1-valueOf  is a restricted
 
843
;; version of Lemma acyclicp1-assoc-acyclicp1-valueOf (above).
 
844
(defthm acyclicp-assoc-acyclicp1-valueOf 
 
845
  (implies (and (uniqueNodeIDp cp)
 
846
                (acyclicp i cp)
 
847
                (assoc i cp))
 
848
           (acyclicp (valueOf i cp) cp))
 
849
  :rule-classes :forward-chaining)
 
850
;;[x]
 
851
 
 
852
;; Lemma acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-1 
 
853
;; states that given an ok constant pool, cp, an acyclic 
 
854
;; index i in cp wrt seen, i appears as the first component of 
 
855
;; of an entry in cp, and the index x belongs to the object 
 
856
;; (valueOf i cp) that is associated with i in cp, then x 
 
857
;; is acyclic in cp wrt seen. 
 
858
 
 
859
(defthm acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-1
 
860
  (implies (and (uniqueNodeIDp cp)
 
861
                (acyclicp1 i cp seen)
 
862
                (assoc i cp)
 
863
                (member-objp x (valueOf i cp)))
 
864
           (acyclicp1 x cp seen)))
 
865
;;[x]
 
866
 
 
867
;; Lemma acyclicp-obj-member-objp-i-acyclicp1-i-1-prime-1 
 
868
;; is a restricted version of Lemma
 
869
;; acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-1 (above).
 
870
(defthm acyclicp-obj-member-objp-i-acyclicp1-i-1-prime-1
 
871
  (implies (and (uniqueNodeIDp cp)
 
872
                (acyclicp i cp)
 
873
                (assoc i cp)
 
874
                (member-objp x (valueOf i cp)))
 
875
           (acyclicp x cp)))
 
876
;;[x]
 
877
 
 
878
;; Lemma acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-2
 
879
;; states that given an ok constant pool, cp, an acyclic 
 
880
;; index i in cp wrt seen, i appears as the first component of 
 
881
;; of an entry in cp, and the index x is equal to i, then x 
 
882
;; is acyclic in cp wrt seen. 
 
883
 
 
884
(defthm acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-2
 
885
  (implies (and (uniqueNodeIDp cp)
 
886
                (acyclicp1 i cp seen)
 
887
                (assoc i cp)
 
888
                (member-equal x (all-indexes-in-obj i)))
 
889
           (acyclicp1 x cp seen)))
 
890
;;[x]
 
891
 
 
892
;; Lemma acyclicp-obj-member-objp-i-acyclicp1-i-1-prime-2-1
 
893
;; is a restricted version of Lemma
 
894
;; acyclicp1-obj-member-objp-i-acyclicp1-i-1-prime-2 (above).
 
895
(defthm acyclicp-obj-member-objp-i-acyclicp1-i-1-prime-2-1
 
896
  (implies (and (uniqueNodeIDp cp)
 
897
                (acyclicp i cp)
 
898
                (assoc i cp)
 
899
                (member-equal x (all-indexes-in-obj i)))
 
900
           (acyclicp x cp)))
 
901
;;[x]
 
902
 
 
903
;; Lemma matchValueRulep-member-i-valueOf-subsetp-pfo-i-1
 
904
;; states that given an ok constant pool, cp, an acyclic 
 
905
;; index i in cp wrt seen, i appears as the first component of 
 
906
;; of an entry in cp, and a match exists between 
 
907
;; the object (valueOf i cp), which represents the object
 
908
;; associated with i in cp, and rule, then
 
909
;; the set of indexes accumulated from the first component 
 
910
;; of rule in cp is a subset of that accumulated from i in cp.
 
911
(defthm matchValueRulep-member-i-valueOf-subsetp-pfo-i-1
 
912
  (implies (and (matchValueRulep (valueOf i cp) rule)
 
913
                (uniqueNodeIDp cp)
 
914
                (acyclicp1 i cp seen)
 
915
                (assoc i cp))
 
916
           (subsetp (indexes-from-obj (car rule) cp)
 
917
                    (indexes-from-obj i cp))))
 
918
;;[x]
 
919
 
 
920
;; Lemma matchValueRulep-member-i-valueOf-subsetp-pfo-i-1-1
 
921
;; is a restricted version of Lemma
 
922
;; matchValueRulep-member-i-valueOf-subsetp-pfo-i-1 (above).
 
923
(defthm matchValueRulep-member-i-valueOf-subsetp-pfo-i-1-1
 
924
  (implies (and (matchValueRulep (valueOf i cp) rule)
 
925
                (uniqueNodeIDp cp)
 
926
                (acyclicp i cp)
 
927
                (assoc i cp))
 
928
           (subsetp (indexes-from-obj (car rule) cp)
 
929
                    (indexes-from-obj i cp)))
 
930
  :hints (("Goal" :use ((:instance matchValueRulep-member-i-valueOf-subsetp-pfo-i-1
 
931
                                   (seen nil)))
 
932
           :in-theory (e/d (acyclicp) 
 
933
                           (matchValueRulep-member-i-valueOf-subsetp-pfo-i-1)))))
 
934
;;[x]
 
935
 
 
936
;;----------------------------------
 
937
(encapsulate ()
 
938
             (local (in-theory (disable 
 
939
                                intersectp-equal-not-acyclicp1
 
940
                                union-equal
 
941
                                intersectp-equal-indexes-acyclicp1
 
942
                                natp-car-assoc-i-c
 
943
                                intersectp-equal
 
944
                                assoc
 
945
                                member-objp)))
 
946
                    
 
947
              ;; Lemma i-not-member-valueOf-subsetp-pfo-r1-valueOf-1-       
 
948
              ;; states that given the object p is not reachable 
 
949
              ;; from the index i, an ok constant pool, cp, 
 
950
              ;; an acyclic index i in cp wrt seen, i appears 
 
951
              ;; as the first component of of an entry in cp, 
 
952
              ;; and a match exists between the object (valueOf i cp), 
 
953
              ;; which represents the object associated with i 
 
954
              ;; in cp, and rule, then p is not reachable 
 
955
              ;; from the first component of rule.
 
956
 
 
957
              (defthm i-not-member-valueOf-subsetp-pfo-r1-valueOf-1-
 
958
                (implies (and (not (member-equal p (indexes-from-obj i cp)))
 
959
                              (uniqueNodeIDp cp)
 
960
                              (acyclicp1 i cp seen)
 
961
                              (assoc i cp)
 
962
                              (matchValueRulep (valueOf i cp) rule))
 
963
                         (not (member-equal p (indexes-from-obj (car rule) cp)))))
 
964
              ;;[x]
 
965
 
 
966
              ;; Lemma i-not-member-valueOf-subsetp-pfo-r1-valueOf-1-1- is 
 
967
              ;; a restricted version of Lemma 
 
968
              ;; i-not-member-valueOf-subsetp-pfo-r1-valueOf-1-     
 
969
              (defthm i-not-member-valueOf-subsetp-pfo-r1-valueOf-1-1-
 
970
                (implies (and (not (member-equal p (indexes-from-obj i cp)))
 
971
                              (uniqueNodeIDp cp)
 
972
                              (acyclicp i cp)
 
973
                              (assoc i cp)
 
974
                              (matchValueRulep (valueOf i cp) rule))
 
975
                         (not (member-equal p (indexes-from-obj (car rule) cp))))
 
976
                :hints (("Goal" :in-theory (enable acyclicp))))
 
977
              ;;[x]
 
978
 
 
979
              ;; Lemma |(cdr rule) is not reachable from p| 
 
980
              ;; states that given that the object p is not reachable 
 
981
              ;; from the index i, a match exists between the object (valueOf i cp), 
 
982
              ;; which represents the object associated with i 
 
983
              ;; in cp, and rule, an acyclic index i in cp wrt seen,
 
984
              ;; an ok constant pool, cp, i appears as the first 
 
985
              ;; component of of an entry in cp, and the set of 
 
986
              ;; indexes accumulated from the second component of rule 
 
987
              ;; in cp is a subset of that accumulated from the 
 
988
              ;; first component of rule in cp, then p is not reachable 
 
989
              ;; from the second component of rule.
 
990
              (defthm |(cdr rule) is not reachable from p| 
 
991
                (implies (and (not (member-equal p (indexes-from-obj i cp)))
 
992
                              (matchValueRulep (valueOf i cp) rule)
 
993
                              (acyclicp1 i cp seen)
 
994
                              (uniqueNodeIDp cp)
 
995
                              (assoc i cp)
 
996
                              (subsetp (indexes-from-obj (cdr rule) cp)
 
997
                                       (indexes-from-obj (car rule) cp)))
 
998
                         (not (member-equal p (indexes-from-obj (cdr rule) cp))))
 
999
                :rule-classes :forward-chaining)
 
1000
              ;;[x]
 
1001
              
 
1002
              ;; Lemma
 
1003
              ;; |(cdr rule) is not reachable from p rst| 
 
1004
              ;; is a restricted version of Lemma
 
1005
              ;; |(cdr rule) is not reachable from p| 
 
1006
              ;; (above).
 
1007
              (defthm |(cdr rule) is not reachable from p rst| 
 
1008
                (implies (and (not (member-equal p (indexes-from-obj i cp)))
 
1009
                              (matchValueRulep (valueOf i cp) rule)
 
1010
                              (acyclicp i cp)
 
1011
                              (uniqueNodeIDp cp)
 
1012
                              (assoc i cp)
 
1013
                              (subsetp (indexes-from-obj (cdr rule) cp)
 
1014
                                       (indexes-from-obj (car rule) cp)))
 
1015
                         (not (member-equal p (indexes-from-obj (cdr rule) cp))))
 
1016
                :hints (("Goal" :in-theory (enable acyclicp)))
 
1017
                :rule-classes :forward-chaining)
 
1018
              ;;[x]
 
1019
              )
 
1020
 
 
1021
;; Lemma replaceValue-i-valueOf-i-cp-is-cp states that given an
 
1022
;; ok constant pool cp, then the result of inseting 
 
1023
;; i and the object (valueOf i cp), which represent the 
 
1024
;; object associted with i in cp, back in the cp 
 
1025
;; is equal to the original cp. 
 
1026
(defthm replaceValue-i-valueOf-i-cp-is-cp
 
1027
  (implies (uniqueNodeIDp cp)
 
1028
           (equal (replaceValue i (valueOf i cp) cp)
 
1029
                  cp))
 
1030
  :hints (("Goal" :cases ((not (assoc i cp)))
 
1031
           :in-theory (enable valueOf assoc))))
 
1032
;;[x]
 
1033
 
 
1034
;; Lemma acyclicp1-replaceValue-i-i-x states that given an acyclic
 
1035
;; index, i, in cp, and i appears as the first 
 
1036
;; component of an entry in cp, and cp is an ok
 
1037
;; constant pool, then i is also acyclic in 
 
1038
;; the new cp that results from insering i with its associated
 
1039
;; object in cp, (valueOf i cp), in the original cp wrt seen.
 
1040
 
 
1041
(defthm acyclicp1-replaceValue-i-i-x
 
1042
  (implies (and (acyclicp1 i cp seen)
 
1043
                (assoc i cp)
 
1044
                (uniqueNodeIDp cp))
 
1045
           (acyclicp1 i (replaceValue i (valueOf i cp) cp) seen)))
 
1046
;;[x]
 
1047
 
 
1048
;; Lemma not-matchValueRulep-applySubstitution-does-not-chaged
 
1049
;; states that if there is no match between an object
 
1050
;; x and a rule, then the result of replacing every 
 
1051
;; ocuurence of the lhs of rule in x with rhs of rule 
 
1052
;; will be equal to the original x.
 
1053
(defthm not-matchValueRulep-applySubstitution-does-not-chaged
 
1054
  (implies (not (matchValueRulep x rule))
 
1055
           (equal (applySubstitution x rule) 
 
1056
                  x)))
 
1057
;;[x]
 
1058
 
 
1059
 
 
1060
;;---------------------------------------------------------------------------
 
1061
;; Begin: acyclicp1-p-replaceValue-i-applySubstitution
 
1062
;; this part is an attempt to proof (acyclicp1 p (replaceValue i (applySubstitution (valueOf i
 
1063
;; cp) cp seen). I had first to split the main goal into two cases:
 
1064
;; (1) (equal p i) and (2) (not (equal p i)). 
 
1065
;; The first part seems to be straightforward; however, for the second
 
1066
;; part I had to split it into two cases:
 
1067
;; (2.1) (matchValueRulep (valueOf i cp) cp) (2.2) (not (matchValueRulep (valueOf i cp) cp))
 
1068
;;---------------------------------------------------------------------------
 
1069
;; replaceValue
 
1070
;;---------------------------------------------------------------------------
 
1071
(encapsulate ()
 
1072
             (local (in-theory (disable 
 
1073
                                intersectp-equal-not-acyclicp1
 
1074
                                union-equal
 
1075
                                intersectp-equal-indexes-acyclicp1
 
1076
                                natp-car-assoc-i-c
 
1077
                                intersectp-equal
 
1078
                                assoc
 
1079
                                member-objp)))
 
1080
 
 
1081
             (defthm not-member-ifo-applySubstitution
 
1082
               (implies (and (consp rule)
 
1083
                             (uniqueNodeIDp cp)
 
1084
                             (assoc (car rule) cp)
 
1085
                             (subsetp (indexes-from-obj (cdr rule) cp)
 
1086
                                      (indexes-from-obj (car rule) cp))
 
1087
                             (acyclicp1 (cdr rule) cp seen)
 
1088
                             (acyclicp1 i cp seen)
 
1089
                             (assoc i cp))
 
1090
                        (not (member-equal i 
 
1091
                                           (indexes-from-obj 
 
1092
                                            (applySubstitution (valueOf i cp) rule) cp))))
 
1093
               :hints (("Goal" :cases ((matchValueRulep (valueOf i cp) rule))))
 
1094
               :rule-classes :forward-chaining)
 
1095
             ;;[x]
 
1096
 
 
1097
             ;; acyclicp version
 
1098
             (defthm not-member-ifo-applySubstitution-1
 
1099
               (implies (and (consp rule)
 
1100
                             (uniqueNodeIDp cp)
 
1101
                             (assoc (car rule) cp)
 
1102
                             (subsetp (indexes-from-obj (cdr rule) cp)
 
1103
                                      (indexes-from-obj (car rule) cp))
 
1104
                             (acyclicp (cdr rule) cp)
 
1105
                             (acyclicp i cp)
 
1106
                             (assoc i cp))
 
1107
                        (not (member-equal i 
 
1108
                                           (indexes-from-obj 
 
1109
                                            (applySubstitution (valueOf i cp) rule) cp))))
 
1110
               :hints (("Goal" :in-theory (enable acyclicp)))
 
1111
               :rule-classes :forward-chaining)
 
1112
             ;;[x]
 
1113
             
 
1114
             (defthm acyclicp1-obj-member-equal-1
 
1115
               (implies (and (uniqueNodeIDp cp)
 
1116
                             (assoc i cp)
 
1117
                             (acyclicp1 i cp seen)
 
1118
                             (acyclicp1 obj cp seen)
 
1119
                             (not (member-equal i (all-indexes-in-obj obj)))
 
1120
                             (not (member-equal i (indexes-from-obj obj cp))))
 
1121
                        (acyclicp1 i (replaceValue i obj cp) seen))
 
1122
               :hints (("Goal" :expand (acyclicp1 i (replaceValue i obj cp) seen))))
 
1123
             ;;[x]
 
1124
             
 
1125
             (defthm acyclicp1-obj-member-equal-2
 
1126
               (implies (and (uniqueNodeIDp cp)
 
1127
                             (not (assoc i cp))
 
1128
                             (acyclicp1 i cp seen)
 
1129
                             (acyclicp1 obj cp seen)
 
1130
                             (not (member-equal i (all-indexes-in-obj obj)))
 
1131
                             (not (member-equal i (indexes-from-obj obj cp))))
 
1132
                        (acyclicp1 i (replaceValue i obj cp) seen)))
 
1133
             ;;[x]
 
1134
             )
 
1135
 
 
1136
(defthm acyclicp1-obj-member-equal
 
1137
  (implies (and (uniqueNodeIDp cp)
 
1138
                (acyclicp1 i cp seen)
 
1139
                (acyclicp1 obj cp seen)
 
1140
                (not (member-equal i (all-indexes-in-obj obj)))
 
1141
                (not (member-equal i (indexes-from-obj obj cp))))
 
1142
           (acyclicp1 i (replaceValue i obj cp) seen))
 
1143
  :hints (("Goal" :cases ((assoc i cp)))))
 
1144
;  :rule-classes :forward-chaining)
 
1145
;;[x]
 
1146
 
 
1147
(defthm acyclicp1-i-seen-acyclicp1-valueOf
 
1148
  (implies (and (uniqueNodeIDp cp)
 
1149
                (acyclicp1 i cp seen))
 
1150
           (acyclicp1 (valueOf i cp) cp seen))
 
1151
  :hints (("Goal" :cases ((assoc i cp)))
 
1152
          ("Subgoal 2'" :in-theory (enable valueOf)))
 
1153
  :rule-classes :forward-chaining)
 
1154
;;[x]
 
1155
 
 
1156
(defthm matchValueRulep-obj-cons-r1-r2
 
1157
  (implies (and (assoc r1 cp)
 
1158
                (uniqueNodeIDp cp)
 
1159
                (matchValueRulep obj (cons r1 r2))
 
1160
                (atom obj))
 
1161
           (natp obj))
 
1162
  :rule-classes :forward-chaining)
 
1163
;;[x]
 
1164
 
 
1165
(defthm matchValueRulep-obj-member-equal
 
1166
  (implies (and (matchValueRulep obj (cons r1 r2))
 
1167
                (uniqueNodeIDp cp)
 
1168
                (assoc r1 cp))
 
1169
           (member-equal r1 (all-indexes-in-obj obj))))
 
1170
;;[x]      
 
1171
 
 
1172
(encapsulate ()
 
1173
             (local (in-theory (disable 
 
1174
                                indexes-from-obj
 
1175
                                not-subsetp-not-member-equal-1
 
1176
                                assoc
 
1177
                                acyclicp-member-equal-all-indexes
 
1178
                                uniqueNodeIDp
 
1179
                                natp-car-assoc-i-c
 
1180
                                not-acyclicp-cons-any)))
 
1181
 
 
1182
 
 
1183
             (defthm acyclicp1-obj-member-equal-all
 
1184
               (implies (and (acyclicp1 obj cp seen)
 
1185
                             (member-equal i (all-indexes-in-obj obj)))
 
1186
                        (acyclicp1 i cp seen)))
 
1187
             ;;[x]
 
1188
 
 
1189
 
 
1190
             (defthm acyclicp-obj-member-equal
 
1191
               (implies (and (acyclicp obj cp)
 
1192
                             (member-equal i (all-indexes-in-obj obj)))
 
1193
                        (acyclicp i cp))
 
1194
               :hints (("Goal" :in-theory (enable acyclicp))))
 
1195
             ;;[x]
 
1196
             
 
1197
 
 
1198
 
 
1199
             (defthm matchValueRulep-acyclicp1-indexes-from-obj
 
1200
               (implies (and (matchValueRulep obj rule)
 
1201
                             (acyclicp1 obj cp seen))
 
1202
                        (subsetp (indexes-from-obj (car rule) cp)
 
1203
                                 (indexes-from-obj obj cp))))
 
1204
             ;;[x]
 
1205
 
 
1206
             (defthm matchValueRulep-acyclicp-indexes-from-obj
 
1207
               (implies (and (matchValueRulep obj rule)
 
1208
                             (acyclicp obj cp))
 
1209
                        (subsetp (indexes-from-obj (car rule) cp)
 
1210
                                 (indexes-from-obj obj cp)))
 
1211
               :hints (("Goal" :in-theory (enable acyclicp))))
 
1212
             ;;[x]
 
1213
 
 
1214
             (defthm not-member-equal-acyclicp1-all-indexes-from-obj-matchValueRulep
 
1215
               (implies (and (not (member-equal i (all-indexes-in-obj obj)))
 
1216
                             (matchValueRulep obj rule)
 
1217
                             (acyclicp1 obj cp seen))
 
1218
                        (not (member-equal i (all-indexes-in-obj (car rule))))))
 
1219
             ;;[x]
 
1220
 
 
1221
             (defthm not-member-equal-acyclicp-all-indexes-from-obj-matchValueRulep
 
1222
               (implies (and (not (member-equal i (all-indexes-in-obj obj)))
 
1223
                             (matchValueRulep obj rule)
 
1224
                             (acyclicp obj cp))
 
1225
                        (not (member-equal i (all-indexes-in-obj (car rule)))))
 
1226
               :hints (("Goal" :in-theory (enable acyclicp)))))
 
1227
;;[x]
 
1228
;;----------------------------------------------------
 
1229
(defthm member-equal-matchValueRulep-acyclicp1-member-equal
 
1230
  (implies (and (uniqueNodeIDp cp)
 
1231
                (assoc i cp)
 
1232
                (assoc r1 cp)
 
1233
                (member-equal i (all-indexes-in-obj r2)) 
 
1234
                (matchValueRulep  (valueOf i cp) (cons r1 r2))
 
1235
                (acyclicp1 r2 cp seen))
 
1236
           (member-equal r1 (indexes-from-obj r2 cp)))
 
1237
  :rule-classes :forward-chaining)
 
1238
 
 
1239
(defthm member-equal-acyclicp1-assoc-r1
 
1240
  (implies (and (uniqueNodeIDp cp)
 
1241
                (assoc r1 cp)
 
1242
                (acyclicp1 r1 cp seen))
 
1243
           (not (member-equal r1 (indexes-from-obj r1 cp))))
 
1244
  :rule-classes :forward-chaining)
 
1245
 
 
1246
 
 
1247
(defthm not-member-equal-i-all-indexes-in-ob
 
1248
  (implies (and (uniqueNodeIDp cp)
 
1249
                (assoc i cp)
 
1250
                (assoc r1 cp)
 
1251
                (matchValueRulep  (valueOf i cp) (cons r1 r2))
 
1252
                (acyclicp1 r1 cp seen)
 
1253
                (acyclicp1 r2 cp seen)
 
1254
                (not (member-equal r1 
 
1255
                                   (all-indexes-in-obj r2)))
 
1256
                (subsetp (indexes-from-obj r2 cp)
 
1257
                         (indexes-from-obj r1 cp)))
 
1258
           (not (member-equal i (all-indexes-in-obj r2))))
 
1259
  :rule-classes :forward-chaining
 
1260
  :hints (("Goal" :use ((:instance member-equal-matchValueRulep-acyclicp1-member-equal)
 
1261
                        (:instance member-equal-acyclicp1-assoc-r1))
 
1262
           :in-theory (disable member-equal-matchValueRulep-acyclicp1-member-equal 
 
1263
                               member-equal-acyclicp1-assoc-r1))))
 
1264
                        
 
1265
 
 
1266
 
 
1267
(defthm not-member-all-indexes-in-obj-replaced
 
1268
  (implies (and (not (member-equal i (all-indexes-in-obj (valueOf i cp))))
 
1269
                (not (member-equal i (all-indexes-in-obj r2))))
 
1270
           (not (member-equal i 
 
1271
                              (all-indexes-in-obj 
 
1272
                               (applySubstitution (valueOf i cp)
 
1273
                                                (cons r1 r2)))))))
 
1274
;; Main 2
 
1275
(defthm not-member-all-indexes-in-obj-replaced-1
 
1276
  (implies (and (uniqueNodeIDp cp)
 
1277
                (assoc i cp)
 
1278
                (assoc r1 cp)
 
1279
                (matchValueRulep (valueOf i cp) (cons r1 r2))
 
1280
                (acyclicp1 r1 cp seen)
 
1281
                (acyclicp1 r2 cp seen)
 
1282
                (not (member-equal r1 
 
1283
                                   (all-indexes-in-obj r2)))
 
1284
                (subsetp (indexes-from-obj r2 cp)
 
1285
                         (indexes-from-obj r1 cp))
 
1286
                (acyclicp1 i cp seen))
 
1287
           (not (member-equal i 
 
1288
                              (all-indexes-in-obj 
 
1289
                               (applySubstitution (valueOf i cp)
 
1290
                                                (cons r1 r2))))))
 
1291
  :hints (("Goal" :use ((:instance not-member-equal-i-all-indexes-in-ob)
 
1292
                        (:instance not-member-all-indexes-in-obj-replaced))
 
1293
           :in-theory (disable not-member-equal-i-all-indexes-in-ob 
 
1294
                               not-member-all-indexes-in-obj-replaced))))
 
1295
 
 
1296
;; Main 2
 
1297
(defthm not-member-all-indexes-in-obj-replace
 
1298
  (implies (and (uniqueNodeIDp cp)
 
1299
                (assoc i cp)
 
1300
                (assoc (car rule) cp)
 
1301
                (matchValueRulep (valueOf i cp) rule)
 
1302
                (acyclicp1 (car rule) cp seen)
 
1303
                (acyclicp1 (cdr rule) cp seen)
 
1304
                (not (member-equal (car rule) 
 
1305
                                   (all-indexes-in-obj (cdr rule))))
 
1306
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1307
                         (indexes-from-obj (car rule) cp))
 
1308
                (acyclicp1 i cp seen))
 
1309
           (not (member-equal i 
 
1310
                              (all-indexes-in-obj (applySubstitution (valueOf i cp)
 
1311
                                                                   rule)))))
 
1312
  :hints (("Goal" :do-not-induct t
 
1313
           :do-not '(generalize fertilize )
 
1314
           :use ((:instance not-member-all-indexes-in-obj-replaced-1
 
1315
                            (r1 (car rule))
 
1316
                            (r2 (cdr rule))))
 
1317
           
 
1318
           :in-theory (disable
 
1319
                       not-member-all-indexes-in-obj-replaced-1 
 
1320
                       not-member-equal-i-all-indexes-in-ob))))
 
1321
 
 
1322
 
 
1323
;;------------------------------------------
 
1324
;; Main Theorem (Equal Part)
 
1325
;;------------------------------------------
 
1326
(defthm acyclicp1-i-replaceValue-i-applySubstitution-1
 
1327
  (implies (and (consp rule)
 
1328
                (matchValueRulep (valueOf i cp) rule)
 
1329
                (uniqueNodeIDp cp)                        
 
1330
                (assoc (car rule) cp)
 
1331
                (not (member-equal (car rule) 
 
1332
                                   (all-indexes-in-obj (cdr
 
1333
                                                        rule)))) 
 
1334
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1335
                         (indexes-from-obj (car rule) cp))
 
1336
                (acyclicp1 (cdr rule) cp seen)
 
1337
                (acyclicp1 i cp seen))                          
 
1338
           (acyclicp1 i (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1339
  :hints (("Goal" :do-not-induct t
 
1340
           :do-not '(generalize fertilize eliminate-destructors)
 
1341
           :use ((:instance not-member-ifo-applySubstitution
 
1342
                            )
 
1343
                 (:instance not-member-all-indexes-in-obj-replace)
 
1344
                 (:instance acyclicp1-obj-member-equal-all 
 
1345
                            (obj (applySubstitution (valueOf i cp) rule)))
 
1346
                 (:instance acyclicp1-applySubstitution
 
1347
                            (p (valueOf i cp))))
 
1348
 
 
1349
           :in-theory (disable acyclicp1-obj-member-equal-all
 
1350
                               not-member-ifo-applySubstitution
 
1351
                               not-member-all-indexes-in-obj-replace
 
1352
                               not-member-equal-i-all-indexes-in-ob
 
1353
                               acyclicp1-applySubstitution
 
1354
                               acyclicp1
 
1355
                               indexes-from-obj
 
1356
                               union-equal
 
1357
                               intersectp-equal-indexes-acyclicp1
 
1358
                               member-equal
 
1359
                               not-subsetp-not-member-equal-1
 
1360
                               acyclicp-member-equal-all-indexes
 
1361
                               uniqueNodeIDp))))
 
1362
 
 
1363
(defthm acyclicp1-i-replaceValue-i-applySubstitution-2
 
1364
  (implies (and (consp rule)
 
1365
                (uniqueNodeIDp cp)                        
 
1366
                (assoc (car rule) cp)
 
1367
                (not (member-equal (car rule) 
 
1368
                                   (all-indexes-in-obj (cdr
 
1369
                                                        rule)))) 
 
1370
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1371
                         (indexes-from-obj (car rule) cp))
 
1372
                (acyclicp1 (cdr rule) cp seen)
 
1373
                (acyclicp1 i cp seen))                          
 
1374
           (acyclicp1 i (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1375
  :hints (("Goal" :cases ((matchValueRulep (valueOf i cp) rule))
 
1376
           :in-theory (disable acyclicp1
 
1377
                               indexes-from-obj
 
1378
                               union-equal
 
1379
                               intersectp-equal-indexes-acyclicp1
 
1380
                               member-equal
 
1381
                               not-subsetp-not-member-equal-1
 
1382
                               acyclicp-member-equal-all-indexes
 
1383
                               uniqueNodeIDp))))
 
1384
 
 
1385
;;------------------------------------------
 
1386
;; Main Theorem (i is equal p)
 
1387
;;------------------------------------------
 
1388
(defthm acyclicp1-i-replaceValue-i-applySubstitution-3
 
1389
  (implies (and (consp rule)
 
1390
                (uniqueNodeIDp cp)                        
 
1391
                (assoc (car rule) cp)
 
1392
                (not (member-equal (car rule) 
 
1393
                                   (all-indexes-in-obj (cdr
 
1394
                                                        rule)))) 
 
1395
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1396
                         (indexes-from-obj (car rule) cp))
 
1397
                (acyclicp (cdr rule) cp)
 
1398
                (acyclicp i cp))                          
 
1399
           (acyclicp i (replaceValue i (applySubstitution (valueOf i cp) rule) cp)))
 
1400
  :hints (("Goal" :in-theory (e/d (acyclicp)
 
1401
                                  (acyclicp1
 
1402
                                   indexes-from-obj
 
1403
                                   union-equal
 
1404
                                   intersectp-equal-indexes-acyclicp1
 
1405
                                   member-equal
 
1406
                                   not-subsetp-not-member-equal-1
 
1407
                                   acyclicp-member-equal-all-indexes
 
1408
                                   uniqueNodeIDp)))))
 
1409
           
 
1410
 
 
1411
;;------------------------------------------
 
1412
;; Main Theorem (i is not reachable from p)
 
1413
;;------------------------------------------
 
1414
(defthm acyclicp1-replaceValue-main-21
 
1415
  (implies (and (uniqueNodeIDp cp)
 
1416
                (acyclicp1 p cp seen)
 
1417
                (not (member-equal i (all-indexes-in-obj p)))
 
1418
                (not (member-equal i (indexes-from-obj p cp))))
 
1419
           (acyclicp1 p (replaceValue i obj cp) seen))
 
1420
  :hints (("Goal" :in-theory (disable 
 
1421
                              union-equal
 
1422
                              intersectp-equal-indexes-acyclicp1
 
1423
                              not-subsetp-not-member-equal-1
 
1424
                              acyclicp-member-equal-all-indexes
 
1425
                              uniqueNodeIDp))))
 
1426
  
 
1427
 
 
1428
(defthm acyclicp1-i-replaceValue-i-applySubstitution-A-1
 
1429
  (implies (and (consp rule)
 
1430
                (uniqueNodeIDp cp)                        
 
1431
                (assoc (car rule) cp)
 
1432
                (not (member-equal (car rule) 
 
1433
                                   (all-indexes-in-obj (cdr
 
1434
                                                        rule)))) 
 
1435
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1436
                         (indexes-from-obj (car rule) cp))
 
1437
                (member-equal i (all-indexes-in-obj p))
 
1438
                (not (member-equal i (indexes-from-obj p cp)))
 
1439
                (acyclicp1 (cdr rule) cp seen)
 
1440
                (acyclicp1 p cp seen)
 
1441
                (acyclicp1 i cp seen))                          
 
1442
           (acyclicp1 p (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1443
  :hints (("Goal" :in-theory (e/d (acyclicp)
 
1444
                                  (union-equal
 
1445
                                   intersectp-equal-indexes-acyclicp1
 
1446
                                   not-subsetp-not-member-equal-1
 
1447
                                   acyclicp-member-equal-all-indexes
 
1448
                                   uniqueNodeIDp
 
1449
                                   union-equal
 
1450
                                   intersectp-equal-indexes-acyclicp1
 
1451
                                   assoc
 
1452
                                   not-subsetp-not-member-equal-1
 
1453
                                   natp-car-assoc-i-c
 
1454
                                   acyclicp-member-equal-all-indexes
 
1455
                                   uniqueNodeIDp)))))
 
1456
 
 
1457
 
 
1458
;;general
 
1459
(defthm acyclicp1-i-replaceValue-i-applySubstitution-A-2
 
1460
  (implies (and (consp rule)
 
1461
                (uniqueNodeIDp cp)                        
 
1462
                (assoc (car rule) cp)
 
1463
                (not (member-equal (car rule) 
 
1464
                                   (all-indexes-in-obj (cdr
 
1465
                                                        rule)))) 
 
1466
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1467
                         (indexes-from-obj (car rule) cp))
 
1468
                (not (member-equal i (indexes-from-obj p cp))) ;;;;;
 
1469
                (acyclicp1 (cdr rule) cp seen)
 
1470
                (acyclicp1 p cp seen)
 
1471
                (acyclicp1 i cp seen))                          
 
1472
           (acyclicp1 p (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1473
  :hints (("Goal" :in-theory (enable acyclicp)
 
1474
           :cases ((member-equal i (all-indexes-in-obj p))))))
 
1475
 
 
1476
 
 
1477
 
 
1478
;;------------------------------------------
 
1479
;; Main Theorem (Not Equal Part)
 
1480
;;------------------------------------------
 
1481
(encapsulate ()
 
1482
             (local (in-theory (disable union-equal
 
1483
                                        intersectp-equal-indexes-acyclicp1
 
1484
                                        not-subsetp-not-member-equal-1
 
1485
                                        acyclicp-member-equal-all-indexes
 
1486
                                        uniqueNodeIDp
 
1487
                                        union-equal
 
1488
                                        intersectp-equal-indexes-acyclicp1
 
1489
                                        assoc
 
1490
                                        not-subsetp-not-member-equal-1
 
1491
                                        natp-car-assoc-i-c
 
1492
                                        acyclicp-member-equal-all-indexes
 
1493
                                        uniqueNodeIDp)))
 
1494
 
 
1495
             ;; Lemma acyclicp1-member-equal-pfo-not-member-equal
 
1496
             ;; states that if p is a natural number, cp is an ok 
 
1497
             ;; constant pool, p is acyclic in cp wrt seen,
 
1498
             ;; and p is reachable from i, then i is NOT reachable
 
1499
             ;; from p.
 
1500
             (defthm acyclicp1-member-equal-pfo-not-member-equal
 
1501
               (implies (and (natp p ) 
 
1502
                             (uniqueNodeIDp cp)
 
1503
                             (acyclicp1 p cp seen)
 
1504
                             (member-equal i (indexes-from-obj p cp)))
 
1505
                        (not (member-equal p (indexes-from-obj i cp))))
 
1506
               :rule-classes :forward-chaining
 
1507
               :hints (("Goal" :use ((:instance member-equal-acyclicp1-assoc-r1
 
1508
                                                (r1 p)))
 
1509
                        :in-theory (disable member-equal-acyclicp1-assoc-r1)))))
 
1510
             
 
1511
 
 
1512
;; Lemma not-member-equal-p-indexes-i-cp states that
 
1513
;; if cp is an ok constant pool, the object that is associated 
 
1514
;; with p in cp, (valueOf p cp), is acyclic in cp wrt (cons p seen),
 
1515
;; and the object (valueOf p cp) is reachable from i, then i is NOT reachable
 
1516
;; from p.
 
1517
(defthm not-member-equal-p-indexes-i-cp
 
1518
  (implies (and (uniqueNodeIDp cp)
 
1519
                (acyclicp1 (valueOf p cp) cp (cons p seen))
 
1520
                (member-equal i (indexes-from-obj (valueOf p cp) cp)))
 
1521
           (not (member-equal p (indexes-from-obj i cp))))
 
1522
  :rule-classes :forward-chaining)
 
1523
 
 
1524
;; Lemma acyclicp1-i-cp-cons-p-seen states that
 
1525
;; given an an ok constant pool, cp, i is acyclic 
 
1526
;; in cp wrt seen, i is not equal to p, i appears 
 
1527
;; as the first component of one of the cp's entries,
 
1528
;; the object that is associated with p in cp, 
 
1529
;; (valueOf p cp), is acyclic in cp wrt (cons p seen), 
 
1530
;; and the object (valueOf p cp) is reachable from i, 
 
1531
;; then i is also acyclic in cp wrt (cons p seen). 
 
1532
 
 
1533
(defthm acyclicp1-i-cp-cons-p-seen
 
1534
  (implies (and (uniqueNodeIDp cp)
 
1535
                (acyclicp1 i cp seen)
 
1536
                (not (equal i p))
 
1537
                (assoc i cp)
 
1538
                (acyclicp1 (valueOf p cp) cp (cons p seen))
 
1539
                (member-equal i (indexes-from-obj (valueOf p cp) cp)))
 
1540
           (acyclicp1 i cp (cons p seen)))
 
1541
  :rule-classes :forward-chaining)
 
1542
                        
 
1543
;; Lemma acyclicp1-member-equal-pfo-not-member-equal-1 
 
1544
;; states that given a natural number p, an an ok 
 
1545
;; constant pool, cp, p is acyclic in cp wrt seen, 
 
1546
;; i is not equal to p, and  p is reachable from i,
 
1547
;; then i is not reachable from p. 
 
1548
 
 
1549
(defthm acyclicp1-member-equal-pfo-not-member-equal-1
 
1550
  (implies (and (natp p)
 
1551
                (uniqueNodeIDp cp)
 
1552
                (acyclicp1 p cp seen)
 
1553
                (not (member-equal i (all-indexes-in-obj p))) ;(not (equal p i))
 
1554
                (member-equal i (indexes-from-obj p cp)))
 
1555
           (not (member-equal p (indexes-from-obj i cp))))
 
1556
  :rule-classes :forward-chaining)
 
1557
;;[x]
 
1558
 
 
1559
;; Lemma not-member-equal-p-indexes-cdr-rule states that 
 
1560
;; if i is not reachable from p, there is a match between 
 
1561
;; the object (valueOf i cp) and rule, i is acyclic in cp wrt seen,
 
1562
;; cp is an ok constant pool, i apprears as the first components
 
1563
;; in one of the cp's entries, the set of indexes collected in 
 
1564
;; cp starting from (cdr rule) are subset of that of the (car rule),
 
1565
;; then (cdr rule) is not reachable from p.
 
1566
(defthm not-member-equal-p-indexes-cdr-rule 
 
1567
  (implies (and (not (member-equal p (indexes-from-obj i cp)))
 
1568
                (matchValueRulep (valueOf i cp) rule)
 
1569
                (acyclicp1 i cp seen)
 
1570
                (uniqueNodeIDp cp)
 
1571
                (assoc i cp)
 
1572
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1573
                         (indexes-from-obj (car rule) cp)))
 
1574
           (not (member-equal p (indexes-from-obj (cdr rule) cp))))
 
1575
  :rule-classes :forward-chaining)
 
1576
;;[x]
 
1577
 
 
1578
;(i-am-here)
 
1579
 
 
1580
(defthm p-is-not-reachable-from-cdr-rule
 
1581
  (implies (and 
 
1582
                (natp p)
 
1583
                (matchValueRulep (valueOf i cp) rule)
 
1584
                (not (member-equal i (all-indexes-in-obj p)))
 
1585
                (member-equal i (indexes-from-obj p cp))
 
1586
                (acyclicp1 i cp seen)
 
1587
                (acyclicp1 p cp seen)
 
1588
                (uniqueNodeIDp cp)
 
1589
                (assoc i cp)
 
1590
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1591
                         (indexes-from-obj (car rule) cp)))
 
1592
           (not (member-equal p (indexes-from-obj (cdr rule) cp))))
 
1593
  :rule-classes :forward-chaining)
 
1594
;;[x]
 
1595
 
 
1596
(defthm p-is-not-reachable-from-cdr-rule-1
 
1597
  (implies (and 
 
1598
                (natp p)
 
1599
                (matchValueRulep (valueOf i cp) rule)
 
1600
                (not (equal i p))
 
1601
                (member-equal i (indexes-from-obj p cp))
 
1602
                (acyclicp1 i cp seen)
 
1603
                (acyclicp1 p cp seen)
 
1604
                (uniqueNodeIDp cp)
 
1605
                (assoc i cp)
 
1606
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1607
                         (indexes-from-obj (car rule) cp)))
 
1608
           (not (member-equal p (indexes-from-obj (cdr rule) cp))))
 
1609
  :rule-classes :forward-chaining)
 
1610
;;[x]
 
1611
 
 
1612
(defthm p-is-not-reachable-from-p
 
1613
  (implies (and (acyclicp1 p cp seen)
 
1614
                (natp p))
 
1615
           (not (member-equal p (indexes-from-obj p cp))))
 
1616
  :rule-classes :forward-chaining)
 
1617
 
 
1618
;;[x]           
 
1619
                
 
1620
(defthm p-is-not-reachable-from-i
 
1621
  (implies (and (assoc i cp)
 
1622
                (natp p) 
 
1623
                (uniqueNodeIDp cp)
 
1624
                (acyclicp1 p cp seen)
 
1625
                (member-equal i (indexes-from-obj p cp)))
 
1626
           (not (member-equal p (indexes-from-obj i cp)))))
 
1627
;;[x]
 
1628
 
 
1629
(defthm indexes-car-rule-subset-i
 
1630
    (implies (and (assoc i cp)
 
1631
                  (uniqueNodeIDp cp)
 
1632
                  (acyclicp1 i cp seen)
 
1633
                  (matchValueRulep (valueOf i cp) rule)
 
1634
                  (member-equal i (indexes-from-obj p cp))
 
1635
                  (subsetp (indexes-from-obj (cdr rule) cp)
 
1636
                           (indexes-from-obj (car rule) cp)))
 
1637
             (subsetp (indexes-from-obj (car rule) cp)
 
1638
                      (indexes-from-obj i cp)))
 
1639
    :hints (("Goal" :in-theory (enable acyclicp))))
 
1640
;;[x]
 
1641
 
 
1642
(defthm car-rule-is-reachable-from-p
 
1643
  (implies (and (natp p)
 
1644
                (assoc i cp)
 
1645
                (uniqueNodeIDp cp)
 
1646
                (acyclicp1 i cp seen)
 
1647
                (acyclicp1 p cp seen)
 
1648
                (matchValueRulep (valueOf i cp) rule)
 
1649
                (member-equal i (indexes-from-obj p cp))
 
1650
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1651
                         (indexes-from-obj (car rule) cp)))
 
1652
           (not (member-equal p (indexes-from-obj (car rule) cp)))))
 
1653
;;[x]
 
1654
 
 
1655
(in-theory (disable 
 
1656
            uniqueNodeIDp
 
1657
            acyclicp-member-equal-all-indexes
 
1658
            union-equal
 
1659
            member-equal-subsetp-member-equal
 
1660
            natp-car-assoc-i-c
 
1661
            not-subsetp-not-member-equal-1
 
1662
            assoc
 
1663
            member-equal-subset-index-from-obj))
 
1664
 
 
1665
 
 
1666
(defthm cdr-rule-is-reachable-from-i
 
1667
  (implies (and (acyclicp1 cdr-rule cp seen)
 
1668
                (member-equal p (all-indexes-in-obj cdr-rule))
 
1669
                (member-equal i (indexes-from-obj p cp)))
 
1670
           (member-equal i (indexes-from-obj cdr-rule cp))))
 
1671
 
 
1672
(defthm not-acyclicp1-i-cp-seen
 
1673
  (implies (and (member-equal i (indexes-from-obj i cp))
 
1674
                (natp i))
 
1675
           (equal (acyclicp1 i cp seen)
 
1676
                  nil)))
 
1677
 
 
1678
(defthm not-member-p-in-object-cdr-rule
 
1679
  (implies  (and (acyclicp1 (cdr rule) cp seen)
 
1680
                 (uniqueNodeIDp cp)
 
1681
                 (member-equal i (indexes-from-obj p cp))
 
1682
                 (assoc i cp)
 
1683
                 (acyclicp1 i cp seen)
 
1684
                 (subsetp (indexes-from-obj (cdr rule) cp)
 
1685
                          (indexes-from-obj (car rule) cp))
 
1686
                 (matchValueRulep (valueOf i cp) rule))
 
1687
            (not (member-equal p (all-indexes-in-obj (cdr rule)))))
 
1688
  :hints (("Goal" :use ((:instance cdr-rule-is-reachable-from-i
 
1689
                                   (cdr-rule (cdr rule)))
 
1690
                        (:instance not-acyclicp1-i-cp-seen))
 
1691
           :in-theory (disable cdr-rule-is-reachable-from-i 
 
1692
                               not-acyclicp1-i-cp-seen)
 
1693
           :do-not-induct t)))
 
1694
 
 
1695
 
 
1696
(encapsulate ()
 
1697
             (defthm |lemma 1-Subgoal*1/3|
 
1698
               (implies
 
1699
                (and (natp p)
 
1700
                     (member-equal i (indexes-from-obj p cp))
 
1701
                     (uniqueNodeIDp cp)
 
1702
                     (assoc i cp)
 
1703
                     (assoc (car rule) cp)
 
1704
                     (matchValueRulep (valueOf i cp) rule)
 
1705
                     (acyclicp1 i cp seen)
 
1706
                     (acyclicp1 p cp seen)
 
1707
                     (not (member-equal (car rule)
 
1708
                                        (all-indexes-in-obj (cdr rule))))
 
1709
                     (subsetp (indexes-from-obj (cdr rule) cp)
 
1710
                              (indexes-from-obj (car rule) cp))
 
1711
                     (acyclicp1 (cdr rule) cp seen))
 
1712
                (acyclicp1 i cp (cons p seen)))
 
1713
               :hints (("Goal" :do-not-induct t
 
1714
                        :use ((:instance acyclicp1-i-cp-cons-p-seen))
 
1715
                        :in-theory (disable acyclicp1-i-cp-cons-p-seen))))
 
1716
 
 
1717
             (in-theory (disable acyclicp1))
 
1718
             (in-theory (disable matchValueRulep all-indexes-in-obj indexes-from-obj))
 
1719
             
 
1720
             (defthm |Subgoal *1/3- p is not reachable from i|
 
1721
               (implies
 
1722
                (and (not (consp p))
 
1723
                     (natp p)
 
1724
                     (assoc p cp)
 
1725
                     (member-equal i (indexes-from-obj p cp))
 
1726
                     (not (member-equal p seen))
 
1727
                     (implies (and (consp rule)
 
1728
                                   (uniqueNodeIDp cp)
 
1729
                                   (assoc i cp)
 
1730
                                   (assoc (car rule) cp)
 
1731
                                   (matchValueRulep (valueOf i cp) rule)
 
1732
                                   (acyclicp1 i cp (cons p seen))
 
1733
                                   (acyclicp1 (valueOf p cp) cp (cons p seen))
 
1734
                                   (not (member-equal (car rule)
 
1735
                                                      (all-indexes-in-obj (cdr rule))))
 
1736
                                   (subsetp (indexes-from-obj (cdr rule) cp)
 
1737
                                            (indexes-from-obj (car rule) cp))
 
1738
                                   (acyclicp1 (cdr rule) cp (cons p seen)))
 
1739
                              (acyclicp1 (valueOf p cp)
 
1740
                                         (replaceValue i (applySubstitution (valueOf i cp) rule)
 
1741
                                              cp)
 
1742
                                         (cons p seen)))
 
1743
                     (consp rule)
 
1744
                     (uniqueNodeIDp cp)
 
1745
                     (assoc i cp)
 
1746
                     (assoc (car rule) cp)
 
1747
                     (matchValueRulep (valueOf i cp) rule)
 
1748
                     (acyclicp1 i cp seen)
 
1749
                     (acyclicp1 p cp seen)
 
1750
                     (not (member-equal (car rule)
 
1751
                                        (all-indexes-in-obj (cdr rule))))
 
1752
                     (subsetp (indexes-from-obj (cdr rule) cp)
 
1753
                              (indexes-from-obj (car rule) cp))
 
1754
                     (acyclicp1 (cdr rule) cp seen))
 
1755
                (acyclicp1 p
 
1756
                           (replaceValue i (applySubstitution (valueOf i cp) rule)
 
1757
                                cp)
 
1758
                           seen))
 
1759
               :hints (("Subgoal 2" :in-theory (enable acyclicp1))
 
1760
                       ("Subgoal 1" :expand 
 
1761
                        (acyclicp1 p
 
1762
                                   (replaceValue i 
 
1763
                                        (applySubstitution (valueOf i cp) rule)
 
1764
                                        cp)
 
1765
                                   seen))))
 
1766
 
 
1767
 
 
1768
             (in-theory (enable acyclicp1))
 
1769
             (in-theory (enable matchValueRulep all-indexes-in-obj indexes-from-obj))
 
1770
 
 
1771
             (defthm acyclicp1-p-replaceValue-replace
 
1772
               (implies (and (uniqueNodeIDp cp)              
 
1773
                             (not (member-equal i (indexes-from-obj p cp)))
 
1774
                             (assoc (car rule) cp) 
 
1775
                             (acyclicp1 i cp seen) 
 
1776
                             (acyclicp1 p cp seen)
 
1777
                             (not (member-equal 
 
1778
                                   (car rule) 
 
1779
                                   (all-indexes-in-obj (cdr
 
1780
                                                        rule)))) 
 
1781
                             (subsetp (indexes-from-obj (cdr rule) cp)
 
1782
                                      (indexes-from-obj (car rule) cp))
 
1783
                             (acyclicp1 (cdr rule) cp seen))
 
1784
                        (acyclicp1 p (replaceValue i 
 
1785
                                          (applySubstitution (valueOf i cp) rule) 
 
1786
                                          cp) seen)))
 
1787
             
 
1788
             (defthm acyclicp1-p-replaceValue-i-applySubstitution
 
1789
               (implies (and (consp rule)
 
1790
                             (uniqueNodeIDp cp)                        
 
1791
                             (assoc i cp) 
 
1792
                             (assoc (car rule) cp) 
 
1793
                             (matchValueRulep (valueOf i cp) rule) 
 
1794
                             (acyclicp1 i cp seen) 
 
1795
                             (acyclicp1 p cp seen)
 
1796
                             (not (member-equal (car rule) 
 
1797
                                                (all-indexes-in-obj (cdr
 
1798
                                                                     rule)))) 
 
1799
                             (subsetp (indexes-from-obj (cdr rule) cp)
 
1800
                                      (indexes-from-obj (car rule) cp))
 
1801
                             (acyclicp1 (cdr rule) cp seen))
 
1802
                        (acyclicp1 p (replaceValue i 
 
1803
                                          (applySubstitution (valueOf i cp) rule) 
 
1804
                                          cp) seen))
 
1805
               :hints (("Subgoal *1/3" :cases 
 
1806
                        ((not (member-equal i (indexes-from-obj p cp)))))
 
1807
                       ("Subgoal *1/3.2" :use 
 
1808
                        ((:instance |Subgoal *1/3- p is not reachable from i|))
 
1809
                        :in-theory (disable |Subgoal *1/3- p is not reachable from i|))
 
1810
                       ("Subgoal *1/3.1" :use ((:instance
 
1811
                                                acyclicp1-p-replaceValue-replace))
 
1812
                        :in-theory (disable acyclicp1-p-replaceValue-replace)))))
 
1813
 
 
1814
 
 
1815
(defthm acyclicp1-i-replaceValue-i-applySubstitution-general
 
1816
  (implies (and (consp rule)
 
1817
                (uniqueNodeIDp cp)                        
 
1818
                (assoc i cp) 
 
1819
                (assoc (car rule) cp) 
 
1820
                (acyclicp1 i cp seen) 
 
1821
                (acyclicp1 p cp seen)
 
1822
                (not (member-equal (car rule) 
 
1823
                                   (all-indexes-in-obj (cdr
 
1824
                                                        rule)))) 
 
1825
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1826
                         (indexes-from-obj (car rule) cp))
 
1827
                (acyclicp1 (cdr rule) cp seen))
 
1828
           (acyclicp1 p (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1829
  :hints (("Goal" :cases ((matchValueRulep (valueOf i cp) rule)))))
 
1830
 
 
1831
 
 
1832
(defthm acyclicp1-p-replaceValue-i-obj-cp
 
1833
  (implies (and (acyclicp1 p cp seen)
 
1834
                (uniqueNodeIDp cp)
 
1835
                (not (assoc i cp)))
 
1836
           (acyclicp1 p (replaceValue i obj cp) seen)))
 
1837
 
 
1838
(defthm acyclicp1-i-replaceValue-i-applySubstitution-general-*1
 
1839
  (implies (and (uniqueNodeIDp cp)                        
 
1840
                (assoc (car rule) cp) 
 
1841
                (acyclicp1 i cp seen) 
 
1842
                (acyclicp1 p cp seen)
 
1843
                (not (member-equal (car rule) 
 
1844
                                   (all-indexes-in-obj (cdr
 
1845
                                                        rule)))) 
 
1846
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1847
                         (indexes-from-obj (car rule) cp))
 
1848
                (acyclicp1 (cdr rule) cp seen))
 
1849
           (acyclicp1 p (replaceValue i (applySubstitution (valueOf i cp) rule) cp) seen))
 
1850
  :hints (("Goal" :cases ((assoc i cp)))))
 
1851
 
 
1852
(defthm acyclicp-i-replaceValue-i-applySubstitution-general
 
1853
  (implies (and (consp rule)
 
1854
                (uniqueNodeIDp cp)                        
 
1855
                (assoc (car rule) cp) ;; 
 
1856
                (acyclicp i cp) ;;
 
1857
                (acyclicp p cp)
 
1858
                (not (member-equal (car rule) 
 
1859
                                   (all-indexes-in-obj (cdr
 
1860
                                                        rule)))) 
 
1861
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1862
                         (indexes-from-obj (car rule) cp))
 
1863
                (acyclicp (cdr rule) cp))
 
1864
           (acyclicp p (replaceValue i (applySubstitution (valueOf i cp) rule) cp)))
 
1865
  :hints (("Goal" :in-theory (enable acyclicp))))
 
1866
 
 
1867
;(i-am-here)
 
1868
; lemma 6
 
1869
(defthm acyclicp-i-replaceValue-i-applySubstitution-general-1
 
1870
  (implies (and (ok-rulep rule cp)
 
1871
                (acyclicp p cp)
 
1872
                (acyclicp i cp)
 
1873
                (uniqueNodeIDp cp))
 
1874
           (acyclicp p (replaceValue i (applySubstitution (valueOf i cp) rule) cp))))
 
1875
 
 
1876
(defthm dref-replaceValue
 
1877
  (implies (and 
 
1878
            (uniqueNodeIDp cp)                        
 
1879
            (equal (dref (car rule) cp)
 
1880
                   (dref (cdr rule) cp)) ;; 
 
1881
            (assoc (car rule) cp) ;; 
 
1882
            (acyclicp i cp) ;;
 
1883
            (acyclicp p cp)
 
1884
            (acyclicp (cdr rule) cp)
 
1885
           (not (member-equal (car rule) 
 
1886
                              (all-indexes-in-obj (cdr
 
1887
                                                   rule))))
 
1888
           (subsetp (indexes-from-obj (cdr rule) cp)
 
1889
                    (indexes-from-obj (car rule) cp)))
 
1890
           (equal (dref p (replaceValue i (applySubstitution (valueOf i cp) rule) cp))
 
1891
                  (dref p cp))))
 
1892
                
 
1893
 
 
1894
(defthm dref-replaceValue-ok-rulep
 
1895
  (implies (and (ok-rulep rule cp)
 
1896
                (acyclicp p cp)
 
1897
                (acyclicp i cp)
 
1898
                (uniqueNodeIDp cp))
 
1899
           (equal (dref p (replaceValue i (applySubstitution (valueOf i cp) rule) cp))
 
1900
                  (dref p cp))))
 
1901
 
 
1902
(defthm acyclicp1-apply-rule-to-entry-1
 
1903
  (implies (and (uniqueNodeIDp cp)                        
 
1904
                (assoc (car rule) cp) ;; 
 
1905
                (acyclicp1 i cp seen) ;;
 
1906
                (acyclicp1 p cp seen)
 
1907
                (not (member-equal (car rule) 
 
1908
                                   (all-indexes-in-obj (cdr
 
1909
                                                        rule)))) 
 
1910
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1911
                         (indexes-from-obj (car rule) cp))
 
1912
                (acyclicp1 (cdr rule) cp seen))
 
1913
           (acyclicp1 p (apply-rule-to-entry-1 rule i cp) seen)))
 
1914
           
 
1915
 
 
1916
(in-theory (disable apply-rule-to-entry-1))
 
1917
           
 
1918
(defthm acyclicp-apply-rule-to-entry-1
 
1919
  (implies (and (uniqueNodeIDp cp)                        
 
1920
                (assoc (car rule) cp) ;; 
 
1921
                (acyclicp i cp) ;;
 
1922
                (acyclicp p cp)
 
1923
                (not (member-equal (car rule) 
 
1924
                                   (all-indexes-in-obj (cdr
 
1925
                                                        rule)))) 
 
1926
                (subsetp (indexes-from-obj (cdr rule) cp)
 
1927
                         (indexes-from-obj (car rule) cp))
 
1928
                (acyclicp (cdr rule) cp))
 
1929
           (acyclicp p (apply-rule-to-entry-1 rule i cp)))
 
1930
  :hints (("Goal" :in-theory (enable acyclicp))))
 
1931
 
 
1932
;; Main
 
1933
(defthm acyclicp-apply-rule-to-entry-1-new
 
1934
  (implies (and (ok-rulep rule cp)
 
1935
                (acyclicp p cp)
 
1936
                (acyclicp i cp)
 
1937
                (uniqueNodeIDp cp))
 
1938
           (acyclicp p (apply-rule-to-entry-1 rule i cp))))
 
1939
 
 
1940
 
 
1941
(defthm dref-apply-rule-to-entry-1
 
1942
  (implies (and 
 
1943
            (uniqueNodeIDp cp)                        
 
1944
            (equal (dref (car rule) cp)
 
1945
                   (dref (cdr rule) cp)) ;; 
 
1946
            (assoc (car rule) cp) ;; 
 
1947
            (acyclicp i cp) ;;
 
1948
            (acyclicp p cp)
 
1949
            (acyclicp (cdr rule) cp)
 
1950
            (not (member-equal (car rule) 
 
1951
                               (all-indexes-in-obj (cdr
 
1952
                                                    rule))))
 
1953
            (subsetp (indexes-from-obj (cdr rule) cp)
 
1954
                     (indexes-from-obj (car rule) cp)))
 
1955
           
 
1956
           (equal (dref p (apply-rule-to-entry-1 rule i cp))
 
1957
                  (dref p cp)))
 
1958
  :hints (("Goal" :in-theory (enable acyclicp apply-rule-to-entry-1))))
 
1959
 
 
1960
;; Main
 
1961
(defthm dref-apply-rule-to-entry-1-new
 
1962
  (implies (and (ok-rulep rule dag)
 
1963
                (uniqueNodeIDp dag)                        
 
1964
                (acyclicp i dag);;
 
1965
                (acyclicp p dag))
 
1966
           (equal (dref p (apply-rule-to-entry-1 rule i dag))
 
1967
                  (dref p dag)))
 
1968
  :hints (("Goal" :in-theory (enable ok-rulep))))
 
1969
 
 
1970
 
 
1971
;; Now we prove that given an all-indexes-acyclicp-cp, cp, and an acyclicp 
 
1972
;; object p in cp, the result of dreferencing p in cp contains NO indexes.
 
1973
 
 
1974
(defthm no-pointersp-dref
 
1975
  (implies (and (acyclic-constant-poolp cp)
 
1976
                (acyclicp p cp))
 
1977
           (no-indexesp (dref p cp))))
 
1978