26 for (
int i = 1; i < n_path_constraints - 1; i++) {
36 if (n_path_constraints == 0) {
41 for (
int i = 1; i < n_path_constraints; i++) {
45 state.
p =
new SymProb(n_cond, d_cond);
68 bool is_unknown_path_constraint,
69 bool is_target,
bool is_sat,
int pc,
70 std::string constraints_str,
SymState &state,
71 const std::unordered_map<int, float> ¶ms) {
72 if (verbose_level >= 1) {
73 if ((verbose_level >= 1 && is_unknown_path_constraint && is_target) ||
74 (verbose_level >= 2)) {
80 printf(
"pc=%d, IS_SAT - %d\x1b[39m, Pr.REACH - %s, %s, params = {",
82 constraints_str.c_str());
83 for (
auto &p : params) {
85 if (state.
mem.find(p.first) != state.
mem.end()) {
90 printf(
"%d: %d, ", p.first, (
int)p.second);
92 printf(
"%d: %f, ", p.first, p.second);
117 if (prob_constraints_table.find(pc) == prob_constraints_table.end()) {
118 std::vector<std::tuple<Sym, Mem, SymProb>> tmp = {
119 std::make_tuple(cc, state.
mem, *state.
p)};
120 prob_constraints_table.emplace(pc, tmp);
122 prob_constraints_table[pc].emplace_back(
123 std::make_tuple(cc, state.
mem, *state.
p));
158 std::string constraints_str = state.
toString(
false);
160 std::unordered_map<int, float> params = {};
164 bool is_unknown_path_constraint =
true;
170 is_unknown_path_constraint =
false;
172 bool is_contain_prob_var =
false;
173 std::unordered_set<int> unique_var_ids;
177 for (
int i : unique_var_ids) {
179 is_contain_prob_var =
true;
184 if (is_contain_prob_var) {
207 std::make_pair(is_sat, params));
212 is_target, is_sat, pc, constraints_str, state,
236 int maxDepth = 256) {
243 is_sat =
solve(is_target, pc, state);
253 return Trace(state, {});
255 Instr instr = prog[pc];
256 std::vector<SymState *> newStates;
257 symStep(&state, instr, newStates);
258 std::vector<Trace> children;
259 for (
SymState *newState : newStates) {
260 Trace child =
run(prog, target_pcs, *newState, maxDepth - 1);
262 children.push_back(child);
265 return Trace(state, children);
267 return Trace(state, {});
Class representing an instruction.
Definition: type.h:53
Definition: compiler.h:11
std::unordered_map< int, std::vector< std::tuple< Sym, Mem, SymProb > >> ProbPathConstraintsTable
Alias for a table of probabilistic path constraints.
Definition: type.h:1205
bool explore_further(int maxDepth, int maxSAT, int maxUNSAT)
Checks if further exploration is allowed based on maximum depth and satisfiability conditions.
Definition: symbolic.h:40
void call_smt_solver(bool &is_sat, SymState &state, std::unordered_map< int, float > ¶ms, GDOptimizer &optimizer, int max_num_trials, bool ignore_memory, bool use_dpll)
Calls the SMT solver based on the specified options.
Definition: symbolic.h:58
void pbranch(SymState &state)
Perform probabilistic branching based on symbolic execution.
Definition: psymbolic.h:21
bool is_integer(float x)
Checks if a float is an integer.
Definition: utils.h:25
void initialize_params(std::unordered_map< int, float > ¶ms, SymState &state, bool ignore_memory)
Initialize Parameter Values from Memory.
Definition: smt.h:23
bool is_target_pc(const std::unordered_set< int > &target_pcs, int pc)
Checks if the given program counter (pc) is a target program counter.
Definition: symbolic.h:22
void verbose_pre(int verbose_level, int pc, Prog &prog, SymState &state)
Prints a verbose representation before solving constraints.
Definition: symbolic.h:128
uint32_t FloatToWord(float val)
Converts a float value to a 32-bit word representation.
Definition: utils.h:36
void symStep(SymState *state, Instr &instr, std::vector< SymState * > &result)
Symbolically Execute a Single Instruction of a Program.
Definition: symbolic.h:164
std::vector< Instr > Prog
Alias for a program, represented as a vector of instructions.
Definition: type.h:143
void update_prob_constraints_table(int pc, SymState &state, ProbPathConstraintsTable &prob_constraints_table)
Updates the table of probabilistic path constraints.
Definition: psymbolic.h:111
void verbose_post(int verbose_level)
Prints a verbose representation after solving constraints.
Definition: symbolic.h:146
void verbose_pconstraints(int verbose_level, bool is_unknown_path_constraint, bool is_target, bool is_sat, int pc, std::string constraints_str, SymState &state, const std::unordered_map< int, float > ¶ms)
Prints verbose information about probabilistic path constraints.
Definition: psymbolic.h:67
std::unordered_map< std::string, std::pair< bool, std::unordered_map< int, float > >> PathConstraintsTable
Alias for a table of path constraints.
Definition: type.h:1189
Represents the base class for symbolic execution engine.
Definition: symbolic.h:397
int max_num_trials
Definition: symbolic.h:402
bool return_trace
Definition: symbolic.h:409
bool ignore_memory
Definition: symbolic.h:405
int maxUNSAT
The maximum number of UNSAT constraints to collect.
Definition: symbolic.h:401
GDOptimizer optimizer
Definition: symbolic.h:398
int maxSAT
The maximum number of SAT constraints to collect.
Definition: symbolic.h:400
int verbose_level
The level of verbosity.
Definition: symbolic.h:404
BaseExecutor(GDOptimizer optimizer, int maxSAT=256, int maxUNSAT=256, int max_num_trials=10, bool ignore_memory=false, bool use_dpll=false, int verbose_level=0, bool return_trace=false)
Constructor for BaseExecutor.
Definition: symbolic.h:429
bool use_dpll
Definition: symbolic.h:407
Represents a derived class for symbolic execution engine for probabilistic programs.
Definition: psymbolic.h:132
std::unordered_set< int > random_vars
Set of random variables'IDs.
Definition: psymbolic.h:133
Trace run(Prog &prog, std::unordered_set< int > &target_pcs, SymState &state, int maxDepth=256)
Run probabilistic symbolic execution on a program.
Definition: psymbolic.h:235
PathConstraintsTable constraints_cache
Cache for storing and reusing path constraints.
Definition: psymbolic.h:135
void register_random_var(int var_id)
Definition: psymbolic.h:142
ProbPathConstraintsTable prob_constraints_table
Definition: psymbolic.h:137
bool solve(bool is_target, int pc, SymState &state)
Solves path constraints and updates the symbolic state.
Definition: psymbolic.h:157
Represents a symbolic probability with a numerator and denominator.
Definition: type.h:878
std::string toString()
Converts SymProb to a string.
Definition: type.h:910
SymProb * pmul(SymProb *other)
Multiplies two SymProb instances.
Definition: type.h:940
Struct representing the symbolic state of the symbolic execution.
Definition: type.h:1042
SymProb * p
Definition: type.h:1050
SymProb * cond_p
Definition: type.h:1051
bool has_observed_p_cond
Definition: type.h:1055
std::vector< Sym > path_constraints
Definition: type.h:1049
int pc
Definition: type.h:1043
std::string toString(bool include_memory=true) const
Returns the human-redable string representation of concrete memory, symbolic memory and path constrai...
Definition: type.h:1119
Mem mem
Definition: type.h:1045
Struct representing a symbolic expression.
Definition: type.h:265
Sym * copy()
Definition: type.h:319
Struct representing a trace in symbolic execution.
Definition: type.h:1210
Core implementation of gradient-based symbolic execution.