4#ifndef CPROVER_ANALYSES_INTERVAL_DOMAIN_H
5#define CPROVER_ANALYSES_INTERVAL_DOMAIN_H
10#include <boost/serialization/nvp.hpp>
15#include <boost/multiprecision/cpp_bin_float.hpp>
31 std::shared_ptr<integer_intervalt>,
32 std::shared_ptr<real_intervalt>,
33 std::shared_ptr<wrapped_interval>>;
38 using interval_map = std::unordered_map<irep_idt, interval, irep_id_hash>;
50 void output(std::ostream &out)
const override;
127 const bool result =
join(b, to);
211 void join_snapshot(
const std::shared_ptr<interval_map> &snapshot);
259 static std::shared_ptr<interval_map> map = std::make_shared<interval_map>();
266 std::shared_ptr<interval_map> cpy = std::make_shared<interval_map>();
309 void assign(
const expr2tc &assignment,
const bool recursive =
false);
320 template <
class Interval>
354 template <
class Interval>
380 template <
class Interval>
391 template <
class Interval>
401 template <
class Interval>
412 template <
class Interval>
417 template <
class Interval>
430 template <
class Interval>
440 template <
class Interval>
443 template <
size_t Index,
class Interval>
446 template <
class Interval>
448 const std::shared_ptr<Interval> &after,
449 std::shared_ptr<Interval> &dst,
450 bool can_extrapolate)
const;
459 template <
class Interval>
462 template <
class Interval>
466 template <
class Interval>
469 template <
class Interval>
472 template <
class Interval>
475 template <
class Interval>
482 template <
class IntervalMap>
484 IntervalMap &new_map,
485 const IntervalMap &previous_map,
486 const bool is_guard_instruction =
true);
495 template <
class Interval>
498 template <
size_t Index,
class Interval>
This is the basic interface of the abstract interpreter with default implementations of the core func...
Definition ai.h:27
ai_domain_baset()
The constructor is expected to produce 'false' or 'bottom'.
Definition ai_domain.h:19
Definition irep2_expr.h:2175
expr_ids
Enumeration identifying each sort of expr.
Definition irep2.h:730
instructionst::const_iterator const_targett
Definition goto_program.h:591
void clear_state()
Definition interval_domain.h:132
Interval get_interval_from_const(const expr2tc &sym) const
Get the interval from constant expression.
bool copied
Definition interval_domain.h:255
bool join(const interval_domaint &b, const goto_programt::const_targett &to)
Sets *this to the mathematical join between the two domains.
Definition interval_domain.cpp:1242
bool is_bottom() const override final
Definition interval_domain.h:158
void output(std::ostream &out) const override
Definition interval_domain.cpp:911
void make_bottom() final override
no states
Definition interval_domain.h:140
Interval get_interval_from_typecast(const typecast2t &cast, Interval result) const
bool join_intervals(const std::shared_ptr< Interval > &after, std::shared_ptr< Interval > &dst, bool can_extrapolate) const
Definition interval_domain.cpp:1121
Interval wrap_to_type(const Interval &i, const type2tc &t) const
Bring an interval computed over unbounded integers back into the range of the bitvector type t,...
Definition interval_domain.cpp:262
void copy_if_needed()
Definition interval_domain.h:262
virtual bool ai_simplify(expr2tc &condition, const namespacet &ns) const override
Uses the abstract state to simplify a given expression using context- specific information.
Definition interval_domain.cpp:1692
static bool enable_real_intervals
Enabled wrapped intervals (disables Integers).
Definition interval_domain.h:70
expr2tc make_expression_helper(const expr2tc &symbol) const
Definition interval_domain.cpp:839
expr2tc make_expression(const expr2tc &symbol) const
Creates an expression with the intervals found for the given symbol.
Definition interval_domain.cpp:1675
void update_symbol_interval(const symbol2t &sym, const Interval &value)
Sets new interval for symbol.
void apply_assume_less(const expr2tc &lhs, const expr2tc &rhs)
Applies LHS < RHS.
Definition interval_domain.cpp:653
static bool widening_under_approximate_bound
Sets a limit for number of iterations before widening.
Definition interval_domain.h:93
void assume_assertion(const expr2tc &guard, const ai_baset &ai)
Under –interval-analysis-assume-asserts, narrows the state to guard.
Definition interval_domain.cpp:1479
std::variant< std::shared_ptr< integer_intervalt >, std::shared_ptr< real_intervalt >, std::shared_ptr< wrapped_interval > > interval
Definition interval_domain.h:30
bool is_top() const override final
Definition interval_domain.h:163
static bool enable_assume_asserts
Enable real (floating-point) intervals.
Definition interval_domain.h:71
void update_symbol_from_variant(const symbol2t &sym, const Interval &value)
Definition interval_domain.cpp:52
static bool enable_eval_assumptions
Asserts are propagates as assumptions.
Definition interval_domain.h:72
Interval interpolate_intervals(const Interval &before, const Interval &after)
Applies Interpolation narrowing algorithm.
static bool enable_ibex_contractor
Try to evaluate in a guard in a TVT to accelerate bottoms.
Definition interval_domain.h:74
interval_domaint()
Definition interval_domain.h:40
bool bottom
Is this state a bottom.
Definition interval_domain.h:276
Interval get_interval_from_symbol(const symbol2t &sym) const
Get the interval from symbol object or top.
Interval get_interval(const expr2tc &e) const
Get the interval for expression.
std::unordered_map< irep_idt, interval, irep_id_hash > interval_map
Definition interval_domain.h:38
void make_top() final override
all states – the analysis doesn't use this, and domains may refuse to implement it.
Definition interval_domain.h:147
static bool widening_extrapolate
Whether to considers overflows for Integers.
Definition interval_domain.h:95
Interval extrapolate_intervals(const Interval &before, const Interval &after) const
Applies Extrapolation widening algorithm.
static bool widening_narrowing
Extrapolate bound to infinity based on previous iteration.
Definition interval_domain.h:97
static tvt eval_boolean_expression(const expr2tc &cond, const interval_domaint &id)
Interpolate bound back after fixpoint.
Definition interval_domain.cpp:1555
void havoc_written_arguments(const code_function_call2t &call)
Forget what a body-less call that symex models may write through its pointer arguments (#8083).
Definition interval_domain.cpp:1372
static bool enable_assertion_simplification
Make a modular operation after every assignment.
Definition interval_domain.h:64
Interval get_top_interval_from_expr(const expr2tc &sym) const
Definition interval_domain.cpp:348
bool is_mapped(const symbol2t &sym) const
static bool enable_interval_bitwise_arithmetic
Enable simplification for arithmetic operators.
Definition interval_domain.h:60
std::shared_ptr< interval_map > intervals
Definition interval_domain.h:254
Interval get_interval_from_variant(const symbol2t &sym) const
Definition interval_domain.cpp:19
void make_entry() final override
a reasonable entry-point state
Definition interval_domain.h:153
void assume(const expr2tc &)
Adds a restriction over all intervals.
Definition interval_domain.cpp:1491
void join_snapshot(const std::shared_ptr< interval_map > &snapshot)
Join the domain recorded when another symex path was parked into this one, over every variable: a pat...
Definition interval_domain.cpp:1274
static std::shared_ptr< interval_map > get_empty()
Definition interval_domain.h:257
static unsigned fixpoint_limit
Definition interval_domain.h:92
void assign(const expr2tc &assignment, const bool recursive=false)
Computes an assignment expression.
Definition interval_domain.cpp:1290
static bool enable_contraction_for_abstract_states
Simplify condition and assertions with the intervals.
Definition interval_domain.h:67
static bool enable_wrapped_intervals
Use contractor for <= operations.
Definition interval_domain.h:69
void dump() const
Definition interval_domain.cpp:1669
bool havoc_pointee(const expr2tc &arg, bool any_type)
Havoc the variable arg points into; false when that is unknown and arg, a pointer or any_type,...
Definition interval_domain.cpp:1359
void havoc_rec(const expr2tc &expr)
Recursively explores an Expression until it reaches a symbol, then removes it from the int_map whatev...
Definition interval_domain.cpp:1392
bool merge(const interval_domaint &b, goto_programt::const_targett, goto_programt::const_targett to)
Definition interval_domain.h:122
static bool enable_interval_arithmetic
Definition interval_domain.h:58
interval_templatet< BigInt > integer_intervalt
Definition interval_domain.h:26
static void set_options(const optionst &options)
Definition interval_domain.cpp:1716
void assume_rec(const expr2tc &expr, bool negation=false)
Recursively explores intervals of an assume expression.
Definition interval_domain.cpp:1586
void apply_assume_symbol_truth(const symbol2t &sym, bool is_false)
Applies symbol = truth.
Definition interval_domain.cpp:101
interval_templatet< boost::multiprecision::cpp_bin_float_100 > real_intervalt
Definition interval_domain.h:27
void apply_assignment(const expr2tc &lhs, const expr2tc &rhs, bool recursive)
Applies LHS <= RHS and RHS <= LHS from assignment instructions.
Definition interval_domain.cpp:291
expr2tc make_expression_value(const Interval &interval, const type2tc &type, bool upper) const
Interval generate_modular_interval(const type2tc &t) const
Generates interval with [min, max] of type t.
void process_instruction(goto_programt::const_targett from)
Updates the interval state based on a single goto-program instruction.
Definition interval_domain.cpp:1749
static bool enable_modular_intervals
Enable simplification for bitwise operations.
Definition interval_domain.h:62
static bool skip_inductive_step_instructions
Use ibex contractor.
Definition interval_domain.h:89
This class is used to store intervals in the form of lower <= upper.
Definition interval_template.h:20
Definition namespace.h:10
Symbol type.
Definition irep2_expr.h:625
Typecast expression.
Definition irep2_expr.h:729
pthread_cond_t cond
Definition cuda.h:50
irep_container< type2t > type2tc
Definition irep2.h:430
irep_container< expr2t > expr2tc
Definition irep2.h:431
bool is_false(const expr2tc &expr)
Test if expr is false.
Definition irep2_utils.h:241
typet any_type()
Definition python_types.cpp:10
#define true
Definition stdbool.h:11