author | paulson |
Fri, 25 Sep 1998 14:06:56 +0200 | |
changeset 5569 | 8c7e1190e789 |
parent 5544 | 96078cf5fd2c |
child 5584 | aad639e56d4e |
permissions | -rw-r--r-- |
4776 | 1 |
(* Title: HOL/UNITY/SubstAx |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1998 University of Cambridge |
|
5 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
6 |
LeadsTo relation, restricted to the set of reachable states. |
4776 | 7 |
*) |
8 |
||
5340 | 9 |
(*Map its type, ['a program, 'a set, 'a set] => bool, to just 'a*) |
10 |
Blast.overloaded ("SubstAx.LeadsTo", |
|
11 |
HOLogic.dest_setT o domain_type o range_type); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
12 |
|
4776 | 13 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
14 |
(*** Specialized laws for handling invariants ***) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
15 |
|
5544 | 16 |
(** Conjoining a safety property **) |
17 |
||
18 |
Goal "[| reachable prg <= C; LeadsTo prg (C Int A) A' |] \ |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
19 |
\ ==> LeadsTo prg A A'"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
20 |
by (asm_full_simp_tac |
5544 | 21 |
(simpset() addsimps [LeadsTo_def, Int_absorb2, Int_assoc RS sym]) 1); |
22 |
qed "reachable_LeadsToI"; |
|
23 |
||
24 |
Goal "[| reachable prg <= C; LeadsTo prg A A' |] \ |
|
25 |
\ ==> LeadsTo prg A (C Int A')"; |
|
26 |
by (asm_full_simp_tac |
|
27 |
(simpset() addsimps [LeadsTo_def, Int_absorb2, |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
28 |
Int_assoc RS sym]) 1); |
5544 | 29 |
qed "reachable_LeadsToD"; |
30 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
31 |
|
5544 | 32 |
(** Conjoining an invariant **) |
33 |
||
34 |
(* [| Invariant prg C; LeadsTo prg (C Int A) A' |] ==> LeadsTo prg A A' *) |
|
35 |
bind_thm ("Invariant_LeadsToI", |
|
36 |
Invariant_includes_reachable RS reachable_LeadsToI); |
|
37 |
||
38 |
(* [| Invariant prg C; LeadsTo prg A A' |] ==> LeadsTo prg A (C Int A') *) |
|
39 |
bind_thm ("Invariant_LeadsToD", |
|
40 |
Invariant_includes_reachable RS reachable_LeadsToD); |
|
41 |
||
42 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
43 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
44 |
|
4776 | 45 |
(*** Introduction rules: Basis, Trans, Union ***) |
46 |
||
5253 | 47 |
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B"; |
5111 | 48 |
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
49 |
by (blast_tac (claset() addIs [psp_stable2, stable_reachable]) 1); |
4776 | 50 |
qed "leadsTo_imp_LeadsTo"; |
51 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
52 |
Goal "[| LeadsTo prg A B; LeadsTo prg B C |] ==> LeadsTo prg A C"; |
5111 | 53 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 54 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 1); |
55 |
qed "LeadsTo_Trans"; |
|
56 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
57 |
val [prem] = Goalw [LeadsTo_def] |
5253 | 58 |
"(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B"; |
5111 | 59 |
by (Simp_tac 1); |
4776 | 60 |
by (stac Int_Union 1); |
5111 | 61 |
by (blast_tac (claset() addIs [leadsTo_UN, |
5340 | 62 |
simplify (simpset()) prem]) 1); |
4776 | 63 |
qed "LeadsTo_Union"; |
64 |
||
65 |
||
66 |
(*** Derived rules ***) |
|
67 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
68 |
Goal "id: Acts prg ==> LeadsTo prg A UNIV"; |
4776 | 69 |
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, |
70 |
Int_lower1 RS subset_imp_leadsTo]) 1); |
|
71 |
qed "LeadsTo_UNIV"; |
|
72 |
Addsimps [LeadsTo_UNIV]; |
|
73 |
||
74 |
(*Useful with cancellation, disjunction*) |
|
5253 | 75 |
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A A'"; |
4776 | 76 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
77 |
qed "LeadsTo_Un_duplicate"; |
|
78 |
||
5253 | 79 |
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (A' Un C)"; |
4776 | 80 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
81 |
qed "LeadsTo_Un_duplicate2"; |
|
82 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
83 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
84 |
Goal "(!!i. i : I ==> LeadsTo prg (A i) B) ==> LeadsTo prg (UN i:I. A i) B"; |
4776 | 85 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
86 |
by (blast_tac (claset() addIs (LeadsTo_Union::prems)) 1); |
|
87 |
qed "LeadsTo_UN"; |
|
88 |
||
89 |
(*Binary union introduction rule*) |
|
5253 | 90 |
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) C"; |
4776 | 91 |
by (stac Un_eq_Union 1); |
92 |
by (blast_tac (claset() addIs [LeadsTo_Union]) 1); |
|
93 |
qed "LeadsTo_Un"; |
|
94 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
95 |
Goal "[| A <= B; id: Acts prg |] ==> LeadsTo prg A B"; |
5111 | 96 |
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 97 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1); |
98 |
qed "subset_imp_LeadsTo"; |
|
99 |
||
100 |
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo); |
|
101 |
Addsimps [empty_LeadsTo]; |
|
102 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
103 |
Goal "[| LeadsTo prg A A'; A' <= B' |] ==> LeadsTo prg A B'"; |
5111 | 104 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 105 |
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1); |
106 |
qed_spec_mp "LeadsTo_weaken_R"; |
|
107 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
108 |
Goal "[| LeadsTo prg A A'; B <= A; id: Acts prg |] \ |
5253 | 109 |
\ ==> LeadsTo prg B A'"; |
5111 | 110 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 111 |
by (blast_tac (claset() addIs [leadsTo_weaken_L]) 1); |
112 |
qed_spec_mp "LeadsTo_weaken_L"; |
|
113 |
||
5340 | 114 |
Goal "[| LeadsTo prg A A'; id: Acts prg; \ |
115 |
\ B <= A; A' <= B' |] \ |
|
116 |
\ ==> LeadsTo prg B B'"; |
|
117 |
by (blast_tac (claset() addIs [LeadsTo_weaken_R, LeadsTo_weaken_L, |
|
118 |
LeadsTo_Trans]) 1); |
|
119 |
qed "LeadsTo_weaken"; |
|
4776 | 120 |
|
5544 | 121 |
Goal "[| reachable prg <= C; LeadsTo prg A A'; id: Acts prg; \ |
122 |
\ C Int B <= A; C Int A' <= B' |] \ |
|
123 |
\ ==> LeadsTo prg B B'"; |
|
124 |
by (blast_tac (claset() addDs [reachable_LeadsToI] addIs[LeadsTo_weaken] |
|
125 |
addIs [reachable_LeadsToD]) 1); |
|
126 |
qed "reachable_LeadsTo_weaken"; |
|
5340 | 127 |
|
128 |
(** Two theorems for "proof lattices" **) |
|
129 |
||
130 |
Goal "[| id: Acts prg; LeadsTo prg A B |] ==> LeadsTo prg (A Un B) B"; |
|
131 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo]) 1); |
|
132 |
qed "LeadsTo_Un_post"; |
|
133 |
||
134 |
Goal "[| id: Acts prg; LeadsTo prg A B; LeadsTo prg B C |] \ |
|
135 |
\ ==> LeadsTo prg (A Un B) C"; |
|
136 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo, |
|
137 |
LeadsTo_weaken_L, LeadsTo_Trans]) 1); |
|
138 |
qed "LeadsTo_Trans_Un"; |
|
139 |
||
140 |
||
141 |
(** Distributive laws **) |
|
142 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
143 |
Goal "id: Acts prg ==> \ |
5253 | 144 |
\ LeadsTo prg (A Un B) C = \ |
145 |
\ (LeadsTo prg A C & LeadsTo prg B C)"; |
|
4776 | 146 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1); |
147 |
qed "LeadsTo_Un_distrib"; |
|
148 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
149 |
Goal "id: Acts prg ==> \ |
5253 | 150 |
\ LeadsTo prg (UN i:I. A i) B = \ |
151 |
\ (ALL i : I. LeadsTo prg (A i) B)"; |
|
4776 | 152 |
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1); |
153 |
qed "LeadsTo_UN_distrib"; |
|
154 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
155 |
Goal "id: Acts prg ==> \ |
5253 | 156 |
\ LeadsTo prg (Union S) B = \ |
157 |
\ (ALL A : S. LeadsTo prg A B)"; |
|
4776 | 158 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1); |
159 |
qed "LeadsTo_Union_distrib"; |
|
160 |
||
161 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
162 |
(** More rules using the premise "Invariant prg" **) |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
163 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
164 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
165 |
"[| Constrains prg (A-A') (A Un A'); transient (Acts prg) (A-A') |] \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
166 |
\ ==> LeadsTo prg A A'"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
167 |
by (rtac (ensuresI RS leadsTo_Basis) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
168 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
169 |
by (blast_tac (claset() addIs [constrains_weaken]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
170 |
qed "LeadsTo_Basis"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
171 |
|
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
172 |
Goal "[| Invariant prg INV; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
173 |
\ Constrains prg (INV Int (A-A')) (A Un A'); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
174 |
\ transient (Acts prg) (INV Int (A-A')) |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
175 |
\ ==> LeadsTo prg A A'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
176 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
177 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
178 |
by (rtac LeadsTo_Basis 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
179 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
180 |
by (blast_tac (claset() addIs [Invariant_ConstrainsD RS Constrains_weaken]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
181 |
qed "Invariant_LeadsTo_Basis"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
182 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
183 |
Goal "[| Invariant prg INV; \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
184 |
\ LeadsTo prg A A'; id: Acts prg; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
185 |
\ INV Int B <= A; INV Int A' <= B' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
186 |
\ ==> LeadsTo prg B B'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
187 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
188 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
189 |
by (dtac Invariant_LeadsToD 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
190 |
by (assume_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
191 |
by (blast_tac (claset()addIs [LeadsTo_weaken]) 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
192 |
qed "Invariant_LeadsTo_weaken"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
193 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
194 |
|
5253 | 195 |
(*Set difference: maybe combine with leadsTo_weaken_L?? |
196 |
This is the most useful form of the "disjunction" rule*) |
|
5340 | 197 |
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg (A Int B) C; id: Acts prg |] \ |
5257 | 198 |
\ ==> LeadsTo prg A C"; |
5479 | 199 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1); |
4776 | 200 |
qed "LeadsTo_Diff"; |
201 |
||
202 |
||
5340 | 203 |
|
204 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
205 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
206 |
Goal "(!! i. i:I ==> LeadsTo prg (A i) (A' i)) \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
207 |
\ ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)"; |
4776 | 208 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
209 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] |
|
210 |
addIs prems) 1); |
|
211 |
qed "LeadsTo_UN_UN"; |
|
212 |
||
213 |
||
214 |
(*Version with no index set*) |
|
5257 | 215 |
val prems = |
216 |
Goal "(!! i. LeadsTo prg (A i) (A' i)) \ |
|
217 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
|
4776 | 218 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN] |
219 |
addIs prems) 1); |
|
220 |
qed "LeadsTo_UN_UN_noindex"; |
|
221 |
||
222 |
(*Version with no index set*) |
|
5253 | 223 |
Goal "ALL i. LeadsTo prg (A i) (A' i) \ |
5257 | 224 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
4776 | 225 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1); |
226 |
qed "all_LeadsTo_UN_UN"; |
|
227 |
||
228 |
||
229 |
(*Binary union version*) |
|
5253 | 230 |
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \ |
5257 | 231 |
\ ==> LeadsTo prg (A Un B) (A' Un B')"; |
4776 | 232 |
by (blast_tac (claset() addIs [LeadsTo_Un, |
233 |
LeadsTo_weaken_R]) 1); |
|
234 |
qed "LeadsTo_Un_Un"; |
|
235 |
||
236 |
||
237 |
(** The cancellation law **) |
|
238 |
||
5253 | 239 |
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg B B'; \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
240 |
\ id: Acts prg |] \ |
5257 | 241 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 242 |
by (blast_tac (claset() addIs [LeadsTo_Un_Un, |
243 |
subset_imp_LeadsTo, LeadsTo_Trans]) 1); |
|
244 |
qed "LeadsTo_cancel2"; |
|
245 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
246 |
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 247 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 248 |
by (rtac LeadsTo_cancel2 1); |
249 |
by (assume_tac 2); |
|
250 |
by (ALLGOALS Asm_simp_tac); |
|
251 |
qed "LeadsTo_cancel_Diff2"; |
|
252 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
253 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \ |
5257 | 254 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 255 |
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1); |
256 |
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1); |
|
257 |
qed "LeadsTo_cancel1"; |
|
258 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
259 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 260 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 261 |
by (rtac LeadsTo_cancel1 1); |
262 |
by (assume_tac 2); |
|
263 |
by (ALLGOALS Asm_simp_tac); |
|
264 |
qed "LeadsTo_cancel_Diff1"; |
|
265 |
||
266 |
||
267 |
||
268 |
(** The impossibility law **) |
|
269 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
270 |
(*The set "A" may be non-empty, but it contains no reachable states*) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
271 |
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}"; |
5111 | 272 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 273 |
by (etac leadsTo_empty 1); |
274 |
qed "LeadsTo_empty"; |
|
275 |
||
276 |
||
277 |
(** PSP: Progress-Safety-Progress **) |
|
278 |
||
279 |
(*Special case of PSP: Misra's "stable conjunction". Doesn't need id:Acts. *) |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
280 |
Goal |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
281 |
"[| LeadsTo prg A A'; Stable prg B |] ==> LeadsTo prg (A Int B) (A' Int B)"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
282 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Stable_eq_stable]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
283 |
by (dtac psp_stable 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
284 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
285 |
by (asm_full_simp_tac (simpset() addsimps Int_ac) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
286 |
qed "PSP_stable"; |
4776 | 287 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
288 |
Goal "[| LeadsTo prg A A'; Stable prg B |] \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
289 |
\ ==> LeadsTo prg (B Int A) (B Int A')"; |
5536 | 290 |
by (asm_simp_tac (simpset() addsimps PSP_stable::Int_ac) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
291 |
qed "PSP_stable2"; |
4776 | 292 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
293 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
294 |
"[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 295 |
\ ==> LeadsTo prg (A Int B) ((A' Int B) Un (B' - B))"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
296 |
by (blast_tac (claset() addDs [psp] addIs [leadsTo_weaken]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
297 |
qed "PSP"; |
4776 | 298 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
299 |
Goal "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 300 |
\ ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))"; |
5536 | 301 |
by (asm_simp_tac (simpset() addsimps PSP::Int_ac) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
302 |
qed "PSP2"; |
4776 | 303 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
304 |
Goalw [Unless_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
305 |
"[| LeadsTo prg A A'; Unless prg B B'; id: Acts prg |] \ |
5257 | 306 |
\ ==> LeadsTo prg (A Int B) ((A' Int B) Un B')"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
307 |
by (dtac PSP 1); |
4776 | 308 |
by (assume_tac 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
309 |
by (blast_tac (claset() addIs [LeadsTo_Diff, LeadsTo_weaken, |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
310 |
subset_imp_LeadsTo]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
311 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
312 |
qed "PSP_Unless"; |
4776 | 313 |
|
314 |
||
315 |
(*** Induction rules ***) |
|
316 |
||
317 |
(** Meta or object quantifier ????? **) |
|
5232 | 318 |
Goal "[| wf r; \ |
5257 | 319 |
\ ALL m. LeadsTo prg (A Int f-``{m}) \ |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
320 |
\ ((A Int f-``(r^-1 ^^ {m})) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
321 |
\ id: Acts prg |] \ |
5257 | 322 |
\ ==> LeadsTo prg A B"; |
5111 | 323 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 324 |
by (etac leadsTo_wf_induct 1); |
325 |
by (assume_tac 2); |
|
326 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
327 |
qed "LeadsTo_wf_induct"; |
|
328 |
||
329 |
||
5232 | 330 |
Goal "[| wf r; \ |
5253 | 331 |
\ ALL m:I. LeadsTo prg (A Int f-``{m}) \ |
5257 | 332 |
\ ((A Int f-``(r^-1 ^^ {m})) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
333 |
\ id: Acts prg |] \ |
5253 | 334 |
\ ==> LeadsTo prg A ((A - (f-``I)) Un B)"; |
4776 | 335 |
by (etac LeadsTo_wf_induct 1); |
336 |
by Safe_tac; |
|
337 |
by (case_tac "m:I" 1); |
|
338 |
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1); |
|
339 |
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
340 |
qed "Bounded_induct"; |
4776 | 341 |
|
342 |
||
5253 | 343 |
Goal "[| ALL m. LeadsTo prg (A Int f-``{m}) \ |
344 |
\ ((A Int f-``(lessThan m)) Un B); \ |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
345 |
\ id: Acts prg |] \ |
5253 | 346 |
\ ==> LeadsTo prg A B"; |
4776 | 347 |
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1); |
348 |
by (assume_tac 2); |
|
349 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
350 |
qed "LessThan_induct"; |
4776 | 351 |
|
5544 | 352 |
(*Integer version. Could generalize from #0 to any lower bound*) |
353 |
val [reach, prem, id] = |
|
354 |
Goal "[| reachable prg <= {s. #0 <= f s}; \ |
|
355 |
\ !! z. LeadsTo prg (A Int {s. f s = z}) \ |
|
356 |
\ ((A Int {s. f s < z}) Un B); \ |
|
357 |
\ id: Acts prg |] \ |
|
358 |
\ ==> LeadsTo prg A B"; |
|
5569
8c7e1190e789
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5544
diff
changeset
|
359 |
by (res_inst_tac [("f", "nat o f")] (allI RS LessThan_induct) 1); |
5544 | 360 |
by (simp_tac (simpset() addsimps [vimage_def]) 1); |
361 |
br ([reach, prem] MRS reachable_LeadsTo_weaken) 1; |
|
362 |
by (auto_tac (claset(), |
|
5569
8c7e1190e789
Renaming of Integ/Integ.* to Integ/Int.*, and renaming of related constants
paulson
parents:
5544
diff
changeset
|
363 |
simpset() addsimps [id, nat_eq_iff, nat_less_iff])); |
5544 | 364 |
qed "integ_0_le_induct"; |
365 |
||
5253 | 366 |
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m}) \ |
4776 | 367 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
368 |
\ id: Acts prg |] \ |
5253 | 369 |
\ ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)"; |
4776 | 370 |
by (simp_tac (HOL_ss addsimps [Diff_eq RS sym, vimage_Compl, Compl_greaterThan RS sym]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
371 |
by (rtac (wf_less_than RS Bounded_induct) 1); |
4776 | 372 |
by (assume_tac 2); |
373 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
374 |
qed "LessThan_bounded_induct"; |
4776 | 375 |
|
5253 | 376 |
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m}) \ |
5232 | 377 |
\ ((A Int f-``(greaterThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
378 |
\ id: Acts prg |] \ |
5253 | 379 |
\ ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)"; |
4776 | 380 |
by (res_inst_tac [("f","f"),("f1", "%k. l - k")] |
381 |
(wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1); |
|
382 |
by (assume_tac 2); |
|
383 |
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1); |
|
384 |
by (Clarify_tac 1); |
|
385 |
by (case_tac "m<l" 1); |
|
386 |
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2); |
|
387 |
by (blast_tac (claset() addIs [LeadsTo_weaken_R, diff_less_mono2]) 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
388 |
qed "GreaterThan_bounded_induct"; |
4776 | 389 |
|
390 |
||
391 |
(*** Completion: Binary and General Finite versions ***) |
|
392 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
393 |
Goal "[| LeadsTo prg A A'; Stable prg A'; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
394 |
\ LeadsTo prg B B'; Stable prg B'; id: Acts prg |] \ |
5253 | 395 |
\ ==> LeadsTo prg (A Int B) (A' Int B')"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
396 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Stable_eq_stable]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
397 |
by (blast_tac (claset() addIs [stable_completion, leadsTo_weaken]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
398 |
qed "Stable_completion"; |
4776 | 399 |
|
400 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
401 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 402 |
\ ==> (ALL i:I. LeadsTo prg (A i) (A' i)) --> \ |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
403 |
\ (ALL i:I. Stable prg (A' i)) --> \ |
5253 | 404 |
\ LeadsTo prg (INT i:I. A i) (INT i:I. A' i)"; |
4776 | 405 |
by (etac finite_induct 1); |
406 |
by (Asm_simp_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
407 |
by (asm_simp_tac (simpset() addsimps [Stable_completion, ball_Stable_INT]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
408 |
qed_spec_mp "Finite_stable_completion"; |
4776 | 409 |
|
410 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
411 |
Goal "[| LeadsTo prg A (A' Un C); Constrains prg A' (A' Un C); \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
412 |
\ LeadsTo prg B (B' Un C); Constrains prg B' (B' Un C); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
413 |
\ id: Acts prg |] \ |
5253 | 414 |
\ ==> LeadsTo prg (A Int B) ((A' Int B') Un C)"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
415 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Constrains_def, |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
416 |
Int_Un_distrib]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
417 |
by (blast_tac (claset() addIs [completion, leadsTo_weaken]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
418 |
qed "Completion"; |
4776 | 419 |
|
420 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
421 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 422 |
\ ==> (ALL i:I. LeadsTo prg (A i) (A' i Un C)) --> \ |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
423 |
\ (ALL i:I. Constrains prg (A' i) (A' i Un C)) --> \ |
5253 | 424 |
\ LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)"; |
4776 | 425 |
by (etac finite_induct 1); |
426 |
by (ALLGOALS Asm_simp_tac); |
|
427 |
by (Clarify_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
428 |
by (dtac ball_Constrains_INT 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
429 |
by (asm_full_simp_tac (simpset() addsimps [Completion]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
430 |
qed "Finite_completion"; |
5232 | 431 |
|
432 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
433 |
(*proves "ensures/leadsTo" properties when the program is specified*) |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5422
diff
changeset
|
434 |
fun ensures_tac sact = |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
435 |
SELECT_GOAL |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
436 |
(EVERY [REPEAT (Invariant_Int_tac 1), |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
437 |
etac Invariant_LeadsTo_Basis 1 |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
438 |
ORELSE (*subgoal may involve LeadsTo, leadsTo or ensures*) |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
439 |
REPEAT (ares_tac [LeadsTo_Basis, ensuresI] 1), |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
440 |
res_inst_tac [("act", sact)] transient_mem 2, |
5340 | 441 |
(*simplify the command's domain*) |
5426
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5422
diff
changeset
|
442 |
simp_tac (simpset() addsimps [Domain_def]) 3, |
566f47250bd0
A new approach, using simp_of_act and simp_of_set to activate definitions when
paulson
parents:
5422
diff
changeset
|
443 |
constrains_tac 1, |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
444 |
ALLGOALS Clarify_tac, |
5422 | 445 |
ALLGOALS Asm_full_simp_tac]); |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
446 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
447 |