Skip to content

Commit a68d19c

Browse files
committed
--show-formula splits up disjunctions into separate lines
This improves readability when viewing large disjunctions.
1 parent eab9d87 commit a68d19c

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
CORE
2+
show-formula1.smv
3+
--bound 2 --show-formula
4+
^\(1\) smv::main::var::x@0 = 1$
5+
^\(2\) smv::main::var::x@1 = 0$
6+
^\(3\) smv::main::var::x@2 = 0$
7+
^\(4\) smv::main::var::x@3 = 0$
8+
^\(5\) ¬\(smv::main::var::x@0 = 1\)$
9+
^ ∨ ¬\(smv::main::var::x@1 = 1\)$
10+
^ ∨ ¬\(smv::main::var::x@2 = 1\)$
11+
^EXIT=0$
12+
^SIGNAL=0$
13+
--
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
MODULE main
2+
3+
VAR x:0..1;
4+
5+
ASSIGN
6+
init(x) := 1;
7+
next(x) := 0;
8+
9+
SPEC AG x=1

src/ebmc/show_formula_solver.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,37 @@ show_formula_solvert::show_formula_solvert()
2222

2323
void show_formula_solvert::set_to(const exprt &expr, bool value)
2424
{
25+
std::string number_str = '(' + std::to_string(++conjunct_counter) + ')';
26+
2527
if(console)
2628
out << consolet::faint;
2729

28-
out << '(' << (++conjunct_counter) << ") ";
30+
out << number_str << ' ';
2931

3032
if(console)
3133
out << consolet::reset;
3234

3335
if(value)
34-
out << format(expr) << '\n';
36+
{
37+
// split up disjunctions into multiple lines for better readability
38+
if(expr.id() == ID_or)
39+
{
40+
bool first = true;
41+
for(auto &op : expr.operands())
42+
{
43+
if(first)
44+
first = false;
45+
else
46+
out << std::string(number_str.size() - 1, ' ') << "\u2228 ";
47+
48+
out << format(op) << '\n';
49+
}
50+
}
51+
else
52+
{
53+
out << format(expr) << '\n';
54+
}
55+
}
3556
else
3657
out << format(not_exprt(expr)) << '\n';
3758
}

0 commit comments

Comments
 (0)