Skip to content

Commit 4b558d8

Browse files
committed
Disallow enumerate equal expr between sub-exprs with different types.
1 parent 45d3399 commit 4b558d8

File tree

4 files changed

+21
-9
lines changed

4 files changed

+21
-9
lines changed

src/goto-instrument/goto_instrument_parse_options.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1433,10 +1433,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
14331433
" or --" FLAG_LOOP_CONTRACTS);
14341434
}
14351435

1436-
log.warning() << "Loop invariant synthesizer is still work in progress. "
1437-
"It only generates TRUE as invariants."
1438-
<< messaget::eom;
1439-
14401436
// Synthesize loop invariants and annotate them into `goto_model`
14411437
enumerative_loop_invariant_synthesizert synthesizer(goto_model, log);
14421438
annotate_invariants(synthesizer.synthesize_all(), goto_model);

src/goto-instrument/synthesizer/enumerative_loop_invariant_synthesizer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,14 @@ std::vector<exprt> construct_terminals(std::set<symbol_exprt> symbols)
4848
// For a variable v with primitive type, we add
4949
// v, __CPROVER_loop_entry(v)
5050
// into the result.
51+
result.push_back(typecast_exprt(e, size_type()));
52+
result.push_back(
53+
typecast_exprt(unary_exprt(ID_loop_entry, e, e.type()), size_type()));
54+
}
55+
if((e.type().id() == ID_signedbv))
56+
{
5157
result.push_back(e);
52-
result.push_back(unary_exprt(ID_loop_entry, e, size_type()));
58+
result.push_back(unary_exprt(ID_loop_entry, e, e.type()));
5359
}
5460
if((e.type().id() == ID_pointer))
5561
{
@@ -62,7 +68,8 @@ std::vector<exprt> construct_terminals(std::set<symbol_exprt> symbols)
6268
unary_exprt(ID_loop_entry, e, e.type()), size_type()));
6369
}
6470
}
65-
result.push_back(from_integer(1, size_type()));
71+
result.push_back(from_integer(1, unsigned_int_type()));
72+
result.push_back(from_integer(1, unsigned_long_int_type()));
6673
return result;
6774
}
6875

src/goto-instrument/synthesizer/expr_enumerator.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,18 @@ exprt binary_functional_enumeratort::instantiate(const expr_listt &exprs) const
316316
exprs.size() == 2,
317317
"number of arguments should be 2: " + integer2string(exprs.size()));
318318
if(op_id == ID_equal)
319+
{
320+
if(exprs.front().type() != exprs.back().type())
321+
return true_exprt();
322+
319323
return equal_exprt(exprs.front(), exprs.back());
324+
}
325+
if(op_id == ID_notequal)
326+
{
327+
if(exprs.front().type() != exprs.back().type())
328+
return true_exprt();
329+
return notequal_exprt(exprs.front(), exprs.back());
330+
}
320331
if(op_id == ID_le)
321332
return less_than_or_equal_exprt(exprs.front(), exprs.back());
322333
if(op_id == ID_lt)
@@ -333,8 +344,6 @@ exprt binary_functional_enumeratort::instantiate(const expr_listt &exprs) const
333344
return plus_exprt(exprs.front(), exprs.back());
334345
if(op_id == ID_minus)
335346
return minus_exprt(exprs.front(), exprs.back());
336-
if(op_id == ID_notequal)
337-
return notequal_exprt(exprs.front(), exprs.back());
338347
return binary_exprt(exprs.front(), op_id, exprs.back());
339348
}
340349

src/goto-programs/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ add_library(goto-programs ${sources})
33

44
generic_includes(goto-programs)
55

6-
target_link_libraries(goto-programs util assembler langapi analyses linking ansi-c)
6+
target_link_libraries(goto-programs util assembler langapi analyses linking ansi-c json)

0 commit comments

Comments
 (0)