Skip to content

Inefficient Equation renaming #2438

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 12 commits into from
Mar 10, 2021

Conversation

andreiburdusa
Copy link
Contributor

@andreiburdusa andreiburdusa commented Mar 4, 2021

Fixes #2120
This pull request addresses the last two checkboxes, but Target was already removed in #2344.


Review checklist

The author performs the actions on the checklist. The reviewer evaluates the work and checks the boxes as they are completed.

  • Summary. Write a summary of the changes. Explain what you did to fix the issue, and why you did it. Present the changes in a logical order. Instead of writing a summary in the pull request, you may push a clean Git history.
  • Documentation. Write documentation for new functions. Update documentation for functions that changed, or complete documentation where it is missing.
  • Tests. Write unit tests for every change. Write the unit tests that were missing before the changes. Include any examples from the reported issue as integration tests.
  • Clean up. The changes are already clean. Clean up anything near the changes that you noticed while working. This does not mean only spatially near the changes, but logically near: any code that interacts with the changes!

@andreiburdusa andreiburdusa marked this pull request as ready for review March 4, 2021 12:32
@ttuegel ttuegel requested review from ttuegel and ana-pantilie March 4, 2021 15:19
Comment on lines 159 to 163
attemptEquation
sideCondition
(not . freeEquationVariableName >>= assert -> termLike)
equation
=
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
attemptEquation
sideCondition
(not . freeEquationVariableName >>= assert -> termLike)
equation
=
attemptEquation sideCondition termLike equation =
assert (not $ freeEquationVariableName termLike) $

Comment on lines 316 to 321
freeEquationVariableName
:: HasFreeVariables pat RewritingVariableName => pat -> Bool
freeEquationVariableName pat =
any
isSomeEquationVariableName
(from @_ @(Set.Set _) . freeVariables @_ @RewritingVariableName $ pat)
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest naming this function hasFreeEquationVariables.

Comment on lines 79 to 92

assertNoFreeEquationVariableName
:: Condition RewritingVariableName
-> Condition RewritingVariableName
assertNoFreeEquationVariableName (Conditional () predicate substitution) =
let
predicate' =
assert (not . freeEquationVariableName $ predicate) predicate
substitution' =
mapTerms
(\t -> assert (not . freeEquationVariableName $ t) t)
substitution
in
Conditional () predicate' substitution'
Copy link
Contributor

Choose a reason for hiding this comment

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

This assertion should appear in Kore.Equation.Application after matching and unification on function arguments.

@andreiburdusa andreiburdusa requested a review from ttuegel March 5, 2021 10:25
Comment on lines 198 to 199
assert (not . hasFreeEquationVariableName $ equation')
$ assert (not . hasFreeEquationVariableName $ predicate)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be factored out? I think it's a little too verbose and it takes longer to read than necessary.

@@ -156,6 +157,7 @@ attemptEquation
-> Equation RewritingVariableName
-> simplifier (AttemptEquationResult RewritingVariableName)
attemptEquation sideCondition termLike equation =
assert (not $ hasFreeEquationVariableName termLike) $
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we ever use hasFreeEquationVariableName on its own (without negating it)? Could we just turn hasFreeEquationVariableName into withoutFreeEquationVariables?

@andreiburdusa andreiburdusa merged commit 7d3ee1b into master Mar 10, 2021
@andreiburdusa andreiburdusa deleted the initialize-equations-EquationVariableName branch March 10, 2021 09:47
@MirceaS MirceaS mentioned this pull request Apr 7, 2021
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.

Inefficient Equation renaming
3 participants