@@ -43,18 +43,16 @@ literalt prop_conv_solvert::get_literal(const irep_idt &identifier)
43
43
}
44
44
45
45
// / get a boolean value from counter example if not valid
46
- bool prop_conv_solvert::get_bool (const exprt &expr, tvt &value ) const
46
+ bool prop_conv_solvert::get_bool (const exprt &expr) const
47
47
{
48
48
// trivial cases
49
49
50
50
if (expr.is_true ())
51
51
{
52
- value = tvt (true );
53
- return false ;
52
+ return true ;
54
53
}
55
54
else if (expr.is_false ())
56
55
{
57
- value = tvt (false );
58
56
return false ;
59
57
}
60
58
else if (expr.id () == ID_symbol)
@@ -63,10 +61,9 @@ bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const
63
61
symbols.find (to_symbol_expr (expr).get_identifier ());
64
62
65
63
if (result == symbols.end ())
66
- return true ;
64
+ return false ; // default value
67
65
68
- value = prop.l_get (result->second );
69
- return false ;
66
+ return prop.l_get (result->second ).is_true ();
70
67
}
71
68
72
69
// sub-expressions
@@ -75,58 +72,40 @@ bool prop_conv_solvert::get_bool(const exprt &expr, tvt &value) const
75
72
{
76
73
if (expr.type ().id () == ID_bool && expr.operands ().size () == 1 )
77
74
{
78
- if (get_bool (expr.op0 (), value))
79
- return true ;
80
- value = !value;
81
- return false ;
75
+ return get_bool (expr.op0 ());
82
76
}
83
77
}
84
78
else if (expr.id () == ID_and || expr.id () == ID_or)
85
79
{
86
80
if (expr.type ().id () == ID_bool && expr.operands ().size () >= 1 )
87
81
{
88
- value = tvt (expr.id () == ID_and);
89
-
90
82
forall_operands (it, expr)
91
83
{
92
- tvt tmp;
93
- if (get_bool (*it, tmp))
94
- return true ;
84
+ auto tmp = get_bool (*it);
95
85
96
86
if (expr.id () == ID_and)
97
87
{
98
- if (tmp.is_false ())
99
- {
100
- value = tvt (false );
88
+ if (tmp == false )
101
89
return false ;
102
- }
103
-
104
- value = value && tmp;
105
90
}
106
91
else // or
107
92
{
108
- if (tmp.is_true ())
109
- {
110
- value = tvt (true );
111
- return false ;
112
- }
113
-
114
- value = value || tmp;
93
+ if (tmp == true )
94
+ return true ;
115
95
}
116
96
}
117
97
118
- return false ;
98
+ return expr. id () == ID_and ;
119
99
}
120
100
}
121
101
122
102
// check cache
123
103
124
104
cachet::const_iterator cache_result = cache.find (expr);
125
105
if (cache_result == cache.end ())
126
- return true ;
127
-
128
- value = prop.l_get (cache_result->second );
129
- return false ;
106
+ return false ; // default value
107
+ else
108
+ return prop.l_get (cache_result->second ).is_true ();
130
109
}
131
110
132
111
literalt prop_conv_solvert::convert (const exprt &expr)
@@ -459,28 +438,12 @@ decision_proceduret::resultt prop_conv_solvert::dec_solve()
459
438
460
439
exprt prop_conv_solvert::get (const exprt &expr) const
461
440
{
462
- tvt value;
463
-
464
- if (expr.type ().id () == ID_bool && !get_bool (expr, value))
465
- {
466
- switch (value.get_value ())
467
- {
468
- case tvt::tv_enumt::TV_TRUE:
469
- return true_exprt ();
470
- case tvt::tv_enumt::TV_FALSE:
471
- return false_exprt ();
472
- case tvt::tv_enumt::TV_UNKNOWN:
473
- return false_exprt (); // default
474
- }
475
- }
441
+ PRECONDITION (expr.type ().id () == ID_bool);
476
442
477
- exprt tmp = expr;
478
- for (auto &op : tmp.operands ())
479
- {
480
- exprt tmp_op = get (op);
481
- op.swap (tmp_op);
482
- }
483
- return tmp;
443
+ if (get_bool (expr))
444
+ return true_exprt ();
445
+ else
446
+ return false_exprt ();
484
447
}
485
448
486
449
void prop_conv_solvert::print_assignment (std::ostream &out) const
0 commit comments