41 if(src.
id() == ID_array)
44 array_type.element_type() =
replace(array_type.element_type());
45 array_type.size() =
replace(array_type.size());
48 else if(src.
id() == ID_pointer)
63 for(
auto b_it = std::next(a_it); b_it !=
evaluate_exprs.end(); b_it++)
65 if(a_it->state() != b_it->state())
68 auto a_op = a_it->address();
70 b_it->address(), a_it->address().type());
93 if(a_it->state() != b_it->state())
95 auto a_op = a_it->address();
97 b_it->address(), a_it->address().type());
117 auto pointers_equal =
same_object(a_it->address(), *b_it);
134 if(a_it->state() != b_it->state())
136 auto operands_equal =
same_object(a_it->address(), b_it->address());
156 auto pointers_equal =
same_object(a_it->address(), *b_it);
169 if(a_it->object_identifier() ==
"return_value")
171 else if(a_it->object_identifier().starts_with(
"va_args::"))
173 else if(a_it->object_identifier().starts_with(
"va_arg::"))
175 else if(a_it->object_identifier().starts_with(
"va_arg_array::"))
177 else if(a_it->object_identifier().starts_with(
"old::"))
180 auto &symbol =
ns.
lookup(a_it->object_expr());
181 bool is_const = symbol.type.get_bool(ID_C_constant);
186 auto pointers_equal =
same_object(*a_it, b_it->address());
188 :
static_cast<exprt>(*b_it);
207 if(a_it->state() != b_it->state())
209 auto operands_equal =
same_object(a_it->address(), b_it->address());
229 if(a_it->state() != b_it->state())
231 auto operands_equal =
same_object(a_it->address(), b_it->address());
246 if(src_simplified != src)
250 std::cout <<
"OBJECT_SIZE1: " <<
format(equal) <<
'\n';
262 if(b_it->object().id() == ID_string_constant)
265 auto pointers_equal =
same_object(a_it->address(), *b_it);
268 from_integer(string_constant.value().size() + 1, a_it->type()));
286 if(a_it->state() != b_it->state())
288 auto operands_equal =
same_object(a_it->address(), b_it->address());
303 for(
auto b_it = std::next(a_it); b_it !=
ok_exprs.end(); b_it++)
305 if(a_it->id() != b_it->id())
307 if(a_it->state() != b_it->state())
309 if(a_it->size() != b_it->size())
311 auto a_op = a_it->address();
313 b_it->address(), a_it->address().type());
332 if(
ns.
lookup(
object.get_identifier(), symbol))
364 src.
id() == ID_initial_state || src.
id() == ID_evaluate ||
365 src.
id() == ID_state_is_cstring || src.
id() == ID_state_cstrlen ||
366 src.
id() == ID_state_is_sentinel_dll ||
367 src.
id() == ID_state_is_dynamic_object ||
368 src.
id() == ID_state_object_size || src.
id() == ID_state_live_object ||
369 src.
id() == ID_state_writeable_object || src.
id() == ID_state_r_ok ||
370 src.
id() == ID_state_w_ok || src.
id() == ID_state_rw_ok ||
371 src.
id() == ID_allocate || src.
id() == ID_reallocate)
381 if(src.
id() == ID_state_is_cstring)
384 std::cout <<
"R " <<
format(s) <<
" --> " <<
format(src) <<
'\n';
401 if(src.
id() == ID_state_is_cstring)
405 else if(src.
id() == ID_state_is_sentinel_dll)
415 is_sentinel_dll_expr.state(),
416 is_sentinel_dll_expr.head(),
417 *ok_expr_h_size_opt);
424 is_sentinel_dll_expr.state(),
425 is_sentinel_dll_expr.tail(),
426 *ok_expr_t_size_opt);
433 std::cout <<
"AXIOM-is-sentinel-dll-1: " <<
format(instance1) <<
"\n";
440 is_sentinel_dll_expr.state(), is_sentinel_dll_expr.head(),
ns);
443 is_sentinel_dll_expr.state(), is_sentinel_dll_expr.tail(),
ns);
445 if(head_next.has_value() && tail_prev.has_value())
447 auto head_next_is_tail =
448 equal_exprt(*head_next, is_sentinel_dll_expr.tail());
450 auto tail_prev_is_head =
451 equal_exprt(*tail_prev, is_sentinel_dll_expr.head());
455 ok_expr_h, ok_expr_t ),
459 std::cout <<
"AXIOM-is-sentinel-dll-2: " <<
format(instance2) <<
"\n";
464 else if(src.
id() == ID_evaluate)
469 else if(src.
id() == ID_state_live_object)
479 std::cout <<
"AXIOMc: " <<
format(instance) <<
"\n";
483 else if(src.
id() == ID_state_writeable_object)
488 else if(src.
id() == ID_state_is_dynamic_object)
493 else if(src.
id() == ID_allocate)
499 auto live_object_expr =
502 auto instance1 =
replace(live_object_expr);
504 std::cout <<
"ALLOCATE1: " <<
format(instance1) <<
"\n";
508 auto writeable_object_expr =
511 auto instance2 =
replace(writeable_object_expr);
513 std::cout <<
"ALLOCATE2: " <<
format(instance2) <<
"\n";
518 allocate_expr.state(), allocate_expr, allocate_expr.size().type());
523 std::cout <<
"ALLOCATE3: " <<
format(instance3) <<
"\n";
530 pointer_offset_expr,
from_integer(0, pointer_offset_expr.type())));
532 std::cout <<
"ALLOCATE4: " <<
format(instance4) <<
"\n";
536 auto is_dynamic_object_expr =
539 auto instance5 =
replace(is_dynamic_object_expr);
541 std::cout <<
"ALLOCATE5: " <<
format(instance5) <<
"\n";
544 else if(src.
id() == ID_reallocate)
550 auto live_object_expr =
553 auto instance1 =
replace(live_object_expr);
555 std::cout <<
"REALLOCATE1: " <<
format(instance1) <<
"\n";
560 reallocate_expr.state(), reallocate_expr, reallocate_expr.size().type());
565 std::cout <<
"REALLOCATE2: " <<
format(instance2) <<
"\n";
572 pointer_offset_expr,
from_integer(0, pointer_offset_expr.type())));
574 std::cout <<
"REALLOCATE3: " <<
format(instance3) <<
"\n";
578 auto is_dynamic_object_expr =
581 auto instance4 =
replace(is_dynamic_object_expr);
583 std::cout <<
"REALLOCATE4: " <<
format(instance4) <<
"\n";
586 else if(src.
id() == ID_deallocate_state)
595 deallocate_state_expr, deallocate_state_expr.address());
599 std::cout <<
"DEALLOCATE1: " <<
format(instance1) <<
"\n";
603 else if(src.
id() == ID_address_of)
607 else if(src.
id() == ID_object_address)
611 else if(src.
id() == ID_state_object_size)
616 else if(src.
id() == ID_initial_state)
621 src.
id() == ID_state_r_ok || src.
id() == ID_state_w_ok ||
622 src.
id() == ID_state_rw_ok)
630 if(!
ok_exprs.insert(ok_expr).second)
633 const auto &state = ok_expr.
state();
634 const auto &pointer = ok_expr.
address();
635 const auto &size = ok_expr.
size();
644 auto live_object_simplified =
650 auto writeable_object_simplified =
655 auto offset_simplified =
670 auto offset_casted_to_unsigned =
673 offset_casted_to_unsigned, size_type_ext);
676 plus_exprt(offset_extended, size_casted), ID_le, object_size_casted);
680 if(ok_expr.
id() == ID_state_w_ok || ok_expr.
id() == ID_state_rw_ok)
686 std::cout <<
"AXIOMd: " <<
format(instance) <<
"\n";
695 std::cout <<
"AXIOMe: " <<
format(instance) <<
"\n";
709 is_cstring_expr.
state(),
716 std::cout <<
"AXIOMa1: " <<
format(instance1) <<
"\n";
720 ok_simplified.visit_pre([
this](
const exprt &src) {
node(src); });
723 std::cout <<
"AXIOMa2: " <<
format(instance2) <<
"\n";
730 auto state = is_cstring_expr.
state();
731 auto p = is_cstring_expr.
address();
742 std::cout <<
"AXIOMb: " <<
format(instance) <<
"\n";
745 add(is_cstring_plus_one,
true);
753 constraint.visit_pre([
this](
const exprt &src) {
node(src); });
755 auto constraint_replaced =
replace(constraint);
759 std::cout <<
"CONSTRAINT1: " <<
format(constraint) <<
"\n";
760 std::cout <<
"CONSTRAINT2: " <<
format(constraint_replaced) <<
"\n";
763 dest << constraint_replaced;
signedbv_typet signed_size_type()
bitvector_typet char_type()
void is_dynamic_object_fc()
std::set< address_of_exprt > address_of_exprs
std::set< state_ok_exprt > ok_exprs
std::unordered_map< exprt, symbol_exprt, irep_hash > replacement_map
std::set< object_address_exprt > object_address_exprs
std::set< state_live_object_exprt > live_object_exprs
std::set< evaluate_exprt > evaluate_exprs
std::set< state_is_dynamic_object_exprt > is_dynamic_object_exprs
std::set< state_is_sentinel_dll_exprt > is_sentinel_dll_exprs
std::set< initial_state_exprt > initial_state_exprs
std::set< state_writeable_object_exprt > writeable_object_exprs
std::map< irep_idt, std::size_t > counters
exprt translate(exprt) const
std::set< state_is_cstring_exprt > is_cstring_exprs
const std::unordered_set< symbol_exprt, irep_hash > & address_taken
decision_proceduret & dest
std::set< state_object_size_exprt > object_size_exprs
std::vector< exprt > constraints
void add(const state_ok_exprt &)
void writeable_object_fc()
A base class for relations, i.e., binary predicates whose two operands have the same type.
Base class for all expressions.
typet & type()
Return the type of the expression.
void add_to_operands(const exprt &expr)
Add the given argument to the end of exprt's operands.
const std::string & id_string() const
const irep_idt & id() const
bool lookup(const irep_idt &name, const symbolt *&symbol) const override
See documentation for namespace_baset::lookup().
Operator to return the address of an object.
The plus expression Associativity is not specified.
The offset (in bytes) of a pointer relative to the object.
const typet & base_type() const
The type of the data what we point to.
const exprt & address() const
const exprt & state() const
const exprt & address() const
const exprt & state() const
const exprt & size() const
Expression to hold a symbol (variable)
An expression with three operands.
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
Fixed-width bit-vector with unsigned binary interpretation.
Decision Procedure Interface.
static exprt implication(exprt lhs, exprt rhs)
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
const object_address_exprt & to_object_address_expr(const exprt &expr)
Cast an exprt to an object_address_exprt.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
exprt pointer_offset(const exprt &pointer)
exprt same_object(const exprt &p1, const exprt &p2)
exprt null_object(const exprt &pointer)
Various predicates over pointers in programs.
exprt simplify_state_expr_node(exprt, const std::unordered_set< symbol_exprt, irep_hash > &address_taken, const namespacet &)
exprt simplify_state_expr(exprt, const std::unordered_set< symbol_exprt, irep_hash > &address_taken, const namespacet &)
std::optional< exprt > sentinel_dll_next(const exprt &state, const exprt &node, const namespacet &ns)
std::optional< exprt > sentinel_dll_prev(const exprt &state, const exprt &node, const namespacet &ns)
const state_is_sentinel_dll_exprt & to_state_is_sentinel_dll_expr(const exprt &expr)
Cast an exprt to a state_is_sentinel_dll_exprt.
Simplify State Expression.
const deallocate_state_exprt & to_deallocate_state_expr(const exprt &expr)
Cast an exprt to a deallocate_state_exprt.
const reallocate_exprt & to_reallocate_expr(const exprt &expr)
Cast an exprt to a reallocate_exprt.
const state_is_dynamic_object_exprt & to_state_is_dynamic_object_expr(const exprt &expr)
Cast an exprt to a state_is_dynamic_object_exprt.
const evaluate_exprt & to_evaluate_expr(const exprt &expr)
Cast an exprt to a evaluate_exprt.
const state_object_size_exprt & to_state_object_size_expr(const exprt &expr)
Cast an exprt to a state_object_size_exprt.
const initial_state_exprt & to_initial_state_expr(const exprt &expr)
Cast an exprt to a initial_state_exprt.
const allocate_exprt & to_allocate_expr(const exprt &expr)
Cast an exprt to a allocate_exprt.
const state_live_object_exprt & to_state_live_object_expr(const exprt &expr)
Cast an exprt to a state_live_object_exprt.
const state_writeable_object_exprt & to_state_writeable_object_expr(const exprt &expr)
Cast an exprt to a state_writeable_object_exprt.
const state_is_cstring_exprt & to_state_is_cstring_expr(const exprt &expr)
Cast an exprt to a state_is_cstring_exprt.
const state_ok_exprt & to_state_ok_expr(const exprt &expr)
Cast an exprt to a state_ok_exprt.
exprt conjunction(const exprt::operandst &op)
1) generates a conjunction for two or more operands 2) for one operand, returns the operand 3) return...
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const string_constantt & to_string_constant(const exprt &expr)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.