Skip to content

Make string_not_contains_constraintt a struct #3256

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

Conversation

romainbrenguier
Copy link
Contributor

@romainbrenguier romainbrenguier commented Nov 1, 2018

In particular it does not inherit from exprt anymore.
Not inheriting from exprt, allows the class to be more structured.
We have fields that have named describing what they contain, instead of
having to define accessor methods.
This also prevent us from mistakenly passing a constraint to an exprt
function, which wouldn't know how to deal with a
string_not_contains_constraintt.

  • Each commit message has a non-empty body, explaining why the change was made.
  • Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • Regression or unit tests are included, or existing tests cover the modified code (in this case I have detailed which ones those are in the commit message).
  • [na] My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • [na] White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@romainbrenguier romainbrenguier force-pushed the refactor/string-not-constains-struct branch 3 times, most recently from e87fae2 to 589dd9a Compare November 2, 2018 10:38
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 589dd9a).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90066851

Copy link

@majakusber majakusber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minor things, otherwise looks good.

@@ -116,98 +116,46 @@ inline std::string to_string(const string_constraintt &expr)
}

/// Constraints to encode non containement of strings.
class string_not_contains_constraintt : public exprt
/// string_not contains_constraintt are formula of the form:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Typo: are formula -> are formulas (or formulae?)
Also typo in commit message: fields that have named -> fields that have names

@@ -46,3 +46,43 @@ string_constraintt::string_constraintt(
"String constraints must have non-negative upper bound.\n" +
upper_bound.pretty());
}

/// Used for debug printing.
/// \param [in] expr: constraint to render

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the [in] needed?

@romainbrenguier romainbrenguier force-pushed the refactor/string-not-constains-struct branch from 589dd9a to a3318cd Compare November 5, 2018 13:34
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: a3318cd).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90278315

Copy link
Collaborator

@martin-cs martin-cs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see anything intrinsically wrong with this patch but the general approach does not seem quite right to me. Maybe there are things that I don't see here. Personally I would lean towards having the expression as an exprt and the information about it that is used during solving as a class / struct. That way we distinguish between what you are reasoning about and the working information about it.


// Create witness for axiom
symbol_tablet symtab;
const namespacet empty_ns(symtab);
string_constraint_generatort generator(ns);
std::map<string_not_contains_constraintt, symbol_exprt> witnesses;
std::unordered_map<string_not_contains_constraintt, symbol_exprt> witnesses;
witnesses[vacuous] = generator.fresh_symbol("w", t.witness_type());

INFO("Original axiom:\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side remark (not for this PR): Calling debug output INFO is a bit confusing.

@@ -116,98 +116,46 @@ inline std::string to_string(const string_constraintt &expr)
}

/// Constraints to encode non containement of strings.
class string_not_contains_constraintt : public exprt
/// string_not contains_constraintt are formulas of the form:
/// forall x in [lb,ub[. p(x) => exists y in [lb,ub[. s0[x+y] != s1[y]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be explained in terms of the members of the struct?

@romainbrenguier
Copy link
Contributor Author

@martin-cs

I don't see anything intrinsically wrong with this patch but the general approach does not seem quite right to me. Maybe there are things that I don't see here. Personally I would lean towards having the expression as an exprt and the information about it that is used during solving as a class / struct. That way we distinguish between what you are reasoning about and the working information about it.

The string_not_contains_constraintt is the information that is only used by the solver. The corresponding exprt that appears in the (goto) program are function_application_exprts (for instance "cprover_string_index_of_func")

In particular it does not inherit from exprt anymore.
Not inheriting from exprt, allows the class to be more structured.
We have fields that have names describing what they contain, instead of
having to define accessor methods.
This also prevent us from mistakenly passing a constraint to an exprt
function, which wouldn't know how to deal with a
string_not_contains_constraintt.
@romainbrenguier romainbrenguier force-pushed the refactor/string-not-constains-struct branch from a3318cd to 14057f5 Compare November 6, 2018 08:05
Copy link
Contributor

@allredj allredj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✔️
Passed Diffblue compatibility checks (cbmc commit: 14057f5).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/90384977

@martin-cs
Copy link
Collaborator

martin-cs commented Nov 6, 2018 via email

@romainbrenguier romainbrenguier merged commit 5b47a4d into diffblue:develop Nov 8, 2018
@romainbrenguier romainbrenguier deleted the refactor/string-not-constains-struct branch November 8, 2018 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants