author | paulson |
Thu, 03 Sep 1998 16:40:02 +0200 | |
changeset 5426 | 566f47250bd0 |
parent 5422 | 578dc167453f |
child 5479 | 5a5dfb0f0d7d |
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 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
16 |
Goal "[| Invariant prg INV; LeadsTo prg (INV Int A) A' |] \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
17 |
\ ==> LeadsTo prg A A'"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
18 |
by (asm_full_simp_tac |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
19 |
(simpset() addsimps [LeadsTo_def, reachable_Int_INV, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
20 |
Int_assoc RS sym]) 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
21 |
qed "Invariant_LeadsToI"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
22 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
23 |
Goal "[| Invariant prg INV; LeadsTo prg A A' |] \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
24 |
\ ==> LeadsTo prg A (INV Int A')"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
25 |
by (asm_full_simp_tac |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
26 |
(simpset() addsimps [LeadsTo_def, reachable_Int_INV, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
27 |
Int_assoc RS sym]) 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
28 |
qed "Invariant_LeadsToD"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
29 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
30 |
|
4776 | 31 |
(*** Introduction rules: Basis, Trans, Union ***) |
32 |
||
5253 | 33 |
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B"; |
5111 | 34 |
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
|
35 |
by (blast_tac (claset() addIs [psp_stable2, stable_reachable]) 1); |
4776 | 36 |
qed "leadsTo_imp_LeadsTo"; |
37 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
38 |
Goal "[| LeadsTo prg A B; LeadsTo prg B C |] ==> LeadsTo prg A C"; |
5111 | 39 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 40 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 1); |
41 |
qed "LeadsTo_Trans"; |
|
42 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
43 |
val [prem] = Goalw [LeadsTo_def] |
5253 | 44 |
"(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B"; |
5111 | 45 |
by (Simp_tac 1); |
4776 | 46 |
by (stac Int_Union 1); |
5111 | 47 |
by (blast_tac (claset() addIs [leadsTo_UN, |
5340 | 48 |
simplify (simpset()) prem]) 1); |
4776 | 49 |
qed "LeadsTo_Union"; |
50 |
||
51 |
||
52 |
(*** Derived rules ***) |
|
53 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
54 |
Goal "id: Acts prg ==> LeadsTo prg A UNIV"; |
4776 | 55 |
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, |
56 |
Int_lower1 RS subset_imp_leadsTo]) 1); |
|
57 |
qed "LeadsTo_UNIV"; |
|
58 |
Addsimps [LeadsTo_UNIV]; |
|
59 |
||
60 |
(*Useful with cancellation, disjunction*) |
|
5253 | 61 |
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A A'"; |
4776 | 62 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
63 |
qed "LeadsTo_Un_duplicate"; |
|
64 |
||
5253 | 65 |
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (A' Un C)"; |
4776 | 66 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
67 |
qed "LeadsTo_Un_duplicate2"; |
|
68 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
69 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
70 |
Goal "(!!i. i : I ==> LeadsTo prg (A i) B) ==> LeadsTo prg (UN i:I. A i) B"; |
4776 | 71 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
72 |
by (blast_tac (claset() addIs (LeadsTo_Union::prems)) 1); |
|
73 |
qed "LeadsTo_UN"; |
|
74 |
||
75 |
(*Binary union introduction rule*) |
|
5253 | 76 |
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) C"; |
4776 | 77 |
by (stac Un_eq_Union 1); |
78 |
by (blast_tac (claset() addIs [LeadsTo_Union]) 1); |
|
79 |
qed "LeadsTo_Un"; |
|
80 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
81 |
Goal "[| A <= B; id: Acts prg |] ==> LeadsTo prg A B"; |
5111 | 82 |
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 83 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1); |
84 |
qed "subset_imp_LeadsTo"; |
|
85 |
||
86 |
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo); |
|
87 |
Addsimps [empty_LeadsTo]; |
|
88 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
89 |
Goal "[| LeadsTo prg A A'; A' <= B' |] ==> LeadsTo prg A B'"; |
5111 | 90 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 91 |
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1); |
92 |
qed_spec_mp "LeadsTo_weaken_R"; |
|
93 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
94 |
Goal "[| LeadsTo prg A A'; B <= A; id: Acts prg |] \ |
5253 | 95 |
\ ==> LeadsTo prg B A'"; |
5111 | 96 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 97 |
by (blast_tac (claset() addIs [leadsTo_weaken_L]) 1); |
98 |
qed_spec_mp "LeadsTo_weaken_L"; |
|
99 |
||
5340 | 100 |
Goal "[| LeadsTo prg A A'; id: Acts prg; \ |
101 |
\ B <= A; A' <= B' |] \ |
|
102 |
\ ==> LeadsTo prg B B'"; |
|
103 |
(*PROOF FAILED unless the Trans rule is last*) |
|
104 |
by (blast_tac (claset() addIs [LeadsTo_weaken_R, LeadsTo_weaken_L, |
|
105 |
LeadsTo_Trans]) 1); |
|
106 |
qed "LeadsTo_weaken"; |
|
4776 | 107 |
|
5340 | 108 |
|
109 |
(** Two theorems for "proof lattices" **) |
|
110 |
||
111 |
Goal "[| id: Acts prg; LeadsTo prg A B |] ==> LeadsTo prg (A Un B) B"; |
|
112 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo]) 1); |
|
113 |
qed "LeadsTo_Un_post"; |
|
114 |
||
115 |
Goal "[| id: Acts prg; LeadsTo prg A B; LeadsTo prg B C |] \ |
|
116 |
\ ==> LeadsTo prg (A Un B) C"; |
|
117 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo, |
|
118 |
LeadsTo_weaken_L, LeadsTo_Trans]) 1); |
|
119 |
qed "LeadsTo_Trans_Un"; |
|
120 |
||
121 |
||
122 |
(** Distributive laws **) |
|
123 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
124 |
Goal "id: Acts prg ==> \ |
5253 | 125 |
\ LeadsTo prg (A Un B) C = \ |
126 |
\ (LeadsTo prg A C & LeadsTo prg B C)"; |
|
4776 | 127 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1); |
128 |
qed "LeadsTo_Un_distrib"; |
|
129 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
130 |
Goal "id: Acts prg ==> \ |
5253 | 131 |
\ LeadsTo prg (UN i:I. A i) B = \ |
132 |
\ (ALL i : I. LeadsTo prg (A i) B)"; |
|
4776 | 133 |
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1); |
134 |
qed "LeadsTo_UN_distrib"; |
|
135 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
136 |
Goal "id: Acts prg ==> \ |
5253 | 137 |
\ LeadsTo prg (Union S) B = \ |
138 |
\ (ALL A : S. LeadsTo prg A B)"; |
|
4776 | 139 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1); |
140 |
qed "LeadsTo_Union_distrib"; |
|
141 |
||
142 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
143 |
(** More rules using the premise "Invariant prg" **) |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
144 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
145 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
146 |
"[| 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
|
147 |
\ ==> LeadsTo prg A A'"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
148 |
by (rtac (ensuresI RS leadsTo_Basis) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
149 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
150 |
by (blast_tac (claset() addIs [constrains_weaken]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
151 |
qed "LeadsTo_Basis"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
152 |
|
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
153 |
Goal "[| Invariant prg INV; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
154 |
\ 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
|
155 |
\ transient (Acts prg) (INV Int (A-A')) |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
156 |
\ ==> LeadsTo prg A A'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
157 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
158 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
159 |
by (rtac LeadsTo_Basis 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
160 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
161 |
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
|
162 |
qed "Invariant_LeadsTo_Basis"; |
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 |
Goal "[| Invariant prg INV; \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
165 |
\ LeadsTo prg A A'; id: Acts prg; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
166 |
\ INV Int B <= A; INV Int A' <= B' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
167 |
\ ==> LeadsTo prg B B'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
168 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
169 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
170 |
by (dtac Invariant_LeadsToD 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
171 |
by (assume_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
172 |
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
|
173 |
qed "Invariant_LeadsTo_weaken"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
174 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
175 |
|
5253 | 176 |
(*Set difference: maybe combine with leadsTo_weaken_L?? |
177 |
This is the most useful form of the "disjunction" rule*) |
|
5340 | 178 |
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg (A Int B) C; id: Acts prg |] \ |
5257 | 179 |
\ ==> LeadsTo prg A C"; |
5340 | 180 |
by (stac (Un_Diff_Int RS sym) 1 THEN rtac LeadsTo_Un 1); |
181 |
by (REPEAT (assume_tac 1)); |
|
182 |
(*One step, but PROOF FAILED... |
|
183 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1); |
|
184 |
*) |
|
4776 | 185 |
qed "LeadsTo_Diff"; |
186 |
||
187 |
||
5340 | 188 |
|
189 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
190 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
191 |
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
|
192 |
\ ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)"; |
4776 | 193 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
194 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] |
|
195 |
addIs prems) 1); |
|
196 |
qed "LeadsTo_UN_UN"; |
|
197 |
||
198 |
||
199 |
(*Version with no index set*) |
|
5257 | 200 |
val prems = |
201 |
Goal "(!! i. LeadsTo prg (A i) (A' i)) \ |
|
202 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
|
4776 | 203 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN] |
204 |
addIs prems) 1); |
|
205 |
qed "LeadsTo_UN_UN_noindex"; |
|
206 |
||
207 |
(*Version with no index set*) |
|
5253 | 208 |
Goal "ALL i. LeadsTo prg (A i) (A' i) \ |
5257 | 209 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
4776 | 210 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1); |
211 |
qed "all_LeadsTo_UN_UN"; |
|
212 |
||
213 |
||
214 |
(*Binary union version*) |
|
5253 | 215 |
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \ |
5257 | 216 |
\ ==> LeadsTo prg (A Un B) (A' Un B')"; |
4776 | 217 |
by (blast_tac (claset() addIs [LeadsTo_Un, |
218 |
LeadsTo_weaken_R]) 1); |
|
219 |
qed "LeadsTo_Un_Un"; |
|
220 |
||
221 |
||
222 |
(** The cancellation law **) |
|
223 |
||
5253 | 224 |
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
|
225 |
\ id: Acts prg |] \ |
5257 | 226 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 227 |
by (blast_tac (claset() addIs [LeadsTo_Un_Un, |
228 |
subset_imp_LeadsTo, LeadsTo_Trans]) 1); |
|
229 |
qed "LeadsTo_cancel2"; |
|
230 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
231 |
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 232 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 233 |
by (rtac LeadsTo_cancel2 1); |
234 |
by (assume_tac 2); |
|
235 |
by (ALLGOALS Asm_simp_tac); |
|
236 |
qed "LeadsTo_cancel_Diff2"; |
|
237 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
238 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \ |
5257 | 239 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 240 |
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1); |
241 |
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1); |
|
242 |
qed "LeadsTo_cancel1"; |
|
243 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
244 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 245 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 246 |
by (rtac LeadsTo_cancel1 1); |
247 |
by (assume_tac 2); |
|
248 |
by (ALLGOALS Asm_simp_tac); |
|
249 |
qed "LeadsTo_cancel_Diff1"; |
|
250 |
||
251 |
||
252 |
||
253 |
(** The impossibility law **) |
|
254 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
255 |
(*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
|
256 |
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}"; |
5111 | 257 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 258 |
by (etac leadsTo_empty 1); |
259 |
qed "LeadsTo_empty"; |
|
260 |
||
261 |
||
262 |
(** PSP: Progress-Safety-Progress **) |
|
263 |
||
264 |
(*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
|
265 |
Goal |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
266 |
"[| 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
|
267 |
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
|
268 |
by (dtac psp_stable 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
269 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
270 |
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
|
271 |
qed "PSP_stable"; |
4776 | 272 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
273 |
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
|
274 |
\ ==> LeadsTo prg (B Int A) (B Int A')"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
275 |
by (asm_simp_tac (simpset() addsimps (PSP_stable::Int_ac)) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
276 |
qed "PSP_stable2"; |
4776 | 277 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
278 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
279 |
"[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 280 |
\ ==> 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
|
281 |
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
|
282 |
qed "PSP"; |
4776 | 283 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
284 |
Goal "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 285 |
\ ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
286 |
by (asm_simp_tac (simpset() addsimps (PSP::Int_ac)) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
287 |
qed "PSP2"; |
4776 | 288 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
289 |
Goalw [Unless_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
290 |
"[| LeadsTo prg A A'; Unless prg B B'; id: Acts prg |] \ |
5257 | 291 |
\ ==> 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
|
292 |
by (dtac PSP 1); |
4776 | 293 |
by (assume_tac 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
294 |
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
|
295 |
subset_imp_LeadsTo]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
296 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
297 |
qed "PSP_Unless"; |
4776 | 298 |
|
299 |
||
300 |
(*** Induction rules ***) |
|
301 |
||
302 |
(** Meta or object quantifier ????? **) |
|
5232 | 303 |
Goal "[| wf r; \ |
5257 | 304 |
\ 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
|
305 |
\ ((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
|
306 |
\ id: Acts prg |] \ |
5257 | 307 |
\ ==> LeadsTo prg A B"; |
5111 | 308 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 309 |
by (etac leadsTo_wf_induct 1); |
310 |
by (assume_tac 2); |
|
311 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
312 |
qed "LeadsTo_wf_induct"; |
|
313 |
||
314 |
||
5232 | 315 |
Goal "[| wf r; \ |
5253 | 316 |
\ ALL m:I. LeadsTo prg (A Int f-``{m}) \ |
5257 | 317 |
\ ((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
|
318 |
\ id: Acts prg |] \ |
5253 | 319 |
\ ==> LeadsTo prg A ((A - (f-``I)) Un B)"; |
4776 | 320 |
by (etac LeadsTo_wf_induct 1); |
321 |
by Safe_tac; |
|
322 |
by (case_tac "m:I" 1); |
|
323 |
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1); |
|
324 |
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
|
325 |
qed "Bounded_induct"; |
4776 | 326 |
|
327 |
||
5253 | 328 |
Goal "[| ALL m. LeadsTo prg (A Int f-``{m}) \ |
329 |
\ ((A Int f-``(lessThan m)) Un B); \ |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
330 |
\ id: Acts prg |] \ |
5253 | 331 |
\ ==> LeadsTo prg A B"; |
4776 | 332 |
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1); |
333 |
by (assume_tac 2); |
|
334 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
335 |
qed "LessThan_induct"; |
4776 | 336 |
|
5253 | 337 |
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m}) \ |
4776 | 338 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
339 |
\ id: Acts prg |] \ |
5253 | 340 |
\ ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)"; |
4776 | 341 |
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
|
342 |
by (rtac (wf_less_than RS Bounded_induct) 1); |
4776 | 343 |
by (assume_tac 2); |
344 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
345 |
qed "LessThan_bounded_induct"; |
4776 | 346 |
|
5253 | 347 |
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m}) \ |
5232 | 348 |
\ ((A Int f-``(greaterThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
349 |
\ id: Acts prg |] \ |
5253 | 350 |
\ ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)"; |
4776 | 351 |
by (res_inst_tac [("f","f"),("f1", "%k. l - k")] |
352 |
(wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1); |
|
353 |
by (assume_tac 2); |
|
354 |
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1); |
|
355 |
by (Clarify_tac 1); |
|
356 |
by (case_tac "m<l" 1); |
|
357 |
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2); |
|
358 |
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
|
359 |
qed "GreaterThan_bounded_induct"; |
4776 | 360 |
|
361 |
||
362 |
(*** Completion: Binary and General Finite versions ***) |
|
363 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
364 |
Goal "[| LeadsTo prg A A'; Stable prg A'; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
365 |
\ LeadsTo prg B B'; Stable prg B'; id: Acts prg |] \ |
5253 | 366 |
\ ==> 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
|
367 |
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
|
368 |
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
|
369 |
qed "Stable_completion"; |
4776 | 370 |
|
371 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
372 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 373 |
\ ==> (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
|
374 |
\ (ALL i:I. Stable prg (A' i)) --> \ |
5253 | 375 |
\ LeadsTo prg (INT i:I. A i) (INT i:I. A' i)"; |
4776 | 376 |
by (etac finite_induct 1); |
377 |
by (Asm_simp_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
378 |
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
|
379 |
qed_spec_mp "Finite_stable_completion"; |
4776 | 380 |
|
381 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
382 |
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
|
383 |
\ 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
|
384 |
\ id: Acts prg |] \ |
5253 | 385 |
\ ==> 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
|
386 |
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
|
387 |
Int_Un_distrib]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
388 |
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
|
389 |
qed "Completion"; |
4776 | 390 |
|
391 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
392 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 393 |
\ ==> (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
|
394 |
\ (ALL i:I. Constrains prg (A' i) (A' i Un C)) --> \ |
5253 | 395 |
\ LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)"; |
4776 | 396 |
by (etac finite_induct 1); |
397 |
by (ALLGOALS Asm_simp_tac); |
|
398 |
by (Clarify_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
399 |
by (dtac ball_Constrains_INT 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
400 |
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
|
401 |
qed "Finite_completion"; |
5232 | 402 |
|
403 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
404 |
(*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
|
405 |
fun ensures_tac sact = |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
406 |
SELECT_GOAL |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
407 |
(EVERY [REPEAT (Invariant_Int_tac 1), |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
408 |
etac Invariant_LeadsTo_Basis 1 |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
409 |
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
|
410 |
REPEAT (ares_tac [LeadsTo_Basis, ensuresI] 1), |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
411 |
res_inst_tac [("act", sact)] transient_mem 2, |
5340 | 412 |
(*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
|
413 |
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
|
414 |
constrains_tac 1, |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
415 |
ALLGOALS Clarify_tac, |
5422 | 416 |
ALLGOALS Asm_full_simp_tac]); |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
417 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
418 |