| author | wenzelm |
| Tue, 09 Mar 1999 12:09:22 +0100 | |
| changeset 6318 | 4a423e8a0b54 |
| parent 6295 | 351b3c2b0d83 |
| child 6535 | 880f31a62784 |
| permissions | -rw-r--r-- |
| 4776 | 1 |
(* Title: HOL/UNITY/UNITY |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
6 |
The basic UNITY theory (revised version, based upon the "co" operator) |
|
7 |
||
8 |
From Misra, "A Logic for Concurrent Programming", 1994 |
|
9 |
*) |
|
10 |
||
11 |
set proof_timing; |
|
12 |
HOL_quantifiers := false; |
|
13 |
||
14 |
||
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
15 |
(*** General lemmas ***) |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
16 |
|
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
17 |
Goal "UNIV Times UNIV = UNIV"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
18 |
by Auto_tac; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
19 |
qed "UNIV_Times_UNIV"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
20 |
Addsimps [UNIV_Times_UNIV]; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
21 |
|
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
22 |
Goal "- (UNIV Times A) = UNIV Times (-A)"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
23 |
by Auto_tac; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
24 |
qed "Compl_Times_UNIV1"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
25 |
|
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
26 |
Goal "- (A Times UNIV) = (-A) Times UNIV"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
27 |
by Auto_tac; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
28 |
qed "Compl_Times_UNIV2"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
29 |
|
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
30 |
Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2]; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
31 |
|
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
32 |
|
| 4776 | 33 |
(*** constrains ***) |
34 |
||
| 5648 | 35 |
overload_1st_set "UNITY.constrains"; |
36 |
overload_1st_set "UNITY.stable"; |
|
37 |
overload_1st_set "UNITY.unless"; |
|
| 5340 | 38 |
|
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
39 |
val prems = Goalw [constrains_def] |
| 5648 | 40 |
"(!!act s s'. [| act: Acts F; (s,s') : act; s: A |] ==> s': A') \ |
41 |
\ ==> F : constrains A A'"; |
|
| 4776 | 42 |
by (blast_tac (claset() addIs prems) 1); |
43 |
qed "constrainsI"; |
|
44 |
||
| 5069 | 45 |
Goalw [constrains_def] |
| 5648 | 46 |
"[| F : constrains A A'; act: Acts F; (s,s'): act; s: A |] ==> s': A'"; |
| 4776 | 47 |
by (Blast_tac 1); |
48 |
qed "constrainsD"; |
|
49 |
||
| 5648 | 50 |
Goalw [constrains_def] "F : constrains {} B";
|
| 4776 | 51 |
by (Blast_tac 1); |
52 |
qed "constrains_empty"; |
|
53 |
||
| 5648 | 54 |
Goalw [constrains_def] "F : constrains A UNIV"; |
| 4776 | 55 |
by (Blast_tac 1); |
56 |
qed "constrains_UNIV"; |
|
57 |
AddIffs [constrains_empty, constrains_UNIV]; |
|
58 |
||
| 5648 | 59 |
(*monotonic in 2nd argument*) |
| 5069 | 60 |
Goalw [constrains_def] |
| 5648 | 61 |
"[| F : constrains A A'; A'<=B' |] ==> F : constrains A B'"; |
| 4776 | 62 |
by (Blast_tac 1); |
63 |
qed "constrains_weaken_R"; |
|
64 |
||
| 5648 | 65 |
(*anti-monotonic in 1st argument*) |
| 5069 | 66 |
Goalw [constrains_def] |
| 5648 | 67 |
"[| F : constrains A A'; B<=A |] ==> F : constrains B A'"; |
| 4776 | 68 |
by (Blast_tac 1); |
69 |
qed "constrains_weaken_L"; |
|
70 |
||
| 5069 | 71 |
Goalw [constrains_def] |
| 5648 | 72 |
"[| F : constrains A A'; B<=A; A'<=B' |] ==> F : constrains B B'"; |
| 4776 | 73 |
by (Blast_tac 1); |
74 |
qed "constrains_weaken"; |
|
75 |
||
76 |
(** Union **) |
|
77 |
||
| 5069 | 78 |
Goalw [constrains_def] |
| 5648 | 79 |
"[| F : constrains A A'; F : constrains B B' |] \ |
80 |
\ ==> F : constrains (A Un B) (A' Un B')"; |
|
| 4776 | 81 |
by (Blast_tac 1); |
82 |
qed "constrains_Un"; |
|
83 |
||
| 5069 | 84 |
Goalw [constrains_def] |
| 5648 | 85 |
"ALL i:I. F : constrains (A i) (A' i) \ |
86 |
\ ==> F : constrains (UN i:I. A i) (UN i:I. A' i)"; |
|
| 4776 | 87 |
by (Blast_tac 1); |
88 |
qed "ball_constrains_UN"; |
|
89 |
||
90 |
(** Intersection **) |
|
91 |
||
| 5069 | 92 |
Goalw [constrains_def] |
| 5648 | 93 |
"[| F : constrains A A'; F : constrains B B' |] \ |
94 |
\ ==> F : constrains (A Int B) (A' Int B')"; |
|
| 4776 | 95 |
by (Blast_tac 1); |
96 |
qed "constrains_Int"; |
|
97 |
||
| 5069 | 98 |
Goalw [constrains_def] |
| 5648 | 99 |
"ALL i:I. F : constrains (A i) (A' i) \ |
100 |
\ ==> F : constrains (INT i:I. A i) (INT i:I. A' i)"; |
|
| 4776 | 101 |
by (Blast_tac 1); |
102 |
qed "ball_constrains_INT"; |
|
103 |
||
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
104 |
Goalw [constrains_def] "F : constrains A A' ==> A <= A'"; |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
105 |
by Auto_tac; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
106 |
qed "constrains_imp_subset"; |
| 4776 | 107 |
|
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
108 |
(*The reasoning is by subsets since "constrains" refers to single actions |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
109 |
only. So this rule isn't that useful.*) |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
110 |
Goalw [constrains_def] |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
111 |
"[| F : constrains A B; F : constrains B C |] \ |
| 5648 | 112 |
\ ==> F : constrains A C"; |
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
113 |
by (Blast_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
114 |
qed "constrains_trans"; |
| 4776 | 115 |
|
|
6295
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
116 |
Goalw [constrains_def] |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
117 |
"[| F : constrains A (A' Un B); F : constrains B B' |] \ |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
118 |
\ ==> F : constrains A (A' Un B')"; |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
119 |
by (Clarify_tac 1); |
|
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
paulson
parents:
6012
diff
changeset
|
120 |
by (Blast_tac 1); |
|
6012
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
121 |
qed "constrains_cancel"; |
|
1894bfc4aee9
Addition of the States component; parts of Comp not working
paulson
parents:
5804
diff
changeset
|
122 |
|
| 4776 | 123 |
|
124 |
(*** stable ***) |
|
125 |
||
| 5648 | 126 |
Goalw [stable_def] "F : constrains A A ==> F : stable A"; |
| 4776 | 127 |
by (assume_tac 1); |
128 |
qed "stableI"; |
|
129 |
||
| 5648 | 130 |
Goalw [stable_def] "F : stable A ==> F : constrains A A"; |
| 4776 | 131 |
by (assume_tac 1); |
132 |
qed "stableD"; |
|
133 |
||
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
134 |
(** Union **) |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
135 |
|
| 5069 | 136 |
Goalw [stable_def] |
| 5648 | 137 |
"[| F : stable A; F : stable A' |] ==> F : stable (A Un A')"; |
| 4776 | 138 |
by (blast_tac (claset() addIs [constrains_Un]) 1); |
139 |
qed "stable_Un"; |
|
140 |
||
| 5069 | 141 |
Goalw [stable_def] |
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
142 |
"ALL i:I. F : stable (A i) ==> F : stable (UN i:I. A i)"; |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
143 |
by (blast_tac (claset() addIs [ball_constrains_UN]) 1); |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
144 |
qed "ball_stable_UN"; |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
145 |
|
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
146 |
(** Intersection **) |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
147 |
|
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
148 |
Goalw [stable_def] |
| 5648 | 149 |
"[| F : stable A; F : stable A' |] ==> F : stable (A Int A')"; |
| 4776 | 150 |
by (blast_tac (claset() addIs [constrains_Int]) 1); |
151 |
qed "stable_Int"; |
|
152 |
||
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
153 |
Goalw [stable_def] |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
154 |
"ALL i:I. F : stable (A i) ==> F : stable (INT i:I. A i)"; |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
155 |
by (blast_tac (claset() addIs [ball_constrains_INT]) 1); |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
156 |
qed "ball_stable_INT"; |
|
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
157 |
|
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
158 |
Goalw [stable_def, constrains_def] |
| 5648 | 159 |
"[| F : stable C; F : constrains A (C Un A') |] \ |
160 |
\ ==> F : constrains (C Un A) (C Un A')"; |
|
| 4776 | 161 |
by (Blast_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
162 |
qed "stable_constrains_Un"; |
| 4776 | 163 |
|
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
164 |
Goalw [stable_def, constrains_def] |
| 5648 | 165 |
"[| F : stable C; F : constrains (C Int A) A' |] \ |
166 |
\ ==> F : constrains (C Int A) (C Int A')"; |
|
| 4776 | 167 |
by (Blast_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5253
diff
changeset
|
168 |
qed "stable_constrains_Int"; |
| 4776 | 169 |
|
| 5648 | 170 |
Goal "Init F <= reachable F"; |
171 |
by (blast_tac (claset() addIs reachable.intrs) 1); |
|
172 |
qed "Init_subset_reachable"; |
|
| 4776 | 173 |
|
| 5648 | 174 |
Goal "Acts G <= Acts F ==> G : stable (reachable F)"; |
175 |
by (blast_tac (claset() addIs [stableI, constrainsI] @ reachable.intrs) 1); |
|
176 |
qed "stable_reachable"; |
|
177 |
||
178 |
(*[| F : stable C; F : constrains (C Int A) A |] ==> F : stable (C Int A)*) |
|
179 |
bind_thm ("stable_constrains_stable", stable_constrains_Int RS stableI);
|
|
180 |
||
181 |
||
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
182 |
(*** invariant ***) |
| 5648 | 183 |
|
184 |
Goal "[| Init F<=A; F: stable A |] ==> F : invariant A"; |
|
185 |
by (asm_simp_tac (simpset() addsimps [invariant_def]) 1); |
|
186 |
qed "invariantI"; |
|
187 |
||
188 |
(*Could also say "invariant A Int invariant B <= invariant (A Int B)"*) |
|
189 |
Goal "[| F : invariant A; F : invariant B |] ==> F : invariant (A Int B)"; |
|
190 |
by (auto_tac (claset(), simpset() addsimps [invariant_def, stable_Int])); |
|
191 |
qed "invariant_Int"; |
|
192 |
||
193 |
(*The set of all reachable states is an invariant...*) |
|
194 |
Goal "F : invariant (reachable F)"; |
|
195 |
by (simp_tac (simpset() addsimps [invariant_def]) 1); |
|
196 |
by (blast_tac (claset() addIs (stable_reachable::reachable.intrs)) 1); |
|
197 |
qed "invariant_reachable"; |
|
198 |
||
199 |
(*...in fact the strongest invariant!*) |
|
200 |
Goal "F : invariant A ==> reachable F <= A"; |
|
201 |
by (full_simp_tac |
|
202 |
(simpset() addsimps [stable_def, constrains_def, invariant_def]) 1); |
|
203 |
by (rtac subsetI 1); |
|
204 |
by (etac reachable.induct 1); |
|
205 |
by (REPEAT (blast_tac (claset() addIs reachable.intrs) 1)); |
|
206 |
qed "invariant_includes_reachable"; |
|
207 |
||
208 |
||
209 |
(*** increasing ***) |
|
210 |
||
211 |
Goalw [increasing_def, stable_def, constrains_def] |
|
212 |
"increasing f <= increasing (length o f)"; |
|
213 |
by Auto_tac; |
|
214 |
by (blast_tac (claset() addIs [prefix_length_le, le_trans]) 1); |
|
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
215 |
qed "increasing_size"; |
| 5648 | 216 |
|
217 |
Goalw [increasing_def] |
|
218 |
"increasing f <= {F. ALL z::nat. F: stable {s. z < f s}}";
|
|
219 |
by (simp_tac (simpset() addsimps [Suc_le_eq RS sym]) 1); |
|
220 |
by (Blast_tac 1); |
|
|
5804
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier. New lemmas
paulson
parents:
5669
diff
changeset
|
221 |
qed "increasing_stable_less"; |
| 5648 | 222 |
|
223 |
||
224 |
(** The Elimination Theorem. The "free" m has become universally quantified! |
|
225 |
Should the premise be !!m instead of ALL m ? Would make it harder to use |
|
226 |
in forward proof. **) |
|
227 |
||
| 5069 | 228 |
Goalw [constrains_def] |
| 5648 | 229 |
"[| ALL m. F : constrains {s. s x = m} (B m) |] \
|
230 |
\ ==> F : constrains {s. s x : M} (UN m:M. B m)";
|
|
| 4776 | 231 |
by (Blast_tac 1); |
232 |
qed "elimination"; |
|
233 |
||
234 |
(*As above, but for the trivial case of a one-variable state, in which the |
|
235 |
state is identified with its one variable.*) |
|
| 5069 | 236 |
Goalw [constrains_def] |
| 5648 | 237 |
"(ALL m. F : constrains {m} (B m)) ==> F : constrains M (UN m:M. B m)";
|
| 4776 | 238 |
by (Blast_tac 1); |
239 |
qed "elimination_sing"; |
|
240 |
||
241 |
||
242 |
||
243 |
(*** Theoretical Results from Section 6 ***) |
|
244 |
||
| 5069 | 245 |
Goalw [constrains_def, strongest_rhs_def] |
| 5648 | 246 |
"F : constrains A (strongest_rhs F A )"; |
| 4776 | 247 |
by (Blast_tac 1); |
248 |
qed "constrains_strongest_rhs"; |
|
249 |
||
| 5069 | 250 |
Goalw [constrains_def, strongest_rhs_def] |
| 5648 | 251 |
"F : constrains A B ==> strongest_rhs F A <= B"; |
| 4776 | 252 |
by (Blast_tac 1); |
253 |
qed "strongest_rhs_is_strongest"; |