Skip to content

check for side effects in quantifiers #2979

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
Sep 26, 2018
Merged

Conversation

kroening
Copy link
Member

@kroening kroening commented Sep 18, 2018

  • Each commit message has a non-empty body, explaining why the change was made.
  • My contribution is formatted in line with CODING_STANDARD.md.
  • 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).
  • My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • White-space or formatting changes outside the feature-related changed lines are in commits of their own.

@@ -93,8 +93,6 @@ bool goto_convertt::needs_cleaning(const exprt &expr)
// g1 = (i == 0)
// g2 = (i > 10)
// forall (i : int) (g1 || g2)
if(expr.id()==ID_forall || expr.id()==ID_exists)
return false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The comment above this code needs to be moved, it doesn't actually make sense when these lines are removed.

@@ -409,7 +407,7 @@ void goto_convertt::clean_expr(
// check if there are side-effects
goto_programt tmp;
clean_expr(expr.op1(), tmp, mode, true);
if(tmp.instructions.empty())
if(!tmp.instructions.empty())
Copy link
Collaborator

Choose a reason for hiding this comment

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

So this was dead code before. It's no longer dead code now - do we have any tests exercising it?

@kroening kroening force-pushed the quantifier-sideeffects branch from cc4fae7 to a887387 Compare September 23, 2018 13:06
@kroening
Copy link
Member Author

Now with different approach -- the rule is now checked in the front-end

@kroening kroening force-pushed the quantifier-sideeffects branch from a887387 to 0812cc1 Compare September 23, 2018 21:30
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: 0812cc1).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85673814

throw 0;
}
return;
// the front-end checks these for side-effects
Copy link
Contributor

Choose a reason for hiding this comment

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

Invariant?

Copy link
Collaborator

Choose a reason for hiding this comment

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

DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

I'd suggest to simplify as described below.

@@ -166,6 +166,18 @@ bool c_typecheck_baset::gcc_types_compatible_p(
return false;
}

static bool has_side_effect(const exprt &expr)
Copy link
Collaborator

Choose a reason for hiding this comment

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

No need - see below.

@@ -303,6 +315,13 @@ void c_typecheck_baset::typecheck_expr_main(exprt &expr)
throw 0;
}

if(has_side_effect(expr.op1()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

if(has_subexpr(expr.op1(), ID_side_effect))

throw 0;
}
return;
// the front-end checks these for side-effects
Copy link
Collaborator

Choose a reason for hiding this comment

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

DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");

Copy link
Collaborator

@tautschnig tautschnig left a comment

Choose a reason for hiding this comment

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

Looks good, except for the line break.

throw 0;
}
return;
DATA_INVARIANT(!has_subexpr(expr, ID_side_effect), "the front-end should check quantified expressions for side-effects");
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line got too long.

@tautschnig tautschnig assigned kroening and unassigned tautschnig Sep 26, 2018
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: f505207).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/85988064

This fixes a failed attempt to check for quantifiers during goto conversion
by checking earlier in the C front-end.
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: a3fa911).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/86019720

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants