@@ -42,6 +42,10 @@ static bool is_char_array(const namespacet &ns, const typet &type);
42
42
exprt substitute_array_lists (exprt expr, size_t string_max_length);
43
43
exprt concretize_arrays_in_expression (
44
44
exprt expr, std::size_t string_max_length);
45
+ static bool is_valid_string_constraint (
46
+ messaget::mstreamt& stream,
47
+ const namespacet& ns,
48
+ const string_constraintt &expr);
45
49
46
50
exprt simplify_sum (const exprt &f);
47
51
@@ -563,12 +567,14 @@ decision_proceduret::resultt string_refinementt::dec_solve()
563
567
replace_expr (symbol_resolve, axiom);
564
568
if (axiom.id ()==ID_string_constraint)
565
569
{
566
- string_constraintt c=to_string_constraint (axiom);
570
+ string_constraintt nc_axiom=
571
+ to_string_constraint (axiom);
572
+ is_valid_string_constraint (error (), ns, nc_axiom);
567
573
DATA_INVARIANT (
568
- is_valid_string_constraint (c ),
574
+ is_valid_string_constraint (error (), ns, nc_axiom ),
569
575
string_refinement_invariantt (
570
576
" string constraints satisfy their invariant" ));
571
- universal_axioms.push_back (c );
577
+ universal_axioms.push_back (nc_axiom );
572
578
}
573
579
else if (axiom.id ()==ID_string_not_contains_constraint)
574
580
{
@@ -1938,21 +1944,24 @@ static bool universal_only_in_index(const string_constraintt &expr)
1938
1944
// / \related string_constraintt
1939
1945
// / \param [in] expr: the string constraint to check
1940
1946
// / \return whether the constraint satisfies the invariant
1941
- bool string_refinementt::is_valid_string_constraint (
1947
+ static bool is_valid_string_constraint (
1948
+ messaget::mstreamt& stream,
1949
+ const namespacet& ns,
1942
1950
const string_constraintt &expr)
1943
1951
{
1952
+ const auto eom = messaget::eom;
1944
1953
// Condition 1: The premise cannot contain any string indices
1945
1954
const array_index_mapt premise_indices=gather_indices (expr.premise ());
1946
1955
if (!premise_indices.empty ())
1947
1956
{
1948
- error () << " Premise has indices: " << from_expr (ns, " " , expr) << " , map: {" ;
1957
+ stream << " Premise has indices: " << from_expr (ns, " " , expr) << " , map: {" ;
1949
1958
for (const auto &pair : premise_indices)
1950
1959
{
1951
- error () << from_expr (ns, " " , pair.first ) << " : {" ;
1960
+ stream << from_expr (ns, " " , pair.first ) << " : {" ;
1952
1961
for (const auto &i : pair.second )
1953
- error () << from_expr (ns, " " , i) << " , " ;
1962
+ stream << from_expr (ns, " " , i) << " , " ;
1954
1963
}
1955
- error () << " }}" << eom;
1964
+ stream << " }}" << eom;
1956
1965
return false ;
1957
1966
}
1958
1967
@@ -1970,26 +1979,26 @@ bool string_refinementt::is_valid_string_constraint(
1970
1979
const exprt result=simplify_expr (equals, ns);
1971
1980
if (result.is_false ())
1972
1981
{
1973
- error () << " Indices not equal: " << from_expr (ns, " " , expr) << " , str: "
1974
- << from_expr (ns, " " , pair.first ) << eom;
1982
+ stream << " Indices not equal: " << from_expr (ns, " " , expr) << " , str: "
1983
+ << from_expr (ns, " " , pair.first ) << eom;
1975
1984
return false ;
1976
1985
}
1977
1986
}
1978
1987
1979
1988
// Condition 3: f must be linear
1980
1989
if (!is_linear_arithmetic_expr (rep))
1981
1990
{
1982
- error () << " f is not linear: " << from_expr (ns, " " , expr) << " , str: "
1983
- << from_expr (ns, " " , pair.first ) << eom;
1991
+ stream << " f is not linear: " << from_expr (ns, " " , expr) << " , str: "
1992
+ << from_expr (ns, " " , pair.first ) << eom;
1984
1993
return false ;
1985
1994
}
1986
1995
1987
1996
// Condition 4: the quantified variable can only occur in indices in the
1988
1997
// body
1989
1998
if (!universal_only_in_index (expr))
1990
1999
{
1991
- error () << " Universal variable outside of index:"
1992
- << from_expr (ns, " " , expr) << eom;
2000
+ stream << " Universal variable outside of index:"
2001
+ << from_expr (ns, " " , expr) << eom;
1993
2002
return false ;
1994
2003
}
1995
2004
}
0 commit comments