| author | wenzelm | 
| Fri, 27 Aug 1999 18:59:27 +0200 | |
| changeset 7380 | 2bcee6a460d8 | 
| parent 7345 | 59bc887290df | 
| child 7403 | c318acb88251 | 
| 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 | ||
| 13 | ||
| 6012 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 14 | (*** General lemmas ***) | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 15 | |
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 16 | Goal "UNIV Times UNIV = UNIV"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 17 | by Auto_tac; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 18 | qed "UNIV_Times_UNIV"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 19 | Addsimps [UNIV_Times_UNIV]; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 20 | |
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 21 | Goal "- (UNIV Times A) = UNIV Times (-A)"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 22 | by Auto_tac; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 23 | qed "Compl_Times_UNIV1"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 24 | |
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 25 | Goal "- (A Times UNIV) = (-A) Times UNIV"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 26 | by Auto_tac; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 27 | qed "Compl_Times_UNIV2"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 28 | |
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 29 | Addsimps [Compl_Times_UNIV1, Compl_Times_UNIV2]; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 30 | |
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 31 | |
| 6535 | 32 | (*** The abstract type of programs ***) | 
| 33 | ||
| 34 | val rep_ss = simpset() addsimps | |
| 35 | [Init_def, Acts_def, mk_program_def, Program_def, Rep_Program, | |
| 36 | Rep_Program_inverse, Abs_Program_inverse]; | |
| 37 | ||
| 38 | ||
| 39 | Goal "Id : Acts F"; | |
| 40 | by (cut_inst_tac [("x", "F")] Rep_Program 1);
 | |
| 41 | by (auto_tac (claset(), rep_ss)); | |
| 42 | qed "Id_in_Acts"; | |
| 43 | AddIffs [Id_in_Acts]; | |
| 44 | ||
| 45 | Goal "insert Id (Acts F) = Acts F"; | |
| 46 | by (simp_tac (simpset() addsimps [insert_absorb, Id_in_Acts]) 1); | |
| 47 | qed "insert_Id_Acts"; | |
| 48 | AddIffs [insert_Id_Acts]; | |
| 49 | ||
| 50 | (** Inspectors for type "program" **) | |
| 51 | ||
| 52 | Goal "Init (mk_program (init,acts)) = init"; | |
| 53 | by (auto_tac (claset(), rep_ss)); | |
| 54 | qed "Init_eq"; | |
| 55 | ||
| 56 | Goal "Acts (mk_program (init,acts)) = insert Id acts"; | |
| 57 | by (auto_tac (claset(), rep_ss)); | |
| 58 | qed "Acts_eq"; | |
| 59 | ||
| 60 | Addsimps [Acts_eq, Init_eq]; | |
| 61 | ||
| 62 | ||
| 63 | (** The notation of equality for type "program" **) | |
| 64 | ||
| 65 | Goal "[| Init F = Init G; Acts F = Acts G |] ==> F = G"; | |
| 66 | by (subgoals_tac ["EX x. Rep_Program F = x", | |
| 67 | "EX x. Rep_Program G = x"] 1); | |
| 68 | by (REPEAT (Blast_tac 2)); | |
| 69 | by (Clarify_tac 1); | |
| 70 | by (auto_tac (claset(), rep_ss)); | |
| 71 | by (REPEAT (dres_inst_tac [("f", "Abs_Program")] arg_cong 1));
 | |
| 72 | by (asm_full_simp_tac rep_ss 1); | |
| 73 | qed "program_equalityI"; | |
| 74 | ||
| 75 | val [major,minor] = | |
| 76 | Goal "[| F = G; [| Init F = Init G; Acts F = Acts G |] ==> P |] ==> P"; | |
| 77 | by (rtac minor 1); | |
| 78 | by (auto_tac (claset(), simpset() addsimps [major])); | |
| 79 | qed "program_equalityE"; | |
| 80 | ||
| 81 | ||
| 82 | (*** These rules allow "lazy" definition expansion | |
| 83 | They avoid expanding the full program, which is a large expression | |
| 84 | ***) | |
| 85 | ||
| 86 | Goal "F == mk_program (init,acts) ==> Init F = init"; | |
| 87 | by Auto_tac; | |
| 88 | qed "def_prg_Init"; | |
| 89 | ||
| 90 | (*The program is not expanded, but its Init and Acts are*) | |
| 91 | val [rew] = goal thy | |
| 92 | "[| F == mk_program (init,acts) |] \ | |
| 93 | \ ==> Init F = init & Acts F = insert Id acts"; | |
| 94 | by (rewtac rew); | |
| 95 | by Auto_tac; | |
| 96 | qed "def_prg_simps"; | |
| 97 | ||
| 98 | (*An action is expanded only if a pair of states is being tested against it*) | |
| 99 | Goal "[| act == {(s,s'). P s s'} |] ==> ((s,s') : act) = P s s'";
 | |
| 100 | by Auto_tac; | |
| 101 | qed "def_act_simp"; | |
| 102 | ||
| 103 | fun simp_of_act def = def RS def_act_simp; | |
| 104 | ||
| 105 | (*A set is expanded only if an element is being tested against it*) | |
| 106 | Goal "A == B ==> (x : A) = (x : B)"; | |
| 107 | by Auto_tac; | |
| 108 | qed "def_set_simp"; | |
| 109 | ||
| 110 | fun simp_of_set def = def RS def_set_simp; | |
| 111 | ||
| 112 | ||
| 6536 | 113 | (*** co ***) | 
| 4776 | 114 | |
| 6536 | 115 | overload_1st_set "UNITY.op co"; | 
| 5648 | 116 | overload_1st_set "UNITY.stable"; | 
| 117 | overload_1st_set "UNITY.unless"; | |
| 5340 | 118 | |
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 119 | val prems = Goalw [constrains_def] | 
| 5648 | 120 | "(!!act s s'. [| act: Acts F; (s,s') : act; s: A |] ==> s': A') \ | 
| 6536 | 121 | \ ==> F : A co A'"; | 
| 4776 | 122 | by (blast_tac (claset() addIs prems) 1); | 
| 123 | qed "constrainsI"; | |
| 124 | ||
| 5069 | 125 | Goalw [constrains_def] | 
| 6536 | 126 | "[| F : A co A'; act: Acts F; (s,s'): act; s: A |] ==> s': A'"; | 
| 4776 | 127 | by (Blast_tac 1); | 
| 128 | qed "constrainsD"; | |
| 129 | ||
| 6536 | 130 | Goalw [constrains_def] "F : {} co B";
 | 
| 4776 | 131 | by (Blast_tac 1); | 
| 132 | qed "constrains_empty"; | |
| 133 | ||
| 6536 | 134 | Goalw [constrains_def] "F : A co UNIV"; | 
| 4776 | 135 | by (Blast_tac 1); | 
| 136 | qed "constrains_UNIV"; | |
| 137 | AddIffs [constrains_empty, constrains_UNIV]; | |
| 138 | ||
| 5648 | 139 | (*monotonic in 2nd argument*) | 
| 5069 | 140 | Goalw [constrains_def] | 
| 6536 | 141 | "[| F : A co A'; A'<=B' |] ==> F : A co B'"; | 
| 4776 | 142 | by (Blast_tac 1); | 
| 143 | qed "constrains_weaken_R"; | |
| 144 | ||
| 5648 | 145 | (*anti-monotonic in 1st argument*) | 
| 5069 | 146 | Goalw [constrains_def] | 
| 6536 | 147 | "[| F : A co A'; B<=A |] ==> F : B co A'"; | 
| 4776 | 148 | by (Blast_tac 1); | 
| 149 | qed "constrains_weaken_L"; | |
| 150 | ||
| 5069 | 151 | Goalw [constrains_def] | 
| 6536 | 152 | "[| F : A co A'; B<=A; A'<=B' |] ==> F : B co B'"; | 
| 4776 | 153 | by (Blast_tac 1); | 
| 154 | qed "constrains_weaken"; | |
| 155 | ||
| 156 | (** Union **) | |
| 157 | ||
| 5069 | 158 | Goalw [constrains_def] | 
| 7345 | 159 | "[| F : A co A'; F : B co B' |] ==> F : (A Un B) co (A' Un B')"; | 
| 4776 | 160 | by (Blast_tac 1); | 
| 161 | qed "constrains_Un"; | |
| 162 | ||
| 5069 | 163 | Goalw [constrains_def] | 
| 7345 | 164 | "ALL i:I. F : (A i) co (A' i) ==> F : (UN i:I. A i) co (UN i:I. A' i)"; | 
| 4776 | 165 | by (Blast_tac 1); | 
| 166 | qed "ball_constrains_UN"; | |
| 167 | ||
| 168 | (** Intersection **) | |
| 169 | ||
| 5069 | 170 | Goalw [constrains_def] | 
| 7345 | 171 | "[| F : A co A'; F : B co B' |] ==> F : (A Int B) co (A' Int B')"; | 
| 4776 | 172 | by (Blast_tac 1); | 
| 173 | qed "constrains_Int"; | |
| 174 | ||
| 5069 | 175 | Goalw [constrains_def] | 
| 7345 | 176 | "ALL i:I. F : (A i) co (A' i) ==> F : (INT i:I. A i) co (INT i:I. A' i)"; | 
| 4776 | 177 | by (Blast_tac 1); | 
| 178 | qed "ball_constrains_INT"; | |
| 179 | ||
| 6536 | 180 | Goalw [constrains_def] "F : A co A' ==> A <= A'"; | 
| 6295 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 181 | by Auto_tac; | 
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 182 | qed "constrains_imp_subset"; | 
| 4776 | 183 | |
| 6536 | 184 | (*The reasoning is by subsets since "co" refers to single actions | 
| 6012 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 185 | only. So this rule isn't that useful.*) | 
| 6295 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 186 | Goalw [constrains_def] | 
| 6536 | 187 | "[| F : A co B; F : B co C |] ==> F : A co C"; | 
| 6295 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 188 | by (Blast_tac 1); | 
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 189 | qed "constrains_trans"; | 
| 4776 | 190 | |
| 6295 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 191 | Goalw [constrains_def] | 
| 7345 | 192 | "[| F : A co (A' Un B); F : B co B' |] ==> F : A co (A' Un B')"; | 
| 6295 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 193 | by (Clarify_tac 1); | 
| 
351b3c2b0d83
removed the infernal States, eqStates, compatible, etc.
 paulson parents: 
6012diff
changeset | 194 | by (Blast_tac 1); | 
| 6012 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 195 | qed "constrains_cancel"; | 
| 
1894bfc4aee9
Addition of the States component; parts of Comp not working
 paulson parents: 
5804diff
changeset | 196 | |
| 4776 | 197 | |
| 198 | (*** stable ***) | |
| 199 | ||
| 6536 | 200 | Goalw [stable_def] "F : A co A ==> F : stable A"; | 
| 4776 | 201 | by (assume_tac 1); | 
| 202 | qed "stableI"; | |
| 203 | ||
| 6536 | 204 | Goalw [stable_def] "F : stable A ==> F : A co A"; | 
| 4776 | 205 | by (assume_tac 1); | 
| 206 | qed "stableD"; | |
| 207 | ||
| 5804 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 208 | (** Union **) | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 209 | |
| 5069 | 210 | Goalw [stable_def] | 
| 5648 | 211 | "[| F : stable A; F : stable A' |] ==> F : stable (A Un A')"; | 
| 4776 | 212 | by (blast_tac (claset() addIs [constrains_Un]) 1); | 
| 213 | qed "stable_Un"; | |
| 214 | ||
| 5069 | 215 | Goalw [stable_def] | 
| 5804 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 216 | "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: 
5669diff
changeset | 217 | by (blast_tac (claset() addIs [ball_constrains_UN]) 1); | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 218 | qed "ball_stable_UN"; | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 219 | |
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 220 | (** Intersection **) | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 221 | |
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 222 | Goalw [stable_def] | 
| 5648 | 223 | "[| F : stable A; F : stable A' |] ==> F : stable (A Int A')"; | 
| 4776 | 224 | by (blast_tac (claset() addIs [constrains_Int]) 1); | 
| 225 | qed "stable_Int"; | |
| 226 | ||
| 5804 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 227 | Goalw [stable_def] | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 228 | "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: 
5669diff
changeset | 229 | by (blast_tac (claset() addIs [ball_constrains_INT]) 1); | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 230 | qed "ball_stable_INT"; | 
| 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 231 | |
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 232 | Goalw [stable_def, constrains_def] | 
| 7345 | 233 | "[| F : stable C; F : A co (C Un A') |] ==> F : (C Un A) co (C Un A')"; | 
| 4776 | 234 | by (Blast_tac 1); | 
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 235 | qed "stable_constrains_Un"; | 
| 4776 | 236 | |
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 237 | Goalw [stable_def, constrains_def] | 
| 7345 | 238 | "[| F : stable C; F : (C Int A) co A' |] ==> F : (C Int A) co (C Int A')"; | 
| 4776 | 239 | by (Blast_tac 1); | 
| 5277 
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
 paulson parents: 
5253diff
changeset | 240 | qed "stable_constrains_Int"; | 
| 4776 | 241 | |
| 6536 | 242 | (*[| F : stable C; F : co (C Int A) A |] ==> F : stable (C Int A)*) | 
| 5648 | 243 | bind_thm ("stable_constrains_stable", stable_constrains_Int RS stableI);
 | 
| 244 | ||
| 245 | ||
| 5804 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 246 | (*** invariant ***) | 
| 5648 | 247 | |
| 248 | Goal "[| Init F<=A; F: stable A |] ==> F : invariant A"; | |
| 249 | by (asm_simp_tac (simpset() addsimps [invariant_def]) 1); | |
| 250 | qed "invariantI"; | |
| 251 | ||
| 252 | (*Could also say "invariant A Int invariant B <= invariant (A Int B)"*) | |
| 253 | Goal "[| F : invariant A; F : invariant B |] ==> F : invariant (A Int B)"; | |
| 254 | by (auto_tac (claset(), simpset() addsimps [invariant_def, stable_Int])); | |
| 255 | qed "invariant_Int"; | |
| 256 | ||
| 257 | ||
| 258 | (*** increasing ***) | |
| 259 | ||
| 260 | Goalw [increasing_def, stable_def, constrains_def] | |
| 6712 | 261 | "mono g ==> increasing f <= increasing (g o f)"; | 
| 5648 | 262 | by Auto_tac; | 
| 6712 | 263 | by (blast_tac (claset() addIs [monoD, order_trans]) 1); | 
| 264 | qed "mono_increasing_o"; | |
| 5648 | 265 | |
| 266 | Goalw [increasing_def] | |
| 267 |      "increasing f <= {F. ALL z::nat. F: stable {s. z < f s}}";
 | |
| 268 | by (simp_tac (simpset() addsimps [Suc_le_eq RS sym]) 1); | |
| 269 | by (Blast_tac 1); | |
| 5804 
8e0a4c4fd67b
Revising the Client proof as suggested by Michel Charpentier.  New lemmas
 paulson parents: 
5669diff
changeset | 270 | qed "increasing_stable_less"; | 
| 5648 | 271 | |
| 272 | ||
| 273 | (** The Elimination Theorem. The "free" m has become universally quantified! | |
| 274 | Should the premise be !!m instead of ALL m ? Would make it harder to use | |
| 275 | in forward proof. **) | |
| 276 | ||
| 5069 | 277 | Goalw [constrains_def] | 
| 6536 | 278 |     "[| ALL m:M. F : {s. s x = m} co (B m) |] \
 | 
| 279 | \    ==> F : {s. s x : M} co (UN m:M. B m)";
 | |
| 4776 | 280 | by (Blast_tac 1); | 
| 281 | qed "elimination"; | |
| 282 | ||
| 283 | (*As above, but for the trivial case of a one-variable state, in which the | |
| 284 | state is identified with its one variable.*) | |
| 5069 | 285 | Goalw [constrains_def] | 
| 6536 | 286 |     "(ALL m:M. F : {m} co (B m)) ==> F : M co (UN m:M. B m)";
 | 
| 4776 | 287 | by (Blast_tac 1); | 
| 288 | qed "elimination_sing"; | |
| 289 | ||
| 290 | ||
| 291 | ||
| 292 | (*** Theoretical Results from Section 6 ***) | |
| 293 | ||
| 5069 | 294 | Goalw [constrains_def, strongest_rhs_def] | 
| 6536 | 295 | "F : A co (strongest_rhs F A )"; | 
| 4776 | 296 | by (Blast_tac 1); | 
| 297 | qed "constrains_strongest_rhs"; | |
| 298 | ||
| 5069 | 299 | Goalw [constrains_def, strongest_rhs_def] | 
| 6536 | 300 | "F : A co B ==> strongest_rhs F A <= B"; | 
| 4776 | 301 | by (Blast_tac 1); | 
| 302 | qed "strongest_rhs_is_strongest"; |