@@ -116,6 +116,20 @@ impl NetworkColoredSpaces {
116
116
pub fn to_colored_vertices ( & self , ctx : & SymbolicSpaceContext ) -> GraphColoredVertices {
117
117
GraphColoredVertices :: new ( ctx. spaces_to_vertices ( self . as_bdd ( ) ) , ctx. inner_context ( ) )
118
118
}
119
+
120
+ /// Produce a set of spaces that is a superset of this set, and in addition contains
121
+ /// all spaces that are a super-space of *some* item in this set.
122
+ pub fn with_all_super_spaces ( & self , ctx : & SymbolicSpaceContext ) -> NetworkColoredSpaces {
123
+ let super_bdd = ctx. mk_super_spaces ( self . as_bdd ( ) ) ;
124
+ self . copy ( super_bdd)
125
+ }
126
+
127
+ /// Produce a set of spaces that is a superset of this set, and in addition contains
128
+ /// all spaces that are a subspace of *some* item in this set.
129
+ pub fn with_all_sub_spaces ( & self , ctx : & SymbolicSpaceContext ) -> NetworkColoredSpaces {
130
+ let sub_bdd = ctx. mk_sub_spaces ( self . as_bdd ( ) ) ;
131
+ self . copy ( sub_bdd)
132
+ }
119
133
}
120
134
121
135
/// Relation operations.
@@ -213,8 +227,8 @@ impl BddSet for NetworkColoredSpaces {
213
227
mod tests {
214
228
use crate :: biodivine_std:: traits:: Set ;
215
229
use crate :: symbolic_async_graph:: SymbolicAsyncGraph ;
216
- use crate :: trap_spaces:: SymbolicSpaceContext ;
217
- use crate :: BooleanNetwork ;
230
+ use crate :: trap_spaces:: { NetworkColoredSpaces , SymbolicSpaceContext } ;
231
+ use crate :: { BooleanNetwork , ExtendedBoolean , Space } ;
218
232
use num_bigint:: BigInt ;
219
233
use num_traits:: One ;
220
234
@@ -236,12 +250,40 @@ mod tests {
236
250
assert ! ( singleton_color. is_singleton( ) ) ;
237
251
assert ! ( singleton_space. is_singleton( ) ) ;
238
252
assert ! ( !unit. intersect_colors( & singleton_color) . is_singleton( ) ) ;
239
- // There is only one color, hence this holds. Otherwise this should not hold.
253
+ // There is only one color, hence this holds. Otherwise, this should not hold.
240
254
assert ! ( unit. intersect_spaces( & singleton_space) . is_singleton( ) ) ;
241
255
assert ! ( unit. minus_colors( & singleton_color) . is_empty( ) ) ;
242
256
assert ! ( unit. minus_spaces( & singleton_space) . is_subset( & unit) ) ;
243
257
244
- // There are 28 network variables and we are eliminating 22 of them, so 6 should be left.
258
+ let mut space = Space :: new ( & bn) ;
259
+ for var in bn. variables ( ) {
260
+ space[ var] = ExtendedBoolean :: Zero ;
261
+ }
262
+
263
+ let all_zero = NetworkColoredSpaces :: new ( ctx. mk_space ( & space) , & ctx)
264
+ . intersect_colors ( stg. unit_colors ( ) ) ;
265
+
266
+ // 2^28, i.e. the number of variables, since each variable can
267
+ // be either fixed to zero or free.
268
+ let unit_colors = stg. unit_colors ( ) ;
269
+ assert_eq ! (
270
+ unit_colors. approx_cardinality( ) ,
271
+ all_zero. with_all_sub_spaces( & ctx) . approx_cardinality( )
272
+ ) ;
273
+ assert_eq ! (
274
+ 268435456.0 * unit_colors. approx_cardinality( ) ,
275
+ all_zero. with_all_super_spaces( & ctx) . approx_cardinality( )
276
+ ) ;
277
+
278
+ // Adding all super-spaces will always add *^n, which has all spaces as sub-spaces.
279
+ assert_eq ! (
280
+ ctx. mk_unit_colored_spaces( & stg) ,
281
+ all_zero
282
+ . with_all_super_spaces( & ctx)
283
+ . with_all_sub_spaces( & ctx)
284
+ ) ;
285
+
286
+ // There are 28 network variables, and we are eliminating 22 of them, so 6 should be left.
245
287
let dual_vars = ctx. inner_context ( ) . all_extra_state_variables ( ) ;
246
288
let project = unit. raw_projection ( & dual_vars[ 0 ..44 ] ) ;
247
289
assert_eq ! ( project. iter( ) . count( ) , 3_usize . pow( 6 ) ) ;
0 commit comments