Skip to content

Ensure result of to_predicates is deterministic #6296

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@
#include <analyses/variable-sensitivity/abstract_environment.h>
#include <analyses/variable-sensitivity/abstract_object_statistics.h>
#include <analyses/variable-sensitivity/variable_sensitivity_object_factory.h>

#include <util/expr_util.h>
#include <util/simplify_expr.h>
#include <util/simplify_expr_class.h>
#include <util/simplify_utils.h>

#include <algorithm>
#include <map>
Expand Down Expand Up @@ -427,7 +429,7 @@ exprt abstract_environmentt::to_predicate() const
if(is_top())
return true_exprt();

auto predicates = std::vector<exprt>{};
exprt::operandst predicates;
for(const auto &entry : map.get_view())
{
auto sym = entry.first;
Expand All @@ -439,6 +441,8 @@ exprt abstract_environmentt::to_predicate() const

if(predicates.size() == 1)
return predicates.front();

sort_operands(predicates);
return and_exprt(predicates);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ SCENARIO(
env.assign(x_name, val2, ns);
env.assign(y_name, val3, ns);

THEN_PREDICATE(env, "y == 3 && x == 2");
THEN_PREDICATE(env, "x == 2 && y == 3");
}
}
}