Skip to content
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

Use simplifying constructor for PEq #545

Merged
merged 1 commit into from
Aug 27, 2024
Merged

Conversation

blishko
Copy link
Collaborator

@blishko blishko commented Aug 27, 2024

Description

The idea is to always normalize Prop equalities such that concrete values appear on the left-hand-side.

This follows the example of the helper functions for expressions, that also immediately simplify if they get concrete arguments, and normalize arguments for commutative operations.

Checklist

  • tested locally
  • added automated tests
  • updated the docs
  • updated the changelog

The idea is to always normalize Prop equalities such that concrete
values appear on the left-hand-side.

This follows the example of the helper functions for expressions, that also
immediately simplify if they get concrete arguments, and normalize
arguments for commutative operations.
@@ -432,6 +432,14 @@ data Prop where
PBool :: Bool -> Prop
deriving instance (Show Prop)

mkPEq :: (Typeable a) => Expr a -> Expr a -> Prop
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure what would be the best name.
I originally had peq, to follow the example of the helper functions for Expr, but I don't like that very much. I think that mkPEq better conveys what the function is doing. We could also use full makePEq.
@msooseth, opinions?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds like a good name to me.

@blishko blishko requested a review from msooseth August 27, 2024 15:50
Copy link
Collaborator

@msooseth msooseth left a comment

Choose a reason for hiding this comment

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

I think traversals should not change things. Otherwise it's actually really good! I also checked, and you left no PEq constructor untouched :)

src/EVM/Traversals.hs Show resolved Hide resolved
src/EVM/Traversals.hs Show resolved Hide resolved
@@ -432,6 +432,14 @@ data Prop where
PBool :: Bool -> Prop
deriving instance (Show Prop)

mkPEq :: (Typeable a) => Expr a -> Expr a -> Prop
Copy link
Collaborator

Choose a reason for hiding this comment

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

This sounds like a good name to me.

@msooseth
Copy link
Collaborator

OK, merging. Let's make sure to add a CHANGELOG entry next time, though! Also, we should add a fuzz test for this as well as the Expr LHS/RHS ;)

@msooseth msooseth merged commit 8f1b9a1 into main Aug 27, 2024
9 checks passed
@msooseth
Copy link
Collaborator

Thanks so much! Really good stuff! We should have done this ages ago!

@msooseth msooseth deleted the simplifying-equality-constructor branch August 27, 2024 16:50
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.

2 participants