author | paulson |
Thu, 06 Aug 1998 15:47:26 +0200 | |
changeset 5277 | e4297d03e5d2 |
parent 5257 | c03e3ba9cbcc |
child 5313 | 1861a564d7e2 |
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 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
9 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
10 |
(*constrains (Acts prg) B B' |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
11 |
==> constrains (Acts prg) (reachable prg Int B) (reachable prg Int B')*) |
4776 | 12 |
bind_thm ("constrains_reachable", |
13 |
rewrite_rule [stable_def] stable_reachable RS constrains_Int); |
|
14 |
||
15 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
16 |
(*** Specialized laws for handling invariants ***) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
17 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
18 |
Goal "invariant prg INV ==> reachable prg Int INV = reachable prg"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
19 |
bd invariant_includes_reachable 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
20 |
by (Blast_tac 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
21 |
qed "reachable_Int_INV"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
22 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
23 |
Goal "[| invariant prg INV; LeadsTo prg (INV Int A) A' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
24 |
\ ==> LeadsTo prg A 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); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
28 |
qed "invariant_LeadsToI"; |
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 |
Goal "[| invariant prg INV; LeadsTo prg A A' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
31 |
\ ==> LeadsTo prg A (INV Int A')"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
32 |
by (asm_full_simp_tac |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
33 |
(simpset() addsimps [LeadsTo_def, reachable_Int_INV, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
34 |
Int_assoc RS sym]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
35 |
qed "invariant_LeadsToD"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
36 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
37 |
|
4776 | 38 |
(*** Introduction rules: Basis, Trans, Union ***) |
39 |
||
5253 | 40 |
Goal "leadsTo (Acts prg) A B ==> LeadsTo prg A B"; |
5111 | 41 |
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
|
42 |
by (blast_tac (claset() addIs [psp_stable2, stable_reachable]) 1); |
4776 | 43 |
qed "leadsTo_imp_LeadsTo"; |
44 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
45 |
(* ensures (Acts prg) A B ==> LeadsTo prg A B *) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
46 |
bind_thm ("LeadsTo_Basis", leadsTo_Basis RS leadsTo_imp_LeadsTo); |
4776 | 47 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
48 |
Goal "[| LeadsTo prg A B; LeadsTo prg B C |] ==> LeadsTo prg A C"; |
5111 | 49 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 50 |
by (blast_tac (claset() addIs [leadsTo_Trans]) 1); |
51 |
qed "LeadsTo_Trans"; |
|
52 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
53 |
val [prem] = Goalw [LeadsTo_def] |
5253 | 54 |
"(!!A. A : S ==> LeadsTo prg A B) ==> LeadsTo prg (Union S) B"; |
5111 | 55 |
by (Simp_tac 1); |
4776 | 56 |
by (stac Int_Union 1); |
5111 | 57 |
by (blast_tac (claset() addIs [leadsTo_UN, |
58 |
simplify (simpset()) prem]) 1); |
|
4776 | 59 |
qed "LeadsTo_Union"; |
60 |
||
61 |
||
62 |
(*** Derived rules ***) |
|
63 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
64 |
Goal "id: Acts prg ==> LeadsTo prg A UNIV"; |
4776 | 65 |
by (asm_simp_tac (simpset() addsimps [LeadsTo_def, |
66 |
Int_lower1 RS subset_imp_leadsTo]) 1); |
|
67 |
qed "LeadsTo_UNIV"; |
|
68 |
Addsimps [LeadsTo_UNIV]; |
|
69 |
||
70 |
(*Useful with cancellation, disjunction*) |
|
5253 | 71 |
Goal "LeadsTo prg A (A' Un A') ==> LeadsTo prg A A'"; |
4776 | 72 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
73 |
qed "LeadsTo_Un_duplicate"; |
|
74 |
||
5253 | 75 |
Goal "LeadsTo prg A (A' Un C Un C) ==> LeadsTo prg A (A' Un C)"; |
4776 | 76 |
by (asm_full_simp_tac (simpset() addsimps Un_ac) 1); |
77 |
qed "LeadsTo_Un_duplicate2"; |
|
78 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
79 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
80 |
Goal "(!!i. i : I ==> LeadsTo prg (A i) B) ==> LeadsTo prg (UN i:I. A i) B"; |
4776 | 81 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
82 |
by (blast_tac (claset() addIs (LeadsTo_Union::prems)) 1); |
|
83 |
qed "LeadsTo_UN"; |
|
84 |
||
85 |
(*Binary union introduction rule*) |
|
5253 | 86 |
Goal "[| LeadsTo prg A C; LeadsTo prg B C |] ==> LeadsTo prg (A Un B) C"; |
4776 | 87 |
by (stac Un_eq_Union 1); |
88 |
by (blast_tac (claset() addIs [LeadsTo_Union]) 1); |
|
89 |
qed "LeadsTo_Un"; |
|
90 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
91 |
Goal "[| A <= B; id: Acts prg |] ==> LeadsTo prg A B"; |
5111 | 92 |
by (simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 93 |
by (blast_tac (claset() addIs [subset_imp_leadsTo]) 1); |
94 |
qed "subset_imp_LeadsTo"; |
|
95 |
||
96 |
bind_thm ("empty_LeadsTo", empty_subsetI RS subset_imp_LeadsTo); |
|
97 |
Addsimps [empty_LeadsTo]; |
|
98 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
99 |
Goal "[| LeadsTo prg A A'; A' <= B' |] ==> LeadsTo prg A B'"; |
5111 | 100 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 101 |
by (blast_tac (claset() addIs [leadsTo_weaken_R]) 1); |
102 |
qed_spec_mp "LeadsTo_weaken_R"; |
|
103 |
||
104 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
105 |
Goal "[| LeadsTo prg A A'; B <= A; id: Acts prg |] \ |
5253 | 106 |
\ ==> LeadsTo prg B A'"; |
5111 | 107 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 108 |
by (blast_tac (claset() addIs [leadsTo_weaken_L]) 1); |
109 |
qed_spec_mp "LeadsTo_weaken_L"; |
|
110 |
||
111 |
||
112 |
(*Distributes over binary unions*) |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
113 |
Goal "id: Acts prg ==> \ |
5253 | 114 |
\ LeadsTo prg (A Un B) C = \ |
115 |
\ (LeadsTo prg A C & LeadsTo prg B C)"; |
|
4776 | 116 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken_L]) 1); |
117 |
qed "LeadsTo_Un_distrib"; |
|
118 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
119 |
Goal "id: Acts prg ==> \ |
5253 | 120 |
\ LeadsTo prg (UN i:I. A i) B = \ |
121 |
\ (ALL i : I. LeadsTo prg (A i) B)"; |
|
4776 | 122 |
by (blast_tac (claset() addIs [LeadsTo_UN, LeadsTo_weaken_L]) 1); |
123 |
qed "LeadsTo_UN_distrib"; |
|
124 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
125 |
Goal "id: Acts prg ==> \ |
5253 | 126 |
\ LeadsTo prg (Union S) B = \ |
127 |
\ (ALL A : S. LeadsTo prg A B)"; |
|
4776 | 128 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_L]) 1); |
129 |
qed "LeadsTo_Union_distrib"; |
|
130 |
||
131 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
132 |
Goal "[| LeadsTo prg A A'; id: Acts prg; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
133 |
\ B <= A; A' <= B' |] \ |
5253 | 134 |
\ ==> LeadsTo prg B B'"; |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
135 |
(*PROOF FAILED*) |
4776 | 136 |
by (blast_tac (claset() addIs [LeadsTo_Trans, LeadsTo_weaken_R, |
137 |
LeadsTo_weaken_L]) 1); |
|
138 |
qed "LeadsTo_weaken"; |
|
139 |
||
140 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
141 |
(** More rules using the premise "invariant prg" **) |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
142 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
143 |
Goal "[| invariant prg INV; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
144 |
\ constrains (Acts prg) (INV Int (A-A')) (A Un A'); \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
145 |
\ transient (Acts prg) (INV Int (A-A')) |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
146 |
\ ==> LeadsTo prg A A'"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
147 |
br invariant_LeadsToI 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
148 |
ba 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
149 |
by (rtac (ensuresI RS LeadsTo_Basis) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
150 |
by (ALLGOALS |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
151 |
(full_simp_tac (simpset() addsimps [Int_Diff, Int_Un_distrib RS sym, |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
152 |
Diff_Int_distrib RS sym]))); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
153 |
be invariantE 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
154 |
by (blast_tac (claset() addSDs [stable_constrains_Int] |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
155 |
addIs [constrains_weaken]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
156 |
qed "invariant_LeadsTo_Basis"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
157 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
158 |
Goal "[| invariant prg INV; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
159 |
\ LeadsTo prg A A'; id: Acts prg; \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
160 |
\ INV Int B <= A; INV Int A' <= B' |] \ |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
161 |
\ ==> LeadsTo prg B B'"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
162 |
br invariant_LeadsToI 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
163 |
ba 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
164 |
bd invariant_LeadsToD 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
165 |
ba 1; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
166 |
by (blast_tac (claset()addIs [LeadsTo_weaken]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
167 |
qed "invariant_LeadsTo_weaken"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
168 |
|
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
169 |
|
5253 | 170 |
(*Set difference: maybe combine with leadsTo_weaken_L?? |
171 |
This is the most useful form of the "disjunction" rule*) |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
172 |
Goal "[| LeadsTo prg (A-B) C; LeadsTo prg B C; id: Acts prg |] \ |
5257 | 173 |
\ ==> LeadsTo prg A C"; |
4776 | 174 |
by (blast_tac (claset() addIs [LeadsTo_Un, LeadsTo_weaken]) 1); |
175 |
qed "LeadsTo_Diff"; |
|
176 |
||
177 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
178 |
val prems = |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
179 |
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
|
180 |
\ ==> LeadsTo prg (UN i:I. A i) (UN i:I. A' i)"; |
4776 | 181 |
by (simp_tac (simpset() addsimps [Union_image_eq RS sym]) 1); |
182 |
by (blast_tac (claset() addIs [LeadsTo_Union, LeadsTo_weaken_R] |
|
183 |
addIs prems) 1); |
|
184 |
qed "LeadsTo_UN_UN"; |
|
185 |
||
186 |
||
187 |
(*Version with no index set*) |
|
5257 | 188 |
val prems = |
189 |
Goal "(!! i. LeadsTo prg (A i) (A' i)) \ |
|
190 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
|
4776 | 191 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN] |
192 |
addIs prems) 1); |
|
193 |
qed "LeadsTo_UN_UN_noindex"; |
|
194 |
||
195 |
(*Version with no index set*) |
|
5253 | 196 |
Goal "ALL i. LeadsTo prg (A i) (A' i) \ |
5257 | 197 |
\ ==> LeadsTo prg (UN i. A i) (UN i. A' i)"; |
4776 | 198 |
by (blast_tac (claset() addIs [LeadsTo_UN_UN]) 1); |
199 |
qed "all_LeadsTo_UN_UN"; |
|
200 |
||
201 |
||
202 |
(*Binary union version*) |
|
5253 | 203 |
Goal "[| LeadsTo prg A A'; LeadsTo prg B B' |] \ |
5257 | 204 |
\ ==> LeadsTo prg (A Un B) (A' Un B')"; |
4776 | 205 |
by (blast_tac (claset() addIs [LeadsTo_Un, |
206 |
LeadsTo_weaken_R]) 1); |
|
207 |
qed "LeadsTo_Un_Un"; |
|
208 |
||
209 |
||
210 |
(** The cancellation law **) |
|
211 |
||
5253 | 212 |
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
|
213 |
\ id: Acts prg |] \ |
5257 | 214 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 215 |
by (blast_tac (claset() addIs [LeadsTo_Un_Un, |
216 |
subset_imp_LeadsTo, LeadsTo_Trans]) 1); |
|
217 |
qed "LeadsTo_cancel2"; |
|
218 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
219 |
Goal "[| LeadsTo prg A (A' Un B); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 220 |
\ ==> LeadsTo prg A (A' Un B')"; |
4776 | 221 |
by (rtac LeadsTo_cancel2 1); |
222 |
by (assume_tac 2); |
|
223 |
by (ALLGOALS Asm_simp_tac); |
|
224 |
qed "LeadsTo_cancel_Diff2"; |
|
225 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
226 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg B B'; id: Acts prg |] \ |
5257 | 227 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 228 |
by (asm_full_simp_tac (simpset() addsimps [Un_commute]) 1); |
229 |
by (blast_tac (claset() addSIs [LeadsTo_cancel2]) 1); |
|
230 |
qed "LeadsTo_cancel1"; |
|
231 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
232 |
Goal "[| LeadsTo prg A (B Un A'); LeadsTo prg (B-A') B'; id: Acts prg |] \ |
5257 | 233 |
\ ==> LeadsTo prg A (B' Un A')"; |
4776 | 234 |
by (rtac LeadsTo_cancel1 1); |
235 |
by (assume_tac 2); |
|
236 |
by (ALLGOALS Asm_simp_tac); |
|
237 |
qed "LeadsTo_cancel_Diff1"; |
|
238 |
||
239 |
||
240 |
||
241 |
(** The impossibility law **) |
|
242 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
243 |
(*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
|
244 |
Goal "LeadsTo prg A {} ==> reachable prg Int A = {}"; |
5111 | 245 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 246 |
by (etac leadsTo_empty 1); |
247 |
qed "LeadsTo_empty"; |
|
248 |
||
249 |
||
250 |
(** PSP: Progress-Safety-Progress **) |
|
251 |
||
252 |
(*Special case of PSP: Misra's "stable conjunction". Doesn't need id:Acts. *) |
|
5253 | 253 |
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \ |
5257 | 254 |
\ ==> LeadsTo prg (A Int B) (A' Int B)"; |
5111 | 255 |
by (asm_full_simp_tac (simpset() addsimps [LeadsTo_def, Int_assoc RS sym, |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
256 |
psp_stable]) 1); |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
257 |
qed "PSP_stable"; |
4776 | 258 |
|
5253 | 259 |
Goal "[| LeadsTo prg A A'; stable (Acts prg) B |] \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
260 |
\ ==> LeadsTo prg (B Int A) (B Int A')"; |
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
261 |
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
|
262 |
qed "PSP_stable2"; |
4776 | 263 |
|
264 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
265 |
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: Acts prg |] \ |
5257 | 266 |
\ ==> LeadsTo prg (A Int B) ((A' Int B) Un (B' - B))"; |
5111 | 267 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
268 |
by (dtac psp 1); |
4776 | 269 |
by (etac constrains_reachable 1); |
270 |
by (etac leadsTo_weaken 2); |
|
271 |
by (ALLGOALS Blast_tac); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
272 |
qed "PSP"; |
4776 | 273 |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
274 |
Goal "[| LeadsTo prg A A'; constrains (Acts prg) B B'; id: Acts prg |] \ |
5257 | 275 |
\ ==> 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
|
276 |
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
|
277 |
qed "PSP2"; |
4776 | 278 |
|
5069 | 279 |
Goalw [unless_def] |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
280 |
"[| LeadsTo prg A A'; unless (Acts prg) B B'; id: Acts prg |] \ |
5257 | 281 |
\ ==> 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
|
282 |
by (dtac PSP 1); |
4776 | 283 |
by (assume_tac 1); |
284 |
by (asm_full_simp_tac (simpset() addsimps [Un_Diff_Diff, Int_Diff_Un]) 2); |
|
285 |
by (asm_full_simp_tac (simpset() addsimps [Diff_Int_distrib]) 2); |
|
286 |
by (etac LeadsTo_Diff 2); |
|
287 |
by (blast_tac (claset() addIs [subset_imp_LeadsTo]) 2); |
|
288 |
by Auto_tac; |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
289 |
qed "PSP_unless"; |
4776 | 290 |
|
291 |
||
292 |
(*** Induction rules ***) |
|
293 |
||
294 |
(** Meta or object quantifier ????? **) |
|
5232 | 295 |
Goal "[| wf r; \ |
5257 | 296 |
\ ALL m. LeadsTo prg (A Int f-``{m}) \ |
297 |
\ ((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
|
298 |
\ id: Acts prg |] \ |
5257 | 299 |
\ ==> LeadsTo prg A B"; |
5111 | 300 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 301 |
by (etac leadsTo_wf_induct 1); |
302 |
by (assume_tac 2); |
|
303 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
304 |
qed "LeadsTo_wf_induct"; |
|
305 |
||
306 |
||
5232 | 307 |
Goal "[| wf r; \ |
5253 | 308 |
\ ALL m:I. LeadsTo prg (A Int f-``{m}) \ |
5257 | 309 |
\ ((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
|
310 |
\ id: Acts prg |] \ |
5253 | 311 |
\ ==> LeadsTo prg A ((A - (f-``I)) Un B)"; |
4776 | 312 |
by (etac LeadsTo_wf_induct 1); |
313 |
by Safe_tac; |
|
314 |
by (case_tac "m:I" 1); |
|
315 |
by (blast_tac (claset() addIs [LeadsTo_weaken]) 1); |
|
316 |
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
|
317 |
qed "Bounded_induct"; |
4776 | 318 |
|
319 |
||
5253 | 320 |
Goal "[| ALL m. LeadsTo prg (A Int f-``{m}) \ |
321 |
\ ((A Int f-``(lessThan m)) Un B); \ |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
322 |
\ id: Acts prg |] \ |
5253 | 323 |
\ ==> LeadsTo prg A B"; |
4776 | 324 |
by (rtac (wf_less_than RS LeadsTo_wf_induct) 1); |
325 |
by (assume_tac 2); |
|
326 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
327 |
qed "LessThan_induct"; |
4776 | 328 |
|
5253 | 329 |
Goal "[| ALL m:(greaterThan l). LeadsTo prg (A Int f-``{m}) \ |
4776 | 330 |
\ ((A Int f-``(lessThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
331 |
\ id: Acts prg |] \ |
5253 | 332 |
\ ==> LeadsTo prg A ((A Int (f-``(atMost l))) Un B)"; |
4776 | 333 |
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
|
334 |
by (rtac (wf_less_than RS Bounded_induct) 1); |
4776 | 335 |
by (assume_tac 2); |
336 |
by (Asm_simp_tac 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
337 |
qed "LessThan_bounded_induct"; |
4776 | 338 |
|
5253 | 339 |
Goal "[| ALL m:(lessThan l). LeadsTo prg (A Int f-``{m}) \ |
5232 | 340 |
\ ((A Int f-``(greaterThan m)) Un B); \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
341 |
\ id: Acts prg |] \ |
5253 | 342 |
\ ==> LeadsTo prg A ((A Int (f-``(atLeast l))) Un B)"; |
4776 | 343 |
by (res_inst_tac [("f","f"),("f1", "%k. l - k")] |
344 |
(wf_less_than RS wf_inv_image RS LeadsTo_wf_induct) 1); |
|
345 |
by (assume_tac 2); |
|
346 |
by (simp_tac (simpset() addsimps [inv_image_def, Image_singleton]) 1); |
|
347 |
by (Clarify_tac 1); |
|
348 |
by (case_tac "m<l" 1); |
|
349 |
by (blast_tac (claset() addIs [not_leE, subset_imp_LeadsTo]) 2); |
|
350 |
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
|
351 |
qed "GreaterThan_bounded_induct"; |
4776 | 352 |
|
353 |
||
354 |
(*** Completion: Binary and General Finite versions ***) |
|
355 |
||
5253 | 356 |
Goal "[| LeadsTo prg A A'; stable (Acts prg) A'; \ |
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
357 |
\ LeadsTo prg B B'; stable (Acts prg) B'; id: Acts prg |] \ |
5253 | 358 |
\ ==> LeadsTo prg (A Int B) (A' Int B')"; |
5111 | 359 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def]) 1); |
4776 | 360 |
by (blast_tac (claset() addIs [stable_completion RS leadsTo_weaken] |
361 |
addSIs [stable_Int, stable_reachable]) 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
362 |
qed "Stable_completion"; |
4776 | 363 |
|
364 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
365 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 366 |
\ ==> (ALL i:I. LeadsTo prg (A i) (A' i)) --> \ |
367 |
\ (ALL i:I. stable (Acts prg) (A' i)) --> \ |
|
368 |
\ LeadsTo prg (INT i:I. A i) (INT i:I. A' i)"; |
|
4776 | 369 |
by (etac finite_induct 1); |
370 |
by (Asm_simp_tac 1); |
|
371 |
by (asm_simp_tac |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
372 |
(simpset() addsimps [Stable_completion, stable_def, |
4776 | 373 |
ball_constrains_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 |
||
5253 | 377 |
Goal "[| LeadsTo prg A (A' Un C); constrains (Acts prg) A' (A' Un C); \ |
378 |
\ LeadsTo prg B (B' Un C); constrains (Acts 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)"; |
5111 | 381 |
by (full_simp_tac (simpset() addsimps [LeadsTo_def, Int_Un_distrib]) 1); |
4776 | 382 |
by (dtac completion 1); |
383 |
by (assume_tac 2); |
|
384 |
by (ALLGOALS |
|
385 |
(asm_simp_tac |
|
386 |
(simpset() addsimps [constrains_reachable, Int_Un_distrib RS sym]))); |
|
387 |
by (blast_tac (claset() addIs [leadsTo_weaken]) 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
388 |
qed "Completion"; |
4776 | 389 |
|
390 |
||
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
391 |
Goal "[| finite I; id: Acts prg |] \ |
5253 | 392 |
\ ==> (ALL i:I. LeadsTo prg (A i) (A' i Un C)) --> \ |
393 |
\ (ALL i:I. constrains (Acts prg) (A' i) (A' i Un C)) --> \ |
|
394 |
\ LeadsTo prg (INT i:I. A i) ((INT i:I. A' i) Un C)"; |
|
4776 | 395 |
by (etac finite_induct 1); |
396 |
by (ALLGOALS Asm_simp_tac); |
|
397 |
by (Clarify_tac 1); |
|
398 |
by (dtac ball_constrains_INT 1); |
|
5277
e4297d03e5d2
A higher-level treatment of LeadsTo, minimizing use of "reachable"
paulson
parents:
5257
diff
changeset
|
399 |
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
|
400 |
qed "Finite_completion"; |
5232 | 401 |
|
402 |
||
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
403 |
(** Constrains/Ensures tactics |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
404 |
main_def defines the main program as a set; |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
405 |
cmd_defs defines the separate commands |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
406 |
**) |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
407 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
408 |
(*proves "constrains" properties when the program is specified*) |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
409 |
fun constrains_tac (main_def::cmd_defs) = |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
410 |
SELECT_GOAL |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
411 |
(EVERY [TRY (rtac stableI 1), |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
412 |
rtac constrainsI 1, |
5253 | 413 |
full_simp_tac (simpset() addsimps [main_def]) 1, |
414 |
REPEAT_FIRST (eresolve_tac [disjE]), |
|
5240
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
415 |
rewrite_goals_tac cmd_defs, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
416 |
ALLGOALS (SELECT_GOAL Auto_tac)]); |
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 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
419 |
(*proves "ensures" properties when the program is specified*) |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
420 |
fun ensures_tac (main_def::cmd_defs) sact = |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
421 |
SELECT_GOAL |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
422 |
(EVERY [REPEAT (invariant_Int_tac 1), |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
423 |
etac invariant_LeadsTo_Basis 1 |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
424 |
ORELSE (*subgoal may involve LeadsTo, leadsTo or ensures*) |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
425 |
REPEAT (ares_tac [leadsTo_imp_LeadsTo, leadsTo_Basis, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
426 |
ensuresI] 1), |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
427 |
res_inst_tac [("act", sact)] transient_mem 2, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
428 |
simp_tac (simpset() addsimps (Domain_partial_func::cmd_defs)) 3, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
429 |
simp_tac (simpset() addsimps [main_def]) 2, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
430 |
constrains_tac (main_def::cmd_defs) 1, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
431 |
rewrite_goals_tac cmd_defs, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
432 |
ALLGOALS Clarify_tac, |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
433 |
Auto_tac]); |
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
434 |
|
bbcd79ef7cf2
Constant "invariant" and new constrains_tac, ensures_tac
paulson
parents:
5232
diff
changeset
|
435 |