| author | obua | 
| Thu, 16 Feb 2006 23:31:32 +0100 | |
| changeset 19090 | c442f3362f7a | 
| parent 17233 | 41eee2e7b465 | 
| child 19741 | f65265d71426 | 
| permissions | -rw-r--r-- | 
| 3071 | 1  | 
(* Title: HOLCF/IOA/meta_theory/Automata.thy  | 
| 3275 | 2  | 
ID: $Id$  | 
| 12218 | 3  | 
Author: Olaf Müller, Konrad Slind, Tobias Nipkow  | 
| 17233 | 4  | 
*)  | 
| 3071 | 5  | 
|
| 17233 | 6  | 
header {* The I/O automata of Lynch and Tuttle in HOLCF *}
 | 
| 3071 | 7  | 
|
| 17233 | 8  | 
theory Automata  | 
9  | 
imports Asig  | 
|
10  | 
begin  | 
|
11  | 
||
12  | 
defaultsort type  | 
|
13  | 
||
| 3071 | 14  | 
types  | 
| 17233 | 15  | 
  ('a, 's) transition = "'s * 'a * 's"
 | 
16  | 
  ('a, 's) ioa = "'a signature * 's set * ('a,'s)transition set * ('a set set) * ('a set set)"
 | 
|
| 3071 | 17  | 
|
18  | 
consts  | 
|
| 17233 | 19  | 
|
| 3071 | 20  | 
(* IO automata *)  | 
| 3521 | 21  | 
|
22  | 
  asig_of        ::"('a,'s)ioa => 'a signature"
 | 
|
23  | 
  starts_of      ::"('a,'s)ioa => 's set"
 | 
|
24  | 
  trans_of       ::"('a,'s)ioa => ('a,'s)transition set"
 | 
|
25  | 
  wfair_of       ::"('a,'s)ioa => ('a set) set"
 | 
|
26  | 
  sfair_of       ::"('a,'s)ioa => ('a set) set"
 | 
|
27  | 
||
28  | 
  is_asig_of     ::"('a,'s)ioa => bool"
 | 
|
| 17233 | 29  | 
  is_starts_of   ::"('a,'s)ioa => bool"
 | 
30  | 
  is_trans_of    ::"('a,'s)ioa => bool"
 | 
|
31  | 
  input_enabled  ::"('a,'s)ioa => bool"
 | 
|
32  | 
  IOA            ::"('a,'s)ioa => bool"
 | 
|
| 3071 | 33  | 
|
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
34  | 
(* constraints for fair IOA *)  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
35  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
36  | 
  fairIOA        ::"('a,'s)ioa => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
37  | 
  input_resistant::"('a,'s)ioa => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
38  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
39  | 
(* enabledness of actions and action sets *)  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
40  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
41  | 
  enabled        ::"('a,'s)ioa => 'a => 's => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
42  | 
  Enabled    ::"('a,'s)ioa => 'a set => 's => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
43  | 
|
| 17233 | 44  | 
(* action set keeps enabled until probably disabled by itself *)  | 
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
45  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
46  | 
  en_persistent  :: "('a,'s)ioa => 'a set => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
47  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
48  | 
(* post_conditions for actions and action sets *)  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
49  | 
|
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
50  | 
  was_enabled        ::"('a,'s)ioa => 'a => 's => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
51  | 
  set_was_enabled    ::"('a,'s)ioa => 'a set => 's => bool"
 | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
52  | 
|
| 3071 | 53  | 
(* reachability and invariants *)  | 
54  | 
  reachable     :: "('a,'s)ioa => 's set"
 | 
|
55  | 
  invariant     :: "[('a,'s)ioa, 's=>bool] => bool"
 | 
|
56  | 
||
57  | 
(* binary composition of action signatures and automata *)  | 
|
58  | 
asig_comp ::"['a signature, 'a signature] => 'a signature"  | 
|
| 3521 | 59  | 
  compatible   ::"[('a,'s)ioa, ('a,'t)ioa] => bool"
 | 
| 3071 | 60  | 
  "||"         ::"[('a,'s)ioa, ('a,'t)ioa] => ('a,'s*'t)ioa"  (infixr 10)
 | 
61  | 
||
| 3521 | 62  | 
(* hiding and restricting *)  | 
63  | 
hide_asig :: "['a signature, 'a set] => 'a signature"  | 
|
| 17233 | 64  | 
  "hide"        :: "[('a,'s)ioa, 'a set] => ('a,'s)ioa"
 | 
| 3071 | 65  | 
restrict_asig :: "['a signature, 'a set] => 'a signature"  | 
66  | 
  restrict      :: "[('a,'s)ioa, 'a set] => ('a,'s)ioa"
 | 
|
67  | 
||
68  | 
(* renaming *)  | 
|
| 3521 | 69  | 
  rename_set    :: "'a set => ('c => 'a option) => 'c set"
 | 
70  | 
  rename        :: "('a, 'b)ioa => ('c => 'a option) => ('c,'b)ioa"
 | 
|
| 3071 | 71  | 
|
72  | 
||
| 17233 | 73  | 
syntax  | 
| 3071 | 74  | 
|
75  | 
  "_trans_of"  :: "'s => 'a => ('a,'s)ioa => 's => bool"  ("_ -_--_-> _" [81,81,81,81] 100)
 | 
|
76  | 
  "reachable"  :: "[('a,'s)ioa, 's] => bool"
 | 
|
77  | 
  "act"        :: "('a,'s)ioa => 'a set"
 | 
|
78  | 
  "ext"        :: "('a,'s)ioa => 'a set"
 | 
|
79  | 
  "int"        :: "('a,'s)ioa => 'a set"
 | 
|
80  | 
  "inp"        :: "('a,'s)ioa => 'a set"
 | 
|
81  | 
  "out"        :: "('a,'s)ioa => 'a set"
 | 
|
| 
3433
 
2de17c994071
added deadlock freedom, polished definitions and proofs
 
mueller 
parents: 
3275 
diff
changeset
 | 
82  | 
  "local"      :: "('a,'s)ioa => 'a set"
 | 
| 3071 | 83  | 
|
84  | 
||
| 
12114
 
a8e860c86252
eliminated old "symbols" syntax, use "xsymbols" instead;
 
wenzelm 
parents: 
7661 
diff
changeset
 | 
85  | 
syntax (xsymbols)  | 
| 3071 | 86  | 
|
| 17233 | 87  | 
  "_trans_of"  :: "'s => 'a => ('a,'s)ioa => 's => bool"
 | 
88  | 
                  ("_ \<midarrow>_\<midarrow>_\<longrightarrow> _" [81,81,81,81] 100)
 | 
|
89  | 
  "op ||"         ::"[('a,'s)ioa, ('a,'t)ioa] => ('a,'s*'t)ioa"  (infixr "\<parallel>" 10)
 | 
|
| 3071 | 90  | 
|
91  | 
||
| 17233 | 92  | 
inductive "reachable C"  | 
93  | 
intros  | 
|
94  | 
reachable_0: "s:(starts_of C) ==> s : reachable C"  | 
|
95  | 
reachable_n: "[|s:reachable C; (s,a,t):trans_of C|] ==> t:reachable C"  | 
|
| 3071 | 96  | 
|
97  | 
||
98  | 
translations  | 
|
99  | 
"s -a--A-> t" == "(s,a,t):trans_of A"  | 
|
100  | 
"reachable A s" == "s:reachable A"  | 
|
101  | 
"act A" == "actions (asig_of A)"  | 
|
102  | 
"ext A" == "externals (asig_of A)"  | 
|
103  | 
"int A" == "internals (asig_of A)"  | 
|
104  | 
"inp A" == "inputs (asig_of A)"  | 
|
105  | 
"out A" == "outputs (asig_of A)"  | 
|
| 
3433
 
2de17c994071
added deadlock freedom, polished definitions and proofs
 
mueller 
parents: 
3275 
diff
changeset
 | 
106  | 
"local A" == "locals (asig_of A)"  | 
| 
 
2de17c994071
added deadlock freedom, polished definitions and proofs
 
mueller 
parents: 
3275 
diff
changeset
 | 
107  | 
|
| 3071 | 108  | 
defs  | 
109  | 
||
110  | 
(* --------------------------------- IOA ---------------------------------*)  | 
|
111  | 
||
| 17233 | 112  | 
asig_of_def: "asig_of == fst"  | 
113  | 
starts_of_def: "starts_of == (fst o snd)"  | 
|
114  | 
trans_of_def: "trans_of == (fst o snd o snd)"  | 
|
115  | 
wfair_of_def: "wfair_of == (fst o snd o snd o snd)"  | 
|
116  | 
sfair_of_def: "sfair_of == (snd o snd o snd o snd)"  | 
|
117  | 
||
118  | 
is_asig_of_def:  | 
|
119  | 
"is_asig_of A == is_asig (asig_of A)"  | 
|
120  | 
||
121  | 
is_starts_of_def:  | 
|
122  | 
  "is_starts_of A ==  (~ starts_of A = {})"
 | 
|
123  | 
||
124  | 
is_trans_of_def:  | 
|
125  | 
"is_trans_of A ==  | 
|
126  | 
(!triple. triple:(trans_of A) --> fst(snd(triple)):actions(asig_of A))"  | 
|
127  | 
||
128  | 
input_enabled_def:  | 
|
129  | 
"input_enabled A ==  | 
|
130  | 
(!a. (a:inputs(asig_of A)) --> (!s1. ? s2. (s1,a,s2):(trans_of A)))"  | 
|
| 3071 | 131  | 
|
132  | 
||
| 17233 | 133  | 
ioa_def:  | 
134  | 
"IOA A == (is_asig_of A &  | 
|
135  | 
is_starts_of A &  | 
|
| 3521 | 136  | 
is_trans_of A &  | 
137  | 
input_enabled A)"  | 
|
| 3071 | 138  | 
|
139  | 
||
| 17233 | 140  | 
invariant_def: "invariant A P == (!s. reachable A s --> P(s))"  | 
| 3071 | 141  | 
|
142  | 
||
143  | 
(* ------------------------- parallel composition --------------------------*)  | 
|
144  | 
||
145  | 
||
| 17233 | 146  | 
compatible_def:  | 
147  | 
"compatible A B ==  | 
|
148  | 
  (((out A Int out B) = {}) &
 | 
|
149  | 
   ((int A Int act B) = {}) &
 | 
|
| 
3433
 
2de17c994071
added deadlock freedom, polished definitions and proofs
 
mueller 
parents: 
3275 
diff
changeset
 | 
150  | 
   ((int B Int act A) = {}))"
 | 
| 3071 | 151  | 
|
| 17233 | 152  | 
asig_comp_def:  | 
153  | 
"asig_comp a1 a2 ==  | 
|
154  | 
(((inputs(a1) Un inputs(a2)) - (outputs(a1) Un outputs(a2)),  | 
|
155  | 
(outputs(a1) Un outputs(a2)),  | 
|
| 3071 | 156  | 
(internals(a1) Un internals(a2))))"  | 
157  | 
||
| 17233 | 158  | 
par_def:  | 
159  | 
"(A || B) ==  | 
|
160  | 
(asig_comp (asig_of A) (asig_of B),  | 
|
161  | 
       {pr. fst(pr):starts_of(A) & snd(pr):starts_of(B)},
 | 
|
162  | 
       {tr. let s = fst(tr); a = fst(snd(tr)); t = snd(snd(tr))
 | 
|
163  | 
in (a:act A | a:act B) &  | 
|
164  | 
(if a:act A then  | 
|
165  | 
(fst(s),a,fst(t)):trans_of(A)  | 
|
166  | 
else fst(t) = fst(s))  | 
|
167  | 
&  | 
|
168  | 
(if a:act B then  | 
|
169  | 
(snd(s),a,snd(t)):trans_of(B)  | 
|
| 3521 | 170  | 
else snd(t) = snd(s))},  | 
171  | 
wfair_of A Un wfair_of B,  | 
|
172  | 
sfair_of A Un sfair_of B)"  | 
|
173  | 
||
| 3071 | 174  | 
|
175  | 
(* ------------------------ hiding -------------------------------------------- *)  | 
|
176  | 
||
| 17233 | 177  | 
restrict_asig_def:  | 
178  | 
"restrict_asig asig actns ==  | 
|
179  | 
(inputs(asig) Int actns,  | 
|
180  | 
outputs(asig) Int actns,  | 
|
| 3071 | 181  | 
internals(asig) Un (externals(asig) - actns))"  | 
182  | 
||
| 17233 | 183  | 
(* Notice that for wfair_of and sfair_of nothing has to be changed, as  | 
184  | 
changes from the outputs to the internals does not touch the locals as  | 
|
| 3521 | 185  | 
a whole, which is of importance for fairness only *)  | 
| 3071 | 186  | 
|
| 17233 | 187  | 
restrict_def:  | 
188  | 
"restrict A actns ==  | 
|
189  | 
(restrict_asig (asig_of A) actns,  | 
|
190  | 
starts_of A,  | 
|
| 3521 | 191  | 
trans_of A,  | 
192  | 
wfair_of A,  | 
|
193  | 
sfair_of A)"  | 
|
194  | 
||
| 17233 | 195  | 
hide_asig_def:  | 
196  | 
"hide_asig asig actns ==  | 
|
197  | 
(inputs(asig) - actns,  | 
|
198  | 
outputs(asig) - actns,  | 
|
| 3521 | 199  | 
internals(asig) Un actns)"  | 
200  | 
||
| 17233 | 201  | 
hide_def:  | 
202  | 
"hide A actns ==  | 
|
203  | 
(hide_asig (asig_of A) actns,  | 
|
204  | 
starts_of A,  | 
|
| 3521 | 205  | 
trans_of A,  | 
206  | 
wfair_of A,  | 
|
207  | 
sfair_of A)"  | 
|
| 3071 | 208  | 
|
209  | 
(* ------------------------- renaming ------------------------------------------- *)  | 
|
| 17233 | 210  | 
|
211  | 
rename_set_def:  | 
|
212  | 
  "rename_set A ren == {b. ? x. Some x = ren b & x : A}"
 | 
|
| 3521 | 213  | 
|
| 17233 | 214  | 
rename_def:  | 
215  | 
"rename ioa ren ==  | 
|
216  | 
((rename_set (inp ioa) ren,  | 
|
217  | 
rename_set (out ioa) ren,  | 
|
218  | 
rename_set (int ioa) ren),  | 
|
219  | 
starts_of ioa,  | 
|
220  | 
   {tr. let s = fst(tr); a = fst(snd(tr));  t = snd(snd(tr))
 | 
|
221  | 
in  | 
|
| 3521 | 222  | 
? x. Some(x) = ren(a) & (s,x,t):trans_of ioa},  | 
223  | 
   {rename_set s ren | s. s: wfair_of ioa},
 | 
|
224  | 
   {rename_set s ren | s. s: sfair_of ioa})"
 | 
|
| 3071 | 225  | 
|
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
226  | 
(* ------------------------- fairness ----------------------------- *)  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
227  | 
|
| 17233 | 228  | 
fairIOA_def:  | 
229  | 
"fairIOA A == (! S : wfair_of A. S<= local A) &  | 
|
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
230  | 
(! S : sfair_of A. S<= local A)"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
231  | 
|
| 17233 | 232  | 
input_resistant_def:  | 
233  | 
"input_resistant A == ! W : sfair_of A. ! s a t.  | 
|
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
234  | 
reachable A s & reachable A t & a:inp A &  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
235  | 
Enabled A W s & s -a--A-> t  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
236  | 
--> Enabled A W t"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
237  | 
|
| 17233 | 238  | 
enabled_def:  | 
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
239  | 
"enabled A a s == ? t. s-a--A-> t"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
240  | 
|
| 17233 | 241  | 
Enabled_def:  | 
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
242  | 
"Enabled A W s == ? w:W. enabled A w s"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
243  | 
|
| 17233 | 244  | 
en_persistent_def:  | 
245  | 
"en_persistent A W == ! s a t. Enabled A W s &  | 
|
246  | 
a ~:W &  | 
|
247  | 
s -a--A-> t  | 
|
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
248  | 
--> Enabled A W t"  | 
| 17233 | 249  | 
was_enabled_def:  | 
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
250  | 
"was_enabled A a t == ? s. s-a--A-> t"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
251  | 
|
| 17233 | 252  | 
set_was_enabled_def:  | 
| 
4559
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
253  | 
"set_was_enabled A W t == ? w:W. was_enabled A w t"  | 
| 
 
8e604d885b54
added files containing temproal logic and abstraction;
 
mueller 
parents: 
3521 
diff
changeset
 | 
254  | 
|
| 17233 | 255  | 
ML {* use_legacy_bindings (the_context ()) *}
 | 
| 3071 | 256  | 
|
257  | 
end  |