forked from diffblue/cbmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminiBDD.cpp
95 lines (67 loc) · 1.6 KB
/
miniBDD.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*******************************************************************\
Module: A minimalistic BDD library, following Bryant's original paper
and Andersen's lecture notes
Author: Daniel Kroening, kroening@kroening.com
\*******************************************************************/
#include <iostream>
#include <solvers/miniBDD/miniBDD.h>
using namespace miniBDD;
void test1()
{
mgr mgr;
BDD x=mgr.Var("x");
BDD y=mgr.Var("y");
BDD z=mgr.Var("z");
BDD f=(x&y&z)|(!x&!y&z);
y.clear();
x.clear();
z.clear();
//mgr.DumpDot(std::cout);
mgr.DumpTikZ(std::cout);
}
void test2()
{
mgr mgr;
BDD a=mgr.Var("a");
BDD b=mgr.Var("b");
BDD c=mgr.Var("c");
BDD d=mgr.Var("d");
BDD final=(a == b) & (c == d);
a.clear();
b.clear();
c.clear();
d.clear();
mgr.DumpTikZ(std::cout, true);
}
void test3()
{
mgr mgr;
BDD final=mgr.Var("x") & mgr.Var("y");
mgr.DumpDot(std::cout);
//mgr.DumpTikZ(std::cout);
//mgr.DumpTable(std::cout);
}
#include <langapi/language_util.h>
#include <langapi/mode.h>
#include <ansi-c/ansi_c_language.h>
#include <util/std_expr.h>
#include <util/symbol_table.h>
#include <util/namespace.h>
#include <solvers/prop/bdd_expr.h>
void test4()
{
register_language(new_ansi_c_language);
symbol_exprt a("a", bool_typet());
symbol_exprt b("b", bool_typet());
or_exprt o(and_exprt(a, b), not_exprt(a));
symbol_tablet symbol_table;
namespacet ns(symbol_table);
std::cout << from_expr(ns, "", o) << std::endl;
bdd_exprt t(ns);
t.from_expr(o);
std::cout << from_expr(ns, "", t.as_expr()) << std::endl;
}
int main()
{
test3();
}