47 mergeAsk :: "nat merge" |
47 mergeAsk :: "nat merge" |
48 distr :: "nat distr" |
48 distr :: "nat distr" |
49 dummy :: 'a (*dummy field for new variables*) |
49 dummy :: 'a (*dummy field for new variables*) |
50 |
50 |
51 |
51 |
52 constdefs |
|
53 |
|
54 (** Merge specification (the number of inputs is Nclients) ***) |
52 (** Merge specification (the number of inputs is Nclients) ***) |
55 |
53 |
|
54 definition |
56 (*spec (10)*) |
55 (*spec (10)*) |
57 merge_increasing :: "('a,'b) merge_d program set" |
56 merge_increasing :: "('a,'b) merge_d program set" |
58 "merge_increasing == |
57 where "merge_increasing = |
59 UNIV guarantees (Increasing merge.Out) Int (Increasing merge.iOut)" |
58 UNIV guarantees (Increasing merge.Out) Int (Increasing merge.iOut)" |
60 |
59 |
|
60 definition |
61 (*spec (11)*) |
61 (*spec (11)*) |
62 merge_eqOut :: "('a,'b) merge_d program set" |
62 merge_eqOut :: "('a,'b) merge_d program set" |
63 "merge_eqOut == |
63 where "merge_eqOut = |
64 UNIV guarantees |
64 UNIV guarantees |
65 Always {s. length (merge.Out s) = length (merge.iOut s)}" |
65 Always {s. length (merge.Out s) = length (merge.iOut s)}" |
66 |
66 |
|
67 definition |
67 (*spec (12)*) |
68 (*spec (12)*) |
68 merge_bounded :: "('a,'b) merge_d program set" |
69 merge_bounded :: "('a,'b) merge_d program set" |
69 "merge_bounded == |
70 where "merge_bounded = |
70 UNIV guarantees |
71 UNIV guarantees |
71 Always {s. \<forall>elt \<in> set (merge.iOut s). elt < Nclients}" |
72 Always {s. \<forall>elt \<in> set (merge.iOut s). elt < Nclients}" |
72 |
73 |
|
74 definition |
73 (*spec (13)*) |
75 (*spec (13)*) |
74 merge_follows :: "('a,'b) merge_d program set" |
76 merge_follows :: "('a,'b) merge_d program set" |
75 "merge_follows == |
77 where "merge_follows = |
76 (\<Inter>i \<in> lessThan Nclients. Increasing (sub i o merge.In)) |
78 (\<Inter>i \<in> lessThan Nclients. Increasing (sub i o merge.In)) |
77 guarantees |
79 guarantees |
78 (\<Inter>i \<in> lessThan Nclients. |
80 (\<Inter>i \<in> lessThan Nclients. |
79 (%s. sublist (merge.Out s) |
81 (%s. sublist (merge.Out s) |
80 {k. k < size(merge.iOut s) & merge.iOut s! k = i}) |
82 {k. k < size(merge.iOut s) & merge.iOut s! k = i}) |
81 Fols (sub i o merge.In))" |
83 Fols (sub i o merge.In))" |
82 |
84 |
|
85 definition |
83 (*spec: preserves part*) |
86 (*spec: preserves part*) |
84 merge_preserves :: "('a,'b) merge_d program set" |
87 merge_preserves :: "('a,'b) merge_d program set" |
85 "merge_preserves == preserves merge.In Int preserves merge_d.dummy" |
88 where "merge_preserves = preserves merge.In Int preserves merge_d.dummy" |
86 |
89 |
|
90 definition |
87 (*environmental constraints*) |
91 (*environmental constraints*) |
88 merge_allowed_acts :: "('a,'b) merge_d program set" |
92 merge_allowed_acts :: "('a,'b) merge_d program set" |
89 "merge_allowed_acts == |
93 where "merge_allowed_acts = |
90 {F. AllowedActs F = |
94 {F. AllowedActs F = |
91 insert Id (UNION (preserves (funPair merge.Out merge.iOut)) Acts)}" |
95 insert Id (UNION (preserves (funPair merge.Out merge.iOut)) Acts)}" |
92 |
96 |
|
97 definition |
93 merge_spec :: "('a,'b) merge_d program set" |
98 merge_spec :: "('a,'b) merge_d program set" |
94 "merge_spec == merge_increasing Int merge_eqOut Int merge_bounded Int |
99 where "merge_spec = merge_increasing Int merge_eqOut Int merge_bounded Int |
95 merge_follows Int merge_allowed_acts Int merge_preserves" |
100 merge_follows Int merge_allowed_acts Int merge_preserves" |
96 |
101 |
97 (** Distributor specification (the number of outputs is Nclients) ***) |
102 (** Distributor specification (the number of outputs is Nclients) ***) |
98 |
103 |
|
104 definition |
99 (*spec (14)*) |
105 (*spec (14)*) |
100 distr_follows :: "('a,'b) distr_d program set" |
106 distr_follows :: "('a,'b) distr_d program set" |
101 "distr_follows == |
107 where "distr_follows = |
102 Increasing distr.In Int Increasing distr.iIn Int |
108 Increasing distr.In Int Increasing distr.iIn Int |
103 Always {s. \<forall>elt \<in> set (distr.iIn s). elt < Nclients} |
109 Always {s. \<forall>elt \<in> set (distr.iIn s). elt < Nclients} |
104 guarantees |
110 guarantees |
105 (\<Inter>i \<in> lessThan Nclients. |
111 (\<Inter>i \<in> lessThan Nclients. |
106 (sub i o distr.Out) Fols |
112 (sub i o distr.Out) Fols |
107 (%s. sublist (distr.In s) |
113 (%s. sublist (distr.In s) |
108 {k. k < size(distr.iIn s) & distr.iIn s ! k = i}))" |
114 {k. k < size(distr.iIn s) & distr.iIn s ! k = i}))" |
109 |
115 |
|
116 definition |
110 distr_allowed_acts :: "('a,'b) distr_d program set" |
117 distr_allowed_acts :: "('a,'b) distr_d program set" |
111 "distr_allowed_acts == |
118 where "distr_allowed_acts = |
112 {D. AllowedActs D = insert Id (UNION (preserves distr.Out) Acts)}" |
119 {D. AllowedActs D = insert Id (UNION (preserves distr.Out) Acts)}" |
113 |
120 |
|
121 definition |
114 distr_spec :: "('a,'b) distr_d program set" |
122 distr_spec :: "('a,'b) distr_d program set" |
115 "distr_spec == distr_follows Int distr_allowed_acts" |
123 where "distr_spec = distr_follows Int distr_allowed_acts" |
116 |
124 |
117 (** Single-client allocator specification (required) ***) |
125 (** Single-client allocator specification (required) ***) |
118 |
126 |
|
127 definition |
119 (*spec (18)*) |
128 (*spec (18)*) |
120 alloc_increasing :: "'a allocState_d program set" |
129 alloc_increasing :: "'a allocState_d program set" |
121 "alloc_increasing == UNIV guarantees Increasing giv" |
130 where "alloc_increasing = UNIV guarantees Increasing giv" |
122 |
131 |
|
132 definition |
123 (*spec (19)*) |
133 (*spec (19)*) |
124 alloc_safety :: "'a allocState_d program set" |
134 alloc_safety :: "'a allocState_d program set" |
125 "alloc_safety == |
135 where "alloc_safety = |
126 Increasing rel |
136 Increasing rel |
127 guarantees Always {s. tokens (giv s) \<le> NbT + tokens (rel s)}" |
137 guarantees Always {s. tokens (giv s) \<le> NbT + tokens (rel s)}" |
128 |
138 |
|
139 definition |
129 (*spec (20)*) |
140 (*spec (20)*) |
130 alloc_progress :: "'a allocState_d program set" |
141 alloc_progress :: "'a allocState_d program set" |
131 "alloc_progress == |
142 where "alloc_progress = |
132 Increasing ask Int Increasing rel Int |
143 Increasing ask Int Increasing rel Int |
133 Always {s. \<forall>elt \<in> set (ask s). elt \<le> NbT} |
144 Always {s. \<forall>elt \<in> set (ask s). elt \<le> NbT} |
134 Int |
145 Int |
135 (\<Inter>h. {s. h \<le> giv s & h pfixGe (ask s)} |
146 (\<Inter>h. {s. h \<le> giv s & h pfixGe (ask s)} |
136 LeadsTo |
147 LeadsTo |
137 {s. tokens h \<le> tokens (rel s)}) |
148 {s. tokens h \<le> tokens (rel s)}) |
138 guarantees (\<Inter>h. {s. h \<le> ask s} LeadsTo {s. h pfixLe giv s})" |
149 guarantees (\<Inter>h. {s. h \<le> ask s} LeadsTo {s. h pfixLe giv s})" |
139 |
150 |
|
151 definition |
140 (*spec: preserves part*) |
152 (*spec: preserves part*) |
141 alloc_preserves :: "'a allocState_d program set" |
153 alloc_preserves :: "'a allocState_d program set" |
142 "alloc_preserves == preserves rel Int |
154 where "alloc_preserves = preserves rel Int |
143 preserves ask Int |
155 preserves ask Int |
144 preserves allocState_d.dummy" |
156 preserves allocState_d.dummy" |
145 |
157 |
146 |
158 |
|
159 definition |
147 (*environmental constraints*) |
160 (*environmental constraints*) |
148 alloc_allowed_acts :: "'a allocState_d program set" |
161 alloc_allowed_acts :: "'a allocState_d program set" |
149 "alloc_allowed_acts == |
162 where "alloc_allowed_acts = |
150 {F. AllowedActs F = insert Id (UNION (preserves giv) Acts)}" |
163 {F. AllowedActs F = insert Id (UNION (preserves giv) Acts)}" |
151 |
164 |
|
165 definition |
152 alloc_spec :: "'a allocState_d program set" |
166 alloc_spec :: "'a allocState_d program set" |
153 "alloc_spec == alloc_increasing Int alloc_safety Int alloc_progress Int |
167 where "alloc_spec = alloc_increasing Int alloc_safety Int alloc_progress Int |
154 alloc_allowed_acts Int alloc_preserves" |
168 alloc_allowed_acts Int alloc_preserves" |
155 |
169 |
156 locale Merge = |
170 locale Merge = |
157 fixes M :: "('a,'b::order) merge_d program" |
171 fixes M :: "('a,'b::order) merge_d program" |
158 assumes |
172 assumes |