| author | wenzelm | 
| Tue, 16 Oct 2007 17:07:40 +0200 | |
| changeset 25056 | 743f3603ba8b | 
| parent 23767 | 7272a839ccd9 | 
| child 32693 | 6c6b1ba5e71e | 
| permissions | -rw-r--r-- | 
| 4776 | 1  | 
(* Title: HOL/UNITY/WFair  | 
2  | 
ID: $Id$  | 
|
3  | 
Author: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
|
4  | 
Copyright 1998 University of Cambridge  | 
|
5  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
6  | 
Conditional Fairness versions of transient, ensures, leadsTo.  | 
| 4776 | 7  | 
|
8  | 
From Misra, "A Logic for Concurrent Programming", 1994  | 
|
9  | 
*)  | 
|
10  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
11  | 
header{*Progress*}
 | 
| 13798 | 12  | 
|
| 16417 | 13  | 
theory WFair imports UNITY begin  | 
| 4776 | 14  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
15  | 
text{*The original version of this theory was based on weak fairness.  (Thus,
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
16  | 
the entire UNITY development embodied this assumption, until February 2003.)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
17  | 
Weak fairness states that if a command is enabled continuously, then it is  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
18  | 
eventually executed. Ernie Cohen suggested that I instead adopt unconditional  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
19  | 
fairness: every command is executed infinitely often.  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
20  | 
|
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
21  | 
In fact, Misra's paper on "Progress" seems to be ambiguous about the correct  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
22  | 
interpretation, and says that the two forms of fairness are equivalent. They  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
23  | 
differ only on their treatment of partial transitions, which under  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
24  | 
unconditional fairness behave magically. That is because if there are partial  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
25  | 
transitions then there may be no fair executions, making all leads-to  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
26  | 
properties hold vacuously.  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
27  | 
|
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
28  | 
Unconditional fairness has some great advantages. By distinguishing partial  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
29  | 
transitions from total ones that are the identity on part of their domain, it  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
30  | 
is more expressive. Also, by simplifying the definition of the transient  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
31  | 
property, it simplifies many proofs. A drawback is that some laws only hold  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
32  | 
under the assumption that all transitions are total. The best-known of these  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
33  | 
is the impossibility law for leads-to.  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
34  | 
*}  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
35  | 
|
| 4776 | 36  | 
constdefs  | 
37  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
38  | 
  --{*This definition specifies conditional fairness.  The rest of the theory
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
39  | 
is generic to all forms of fairness. To get weak fairness, conjoin  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
40  | 
      the inclusion below with @{term "A \<subseteq> Domain act"}, which specifies 
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
41  | 
      that the action is enabled over all of @{term A}.*}
 | 
| 5648 | 42  | 
transient :: "'a set => 'a program set"  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
43  | 
    "transient A == {F. \<exists>act\<in>Acts F. act``A \<subseteq> -A}"
 | 
| 4776 | 44  | 
|
| 13797 | 45  | 
ensures :: "['a set, 'a set] => 'a program set" (infixl "ensures" 60)  | 
| 13805 | 46  | 
"A ensures B == (A-B co A \<union> B) \<inter> transient (A-B)"  | 
| 8006 | 47  | 
|
| 6536 | 48  | 
|
| 23767 | 49  | 
inductive_set  | 
| 
6801
 
9e0037839d63
renamed the underlying relation of leadsTo from "leadsto"
 
paulson 
parents: 
6536 
diff
changeset
 | 
50  | 
  leads :: "'a program => ('a set * 'a set) set"
 | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
51  | 
    --{*LEADS-TO constant for the inductive definition*}
 | 
| 23767 | 52  | 
for F :: "'a program"  | 
53  | 
where  | 
|
| 4776 | 54  | 
|
| 13805 | 55  | 
Basis: "F \<in> A ensures B ==> (A,B) \<in> leads F"  | 
| 4776 | 56  | 
|
| 23767 | 57  | 
| Trans: "[| (A,B) \<in> leads F; (B,C) \<in> leads F |] ==> (A,C) \<in> leads F"  | 
| 4776 | 58  | 
|
| 23767 | 59  | 
| Union: "\<forall>A \<in> S. (A,B) \<in> leads F ==> (Union S, B) \<in> leads F"  | 
| 4776 | 60  | 
|
| 5155 | 61  | 
|
| 8006 | 62  | 
constdefs  | 
| 6536 | 63  | 
|
| 13797 | 64  | 
leadsTo :: "['a set, 'a set] => 'a program set" (infixl "leadsTo" 60)  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
65  | 
     --{*visible version of the LEADS-TO relation*}
 | 
| 13805 | 66  | 
    "A leadsTo B == {F. (A,B) \<in> leads F}"
 | 
| 5648 | 67  | 
|
68  | 
wlt :: "['a program, 'a set] => 'a set"  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
69  | 
     --{*predicate transformer: the largest set that leads to @{term B}*}
 | 
| 13805 | 70  | 
    "wlt F B == Union {A. F \<in> A leadsTo B}"
 | 
| 4776 | 71  | 
|
| 9685 | 72  | 
syntax (xsymbols)  | 
| 13797 | 73  | 
"op leadsTo" :: "['a set, 'a set] => 'a program set" (infixl "\<longmapsto>" 60)  | 
74  | 
||
75  | 
||
| 13798 | 76  | 
subsection{*transient*}
 | 
| 13797 | 77  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
78  | 
lemma stable_transient:  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
79  | 
"[| F \<in> stable A; F \<in> transient A |] ==> \<exists>act\<in>Acts F. A \<subseteq> - (Domain act)"  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
80  | 
apply (simp add: stable_def constrains_def transient_def, clarify)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
81  | 
apply (rule rev_bexI, auto)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
82  | 
done  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
83  | 
|
| 13797 | 84  | 
lemma stable_transient_empty:  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
85  | 
    "[| F \<in> stable A; F \<in> transient A; all_total F |] ==> A = {}"
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
86  | 
apply (drule stable_transient, assumption)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
87  | 
apply (simp add: all_total_def)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
88  | 
done  | 
| 13797 | 89  | 
|
90  | 
lemma transient_strengthen:  | 
|
| 13805 | 91  | 
"[| F \<in> transient A; B \<subseteq> A |] ==> F \<in> transient B"  | 
| 13797 | 92  | 
apply (unfold transient_def, clarify)  | 
93  | 
apply (blast intro!: rev_bexI)  | 
|
94  | 
done  | 
|
95  | 
||
96  | 
lemma transientI:  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
97  | 
"[| act: Acts F; act``A \<subseteq> -A |] ==> F \<in> transient A"  | 
| 13797 | 98  | 
by (unfold transient_def, blast)  | 
99  | 
||
100  | 
lemma transientE:  | 
|
| 13805 | 101  | 
"[| F \<in> transient A;  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
102  | 
!!act. [| act: Acts F; act``A \<subseteq> -A |] ==> P |]  | 
| 13797 | 103  | 
==> P"  | 
104  | 
by (unfold transient_def, blast)  | 
|
105  | 
||
106  | 
lemma transient_empty [simp]: "transient {} = UNIV"
 | 
|
107  | 
by (unfold transient_def, auto)  | 
|
108  | 
||
109  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
110  | 
text{*This equation recovers the notion of weak fairness.  A totalized
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
111  | 
program satisfies a transient assertion just if the original program  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
112  | 
contains a suitable action that is also enabled.*}  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
113  | 
lemma totalize_transient_iff:  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
114  | 
"(totalize F \<in> transient A) = (\<exists>act\<in>Acts F. A \<subseteq> Domain act & act``A \<subseteq> -A)"  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
115  | 
apply (simp add: totalize_def totalize_act_def transient_def  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
116  | 
Un_Image Un_subset_iff, safe)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
117  | 
apply (blast intro!: rev_bexI)+  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
118  | 
done  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
119  | 
|
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
120  | 
lemma totalize_transientI:  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
121  | 
"[| act: Acts F; A \<subseteq> Domain act; act``A \<subseteq> -A |]  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
122  | 
==> totalize F \<in> transient A"  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
123  | 
by (simp add: totalize_transient_iff, blast)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
124  | 
|
| 13798 | 125  | 
subsection{*ensures*}
 | 
| 13797 | 126  | 
|
127  | 
lemma ensuresI:  | 
|
| 13805 | 128  | 
"[| F \<in> (A-B) co (A \<union> B); F \<in> transient (A-B) |] ==> F \<in> A ensures B"  | 
| 13797 | 129  | 
by (unfold ensures_def, blast)  | 
130  | 
||
131  | 
lemma ensuresD:  | 
|
| 13805 | 132  | 
"F \<in> A ensures B ==> F \<in> (A-B) co (A \<union> B) & F \<in> transient (A-B)"  | 
| 13797 | 133  | 
by (unfold ensures_def, blast)  | 
134  | 
||
135  | 
lemma ensures_weaken_R:  | 
|
| 13805 | 136  | 
"[| F \<in> A ensures A'; A'<=B' |] ==> F \<in> A ensures B'"  | 
| 13797 | 137  | 
apply (unfold ensures_def)  | 
138  | 
apply (blast intro: constrains_weaken transient_strengthen)  | 
|
139  | 
done  | 
|
140  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
141  | 
text{*The L-version (precondition strengthening) fails, but we have this*}
 | 
| 13797 | 142  | 
lemma stable_ensures_Int:  | 
| 13805 | 143  | 
"[| F \<in> stable C; F \<in> A ensures B |]  | 
144  | 
==> F \<in> (C \<inter> A) ensures (C \<inter> B)"  | 
|
| 13797 | 145  | 
apply (unfold ensures_def)  | 
146  | 
apply (auto simp add: ensures_def Int_Un_distrib [symmetric] Diff_Int_distrib [symmetric])  | 
|
147  | 
prefer 2 apply (blast intro: transient_strengthen)  | 
|
148  | 
apply (blast intro: stable_constrains_Int constrains_weaken)  | 
|
149  | 
done  | 
|
150  | 
||
151  | 
lemma stable_transient_ensures:  | 
|
| 13805 | 152  | 
"[| F \<in> stable A; F \<in> transient C; A \<subseteq> B \<union> C |] ==> F \<in> A ensures B"  | 
| 13797 | 153  | 
apply (simp add: ensures_def stable_def)  | 
154  | 
apply (blast intro: constrains_weaken transient_strengthen)  | 
|
155  | 
done  | 
|
156  | 
||
| 13805 | 157  | 
lemma ensures_eq: "(A ensures B) = (A unless B) \<inter> transient (A-B)"  | 
| 13797 | 158  | 
by (simp (no_asm) add: ensures_def unless_def)  | 
159  | 
||
160  | 
||
| 13798 | 161  | 
subsection{*leadsTo*}
 | 
| 13797 | 162  | 
|
| 13805 | 163  | 
lemma leadsTo_Basis [intro]: "F \<in> A ensures B ==> F \<in> A leadsTo B"  | 
| 13797 | 164  | 
apply (unfold leadsTo_def)  | 
165  | 
apply (blast intro: leads.Basis)  | 
|
166  | 
done  | 
|
167  | 
||
168  | 
lemma leadsTo_Trans:  | 
|
| 13805 | 169  | 
"[| F \<in> A leadsTo B; F \<in> B leadsTo C |] ==> F \<in> A leadsTo C"  | 
| 13797 | 170  | 
apply (unfold leadsTo_def)  | 
171  | 
apply (blast intro: leads.Trans)  | 
|
172  | 
done  | 
|
173  | 
||
| 14112 | 174  | 
lemma leadsTo_Basis':  | 
175  | 
"[| F \<in> A co A \<union> B; F \<in> transient A |] ==> F \<in> A leadsTo B"  | 
|
176  | 
apply (drule_tac B = "A-B" in constrains_weaken_L)  | 
|
177  | 
apply (drule_tac [2] B = "A-B" in transient_strengthen)  | 
|
178  | 
apply (rule_tac [3] ensuresI [THEN leadsTo_Basis])  | 
|
179  | 
apply (blast+)  | 
|
180  | 
done  | 
|
181  | 
||
| 13805 | 182  | 
lemma transient_imp_leadsTo: "F \<in> transient A ==> F \<in> A leadsTo (-A)"  | 
| 13797 | 183  | 
by (simp (no_asm_simp) add: leadsTo_Basis ensuresI Compl_partition)  | 
184  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
185  | 
text{*Useful with cancellation, disjunction*}
 | 
| 13805 | 186  | 
lemma leadsTo_Un_duplicate: "F \<in> A leadsTo (A' \<union> A') ==> F \<in> A leadsTo A'"  | 
| 13797 | 187  | 
by (simp add: Un_ac)  | 
188  | 
||
189  | 
lemma leadsTo_Un_duplicate2:  | 
|
| 13805 | 190  | 
"F \<in> A leadsTo (A' \<union> C \<union> C) ==> F \<in> A leadsTo (A' \<union> C)"  | 
| 13797 | 191  | 
by (simp add: Un_ac)  | 
192  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
193  | 
text{*The Union introduction rule as we should have liked to state it*}
 | 
| 13797 | 194  | 
lemma leadsTo_Union:  | 
| 13805 | 195  | 
"(!!A. A \<in> S ==> F \<in> A leadsTo B) ==> F \<in> (Union S) leadsTo B"  | 
| 13797 | 196  | 
apply (unfold leadsTo_def)  | 
197  | 
apply (blast intro: leads.Union)  | 
|
198  | 
done  | 
|
199  | 
||
200  | 
lemma leadsTo_Union_Int:  | 
|
| 13805 | 201  | 
"(!!A. A \<in> S ==> F \<in> (A \<inter> C) leadsTo B) ==> F \<in> (Union S \<inter> C) leadsTo B"  | 
| 13797 | 202  | 
apply (unfold leadsTo_def)  | 
203  | 
apply (simp only: Int_Union_Union)  | 
|
204  | 
apply (blast intro: leads.Union)  | 
|
205  | 
done  | 
|
206  | 
||
207  | 
lemma leadsTo_UN:  | 
|
| 13805 | 208  | 
"(!!i. i \<in> I ==> F \<in> (A i) leadsTo B) ==> F \<in> (\<Union>i \<in> I. A i) leadsTo B"  | 
| 13797 | 209  | 
apply (subst Union_image_eq [symmetric])  | 
210  | 
apply (blast intro: leadsTo_Union)  | 
|
211  | 
done  | 
|
212  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
213  | 
text{*Binary union introduction rule*}
 | 
| 13797 | 214  | 
lemma leadsTo_Un:  | 
| 13805 | 215  | 
"[| F \<in> A leadsTo C; F \<in> B leadsTo C |] ==> F \<in> (A \<union> B) leadsTo C"  | 
| 13797 | 216  | 
apply (subst Un_eq_Union)  | 
217  | 
apply (blast intro: leadsTo_Union)  | 
|
218  | 
done  | 
|
219  | 
||
220  | 
lemma single_leadsTo_I:  | 
|
| 13805 | 221  | 
     "(!!x. x \<in> A ==> F \<in> {x} leadsTo B) ==> F \<in> A leadsTo B"
 | 
| 13797 | 222  | 
by (subst UN_singleton [symmetric], rule leadsTo_UN, blast)  | 
223  | 
||
224  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
225  | 
text{*The INDUCTION rule as we should have liked to state it*}
 | 
| 13797 | 226  | 
lemma leadsTo_induct:  | 
| 13805 | 227  | 
"[| F \<in> za leadsTo zb;  | 
228  | 
!!A B. F \<in> A ensures B ==> P A B;  | 
|
229  | 
!!A B C. [| F \<in> A leadsTo B; P A B; F \<in> B leadsTo C; P B C |]  | 
|
| 13797 | 230  | 
==> P A C;  | 
| 13805 | 231  | 
!!B S. \<forall>A \<in> S. F \<in> A leadsTo B & P A B ==> P (Union S) B  | 
| 13797 | 232  | 
|] ==> P za zb"  | 
233  | 
apply (unfold leadsTo_def)  | 
|
234  | 
apply (drule CollectD, erule leads.induct)  | 
|
235  | 
apply (blast+)  | 
|
236  | 
done  | 
|
237  | 
||
238  | 
||
| 13805 | 239  | 
lemma subset_imp_ensures: "A \<subseteq> B ==> F \<in> A ensures B"  | 
| 13797 | 240  | 
by (unfold ensures_def constrains_def transient_def, blast)  | 
241  | 
||
242  | 
lemmas subset_imp_leadsTo = subset_imp_ensures [THEN leadsTo_Basis, standard]  | 
|
243  | 
||
244  | 
lemmas leadsTo_refl = subset_refl [THEN subset_imp_leadsTo, standard]  | 
|
245  | 
||
246  | 
lemmas empty_leadsTo = empty_subsetI [THEN subset_imp_leadsTo, standard, simp]  | 
|
247  | 
||
248  | 
lemmas leadsTo_UNIV = subset_UNIV [THEN subset_imp_leadsTo, standard, simp]  | 
|
249  | 
||
250  | 
||
251  | 
||
252  | 
(** Variant induction rule: on the preconditions for B **)  | 
|
253  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
254  | 
text{*Lemma is the weak version: can't see how to do it in one step*}
 | 
| 13797 | 255  | 
lemma leadsTo_induct_pre_lemma:  | 
| 13805 | 256  | 
"[| F \<in> za leadsTo zb;  | 
| 13797 | 257  | 
P zb;  | 
| 13805 | 258  | 
!!A B. [| F \<in> A ensures B; P B |] ==> P A;  | 
259  | 
!!S. \<forall>A \<in> S. P A ==> P (Union S)  | 
|
| 13797 | 260  | 
|] ==> P za"  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
261  | 
txt{*by induction on this formula*}
 | 
| 13797 | 262  | 
apply (subgoal_tac "P zb --> P za")  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
263  | 
txt{*now solve first subgoal: this formula is sufficient*}
 | 
| 13797 | 264  | 
apply (blast intro: leadsTo_refl)  | 
265  | 
apply (erule leadsTo_induct)  | 
|
266  | 
apply (blast+)  | 
|
267  | 
done  | 
|
268  | 
||
269  | 
lemma leadsTo_induct_pre:  | 
|
| 13805 | 270  | 
"[| F \<in> za leadsTo zb;  | 
| 13797 | 271  | 
P zb;  | 
| 13805 | 272  | 
!!A B. [| F \<in> A ensures B; F \<in> B leadsTo zb; P B |] ==> P A;  | 
273  | 
!!S. \<forall>A \<in> S. F \<in> A leadsTo zb & P A ==> P (Union S)  | 
|
| 13797 | 274  | 
|] ==> P za"  | 
| 13805 | 275  | 
apply (subgoal_tac "F \<in> za leadsTo zb & P za")  | 
| 13797 | 276  | 
apply (erule conjunct2)  | 
277  | 
apply (erule leadsTo_induct_pre_lemma)  | 
|
278  | 
prefer 3 apply (blast intro: leadsTo_Union)  | 
|
279  | 
prefer 2 apply (blast intro: leadsTo_Trans)  | 
|
280  | 
apply (blast intro: leadsTo_refl)  | 
|
281  | 
done  | 
|
282  | 
||
283  | 
||
| 13805 | 284  | 
lemma leadsTo_weaken_R: "[| F \<in> A leadsTo A'; A'<=B' |] ==> F \<in> A leadsTo B'"  | 
| 13797 | 285  | 
by (blast intro: subset_imp_leadsTo leadsTo_Trans)  | 
286  | 
||
| 13798 | 287  | 
lemma leadsTo_weaken_L [rule_format]:  | 
| 13805 | 288  | 
"[| F \<in> A leadsTo A'; B \<subseteq> A |] ==> F \<in> B leadsTo A'"  | 
| 13797 | 289  | 
by (blast intro: leadsTo_Trans subset_imp_leadsTo)  | 
290  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
291  | 
text{*Distributes over binary unions*}
 | 
| 13797 | 292  | 
lemma leadsTo_Un_distrib:  | 
| 13805 | 293  | 
"F \<in> (A \<union> B) leadsTo C = (F \<in> A leadsTo C & F \<in> B leadsTo C)"  | 
| 13797 | 294  | 
by (blast intro: leadsTo_Un leadsTo_weaken_L)  | 
295  | 
||
296  | 
lemma leadsTo_UN_distrib:  | 
|
| 13805 | 297  | 
"F \<in> (\<Union>i \<in> I. A i) leadsTo B = (\<forall>i \<in> I. F \<in> (A i) leadsTo B)"  | 
| 13797 | 298  | 
by (blast intro: leadsTo_UN leadsTo_weaken_L)  | 
299  | 
||
300  | 
lemma leadsTo_Union_distrib:  | 
|
| 13805 | 301  | 
"F \<in> (Union S) leadsTo B = (\<forall>A \<in> S. F \<in> A leadsTo B)"  | 
| 13797 | 302  | 
by (blast intro: leadsTo_Union leadsTo_weaken_L)  | 
303  | 
||
304  | 
||
305  | 
lemma leadsTo_weaken:  | 
|
| 13805 | 306  | 
"[| F \<in> A leadsTo A'; B \<subseteq> A; A'<=B' |] ==> F \<in> B leadsTo B'"  | 
| 13797 | 307  | 
by (blast intro: leadsTo_weaken_R leadsTo_weaken_L leadsTo_Trans)  | 
308  | 
||
309  | 
||
| 14150 | 310  | 
text{*Set difference: maybe combine with @{text leadsTo_weaken_L}??*}
 | 
| 13797 | 311  | 
lemma leadsTo_Diff:  | 
| 13805 | 312  | 
"[| F \<in> (A-B) leadsTo C; F \<in> B leadsTo C |] ==> F \<in> A leadsTo C"  | 
| 13797 | 313  | 
by (blast intro: leadsTo_Un leadsTo_weaken)  | 
314  | 
||
315  | 
lemma leadsTo_UN_UN:  | 
|
| 13805 | 316  | 
"(!! i. i \<in> I ==> F \<in> (A i) leadsTo (A' i))  | 
317  | 
==> F \<in> (\<Union>i \<in> I. A i) leadsTo (\<Union>i \<in> I. A' i)"  | 
|
| 13797 | 318  | 
apply (simp only: Union_image_eq [symmetric])  | 
319  | 
apply (blast intro: leadsTo_Union leadsTo_weaken_R)  | 
|
320  | 
done  | 
|
321  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
322  | 
text{*Binary union version*}
 | 
| 13797 | 323  | 
lemma leadsTo_Un_Un:  | 
| 13805 | 324  | 
"[| F \<in> A leadsTo A'; F \<in> B leadsTo B' |]  | 
325  | 
==> F \<in> (A \<union> B) leadsTo (A' \<union> B')"  | 
|
| 13797 | 326  | 
by (blast intro: leadsTo_Un leadsTo_weaken_R)  | 
327  | 
||
328  | 
||
329  | 
(** The cancellation law **)  | 
|
330  | 
||
331  | 
lemma leadsTo_cancel2:  | 
|
| 13805 | 332  | 
"[| F \<in> A leadsTo (A' \<union> B); F \<in> B leadsTo B' |]  | 
333  | 
==> F \<in> A leadsTo (A' \<union> B')"  | 
|
| 13797 | 334  | 
by (blast intro: leadsTo_Un_Un subset_imp_leadsTo leadsTo_Trans)  | 
335  | 
||
336  | 
lemma leadsTo_cancel_Diff2:  | 
|
| 13805 | 337  | 
"[| F \<in> A leadsTo (A' \<union> B); F \<in> (B-A') leadsTo B' |]  | 
338  | 
==> F \<in> A leadsTo (A' \<union> B')"  | 
|
| 13797 | 339  | 
apply (rule leadsTo_cancel2)  | 
340  | 
prefer 2 apply assumption  | 
|
341  | 
apply (simp_all (no_asm_simp))  | 
|
342  | 
done  | 
|
343  | 
||
344  | 
lemma leadsTo_cancel1:  | 
|
| 13805 | 345  | 
"[| F \<in> A leadsTo (B \<union> A'); F \<in> B leadsTo B' |]  | 
346  | 
==> F \<in> A leadsTo (B' \<union> A')"  | 
|
| 13797 | 347  | 
apply (simp add: Un_commute)  | 
348  | 
apply (blast intro!: leadsTo_cancel2)  | 
|
349  | 
done  | 
|
350  | 
||
351  | 
lemma leadsTo_cancel_Diff1:  | 
|
| 13805 | 352  | 
"[| F \<in> A leadsTo (B \<union> A'); F \<in> (B-A') leadsTo B' |]  | 
353  | 
==> F \<in> A leadsTo (B' \<union> A')"  | 
|
| 13797 | 354  | 
apply (rule leadsTo_cancel1)  | 
355  | 
prefer 2 apply assumption  | 
|
356  | 
apply (simp_all (no_asm_simp))  | 
|
357  | 
done  | 
|
358  | 
||
359  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
360  | 
text{*The impossibility law*}
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
361  | 
lemma leadsTo_empty: "[|F \<in> A leadsTo {}; all_total F|] ==> A={}"
 | 
| 13797 | 362  | 
apply (erule leadsTo_induct_pre)  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
363  | 
apply (simp_all add: ensures_def constrains_def transient_def all_total_def, clarify)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
364  | 
apply (drule bspec, assumption)+  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
365  | 
apply blast  | 
| 13797 | 366  | 
done  | 
367  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
368  | 
subsection{*PSP: Progress-Safety-Progress*}
 | 
| 13797 | 369  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
370  | 
text{*Special case of PSP: Misra's "stable conjunction"*}
 | 
| 13797 | 371  | 
lemma psp_stable:  | 
| 13805 | 372  | 
"[| F \<in> A leadsTo A'; F \<in> stable B |]  | 
373  | 
==> F \<in> (A \<inter> B) leadsTo (A' \<inter> B)"  | 
|
| 13797 | 374  | 
apply (unfold stable_def)  | 
375  | 
apply (erule leadsTo_induct)  | 
|
376  | 
prefer 3 apply (blast intro: leadsTo_Union_Int)  | 
|
377  | 
prefer 2 apply (blast intro: leadsTo_Trans)  | 
|
378  | 
apply (rule leadsTo_Basis)  | 
|
379  | 
apply (simp add: ensures_def Diff_Int_distrib2 [symmetric] Int_Un_distrib2 [symmetric])  | 
|
380  | 
apply (blast intro: transient_strengthen constrains_Int)  | 
|
381  | 
done  | 
|
382  | 
||
383  | 
lemma psp_stable2:  | 
|
| 13805 | 384  | 
"[| F \<in> A leadsTo A'; F \<in> stable B |] ==> F \<in> (B \<inter> A) leadsTo (B \<inter> A')"  | 
| 13797 | 385  | 
by (simp add: psp_stable Int_ac)  | 
386  | 
||
387  | 
lemma psp_ensures:  | 
|
| 13805 | 388  | 
"[| F \<in> A ensures A'; F \<in> B co B' |]  | 
389  | 
==> F \<in> (A \<inter> B') ensures ((A' \<inter> B) \<union> (B' - B))"  | 
|
| 13797 | 390  | 
apply (unfold ensures_def constrains_def, clarify) (*speeds up the proof*)  | 
391  | 
apply (blast intro: transient_strengthen)  | 
|
392  | 
done  | 
|
393  | 
||
394  | 
lemma psp:  | 
|
| 13805 | 395  | 
"[| F \<in> A leadsTo A'; F \<in> B co B' |]  | 
396  | 
==> F \<in> (A \<inter> B') leadsTo ((A' \<inter> B) \<union> (B' - B))"  | 
|
| 13797 | 397  | 
apply (erule leadsTo_induct)  | 
398  | 
prefer 3 apply (blast intro: leadsTo_Union_Int)  | 
|
399  | 
 txt{*Basis case*}
 | 
|
400  | 
apply (blast intro: psp_ensures)  | 
|
401  | 
txt{*Transitivity case has a delicate argument involving "cancellation"*}
 | 
|
402  | 
apply (rule leadsTo_Un_duplicate2)  | 
|
403  | 
apply (erule leadsTo_cancel_Diff1)  | 
|
404  | 
apply (simp add: Int_Diff Diff_triv)  | 
|
405  | 
apply (blast intro: leadsTo_weaken_L dest: constrains_imp_subset)  | 
|
406  | 
done  | 
|
407  | 
||
408  | 
lemma psp2:  | 
|
| 13805 | 409  | 
"[| F \<in> A leadsTo A'; F \<in> B co B' |]  | 
410  | 
==> F \<in> (B' \<inter> A) leadsTo ((B \<inter> A') \<union> (B' - B))"  | 
|
| 13797 | 411  | 
by (simp (no_asm_simp) add: psp Int_ac)  | 
412  | 
||
413  | 
lemma psp_unless:  | 
|
| 13805 | 414  | 
"[| F \<in> A leadsTo A'; F \<in> B unless B' |]  | 
415  | 
==> F \<in> (A \<inter> B) leadsTo ((A' \<inter> B) \<union> B')"  | 
|
| 13797 | 416  | 
|
417  | 
apply (unfold unless_def)  | 
|
418  | 
apply (drule psp, assumption)  | 
|
419  | 
apply (blast intro: leadsTo_weaken)  | 
|
420  | 
done  | 
|
421  | 
||
422  | 
||
| 13798 | 423  | 
subsection{*Proving the induction rules*}
 | 
| 13797 | 424  | 
|
425  | 
(** The most general rule: r is any wf relation; f is any variant function **)  | 
|
426  | 
||
427  | 
lemma leadsTo_wf_induct_lemma:  | 
|
428  | 
"[| wf r;  | 
|
| 13805 | 429  | 
         \<forall>m. F \<in> (A \<inter> f-`{m}) leadsTo                      
 | 
430  | 
                    ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | 
|
431  | 
      ==> F \<in> (A \<inter> f-`{m}) leadsTo B"
 | 
|
| 13797 | 432  | 
apply (erule_tac a = m in wf_induct)  | 
| 13805 | 433  | 
apply (subgoal_tac "F \<in> (A \<inter> (f -` (r^-1 `` {x}))) leadsTo B")
 | 
| 13797 | 434  | 
apply (blast intro: leadsTo_cancel1 leadsTo_Un_duplicate)  | 
435  | 
apply (subst vimage_eq_UN)  | 
|
436  | 
apply (simp only: UN_simps [symmetric])  | 
|
437  | 
apply (blast intro: leadsTo_UN)  | 
|
438  | 
done  | 
|
439  | 
||
440  | 
||
441  | 
(** Meta or object quantifier ? **)  | 
|
442  | 
lemma leadsTo_wf_induct:  | 
|
443  | 
"[| wf r;  | 
|
| 13805 | 444  | 
         \<forall>m. F \<in> (A \<inter> f-`{m}) leadsTo                      
 | 
445  | 
                    ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | 
|
446  | 
==> F \<in> A leadsTo B"  | 
|
| 13797 | 447  | 
apply (rule_tac t = A in subst)  | 
448  | 
defer 1  | 
|
449  | 
apply (rule leadsTo_UN)  | 
|
450  | 
apply (erule leadsTo_wf_induct_lemma)  | 
|
451  | 
apply assumption  | 
|
452  | 
apply fast (*Blast_tac: Function unknown's argument not a parameter*)  | 
|
453  | 
done  | 
|
454  | 
||
455  | 
||
456  | 
lemma bounded_induct:  | 
|
457  | 
"[| wf r;  | 
|
| 13805 | 458  | 
         \<forall>m \<in> I. F \<in> (A \<inter> f-`{m}) leadsTo                    
 | 
459  | 
                      ((A \<inter> f-`(r^-1 `` {m})) \<union> B) |]  
 | 
|
460  | 
==> F \<in> A leadsTo ((A - (f-`I)) \<union> B)"  | 
|
| 13797 | 461  | 
apply (erule leadsTo_wf_induct, safe)  | 
| 13805 | 462  | 
apply (case_tac "m \<in> I")  | 
| 13797 | 463  | 
apply (blast intro: leadsTo_weaken)  | 
464  | 
apply (blast intro: subset_imp_leadsTo)  | 
|
465  | 
done  | 
|
466  | 
||
467  | 
||
| 13805 | 468  | 
(*Alternative proof is via the lemma F \<in> (A \<inter> f-`(lessThan m)) leadsTo B*)  | 
| 13797 | 469  | 
lemma lessThan_induct:  | 
| 15045 | 470  | 
     "[| !!m::nat. F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`{..<m}) \<union> B) |]  
 | 
| 13805 | 471  | 
==> F \<in> A leadsTo B"  | 
| 13797 | 472  | 
apply (rule wf_less_than [THEN leadsTo_wf_induct])  | 
473  | 
apply (simp (no_asm_simp))  | 
|
474  | 
apply blast  | 
|
475  | 
done  | 
|
476  | 
||
477  | 
lemma lessThan_bounded_induct:  | 
|
| 13805 | 478  | 
"!!l::nat. [| \<forall>m \<in> greaterThan l.  | 
479  | 
            F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`(lessThan m)) \<union> B) |]  
 | 
|
480  | 
==> F \<in> A leadsTo ((A \<inter> (f-`(atMost l))) \<union> B)"  | 
|
| 13797 | 481  | 
apply (simp only: Diff_eq [symmetric] vimage_Compl Compl_greaterThan [symmetric])  | 
482  | 
apply (rule wf_less_than [THEN bounded_induct])  | 
|
483  | 
apply (simp (no_asm_simp))  | 
|
484  | 
done  | 
|
485  | 
||
486  | 
lemma greaterThan_bounded_induct:  | 
|
| 13805 | 487  | 
"(!!l::nat. \<forall>m \<in> lessThan l.  | 
488  | 
                 F \<in> (A \<inter> f-`{m}) leadsTo ((A \<inter> f-`(greaterThan m)) \<union> B))
 | 
|
489  | 
==> F \<in> A leadsTo ((A \<inter> (f-`(atLeast l))) \<union> B)"  | 
|
| 13797 | 490  | 
apply (rule_tac f = f and f1 = "%k. l - k"  | 
491  | 
in wf_less_than [THEN wf_inv_image, THEN leadsTo_wf_induct])  | 
|
| 
19769
 
c40ce2de2020
Added [simp]-lemmas "in_inv_image" and "in_lex_prod" in the spirit of "in_measure".
 
krauss 
parents: 
16417 
diff
changeset
 | 
492  | 
apply (simp (no_asm) add:Image_singleton)  | 
| 13797 | 493  | 
apply clarify  | 
494  | 
apply (case_tac "m<l")  | 
|
| 13805 | 495  | 
apply (blast intro: leadsTo_weaken_R diff_less_mono2)  | 
496  | 
apply (blast intro: not_leE subset_imp_leadsTo)  | 
|
| 13797 | 497  | 
done  | 
498  | 
||
499  | 
||
| 13798 | 500  | 
subsection{*wlt*}
 | 
| 13797 | 501  | 
|
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
502  | 
text{*Misra's property W3*}
 | 
| 13805 | 503  | 
lemma wlt_leadsTo: "F \<in> (wlt F B) leadsTo B"  | 
| 13797 | 504  | 
apply (unfold wlt_def)  | 
505  | 
apply (blast intro!: leadsTo_Union)  | 
|
506  | 
done  | 
|
507  | 
||
| 13805 | 508  | 
lemma leadsTo_subset: "F \<in> A leadsTo B ==> A \<subseteq> wlt F B"  | 
| 13797 | 509  | 
apply (unfold wlt_def)  | 
510  | 
apply (blast intro!: leadsTo_Union)  | 
|
511  | 
done  | 
|
512  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
513  | 
text{*Misra's property W2*}
 | 
| 13805 | 514  | 
lemma leadsTo_eq_subset_wlt: "F \<in> A leadsTo B = (A \<subseteq> wlt F B)"  | 
| 13797 | 515  | 
by (blast intro!: leadsTo_subset wlt_leadsTo [THEN leadsTo_weaken_L])  | 
516  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
517  | 
text{*Misra's property W4*}
 | 
| 13805 | 518  | 
lemma wlt_increasing: "B \<subseteq> wlt F B"  | 
| 13797 | 519  | 
apply (simp (no_asm_simp) add: leadsTo_eq_subset_wlt [symmetric] subset_imp_leadsTo)  | 
520  | 
done  | 
|
521  | 
||
522  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
523  | 
text{*Used in the Trans case below*}
 | 
| 13797 | 524  | 
lemma lemma1:  | 
| 13805 | 525  | 
"[| B \<subseteq> A2;  | 
526  | 
F \<in> (A1 - B) co (A1 \<union> B);  | 
|
527  | 
F \<in> (A2 - C) co (A2 \<union> C) |]  | 
|
528  | 
==> F \<in> (A1 \<union> A2 - C) co (A1 \<union> A2 \<union> C)"  | 
|
| 13797 | 529  | 
by (unfold constrains_def, clarify, blast)  | 
530  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
531  | 
text{*Lemma (1,2,3) of Misra's draft book, Chapter 4, "Progress"*}
 | 
| 13797 | 532  | 
lemma leadsTo_123:  | 
| 13805 | 533  | 
"F \<in> A leadsTo A'  | 
534  | 
==> \<exists>B. A \<subseteq> B & F \<in> B leadsTo A' & F \<in> (B-A') co (B \<union> A')"  | 
|
| 13797 | 535  | 
apply (erule leadsTo_induct)  | 
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
536  | 
  txt{*Basis*}
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
537  | 
apply (blast dest: ensuresD)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
538  | 
 txt{*Trans*}
 | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
539  | 
apply clarify  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
540  | 
apply (rule_tac x = "Ba \<union> Bb" in exI)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
541  | 
apply (blast intro: lemma1 leadsTo_Un_Un leadsTo_cancel1 leadsTo_Un_duplicate)  | 
| 
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
542  | 
txt{*Union*}
 | 
| 13797 | 543  | 
apply (clarify dest!: ball_conj_distrib [THEN iffD1] bchoice)  | 
| 13805 | 544  | 
apply (rule_tac x = "\<Union>A \<in> S. f A" in exI)  | 
| 13797 | 545  | 
apply (auto intro: leadsTo_UN)  | 
546  | 
(*Blast_tac says PROOF FAILED*)  | 
|
| 13805 | 547  | 
apply (rule_tac I1=S and A1="%i. f i - B" and A'1="%i. f i \<union> B"  | 
| 13798 | 548  | 
in constrains_UN [THEN constrains_weaken], auto)  | 
| 13797 | 549  | 
done  | 
550  | 
||
551  | 
||
| 
13812
 
91713a1915ee
converting HOL/UNITY to use unconditional fairness
 
paulson 
parents: 
13805 
diff
changeset
 | 
552  | 
text{*Misra's property W5*}
 | 
| 13805 | 553  | 
lemma wlt_constrains_wlt: "F \<in> (wlt F B - B) co (wlt F B)"  | 
| 13798 | 554  | 
proof -  | 
555  | 
from wlt_leadsTo [of F B, THEN leadsTo_123]  | 
|
556  | 
show ?thesis  | 
|
557  | 
proof (elim exE conjE)  | 
|
558  | 
(* assumes have to be in exactly the form as in the goal displayed at  | 
|
559  | 
this point. Isar doesn't give you any automation. *)  | 
|
560  | 
fix C  | 
|
561  | 
assume wlt: "wlt F B \<subseteq> C"  | 
|
562  | 
and lt: "F \<in> C leadsTo B"  | 
|
563  | 
and co: "F \<in> C - B co C \<union> B"  | 
|
564  | 
have eq: "C = wlt F B"  | 
|
565  | 
proof -  | 
|
566  | 
from lt and wlt show ?thesis  | 
|
567  | 
by (blast dest: leadsTo_eq_subset_wlt [THEN iffD1])  | 
|
568  | 
qed  | 
|
569  | 
from co show ?thesis by (simp add: eq wlt_increasing Un_absorb2)  | 
|
570  | 
qed  | 
|
571  | 
qed  | 
|
| 13797 | 572  | 
|
573  | 
||
| 13798 | 574  | 
subsection{*Completion: Binary and General Finite versions*}
 | 
| 13797 | 575  | 
|
576  | 
lemma completion_lemma :  | 
|
| 13805 | 577  | 
"[| W = wlt F (B' \<union> C);  | 
578  | 
F \<in> A leadsTo (A' \<union> C); F \<in> A' co (A' \<union> C);  | 
|
579  | 
F \<in> B leadsTo (B' \<union> C); F \<in> B' co (B' \<union> C) |]  | 
|
580  | 
==> F \<in> (A \<inter> B) leadsTo ((A' \<inter> B') \<union> C)"  | 
|
581  | 
apply (subgoal_tac "F \<in> (W-C) co (W \<union> B' \<union> C) ")  | 
|
| 13797 | 582  | 
prefer 2  | 
583  | 
apply (blast intro: wlt_constrains_wlt [THEN [2] constrains_Un,  | 
|
584  | 
THEN constrains_weaken])  | 
|
| 13805 | 585  | 
apply (subgoal_tac "F \<in> (W-C) co W")  | 
| 13797 | 586  | 
prefer 2  | 
587  | 
apply (simp add: wlt_increasing Un_assoc Un_absorb2)  | 
|
| 13805 | 588  | 
apply (subgoal_tac "F \<in> (A \<inter> W - C) leadsTo (A' \<inter> W \<union> C) ")  | 
| 13797 | 589  | 
prefer 2 apply (blast intro: wlt_leadsTo psp [THEN leadsTo_weaken])  | 
590  | 
(** LEVEL 6 **)  | 
|
| 13805 | 591  | 
apply (subgoal_tac "F \<in> (A' \<inter> W \<union> C) leadsTo (A' \<inter> B' \<union> C) ")  | 
| 13797 | 592  | 
prefer 2  | 
593  | 
apply (rule leadsTo_Un_duplicate2)  | 
|
594  | 
apply (blast intro: leadsTo_Un_Un wlt_leadsTo  | 
|
595  | 
[THEN psp2, THEN leadsTo_weaken] leadsTo_refl)  | 
|
596  | 
apply (drule leadsTo_Diff)  | 
|
597  | 
apply (blast intro: subset_imp_leadsTo)  | 
|
| 13805 | 598  | 
apply (subgoal_tac "A \<inter> B \<subseteq> A \<inter> W")  | 
| 13797 | 599  | 
prefer 2  | 
600  | 
apply (blast dest!: leadsTo_subset intro!: subset_refl [THEN Int_mono])  | 
|
601  | 
apply (blast intro: leadsTo_Trans subset_imp_leadsTo)  | 
|
602  | 
done  | 
|
603  | 
||
604  | 
lemmas completion = completion_lemma [OF refl]  | 
|
605  | 
||
606  | 
lemma finite_completion_lemma:  | 
|
| 13805 | 607  | 
"finite I ==> (\<forall>i \<in> I. F \<in> (A i) leadsTo (A' i \<union> C)) -->  | 
608  | 
(\<forall>i \<in> I. F \<in> (A' i) co (A' i \<union> C)) -->  | 
|
609  | 
F \<in> (\<Inter>i \<in> I. A i) leadsTo ((\<Inter>i \<in> I. A' i) \<union> C)"  | 
|
| 13797 | 610  | 
apply (erule finite_induct, auto)  | 
611  | 
apply (rule completion)  | 
|
612  | 
prefer 4  | 
|
613  | 
apply (simp only: INT_simps [symmetric])  | 
|
614  | 
apply (rule constrains_INT, auto)  | 
|
615  | 
done  | 
|
616  | 
||
617  | 
lemma finite_completion:  | 
|
618  | 
"[| finite I;  | 
|
| 13805 | 619  | 
!!i. i \<in> I ==> F \<in> (A i) leadsTo (A' i \<union> C);  | 
620  | 
!!i. i \<in> I ==> F \<in> (A' i) co (A' i \<union> C) |]  | 
|
621  | 
==> F \<in> (\<Inter>i \<in> I. A i) leadsTo ((\<Inter>i \<in> I. A' i) \<union> C)"  | 
|
| 13797 | 622  | 
by (blast intro: finite_completion_lemma [THEN mp, THEN mp])  | 
623  | 
||
624  | 
lemma stable_completion:  | 
|
| 13805 | 625  | 
"[| F \<in> A leadsTo A'; F \<in> stable A';  | 
626  | 
F \<in> B leadsTo B'; F \<in> stable B' |]  | 
|
627  | 
==> F \<in> (A \<inter> B) leadsTo (A' \<inter> B')"  | 
|
| 13797 | 628  | 
apply (unfold stable_def)  | 
629  | 
apply (rule_tac C1 = "{}" in completion [THEN leadsTo_weaken_R])
 | 
|
630  | 
apply (force+)  | 
|
631  | 
done  | 
|
632  | 
||
633  | 
lemma finite_stable_completion:  | 
|
634  | 
"[| finite I;  | 
|
| 13805 | 635  | 
!!i. i \<in> I ==> F \<in> (A i) leadsTo (A' i);  | 
636  | 
!!i. i \<in> I ==> F \<in> stable (A' i) |]  | 
|
637  | 
==> F \<in> (\<Inter>i \<in> I. A i) leadsTo (\<Inter>i \<in> I. A' i)"  | 
|
| 13797 | 638  | 
apply (unfold stable_def)  | 
639  | 
apply (rule_tac C1 = "{}" in finite_completion [THEN leadsTo_weaken_R])
 | 
|
640  | 
apply (simp_all (no_asm_simp))  | 
|
641  | 
apply blast+  | 
|
642  | 
done  | 
|
| 9685 | 643  | 
|
| 4776 | 644  | 
end  |