Skip to content

Commit 21259a1

Browse files
Replace negation of constraint by a method
1 parent b7ef5af commit 21259a1

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

src/solvers/refinement/string_constraint.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ class string_constraintt : public exprt
118118
binary_relation_exprt(lower_bound(), ID_le, univ_var()),
119119
binary_relation_exprt(upper_bound(), ID_gt, univ_var()));
120120
}
121+
122+
exprt negation() const
123+
{
124+
return and_exprt(univ_within_bounds(), not_exprt(body()));
125+
}
121126
};
122127

123128
extern inline const string_constraintt &to_string_constraint(const exprt &expr)

src/solvers/refinement/string_refinement.cpp

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,38 +1241,6 @@ static exprt negation_of_not_contains_constraint(
12411241
return negaxiom;
12421242
}
12431243

1244-
/// Negates the constraint to be fed to a solver. The intended usage is to find
1245-
/// an assignment of the universal variable that would violate the axiom. To
1246-
/// avoid false positives, the symbols other than the universal variable should
1247-
/// have been replaced by their valuation in the current model.
1248-
/// \pre Symbols other than the universal variable should have been replaced by
1249-
/// their valuation in the current model.
1250-
/// \param axiom: the not_contains constraint to add the negation of
1251-
/// \return: the negation of the axiom under the current evaluation
1252-
static exprt negation_of_constraint(const string_constraintt &axiom)
1253-
{
1254-
// If the for all is vacuously true, the negation is false.
1255-
const exprt &lb=axiom.lower_bound();
1256-
const exprt &ub=axiom.upper_bound();
1257-
if(lb.id()==ID_constant && ub.id()==ID_constant)
1258-
{
1259-
const auto lb_int = numeric_cast<mp_integer>(lb);
1260-
const auto ub_int = numeric_cast<mp_integer>(ub);
1261-
if(!lb_int || !ub_int || ub_int<=lb_int)
1262-
return false_exprt();
1263-
}
1264-
1265-
// If the premise is false, the implication is trivially true, so the
1266-
// negation is false.
1267-
if(axiom.premise()==false_exprt())
1268-
return false_exprt();
1269-
1270-
and_exprt premise(axiom.premise(), axiom.univ_within_bounds());
1271-
and_exprt negaxiom(premise, not_exprt(axiom.body()));
1272-
1273-
return negaxiom;
1274-
}
1275-
12761244
/// Debugging function which outputs the different steps an axiom goes through
12771245
/// to be checked in check axioms.
12781246
static void debug_check_axioms_step(
@@ -1370,7 +1338,7 @@ static std::pair<bool, std::vector<exprt>> check_axioms(
13701338
const string_constraintt axiom_in_model(
13711339
univ_var, get(bound_inf), get(bound_sup), get(body));
13721340

1373-
exprt negaxiom=negation_of_constraint(axiom_in_model);
1341+
exprt negaxiom = axiom_in_model.negation();
13741342
negaxiom = simplify_expr(negaxiom, ns);
13751343

13761344
stream << indent << i << ".\n";

0 commit comments

Comments
 (0)