author | paulson |
Wed, 23 Sep 1998 10:11:18 +0200 | |
changeset 5536 | 130f3d891fb2 |
parent 5479 | 5a5dfb0f0d7d |
child 5544 | 96078cf5fd2c |
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 |
by (blast_tac (claset() addIs [LeadsTo_weaken_R, LeadsTo_weaken_L, |
|
104 |
LeadsTo_Trans]) 1); |
|
105 |
qed "LeadsTo_weaken"; |
|
4776 | 106 |
|
5340 | 107 |
|
108 |
(** Two theorems for "proof lattices" **) |
|
109 |
||
110 |
Goal "[| id: Acts prg; LeadsTo prg A B |] ==> LeadsTo prg (A Un B) B"; |
|
111 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo]) 1); |
|
112 |
qed "LeadsTo_Un_post"; |
|
113 |
||
114 |
Goal "[| id: Acts prg; LeadsTo prg A B; LeadsTo prg B C |] \ |
|
115 |
\ ==> LeadsTo prg (A Un B) C"; |
|
116 |
by (blast_tac (claset() addIs [LeadsTo_Un, subset_imp_LeadsTo, |
|
117 |
LeadsTo_weaken_L, LeadsTo_Trans]) 1); |
|
118 |
qed "LeadsTo_Trans_Un"; |
|
119 |
||
120 |
||
121 |
(** Distributive laws **) |
|
122 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
123 |
Goal "id: Acts prg ==> \ |
5253 | 124 |
\ LeadsTo prg (A Un B) C = \ |
125 |
\ (LeadsTo prg A C & LeadsTo prg B C)"; |
|
4776 | 126 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1); |
127 |
qed "LeadsTo_Un_distrib"; |
|
128 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
129 |
Goal "id: Acts prg ==> \ |
5253 | 130 |
\ LeadsTo prg (UN i:I. A i) B = \ |
131 |
\ (ALL i : I. LeadsTo prg (A i) B)"; |
|
4776 | 132 |
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1); |
133 |
qed "LeadsTo_UN_distrib"; |
|
134 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
135 |
Goal "id: Acts prg ==> \ |
5253 | 136 |
\ LeadsTo prg (Union S) B = \ |
137 |
\ (ALL A : S. LeadsTo prg A B)"; |
|
4776 | 138 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1); |
139 |
qed "LeadsTo_Union_distrib"; |
|
140 |
||
141 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
142 |
(** More rules using the premise "Invariant prg" **) |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
143 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
144 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
145 |
"[| 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
|
146 |
\ ==> LeadsTo prg A A'"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
147 |
by (rtac (ensuresI RS leadsTo_Basis) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
148 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
149 |
by (blast_tac (claset() addIs [constrains_weaken]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
150 |
qed "LeadsTo_Basis"; |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
151 |
|
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
152 |
Goal "[| Invariant prg INV; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
153 |
\ 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
|
154 |
\ transient (Acts prg) (INV Int (A-A')) |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
155 |
\ ==> LeadsTo prg A A'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
156 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
157 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
158 |
by (rtac LeadsTo_Basis 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
159 |
by (blast_tac (claset() addIs [transient_strengthen]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
160 |
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
|
161 |
qed "Invariant_LeadsTo_Basis"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
162 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
163 |
Goal "[| Invariant prg INV; \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
164 |
\ LeadsTo prg A A'; id: Acts prg; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
165 |
\ INV Int B <= A; INV Int A' <= B' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
166 |
\ ==> LeadsTo prg B B'"; |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
167 |
by (rtac Invariant_LeadsToI 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
168 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
169 |
by (dtac Invariant_LeadsToD 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
170 |
by (assume_tac 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
171 |
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
|
172 |
qed "Invariant_LeadsTo_weaken"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
173 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
174 |
|
5253 | 175 |
(*Set difference: maybe combine with leadsTo_weaken_L?? |
176 |
This is the most useful form of the "disjunction" rule*) |
|
5340 | 177 |
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg (A Int B) C; id: Acts prg |] \ |
5257 | 178 |
\ ==> LeadsTo prg A C"; |
5479 | 179 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1); |
4776 | 180 |
qed "LeadsTo_Diff"; |
181 |
||
182 |
||
5340 | 183 |
|
184 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
185 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
186 |
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
|
187 |
\ ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)"; |
4776 | 188 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
189 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] |
|
190 |
addIs prems) 1); |
|
191 |
qed "LeadsTo_UN_UN"; |
|
192 |
||
193 |
||
194 |
(*Version with no index set*) |
|
5257 | 195 |
val prems = |
196 |
Goal "(!! i. LeadsTo prg (A i) (A' i)) \ |
|
197 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
|
4776 | 198 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN] |
199 |
addIs prems) 1); |
|
200 |
qed "LeadsTo_UN_UN_noindex"; |
|
201 |
||
202 |
(*Version with no index set*) |
|
5253 | 203 |
Goal "ALL i. LeadsTo prg (A i) (A' i) \ |
5257 | 204 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
4776 | 205 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1); |
206 |
qed "all_LeadsTo_UN_UN"; |
|
207 |
||
208 |
||
209 |
(*Binary union version*) |
|
5253 | 210 |
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \ |
5257 | 211 |
\ ==> LeadsTo prg (A Un B) (A' Un B')"; |
4776 | 212 |
by (blast_tac (claset() addIs [LeadsTo_Un, |
213 |
LeadsTo_weaken_R]) 1); |
|
214 |
qed "LeadsTo_Un_Un"; |
|
215 |
||
216 |
||
217 |
(** The cancellation law **) |
|
218 |
||
5253 | 219 |
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
|
220 |
\ id: Acts prg |] \ |
5257 | 221 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 222 |
by (blast_tac (claset() addIs [LeadsTo_Un_Un, |
223 |
subset_imp_LeadsTo, LeadsTo_Trans]) 1); |
|
224 |
qed "LeadsTo_cancel2"; |
|
225 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
226 |
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 227 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 228 |
by (rtac LeadsTo_cancel2 1); |
229 |
by (assume_tac 2); |
|
230 |
by (ALLGOALS Asm_simp_tac); |
|
231 |
qed "LeadsTo_cancel_Diff2"; |
|
232 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
233 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \ |
5257 | 234 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 235 |
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1); |
236 |
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1); |
|
237 |
qed "LeadsTo_cancel1"; |
|
238 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
239 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 240 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 241 |
by (rtac LeadsTo_cancel1 1); |
242 |
by (assume_tac 2); |
|
243 |
by (ALLGOALS Asm_simp_tac); |
|
244 |
qed "LeadsTo_cancel_Diff1"; |
|
245 |
||
246 |
||
247 |
||
248 |
(** The impossibility law **) |
|
249 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
250 |
(*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
|
251 |
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}"; |
5111 | 252 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 253 |
by (etac leadsTo_empty 1); |
254 |
qed "LeadsTo_empty"; |
|
255 |
||
256 |
||
257 |
(** PSP: Progress-Safety-Progress **) |
|
258 |
||
259 |
(*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
|
260 |
Goal |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
261 |
"[| 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
|
262 |
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
|
263 |
by (dtac psp_stable 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
264 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
265 |
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
|
266 |
qed "PSP_stable"; |
4776 | 267 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
268 |
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
|
269 |
\ ==> LeadsTo prg (B Int A) (B Int A')"; |
5536 | 270 |
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
|
271 |
qed "PSP_stable2"; |
4776 | 272 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
273 |
Goalw [LeadsTo_def, Constrains_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
274 |
"[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 275 |
\ ==> 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
|
276 |
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
|
277 |
qed "PSP"; |
4776 | 278 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
279 |
Goal "[| LeadsTo prg A A'; Constrains prg B B'; id: Acts prg |] \ |
5257 | 280 |
\ ==> LeadsTo prg (B Int A) ((B Int A') Un (B' - B))"; |
5536 | 281 |
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
|
282 |
qed "PSP2"; |
4776 | 283 |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
284 |
Goalw [Unless_def] |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
285 |
"[| LeadsTo prg A A'; Unless prg B B'; id: Acts prg |] \ |
5257 | 286 |
\ ==> 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
|
287 |
by (dtac PSP 1); |
4776 | 288 |
by (assume_tac 1); |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
289 |
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
|
290 |
subset_imp_LeadsTo]) 2); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
291 |
by (assume_tac 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
292 |
qed "PSP_Unless"; |
4776 | 293 |
|
294 |
||
295 |
(*** Induction rules ***) |
|
296 |
||
297 |
(** Meta or object quantifier ????? **) |
|
5232 | 298 |
Goal "[| wf r; \ |
5257 | 299 |
\ 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
|
300 |
\ ((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
|
301 |
\ id: Acts prg |] \ |
5257 | 302 |
\ ==> LeadsTo prg A B"; |
5111 | 303 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 304 |
by (etac leadsTo_wf_induct 1); |
305 |
by (assume_tac 2); |
|
306 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
307 |
qed "LeadsTo_wf_induct"; |
|
308 |
||
309 |
||
5232 | 310 |
Goal "[| wf r; \ |
5253 | 311 |
\ ALL m:I. LeadsTo prg (A Int f-``{m}) \ |
5257 | 312 |
\ ((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
|
313 |
\ id: Acts prg |] \ |
5253 | 314 |
\ ==> LeadsTo prg A ((A - (f-``I)) Un B)"; |
4776 | 315 |
by (etac LeadsTo_wf_induct 1); |
316 |
by Safe_tac; |
|
317 |
by (case_tac "m:I" 1); |
|
318 |
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1); |
|
319 |
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
|
320 |
qed "Bounded_induct"; |
4776 | 321 |
|
322 |
||
5253 | 323 |
Goal "[| ALL m. LeadsTo prg (A Int f-``{m}) \ |
324 |
\ ((A Int f-``(lessThan m)) Un B); \ |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
325 |
\ id: Acts prg |] \ |
5253 | 326 |
\ ==> LeadsTo prg A B"; |
4776 | 327 |
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1); |
328 |
by (assume_tac 2); |
|
329 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
330 |
qed "LessThan_induct"; |
4776 | 331 |
|
5253 | 332 |
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m}) \ |
4776 | 333 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
334 |
\ id: Acts prg |] \ |
5253 | 335 |
\ ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)"; |
4776 | 336 |
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
|
337 |
by (rtac (wf_less_than RS Bounded_induct) 1); |
4776 | 338 |
by (assume_tac 2); |
339 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
340 |
qed "LessThan_bounded_induct"; |
4776 | 341 |
|
5253 | 342 |
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m}) \ |
5232 | 343 |
\ ((A Int f-``(greaterThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
344 |
\ id: Acts prg |] \ |
5253 | 345 |
\ ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)"; |
4776 | 346 |
by (res_inst_tac [("f","f"),("f1", "%k. l - k")] |
347 |
(wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1); |
|
348 |
by (assume_tac 2); |
|
349 |
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1); |
|
350 |
by (Clarify_tac 1); |
|
351 |
by (case_tac "m<l" 1); |
|
352 |
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2); |
|
353 |
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
|
354 |
qed "GreaterThan_bounded_induct"; |
4776 | 355 |
|
356 |
||
357 |
(*** Completion: Binary and General Finite versions ***) |
|
358 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
359 |
Goal "[| LeadsTo prg A A'; Stable prg A'; \ |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
360 |
\ LeadsTo prg B B'; Stable prg B'; id: Acts prg |] \ |
5253 | 361 |
\ ==> 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
|
362 |
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
|
363 |
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
|
364 |
qed "Stable_completion"; |
4776 | 365 |
|
366 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
367 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 368 |
\ ==> (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
|
369 |
\ (ALL i:I. Stable prg (A' i)) --> \ |
5253 | 370 |
\ LeadsTo prg (INT i:I. A i) (INT i:I. A' i)"; |
4776 | 371 |
by (etac finite_induct 1); |
372 |
by (Asm_simp_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
373 |
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
|
374 |
qed_spec_mp "Finite_stable_completion"; |
4776 | 375 |
|
376 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
377 |
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
|
378 |
\ 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
|
379 |
\ id: Acts prg |] \ |
5253 | 380 |
\ ==> 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
|
381 |
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
|
382 |
Int_Un_distrib]) 1); |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
383 |
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
|
384 |
qed "Completion"; |
4776 | 385 |
|
386 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
387 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 388 |
\ ==> (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
|
389 |
\ (ALL i:I. Constrains prg (A' i) (A' i Un C)) --> \ |
5253 | 390 |
\ LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)"; |
4776 | 391 |
by (etac finite_induct 1); |
392 |
by (ALLGOALS Asm_simp_tac); |
|
393 |
by (Clarify_tac 1); |
|
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
394 |
by (dtac ball_Constrains_INT 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
395 |
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
|
396 |
qed "Finite_completion"; |
5232 | 397 |
|
398 |
||
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
399 |
(*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
|
400 |
fun ensures_tac sact = |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
401 |
SELECT_GOAL |
5313
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
402 |
(EVERY [REPEAT (Invariant_Int_tac 1), |
1861a564d7e2
Constrains, Stable, Invariant...more of the substitution axiom, but Union
paulson
parents:
5277
diff
changeset
|
403 |
etac Invariant_LeadsTo_Basis 1 |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
404 |
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
|
405 |
REPEAT (ares_tac [LeadsTo_Basis, ensuresI] 1), |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
406 |
res_inst_tac [("act", sact)] transient_mem 2, |
5340 | 407 |
(*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
|
408 |
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
|
409 |
constrains_tac 1, |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
410 |
ALLGOALS Clarify_tac, |
5422 | 411 |
ALLGOALS Asm_full_simp_tac]); |
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
412 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
413 |