3807
|
1 |
(*
|
|
2 |
File: Buffer.thy
|
17309
|
3 |
ID: $Id$
|
3807
|
4 |
Author: Stephan Merz
|
|
5 |
Copyright: 1997 University of Munich
|
|
6 |
*)
|
|
7 |
|
17309
|
8 |
header {* A simple FIFO buffer (synchronous communication, interleaving) *}
|
|
9 |
|
|
10 |
theory Buffer
|
|
11 |
imports TLA
|
|
12 |
begin
|
3807
|
13 |
|
|
14 |
consts
|
|
15 |
(* actions *)
|
6255
|
16 |
BInit :: "'a stfun => 'a list stfun => 'a stfun => stpred"
|
3807
|
17 |
Enq :: "'a stfun => 'a list stfun => 'a stfun => action"
|
|
18 |
Deq :: "'a stfun => 'a list stfun => 'a stfun => action"
|
|
19 |
Next :: "'a stfun => 'a list stfun => 'a stfun => action"
|
|
20 |
|
|
21 |
(* temporal formulas *)
|
|
22 |
IBuffer :: "'a stfun => 'a list stfun => 'a stfun => temporal"
|
|
23 |
Buffer :: "'a stfun => 'a stfun => temporal"
|
|
24 |
|
17309
|
25 |
defs
|
|
26 |
BInit_def: "BInit ic q oc == PRED q = #[]"
|
|
27 |
Enq_def: "Enq ic q oc == ACT (ic$ ~= $ic)
|
|
28 |
& (q$ = $q @ [ ic$ ])
|
6255
|
29 |
& (oc$ = $oc)"
|
17309
|
30 |
Deq_def: "Deq ic q oc == ACT ($q ~= #[])
|
6255
|
31 |
& (oc$ = hd< $q >)
|
|
32 |
& (q$ = tl< $q >)
|
|
33 |
& (ic$ = $ic)"
|
17309
|
34 |
Next_def: "Next ic q oc == ACT (Enq ic q oc | Deq ic q oc)"
|
|
35 |
IBuffer_def: "IBuffer ic q oc == TEMP Init (BInit ic q oc)
|
6255
|
36 |
& [][Next ic q oc]_(ic,q,oc)
|
|
37 |
& WF(Deq ic q oc)_(ic,q,oc)"
|
17309
|
38 |
Buffer_def: "Buffer ic oc == TEMP (EEX q. IBuffer ic q oc)"
|
3807
|
39 |
|
21624
|
40 |
|
|
41 |
(* ---------------------------- Data lemmas ---------------------------- *)
|
|
42 |
|
|
43 |
(*FIXME: move to theory List? Maybe as (tl xs = xs) = (xs = [])"?*)
|
|
44 |
lemma tl_not_self [simp]: "xs ~= [] ==> tl xs ~= xs"
|
|
45 |
by (auto simp: neq_Nil_conv)
|
|
46 |
|
|
47 |
|
|
48 |
(* ---------------------------- Action lemmas ---------------------------- *)
|
|
49 |
|
|
50 |
(* Dequeue is visible *)
|
|
51 |
lemma Deq_visible: "|- <Deq ic q oc>_(ic,q,oc) = Deq ic q oc"
|
|
52 |
apply (unfold angle_def Deq_def)
|
|
53 |
apply (safe, simp (asm_lr))+
|
|
54 |
done
|
|
55 |
|
|
56 |
(* Enabling condition for dequeue -- NOT NEEDED *)
|
|
57 |
lemma Deq_enabled:
|
|
58 |
"!!q. basevars (ic,q,oc) ==> |- Enabled (<Deq ic q oc>_(ic,q,oc)) = (q ~= #[])"
|
|
59 |
apply (unfold Deq_visible [temp_rewrite])
|
|
60 |
apply (force elim!: base_enabled [temp_use] enabledE [temp_use] simp: Deq_def)
|
|
61 |
done
|
|
62 |
|
|
63 |
(* For the left-to-right implication, we don't need the base variable stuff *)
|
|
64 |
lemma Deq_enabledE:
|
|
65 |
"|- Enabled (<Deq ic q oc>_(ic,q,oc)) --> (q ~= #[])"
|
|
66 |
apply (unfold Deq_visible [temp_rewrite])
|
|
67 |
apply (auto elim!: enabledE simp add: Deq_def)
|
|
68 |
done
|
3807
|
69 |
|
17309
|
70 |
end
|