Skip to content

Commit 01cb066

Browse files
committed
BMC now checks for use of lasso symbol
Instead of examining the property, the BMC engine now looks for the use of a lasso symbol in the property encoding. This prevents a mismatch between the two methods.
1 parent c588d24 commit 01cb066

File tree

6 files changed

+41
-43
lines changed

6 files changed

+41
-43
lines changed

src/ebmc/bmc.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, dkr@amazon.com
99
#include "bmc.h"
1010

1111
#include <solvers/prop/literal_expr.h>
12+
#include <trans-word-level/lasso.h>
1213
#include <trans-word-level/trans_trace_word_level.h>
1314
#include <trans-word-level/unwind.h>
1415

@@ -218,6 +219,8 @@ property_checker_resultt bmc(
218219
// convert the properties
219220
message.status() << "Properties" << messaget::eom;
220221

222+
bool requires_lasso_constraints = false;
223+
221224
for(auto &property : properties.properties)
222225
{
223226
if(property.is_disabled() || property.is_failure())
@@ -233,13 +236,16 @@ property_checker_resultt bmc(
233236
property.timeframe_handles = ::property(
234237
property.normalized_expr, message_handler, solver, bound + 1, ns);
235238

239+
if(uses_lasso_symbol(property.timeframe_handles))
240+
requires_lasso_constraints = true;
241+
236242
// If it's an assumption, then add it as constraint.
237243
if(property.is_assumed())
238244
solver.set_to_true(conjunction(property.timeframe_handles));
239245
}
240246

241247
// lasso constraints, if needed
242-
if(properties.requires_lasso_constraints())
248+
if(requires_lasso_constraints)
243249
{
244250
message.status() << "Adding lasso constraints" << messaget::eom;
245251
lasso_constraints(

src/ebmc/ebmc_properties.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ class ebmc_propertiest
199199

200200
propertyt() = default;
201201

202-
bool requires_lasso_constraints() const
203-
{
204-
return ::requires_lasso_constraints(normalized_expr);
205-
}
206-
207202
bool is_exists_path() const
208203
{
209204
return ::is_exists_path(original_expr);
@@ -236,15 +231,6 @@ class ebmc_propertiest
236231
return false;
237232
}
238233

239-
bool requires_lasso_constraints() const
240-
{
241-
for(const auto &p : properties)
242-
if(!p.is_disabled() && p.requires_lasso_constraints())
243-
return true;
244-
245-
return false;
246-
}
247-
248234
static ebmc_propertiest from_command_line(
249235
const cmdlinet &,
250236
const transition_systemt &,

src/trans-word-level/lasso.cpp

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ Function: lasso_symbol
5959
6060
\*******************************************************************/
6161

62+
#define LASSO_PREFIX "lasso::"
63+
6264
symbol_exprt lasso_symbol(const mp_integer &k, const mp_integer &i)
6365
{
6466
// True when states i and k are equal.
6567
// We require k<i to avoid the symmetric constraints.
6668
PRECONDITION(k < i);
6769
irep_idt lasso_identifier =
68-
"lasso::" + integer2string(i) + "-back-to-" + integer2string(k);
70+
LASSO_PREFIX + integer2string(i) + "-back-to-" + integer2string(k);
6971
return symbol_exprt(lasso_identifier, bool_typet());
7072
}
7173

@@ -136,7 +138,7 @@ void lasso_constraints(
136138

137139
/*******************************************************************\
138140
139-
Function: requires_lasso_constraints
141+
Function: uses_lasso_symbol
140142
141143
Inputs:
142144
@@ -146,21 +148,38 @@ Function: requires_lasso_constraints
146148
147149
\*******************************************************************/
148150

149-
bool requires_lasso_constraints(const exprt &expr)
151+
bool uses_lasso_symbol(const exprt &expr)
150152
{
151153
for(auto subexpr_it = expr.depth_cbegin(), subexpr_end = expr.depth_cend();
152154
subexpr_it != subexpr_end;
153155
subexpr_it++)
154156
{
155-
if(
156-
subexpr_it->id() == ID_sva_until || subexpr_it->id() == ID_sva_s_until ||
157-
subexpr_it->id() == ID_sva_eventually ||
158-
subexpr_it->id() == ID_sva_s_eventually || subexpr_it->id() == ID_AF ||
159-
subexpr_it->id() == ID_F || subexpr_it->id() == ID_U)
160-
{
161-
return true;
162-
}
157+
if(subexpr_it->id() == ID_symbol)
158+
if(to_symbol_expr(*subexpr_it).get_identifier().starts_with(LASSO_PREFIX))
159+
{
160+
return true;
161+
}
163162
}
164163

165164
return false;
166165
}
166+
167+
/*******************************************************************\
168+
169+
Function: uses_lasso_symbol
170+
171+
Inputs:
172+
173+
Outputs:
174+
175+
Purpose:
176+
177+
\*******************************************************************/
178+
179+
bool uses_lasso_symbol(const exprt::operandst &exprs)
180+
{
181+
for(auto &expr : exprs)
182+
if(::uses_lasso_symbol(expr))
183+
return true;
184+
return false;
185+
}

src/trans-word-level/lasso.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Author: Daniel Kroening, dkr@amazon.com
99
#ifndef CPROVER_TRANS_WORD_LEVEL_LASSO_H
1010
#define CPROVER_TRANS_WORD_LEVEL_LASSO_H
1111

12+
#include <util/expr.h>
1213
#include <util/mp_arith.h>
1314
#include <util/namespace.h>
1415

@@ -26,7 +27,7 @@ void lasso_constraints(
2627
/// Precondition: k<i
2728
symbol_exprt lasso_symbol(const mp_integer &k, const mp_integer &i);
2829

29-
/// Returns true iff the given property requires lasso constraints for BMC.
30-
bool requires_lasso_constraints(const exprt &);
30+
/// Returns true iff the given formula uses a lasso symbol
31+
bool uses_lasso_symbol(const exprt::operandst &);
3132

3233
#endif

src/trans-word-level/property.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Author: Daniel Kroening, kroening@kroening.com
2525

2626
#include "instantiate_word_level.h"
2727
#include "obligations.h"
28+
#include "lasso.h"
2829
#include "sequence.h"
2930

3031
#include <cstdlib>

src/trans-word-level/property.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,6 @@ exprt::operandst property(
2626
/// Is the given property supported by word-level unwinding?
2727
bool bmc_supports_property(const exprt &);
2828

29-
/// Adds a constraint that can be used to determine whether the
30-
/// given state has already been seen earlier in the trace.
31-
void lasso_constraints(
32-
decision_proceduret &,
33-
const mp_integer &no_timeframes,
34-
const namespacet &,
35-
const irep_idt &module_identifier);
36-
37-
/// Is there a loop from i back to k?
38-
/// Precondition: k<i
39-
symbol_exprt lasso_symbol(const mp_integer &k, const mp_integer &i);
40-
41-
/// Returns true iff the given property requires lasso constraints for BMC.
42-
bool requires_lasso_constraints(const exprt &);
43-
4429
class obligationst;
4530

4631
obligationst property_obligations(

0 commit comments

Comments
 (0)