|
13 | 13 |
|
14 | 14 | #include <solvers/miniBDD/miniBDD.h>
|
15 | 15 | #include <solvers/flattening/boolbv.h>
|
| 16 | +#include <solvers/prop/bdd_expr.h> |
16 | 17 |
|
17 |
| -#include <util/symbol_table.h> |
18 | 18 | #include <util/arith_tools.h>
|
19 | 19 | #include <util/expanding_vector.h>
|
| 20 | +#include <util/format_expr.h> |
| 21 | +#include <util/symbol_table.h> |
20 | 22 |
|
21 | 23 | class bdd_propt:public propt
|
22 | 24 | {
|
@@ -291,4 +293,65 @@ SCENARIO("miniBDD", "[core][solver][miniBDD]")
|
291 | 293 |
|
292 | 294 | REQUIRE(!result.is_constant());
|
293 | 295 | }
|
| 296 | + |
| 297 | + GIVEN("A bdd for x&y") |
| 298 | + { |
| 299 | + mini_bdd_mgrt mgr; |
| 300 | + |
| 301 | + mini_bddt final_bdd = mgr.Var("x") & mgr.Var("y"); |
| 302 | + |
| 303 | + std::ostringstream oss; |
| 304 | + mgr.DumpDot(oss); |
| 305 | + |
| 306 | + const std::string dot_string = |
| 307 | + "digraph BDD {\n" |
| 308 | + "center = true;\n" |
| 309 | + "{ rank = same; { node [style=invis]; \"T\" };\n" |
| 310 | + " { node [shape=box,fontsize=24]; \"0\"; }\n" |
| 311 | + " { node [shape=box,fontsize=24]; \"1\"; }\n" |
| 312 | + "}\n" |
| 313 | + "\n" |
| 314 | + "{ rank=same; { node [shape=plaintext,fontname=" |
| 315 | + "\"Times Italic\",fontsize=24] \" y \" }; \"4\"; }\n" |
| 316 | + "{ rank=same; { node [shape=plaintext,fontname=" |
| 317 | + "\"Times Italic\",fontsize=24] \" x \" }; \"3\"; }\n" |
| 318 | + "\n" |
| 319 | + "{ edge [style = invis]; \" y \" -> \" x \" -> \"T\"; }\n" |
| 320 | + "\n" |
| 321 | + "\"3\" -> \"1\" [style=solid,arrowsize=\".75\"];\n" |
| 322 | + "\"3\" -> \"0\" [style=dashed,arrowsize=\".75\"];\n" |
| 323 | + "\n" |
| 324 | + "\"4\" -> \"3\" [style=solid,arrowsize=\".75\"];\n" |
| 325 | + "\"4\" -> \"0\" [style=dashed,arrowsize=\".75\"];\n" |
| 326 | + "\n" |
| 327 | + "}\n"; |
| 328 | + |
| 329 | + REQUIRE(oss.str() == dot_string); |
| 330 | + } |
| 331 | + |
| 332 | + GIVEN("A bdd for (a&b)|!a") |
| 333 | + { |
| 334 | + symbol_exprt a("a", bool_typet()); |
| 335 | + symbol_exprt b("b", bool_typet()); |
| 336 | + |
| 337 | + or_exprt o(and_exprt(a, b), not_exprt(a)); |
| 338 | + |
| 339 | + symbol_tablet symbol_table; |
| 340 | + namespacet ns(symbol_table); |
| 341 | + |
| 342 | + { |
| 343 | + std::ostringstream oss; |
| 344 | + oss << format(o); |
| 345 | + REQUIRE(oss.str() == "(a ∧ b) ∨ (¬a)"); |
| 346 | + } |
| 347 | + |
| 348 | + bdd_exprt t(ns); |
| 349 | + t.from_expr(o); |
| 350 | + |
| 351 | + { |
| 352 | + std::ostringstream oss; |
| 353 | + oss << format(t.as_expr()); |
| 354 | + REQUIRE(oss.str() == "(¬a) ∨ b"); |
| 355 | + } |
| 356 | + } |
294 | 357 | }
|
0 commit comments