summaryrefslogtreecommitdiff
path: root/books/workshops/2000/sumners1/cdeq/cdeq-phase1.lisp
blob: c1b0fc3e8e564d04719a623ef81644948bd3aa60 (plain)
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
(in-package "ACL2")

;;;; PROVE cdeq+ <-> cdeq

;;;; we will need a book on record ops and theorems

(include-book "cdeq-defs")

#|----------------------------------------------------------------------------|#

;;;; BEGIN rep, rank, commit, pick, and suff functions ;;;;

(defun rep-thf (f)
  (>_ :loc (loc f)
      :old (old f)
      :bot (bot f)
      :ret (ret f)
      :new (new f)
      :itm (itm f)))

(defthm additive-factoid2
  (implies (and (integerp x) (integerp y))
           (equal (+ x (- x) y) y)))

(defun rep-tvs (N x)
  (if (zp N) ()
    (-> (rep-tvs (1- N) x) N
        (rep-thf (<- x N)))))

(in-theory (disable rep-thf))
(in-theory (enable indexp))

(defthm rep-tvs-unaffected-addresses
  (implies (and (integerp i) (integerp j) (< i j))
           (equal (rep-tvs i (-> x j v))
                  (rep-tvs i x))))

(defthm rep-tvs-rep-thf-reduce
  (implies (indexp i N)
           (equal (rep-tvs N (-> x i f))
                  (-> (rep-tvs N x) i (rep-thf f))))
  :hints (("Subgoal *1/4" :cases ((equal i n)))
          ("Subgoal *1/3" :in-theory (enable posp))))

(defthm rep-tvs-absorbs-update
  (implies (and (indexp i N)
                (equal (rep-thf (<- x i)) v))
           (equal (-> (rep-tvs N x) i v)
                  (rep-tvs N x)))
  :hints (("Subgoal *1/4" :cases ((equal i n)))
          ("Subgoal *1/3" :in-theory (enable posp))))

(defthm rep-tvs-get-is-rep-thf
  (implies (indexp i N)
           (equal (<- (rep-tvs N x) i)
                  (rep-thf (<- x i))))
  :hints (("Subgoal *1/4" :cases ((equal i n)))
          ("Subgoal *1/3" :in-theory (enable posp))))

(in-theory (disable indexp))
(in-theory (enable rep-thf))

(defun rep-onr (o)
  (>_ :loc (loc o)
      :old (old o)
      :bot (bot o)
      :ret (ret o)
      :new (new o)
      :itm (itm o)
      :dtm (dtm o)))

(defun rep-shr (s)
  (>_ :mem (mem s)
      :age (age s)
      :bot (bot s)
      :ret (ret s)
      :clk (clk s)))

(DEFUN rep (st)
  (>_ :shr (rep-shr (shr st))
      :onr (rep-onr (onr st))
      :tvs (rep-tvs (maxf) (tvs st))))


(DEFUN pick (st in) (declare (ignore st)) in)

(DEFUN rank (st) (declare (ignore st)) 0)

(DEFUN commit (st in) (declare (ignore st in)) t)

(DEFUN suff (st in) (declare (ignore st in)) t)


;;;; END rep, rank, commit, pick, and suff functions ;;;;

#|----------------------------------------------------------------------------|#

;;;; BEGIN refinement >> proof -- labeling, stuttering, and matching ;;;;

(DEFTHM >>-well-founded
  (e0-ordinalp (rank s)))  ;; (bounded-ordp (rank s) 1)

(DEFTHM >>-label
  (equal (label (rep st)) (label st)))

(DEFTHM >>-stutter1
  (implies (and (suff st in)
                (not (commit st in)))
           (equal (rep (cdeq+ st in))
                  (rep st))))

(DEFTHM >>-stutter2
  (implies (and (suff st in)
                (not (commit st in)))
           (e0-ord-< (rank (cdeq+ st in))
                     (rank st))))

(DEFTHM >>-match
  (implies (and (suff st in)
                (commit st in))
           (equal (rep (cdeq+ st in))
                  (cdeq (rep st) (pick st in))))
  :hints (("Goal" :in-theory (disable (s))
           :expand ((:free (x) (rep x))
                    (:free (x) (rep-shr x))
                    (:free (x) (rep-onr x))
                    (:free (x) (rep-thf x))))))


;;;; END WEB proof -- labeling, stuttering, and matching ;;;;

#|----------------------------------------------------------------------------|#

;;;; BEGIN invariant defintion ;;;;

(DEFUN inv (st) (declare (ignore st)) t)

;;;; END invariant definition ;;;;

#|----------------------------------------------------------------------------|#

;;;; BEGIN invariant proof ;;;;

(DEFTHM >>-invariant-persistent
  (implies (inv st) (inv (cdeq+ st in))))

(DEFTHM >>-invariant-sufficient
  (implies (inv st) (suff st in)))

;;;; END invariant proof ;;;;

#|----------------------------------------------------------------------------|#