File: la-to-pa-lemmas.lisp

package info (click to toggle)
acl2 8.5dfsg-5
  • links: PTS
  • area: main
  • in suites: bookworm
  • size: 991,452 kB
  • sloc: lisp: 15,567,759; javascript: 22,820; cpp: 13,929; ansic: 12,092; perl: 7,150; java: 4,405; xml: 3,884; makefile: 3,507; sh: 3,187; ruby: 2,633; ml: 763; python: 746; yacc: 723; awk: 295; csh: 186; php: 171; lex: 154; tcl: 49; asm: 23; haskell: 17
file content (520 lines) | stat: -rw-r--r-- 23,326 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
; X86ISA Library

; Note: The license below is based on the template at:
; http://opensource.org/licenses/BSD-3-Clause

; Copyright (C) 2015, Regents of the University of Texas
; All rights reserved.

; Redistribution and use in source and binary forms, with or without
; modification, are permitted provided that the following conditions are
; met:

; o Redistributions of source code must retain the above copyright
;   notice, this list of conditions and the following disclaimer.

; o Redistributions in binary form must reproduce the above copyright
;   notice, this list of conditions and the following disclaimer in the
;   documentation and/or other materials provided with the distribution.

; o Neither the name of the copyright holders nor the names of its
;   contributors may be used to endorse or promote products derived
;   from this software without specific prior written permission.

; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
; HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

; Original Author(s):
; Shilpi Goel         <shigoel@cs.utexas.edu>

(in-package "X86ISA")
(include-book "pml4-table-lemmas" :ttags :all)
(include-book "gather-paging-structures-thms" :ttags :all)

(local (include-book "centaur/bitops/ihs-extensions" :dir :system))
(local (include-book "centaur/bitops/signed-byte-p" :dir :system))

(local (in-theory (e/d () (unsigned-byte-p signed-byte-p))))

;; ======================================================================

(defthm xlate-equiv-memory-and-cr0Bits->wp
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (cr0Bits->wp (loghead 32 (xr :ctr *cr0* x86-1)))
                  (cr0Bits->wp (loghead 32 (xr :ctr *cr0* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr0-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (bool->bit (logbitp 16 (xr :ctr *cr0* x86-1)))
                  (bool->bit (logbitp 16 (xr :ctr *cr0* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures
                                    cr0bits->wp)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr3Bits->pdb
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (cr3Bits->pdb (xr :ctr *cr3* x86-1))
                  (cr3Bits->pdb (xr :ctr *cr3* x86-2))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr3-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (loghead 40 (logtail 12 (xr :ctr *cr3* x86-1)))
                  (loghead 40 (logtail 12 (xr :ctr *cr3* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures
                                    cr3bits->pdb)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr4Bits->smep
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (cr4Bits->smep (loghead 22 (xr :ctr *cr4* x86-1)))
                  (cr4Bits->smep (loghead 22 (xr :ctr *cr4* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr4Bits->smap
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (cr4Bits->smap (loghead 22 (xr :ctr *cr4* x86-1)))
                  (cr4Bits->smap (loghead 22 (xr :ctr *cr4* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-cr4-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (bool->bit (logbitp 20 (xr :ctr *cr4* x86-1)))
                  (bool->bit (logbitp 20 (xr :ctr *cr4* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures
                                    cr4bits->smap
                                    cr4bits->smep)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-ia32_eferbits->nxe
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (ia32_eferbits->nxe (loghead 12 (xr :msr *ia32_efer-idx* x86-1)))
                  (ia32_eferbits->nxe (loghead 12 (xr :msr *ia32_efer-idx* x86-2)))))
  :hints (("goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-msr-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (bool->bit (logbitp 11 (xr :msr *ia32_efer-idx* x86-1)))
                  (bool->bit (logbitp 11 (xr :msr *ia32_efer-idx* x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory 
                                    xlate-equiv-structures
                                    ia32_eferbits->nxe)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-rflagsbits->ac
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (rflagsbits->ac (xr :rflags nil x86-1))
                  (rflagsbits->ac (xr :rflags nil x86-2))))
  :hints (("goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-rflags-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (bool->bit (logbitp 18 (xr :rflags nil x86-1)))
                  (bool->bit (logbitp 18 (xr :rflags nil x86-2)))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures
                                    rflagsbits->ac)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-segment-selectorbits->rpl
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal 
            (segment-selectorbits->rpl (xr :seg-visible 1 x86-1))
            (segment-selectorbits->rpl (xr :seg-visible 1 x86-2))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-seg-visible-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (loghead 2 (xr :seg-visible 1 x86-1))
                  (loghead 2 (xr :seg-visible 1 x86-2))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory
                                    xlate-equiv-structures
                                    segment-selectorbits->rpl)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-marking-view-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (xr :marking-view nil x86-1)
                  (xr :marking-view nil x86-2)))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-app-view-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (xr :app-view nil x86-1)
                  (xr :app-view nil x86-2)))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory xlate-equiv-structures)
                                   ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-in-app-view-implies-equal-states
  (implies (and (xlate-equiv-memory x86-1 x86-2)
                (app-view x86-1))
           (equal x86-1 x86-2))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory) ())))
  :rule-classes nil)

;; ======================================================================

;; Lemmas about ia32e-la-to-pa:

(defthm ia32e-la-to-pa-in-app-view
  (implies (app-view x86)
           (equal (ia32e-la-to-pa lin-addr r-w-x x86)
                  (mv t 0 x86)))
  :hints (("Goal" :in-theory (e/d* (ia32e-la-to-pa) ()))))

(defthmd xlate-equiv-memory-and-ia32e-la-to-pa
  (implies (xlate-equiv-memory (double-rewrite x86-1) x86-2)
           (and
            (equal (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86-1))
                   (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86-2)))
            (equal (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86-1))
                   (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86-2)))))
  :hints (("Goal" :in-theory (e/d* (ia32e-la-to-pa)
                                   ()))))

(defthm xlate-equiv-memory-and-mv-nth-0-ia32e-la-to-pa-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86-1))
                  (mv-nth 0 (ia32e-la-to-pa lin-addr r-w-x x86-2))))
  :hints (("Goal" :use ((:instance xlate-equiv-memory-and-ia32e-la-to-pa))))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-mv-nth-1-ia32e-la-to-pa-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86-1))
                  (mv-nth 1 (ia32e-la-to-pa lin-addr r-w-x x86-2))))
  :hints (("Goal" :use ((:instance xlate-equiv-memory-and-ia32e-la-to-pa))))
  :rule-classes :congruence)

(defthm xlate-equiv-structures-and-mv-nth-2-ia32e-la-to-pa
  (xlate-equiv-structures (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
                          (double-rewrite x86))
  :hints (("Goal" :in-theory (e/d* (ia32e-la-to-pa) (force (force))))))

(defthm xlate-equiv-structures-and-two-mv-nth-2-ia32e-la-to-pa-cong
  (implies (xlate-equiv-structures x86-1 x86-2)
           (xlate-equiv-structures (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-1))
                                   (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-2))))
  :rule-classes :congruence)

(local
 (encapsulate
   ()

   (local (in-theory (e/d* ()
                           (loghead-of-non-integerp
                            acl2::ash-0
                            (:t bitops::logtail-natp)
                            unsigned-byte-p-of-logtail))))

   (defthm all-mem-except-paging-structures-equal-with-mv-nth-2-ia32e-la-to-pa-1G-pages
     (implies
      (and
       ;; (equal (page-present
       ;;         (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
       ;;        1)
       (equal
        (page-size (rm-low-64
                    (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
        0)
       (equal
        (page-size
         (rm-low-64 (page-dir-ptr-table-entry-addr (logext 48 lin-addr) (page-dir-ptr-table-base-addr (logext 48 lin-addr) x86))
                    x86))
        1))
      (all-mem-except-paging-structures-equal
       (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
       x86))
     :hints (("Goal"
              :in-theory (e/d* (ia32e-la-to-pa
                                ia32e-la-to-pa-pml4-table
                                ia32e-la-to-pa-page-dir-ptr-table
                                ia32e-pml4ebits->pdpt
                                cr3bits->pdb)
                               (bitops::logand-with-negated-bitmask
                                accessed-bit
                                dirty-bit
                                force (force)
                                not)))))

   (defthm all-mem-except-paging-structures-equal-with-mv-nth-2-ia32e-la-to-pa-2M-and-4K-pages
     (implies
      (and
       ;; (equal
       ;;  (page-present
       ;;   (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
       ;;  1)
       (equal
        (page-size
         (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
        0)
       ;; (equal
       ;;  (page-present
       ;;   (rm-low-64 (page-dir-ptr-table-entry-addr (logext 48 lin-addr) (page-dir-ptr-table-base-addr (logext 48 lin-addr) x86)) x86))
       ;;  1)
       ;; (equal
       ;;  (page-present
       ;;   (rm-low-64 (page-directory-entry-addr (logext 48 lin-addr) (page-directory-base-addr (logext 48 lin-addr) x86)) x86))
       ;;  1)
       )
      (all-mem-except-paging-structures-equal
       (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
       x86))
     :hints (("Goal"
              :in-theory (e/d* (ia32e-la-to-pa
                                ia32e-la-to-pa-pml4-table
                                ia32e-la-to-pa-page-dir-ptr-table
                                ia32e-pml4ebits->pdpt
                                cr3bits->pdb
                                ia32e-pdpte-pg-dirbits->pd)
                               (bitops::logand-with-negated-bitmask
                                accessed-bit
                                dirty-bit
                                force (force)
                                not)))))

   (defthm all-mem-except-paging-structures-equal-with-mv-nth-2-ia32e-la-to-pa-pml4-page-size=1
     (implies
      (equal (page-size
              (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
             1)
      (all-mem-except-paging-structures-equal
       (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
       x86))
     :hints (("Goal"

              :in-theory (e/d* (ia32e-la-to-pa
                                ia32e-la-to-pa-pml4-table
                                paging-entry-no-page-fault-p
                                page-fault-exception
                                cr3bits->pdb)
                               (bitops::logand-with-negated-bitmask
                                accessed-bit
                                dirty-bit
                                force (force)
                                not)))))))

(defthm all-mem-except-paging-structures-equal-with-mv-nth-2-ia32e-la-to-pa
  (all-mem-except-paging-structures-equal
   (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
   (double-rewrite x86))
  :hints (("Goal"
           :cases ((and
                    ;; (equal (page-present
                    ;;         (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
                    ;;        1)
                    (equal
                     (page-size (rm-low-64
                                 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
                     0)
                    (equal
                     (page-size
                      (rm-low-64 (page-dir-ptr-table-entry-addr (logext 48 lin-addr) (page-dir-ptr-table-base-addr (logext 48 lin-addr) x86))
                                 x86))
                     1))

                   (and
                    ;; (equal
                    ;;  (page-present
                    ;;   (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
                    ;;  1)
                    (equal
                     (page-size
                      (rm-low-64 (pml4-table-entry-addr (logext 48 lin-addr) (pml4-table-base-addr x86)) x86))
                     0)
                    ;; (equal
                    ;;  (page-present
                    ;;   (rm-low-64 (page-dir-ptr-table-entry-addr (logext 48 lin-addr) (page-dir-ptr-table-base-addr (logext 48 lin-addr) x86)) x86))
                    ;;  1)
                    ;; (equal
                    ;;  (page-present
                    ;;   (rm-low-64 (page-directory-entry-addr (logext 48 lin-addr) (page-directory-base-addr (logext 48 lin-addr) x86)) x86))
                    ;;  1)
                    ))
           :in-theory (e/d* ()
                            (bitops::logand-with-negated-bitmask
                             accessed-bit
                             dirty-bit
                             force (force)
                             not)))))

(defthm all-mem-except-paging-structures-equal-with-two-mv-nth-2-ia32e-la-to-pa-cong
  (implies (all-mem-except-paging-structures-equal x86-1 x86-2)
           (all-mem-except-paging-structures-equal
            (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-1))
            (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-2))))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-with-mv-nth-2-ia32e-la-to-pa
  ;; without the 64-bit mode hyp, this theorem is not true,
  ;; because ia32e-la-to-pa may mark bits in the state
  (implies (64-bit-modep x86)
           (xlate-equiv-memory
            (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))
            (double-rewrite x86)))
  :hints (("Goal" :do-not '(preprocess)
           :in-theory (e/d* (xlate-equiv-memory)
                            (bitops::logand-with-negated-bitmask
                             accessed-bit
                             dirty-bit
                             not)))))

(defthm xlate-equiv-memory-with-two-mv-nth-2-ia32e-la-to-pa-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (xlate-equiv-memory
            (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-1))
            (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86-2))))
  :rule-classes :congruence
  ;; add the following after adding 64-bit mode hyp to previous theorem:
  :hints (("Goal" :in-theory (enable xlate-equiv-memory))))

(defthm two-page-walks-ia32e-la-to-pa
  (implies
   ;; the 64-bit mode hyp makes the proof of this theorem easy
   ;; (via xlate-equiv-memory-with-mv-nth-2-ia32e-la-to-pa above),
   ;; but could this hyp be removed from here?
   (64-bit-modep x86)
   (and

    (equal
     (mv-nth 0 (ia32e-la-to-pa lin-addr-1 r-w-x-1
                               (mv-nth 2 (ia32e-la-to-pa lin-addr-2 r-w-x-2 x86))))
     (mv-nth 0 (ia32e-la-to-pa lin-addr-1 r-w-x-1 x86)))

    (equal
     (mv-nth 1 (ia32e-la-to-pa lin-addr-1 r-w-x-1
                               (mv-nth 2 (ia32e-la-to-pa lin-addr-2 r-w-x-2 x86))))
     (mv-nth 1 (ia32e-la-to-pa lin-addr-1 r-w-x-1 x86)))))

  :hints (("Goal" :in-theory (e/d* () (ia32e-la-to-pa)))))

(in-theory (e/d* () (ia32e-la-to-pa)))

;; ======================================================================

(defthm gather-all-paging-structure-qword-addresses-mv-nth-2-ia32e-la-to-pa
  (equal (gather-all-paging-structure-qword-addresses
          (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86)))
         (gather-all-paging-structure-qword-addresses x86))
  :hints (("Goal"
           :use ((:instance
                  gather-all-paging-structure-qword-addresses-with-xlate-equiv-structures
                  (x86-equiv (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))))))))


(defthm xlate-equiv-entries-at-qword-addresses-mv-nth-2-ia32e-la-to-pa
  (implies (equal addrs (gather-all-paging-structure-qword-addresses x86))
           (equal (xlate-equiv-entries-at-qword-addresses
                   addrs addrs
                   x86
                   (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86)))
                  (xlate-equiv-entries-at-qword-addresses addrs addrs x86 x86)))
  :hints (("Goal" :in-theory (e/d* ()
                                   (xlate-equiv-structures-and-xlate-equiv-entries-at-qword-addresses
                                    booleanp-of-xlate-equiv-entries-at-qword-addresses))
           :use ((:instance xlate-equiv-structures-and-xlate-equiv-entries-at-qword-addresses
                            (addrs (gather-all-paging-structure-qword-addresses x86))
                            (x86 x86)
                            (x86-equiv (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))))
                 (:instance booleanp-of-xlate-equiv-entries-at-qword-addresses
                            (addrs (gather-all-paging-structure-qword-addresses x86))
                            (x x86)
                            (y x86))
                 (:instance booleanp-of-xlate-equiv-entries-at-qword-addresses
                            (addrs (gather-all-paging-structure-qword-addresses x86))
                            (x x86)
                            (y (mv-nth 2 (ia32e-la-to-pa lin-addr r-w-x x86))))))))

;; ======================================================================

;; Lemmas about las-to-pas:

(defthmd xlate-equiv-memory-and-las-to-pas
  (implies (xlate-equiv-memory (double-rewrite x86-1) x86-2)
           (and
            (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x x86-1))
                   (mv-nth 0 (las-to-pas n lin-addr r-w-x x86-2)))
            (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x x86-1))
                   (mv-nth 1 (las-to-pas n lin-addr r-w-x x86-2)))))
  :hints (("Goal"
           :induct (cons (las-to-pas n lin-addr r-w-x x86-1)
                         (las-to-pas n lin-addr r-w-x x86-2)))))

(defthm xlate-equiv-memory-and-mv-nth-0-las-to-pas-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (mv-nth 0 (las-to-pas n lin-addr r-w-x x86-1))
                  (mv-nth 0 (las-to-pas n lin-addr r-w-x x86-2))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory-and-las-to-pas) ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-and-mv-nth-1-las-to-pas-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (equal (mv-nth 1 (las-to-pas n lin-addr r-w-x x86-1))
                  (mv-nth 1 (las-to-pas n lin-addr r-w-x x86-2))))
  :hints (("Goal" :in-theory (e/d* (xlate-equiv-memory-and-las-to-pas) ())))
  :rule-classes :congruence)

(defthm xlate-equiv-memory-with-mv-nth-2-las-to-pas
  ;; the 64-bit mode hyp makes the proof of this theorem easy
  ;; (via xlate-equiv-memory-with-mv-nth-2-ia32e-la-to-pa),
  ;; but could this hyp be removed from here?
  (implies (64-bit-modep (double-rewrite x86))
           (xlate-equiv-memory
            (mv-nth 2 (las-to-pas n lin-addr r-w-x x86))
            (double-rewrite x86)))
  :hints (("Goal" :induct (las-to-pas n lin-addr r-w-x x86))))

(defthm xlate-equiv-memory-with-two-mv-nth-2-las-to-pas-cong
  (implies (xlate-equiv-memory x86-1 x86-2)
           (xlate-equiv-memory
            (mv-nth 2 (las-to-pas n lin-addr r-w-x x86-1))
            (mv-nth 2 (las-to-pas n lin-addr r-w-x x86-2))))
  :hints (("Goal"
           :induct (cons (las-to-pas n lin-addr r-w-x x86-1)
                         (las-to-pas n lin-addr r-w-x x86-2))))
  :rule-classes :congruence)

;; ======================================================================