Skip to content

Commit 0ffd0ae

Browse files
Replace negation of constraint by a method
1 parent 34a3d85 commit 0ffd0ae

File tree

2 files changed

+6
-33
lines changed

2 files changed

+6
-33
lines changed

src/solvers/refinement/string_constraint.h

+5
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

+1-33
Original file line numberDiff line numberDiff line change
@@ -1236,38 +1236,6 @@ static exprt negation_of_not_contains_constraint(
12361236
return and_exprt(univ_bounds, get(constraint.premise()), equal_strings);
12371237
}
12381238

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

1368-
exprt negaxiom=negation_of_constraint(axiom_in_model);
1336+
exprt negaxiom = axiom_in_model.negation();
13691337
negaxiom = simplify_expr(negaxiom, ns);
13701338

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

0 commit comments

Comments
 (0)