Skip to content

simplifier: use new interface #4872

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 2 commits into from
Jul 13, 2019
Merged

simplifier: use new interface #4872

merged 2 commits into from
Jul 13, 2019

Conversation

kroening
Copy link
Member

@kroening kroening commented Jul 3, 2019

  • Each commit message has a non-empty body, explaining why the change was made.
  • n/a Methods or procedures I have added are documented, following the guidelines provided in CODING_STANDARD.md.
  • n/a The feature or user visible behaviour I have added or modified has been documented in the User Guide in doc/cprover-manual/
  • 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).
  • n/a My commit message includes data points confirming performance improvements (if claimed).
  • My PR is restricted to a single feature or bugfix.
  • n/a White-space or formatting changes outside the feature-related changed lines are in commits of their own.

Daniel Kroening added 2 commits July 4, 2019 10:47
This improves type safety.
@kroening kroening force-pushed the simplifier_new_interface2 branch from 719479d to 30c134f Compare July 4, 2019 09:47
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: 30c134f).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/117953528

@codecov-io
Copy link

Codecov Report

Merging #4872 into develop will decrease coverage by 0.01%.
The diff coverage is 75.48%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4872      +/-   ##
===========================================
- Coverage    69.06%   69.05%   -0.02%     
===========================================
  Files         1297     1297              
  Lines       106819   106815       -4     
===========================================
- Hits         73779    73760      -19     
- Misses       33040    33055      +15
Impacted Files Coverage Δ
src/util/simplify_expr_class.h 88.88% <ø> (ø) ⬆️
src/util/simplify_expr_int.cpp 81.48% <53.7%> (-2.19%) ⬇️
src/util/simplify_expr_boolean.cpp 88.15% <78.94%> (-8.99%) ⬇️
src/util/simplify_expr.cpp 81.44% <92.06%> (-0.21%) ⬇️
src/util/mathematical_expr.h 90.47% <0%> (ø) ⬆️
src/util/std_expr.h 89.96% <0%> (+1.3%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a1f0dc7...30c134f. Read the comment docs.

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 accept that most of my comments are beyond the immediate changes done in this PR, but really we should get this cleaned up properly. And I'd rather see it done now then be postponed until some future time. It's changes enabled by this new interface.

@@ -1429,11 +1428,9 @@ bool simplify_exprt::get_values(
return true;
}

bool simplify_exprt::simplify_lambda(exprt &)
simplify_exprt::resultt<> simplify_exprt::simplify_lambda(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.

If we're touching this interface, can we make it consume a const array_comprehension_exprt &expr please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Let's defer -- there is the very independent issue of the confusion between array comprehension and lambda expressions (as in Chruch's lambda calculus). Look at 5f0808c.

@@ -2423,30 +2420,24 @@ simplify_exprt::simplify_byte_update(const byte_update_exprt &expr)
return unchanged(expr);
}

bool simplify_exprt::simplify_complex(exprt &expr)
simplify_exprt::resultt<> simplify_exprt::simplify_complex(const exprt &expr)
{
if(expr.id() == ID_complex_real)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't this be two separate functions rather than branching twice on the same id in quick succession? (Once to figure out we need to call simplify_complex and then this one here. We could then have a typesafe interface.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, can be split; will add to #4874

if(
expr.operands().size() != 2 ||
expr.operands().front().type().id() != ID_bool ||
expr.operands().back().type().id() != ID_bool)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we use to_implies_expr and make sure that does the same amount of sanity checking?

Copy link
Member Author

Choose a reason for hiding this comment

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

added as separate commit.

I wouldn't add the operand type checks to to_implies(). This is what the validate() methods do.

auto new_expr = expr;
new_expr.id(ID_or);
new_expr.op0() = boolean_negate(new_expr.op0());
simplify_node(new_expr.op0());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this actually necessary? We don't consistently do this after boolean_negate

Copy link
Member Author

Choose a reason for hiding this comment

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

Indeed, this is a no-op. Added as separate commit to #4874.

}

bool simplify_exprt::simplify_not(exprt &expr)
simplify_exprt::resultt<> simplify_exprt::simplify_not(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.

Shouldn't this be a const not_exprt &expr?

Copy link
Member Author

Choose a reason for hiding this comment

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

In #4874

@@ -774,15 +771,15 @@ simplify_exprt::resultt<> simplify_exprt::simplify_bitwise(const exprt &expr)
return std::move(new_expr);
}

bool simplify_exprt::simplify_extractbit(exprt &expr)
simplify_exprt::resultt<> simplify_exprt::simplify_extractbit(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.

Interface should be const extractbit_exprt &expr

Copy link
Member Author

Choose a reason for hiding this comment

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

in #4874

}

bool simplify_exprt::simplify_concatenation(exprt &expr)
simplify_exprt::resultt<>
simplify_exprt::simplify_concatenation(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.

const concatentation_exprt &expr

Copy link
Member Author

Choose a reason for hiding this comment

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

added to #4874

}

bool simplify_exprt::simplify_unary_plus(exprt &expr)
simplify_exprt::resultt<> simplify_exprt::simplify_unary_plus(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.

const unary_plus_exprt &expr

Copy link
Member Author

Choose a reason for hiding this comment

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

added to #4874

}

bool simplify_exprt::simplify_unary_minus(exprt &expr)
simplify_exprt::resultt<>
simplify_exprt::simplify_unary_minus(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.

const unary_minus_exprt &expr

Copy link
Member Author

Choose a reason for hiding this comment

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

in #4874

}

bool simplify_exprt::simplify_bitnot(exprt &expr)
simplify_exprt::resultt<> simplify_exprt::simplify_bitnot(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.

const bitnot_exprt &expr

Copy link
Member Author

Choose a reason for hiding this comment

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

in #4874

kroening pushed a commit that referenced this pull request Jul 13, 2019
Follow-up from comment in #4872. The call is a no-op.
@kroening kroening assigned tautschnig and unassigned kroening Jul 13, 2019
@tautschnig tautschnig merged commit a941ba9 into develop Jul 13, 2019
@tautschnig tautschnig deleted the simplifier_new_interface2 branch July 13, 2019 15:17
kroening pushed a commit that referenced this pull request Jul 13, 2019
Follow-up from comment in #4872. The call is a no-op.
kroening pushed a commit that referenced this pull request Jul 14, 2019
Follow-up from comment in #4872. The call is a no-op.
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