1 |
|
2 context HOL.thy; |
|
3 |
|
4 Goalw [Ex_def] "EX x. P x ==> P (@x. P x)"; |
|
5 by (assume_tac 1); |
|
6 qed "selectI1"; |
|
7 |
|
8 context thy; |
|
9 |
|
10 |
|
11 |
|
12 (** basic properties of "&&" and "||" **) |
|
13 |
|
14 (* unique existence *) |
|
15 |
|
16 Goalw [inf_def] "is_inf x y (x && y)"; |
|
17 by (rtac (ex_inf RS spec RS spec RS selectI1) 1); |
|
18 qed "inf_is_inf"; |
|
19 |
|
20 Goal "is_inf x y inf --> x && y = inf"; |
|
21 by (rtac impI 1); |
|
22 by (rtac (is_inf_uniq RS mp) 1); |
|
23 by (rtac conjI 1); |
|
24 by (rtac inf_is_inf 1); |
|
25 by (assume_tac 1); |
|
26 qed "inf_uniq"; |
|
27 |
|
28 Goalw [Ex1_def] "ALL x y. EX! inf::'a::lattice. is_inf x y inf"; |
|
29 by Safe_tac; |
|
30 by (Step_tac 1); |
|
31 by (Step_tac 1); |
|
32 by (rtac inf_is_inf 1); |
|
33 by (rtac (inf_uniq RS mp RS sym) 1); |
|
34 by (assume_tac 1); |
|
35 qed "ex1_inf"; |
|
36 |
|
37 |
|
38 Goalw [sup_def] "is_sup x y (x || y)"; |
|
39 by (rtac (ex_sup RS spec RS spec RS selectI1) 1); |
|
40 qed "sup_is_sup"; |
|
41 |
|
42 Goal "is_sup x y sup --> x || y = sup"; |
|
43 by (rtac impI 1); |
|
44 by (rtac (is_sup_uniq RS mp) 1); |
|
45 by (rtac conjI 1); |
|
46 by (rtac sup_is_sup 1); |
|
47 by (assume_tac 1); |
|
48 qed "sup_uniq"; |
|
49 |
|
50 Goalw [Ex1_def] "ALL x y. EX! sup::'a::lattice. is_sup x y sup"; |
|
51 by Safe_tac; |
|
52 by (Step_tac 1); |
|
53 by (Step_tac 1); |
|
54 by (rtac sup_is_sup 1); |
|
55 by (rtac (sup_uniq RS mp RS sym) 1); |
|
56 by (assume_tac 1); |
|
57 qed "ex1_sup"; |
|
58 |
|
59 |
|
60 (* "&&" yields g.l.bs, "||" yields l.u.bs. --- in pieces *) |
|
61 |
|
62 val tac = |
|
63 cut_facts_tac [inf_is_inf] 1 THEN |
|
64 rewrite_goals_tac [inf_def, is_inf_def] THEN |
|
65 Fast_tac 1; |
|
66 |
|
67 Goal "x && y [= x"; |
|
68 by tac; |
|
69 qed "inf_lb1"; |
|
70 |
|
71 Goal "x && y [= y"; |
|
72 by tac; |
|
73 qed "inf_lb2"; |
|
74 |
|
75 val prems = goal thy "[| z [= x; z [= y |] ==> z [= x && y"; |
|
76 by (cut_facts_tac prems 1); |
|
77 by tac; |
|
78 qed "inf_ub_lbs"; |
|
79 |
|
80 |
|
81 val tac = |
|
82 cut_facts_tac [sup_is_sup] 1 THEN |
|
83 rewrite_goals_tac [sup_def, is_sup_def] THEN |
|
84 Fast_tac 1; |
|
85 |
|
86 Goal "x [= x || y"; |
|
87 by tac; |
|
88 qed "sup_ub1"; |
|
89 |
|
90 Goal "y [= x || y"; |
|
91 by tac; |
|
92 qed "sup_ub2"; |
|
93 |
|
94 val prems = goal thy "[| x [= z; y [= z |] ==> x || y [= z"; |
|
95 by (cut_facts_tac prems 1); |
|
96 by tac; |
|
97 qed "sup_lb_ubs"; |
|
98 |
|
99 |
|
100 |
|
101 (** some equations concerning "&&" and "||" vs. "[=" **) |
|
102 |
|
103 (* the Connection Theorems: "[=" expressed via "&&" or "||" *) |
|
104 |
|
105 Goal "(x && y = x) = (x [= y)"; |
|
106 by (rtac iffI 1); |
|
107 (*==>*) |
|
108 by (etac subst 1); |
|
109 by (rtac inf_lb2 1); |
|
110 (*<==*) |
|
111 by (rtac (inf_uniq RS mp) 1); |
|
112 by (rewtac is_inf_def); |
|
113 by (REPEAT_FIRST (rtac conjI)); |
|
114 by (rtac le_refl 1); |
|
115 by (assume_tac 1); |
|
116 by (Fast_tac 1); |
|
117 qed "inf_connect"; |
|
118 |
|
119 Goal "(x || y = y) = (x [= y)"; |
|
120 by (rtac iffI 1); |
|
121 (*==>*) |
|
122 by (etac subst 1); |
|
123 by (rtac sup_ub1 1); |
|
124 (*<==*) |
|
125 by (rtac (sup_uniq RS mp) 1); |
|
126 by (rewtac is_sup_def); |
|
127 by (REPEAT_FIRST (rtac conjI)); |
|
128 by (assume_tac 1); |
|
129 by (rtac le_refl 1); |
|
130 by (Fast_tac 1); |
|
131 qed "sup_connect"; |
|
132 |
|
133 |
|
134 (* minorized infs / majorized sups *) |
|
135 |
|
136 Goal "(x [= y && z) = (x [= y & x [= z)"; |
|
137 by (rtac iffI 1); |
|
138 (*==> (level 1)*) |
|
139 by (cut_facts_tac [inf_lb1, inf_lb2] 1); |
|
140 by (rtac conjI 1); |
|
141 by (rtac (le_trans RS mp) 1); |
|
142 by (etac conjI 1); |
|
143 by (assume_tac 1); |
|
144 by (rtac (le_trans RS mp) 1); |
|
145 by (etac conjI 1); |
|
146 by (assume_tac 1); |
|
147 (*<== (level 9)*) |
|
148 by (etac conjE 1); |
|
149 by (etac inf_ub_lbs 1); |
|
150 by (assume_tac 1); |
|
151 qed "le_inf_eq"; |
|
152 |
|
153 Goal "(x || y [= z) = (x [= z & y [= z)"; |
|
154 by (rtac iffI 1); |
|
155 (*==> (level 1)*) |
|
156 by (cut_facts_tac [sup_ub1, sup_ub2] 1); |
|
157 by (rtac conjI 1); |
|
158 by (rtac (le_trans RS mp) 1); |
|
159 by (etac conjI 1); |
|
160 by (assume_tac 1); |
|
161 by (rtac (le_trans RS mp) 1); |
|
162 by (etac conjI 1); |
|
163 by (assume_tac 1); |
|
164 (*<== (level 9)*) |
|
165 by (etac conjE 1); |
|
166 by (etac sup_lb_ubs 1); |
|
167 by (assume_tac 1); |
|
168 qed "ge_sup_eq"; |
|
169 |
|
170 |
|
171 (** algebraic properties of "&&" and "||": A, C, I, AB **) |
|
172 |
|
173 (* associativity *) |
|
174 |
|
175 Goal "(x && y) && z = x && (y && z)"; |
|
176 by (stac (inf_uniq RS mp RS sym) 1); |
|
177 back(); |
|
178 back(); |
|
179 back(); |
|
180 back(); |
|
181 back(); |
|
182 back(); |
|
183 back(); |
|
184 back(); |
|
185 by (rtac refl 2); |
|
186 by (rtac (is_inf_assoc RS mp) 1); |
|
187 by (REPEAT_FIRST (rtac conjI)); |
|
188 by (REPEAT_FIRST (rtac inf_is_inf)); |
|
189 qed "inf_assoc"; |
|
190 |
|
191 Goal "(x || y) || z = x || (y || z)"; |
|
192 by (stac (sup_uniq RS mp RS sym) 1); |
|
193 back(); |
|
194 back(); |
|
195 back(); |
|
196 back(); |
|
197 back(); |
|
198 back(); |
|
199 back(); |
|
200 back(); |
|
201 by (rtac refl 2); |
|
202 by (rtac (is_sup_assoc RS mp) 1); |
|
203 by (REPEAT_FIRST (rtac conjI)); |
|
204 by (REPEAT_FIRST (rtac sup_is_sup)); |
|
205 qed "sup_assoc"; |
|
206 |
|
207 |
|
208 (* commutativity *) |
|
209 |
|
210 Goalw [inf_def] "x && y = y && x"; |
|
211 by (stac (is_inf_commut RS ext) 1); |
|
212 by (rtac refl 1); |
|
213 qed "inf_commut"; |
|
214 |
|
215 Goalw [sup_def] "x || y = y || x"; |
|
216 by (stac (is_sup_commut RS ext) 1); |
|
217 by (rtac refl 1); |
|
218 qed "sup_commut"; |
|
219 |
|
220 |
|
221 (* idempotency *) |
|
222 |
|
223 Goal "x && x = x"; |
|
224 by (stac inf_connect 1); |
|
225 by (rtac le_refl 1); |
|
226 qed "inf_idemp"; |
|
227 |
|
228 Goal "x || x = x"; |
|
229 by (stac sup_connect 1); |
|
230 by (rtac le_refl 1); |
|
231 qed "sup_idemp"; |
|
232 |
|
233 |
|
234 (* absorption *) |
|
235 |
|
236 Goal "x || (x && y) = x"; |
|
237 by (stac sup_commut 1); |
|
238 by (stac sup_connect 1); |
|
239 by (rtac inf_lb1 1); |
|
240 qed "sup_inf_absorb"; |
|
241 |
|
242 Goal "x && (x || y) = x"; |
|
243 by (stac inf_connect 1); |
|
244 by (rtac sup_ub1 1); |
|
245 qed "inf_sup_absorb"; |
|
246 |
|
247 |
|
248 (* monotonicity *) |
|
249 |
|
250 val prems = goal thy "[| a [= b; x [= y |] ==> a && x [= b && y"; |
|
251 by (cut_facts_tac prems 1); |
|
252 by (stac le_inf_eq 1); |
|
253 by (rtac conjI 1); |
|
254 by (rtac (le_trans RS mp) 1); |
|
255 by (rtac conjI 1); |
|
256 by (rtac inf_lb1 1); |
|
257 by (assume_tac 1); |
|
258 by (rtac (le_trans RS mp) 1); |
|
259 by (rtac conjI 1); |
|
260 by (rtac inf_lb2 1); |
|
261 by (assume_tac 1); |
|
262 qed "inf_mon"; |
|
263 |
|
264 val prems = goal thy "[| a [= b; x [= y |] ==> a || x [= b || y"; |
|
265 by (cut_facts_tac prems 1); |
|
266 by (stac ge_sup_eq 1); |
|
267 by (rtac conjI 1); |
|
268 by (rtac (le_trans RS mp) 1); |
|
269 by (rtac conjI 1); |
|
270 by (assume_tac 1); |
|
271 by (rtac sup_ub1 1); |
|
272 by (rtac (le_trans RS mp) 1); |
|
273 by (rtac conjI 1); |
|
274 by (assume_tac 1); |
|
275 by (rtac sup_ub2 1); |
|
276 qed "sup_mon"; |
|