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

[analysis] Implement an Int lattice #6037

Merged
merged 2 commits into from
Oct 25, 2023
Merged

[analysis] Implement an Int lattice #6037

merged 2 commits into from
Oct 25, 2023

Conversation

tlively
Copy link
Member

@tlively tlively commented Oct 21, 2023

Implement a generic lattice template for integral types ordered by <.

ASSERT_EQ(elem, 0);

EXPECT_TRUE(int32.join(elem, 100));
ASSERT_EQ(elem, 100);
Copy link
Member

Choose a reason for hiding this comment

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

How am I supposed to understand this conceptually? That is, why does joining go "up" the integer values rather than down?

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 the literature, a lattice is a set and a "less than or equal" relation that together satisfy various properties (e.g. reflexivity, transitivity, anti-symmetry, least upper bound, greatest lower bound). Since we call the lattice relation "less than or equal," it is natural to use <= as the default relation for the lattice of integers.

Use cases that require >= instead can use Inverted<UInt32>, introduced in a later PR. If neither ordering is appropriate, it might be a use case for Flat<uint32_t>, also introduced in a later PR.

Copy link
Member

Choose a reason for hiding this comment

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

I see, thanks. I think comments that briefly mention this and related things would be useful, to not assume the reader is completely familiar with that literature.

@tlively
Copy link
Member Author

tlively commented Oct 25, 2023

Merge activity

  • Oct 25, 1:00 PM: @tlively started a stack merge that includes this pull request via Graphite.
  • Oct 25, 2:19 PM: Graphite rebased this pull request as part of a merge.
  • Oct 25, 2:55 PM: @tlively merged this pull request with Graphite.

Base automatically changed from bool-lattice to main October 25, 2023 18:19
Implement a generic lattice template for integral types ordered by `<`.
@tlively tlively merged commit a09ea69 into main Oct 25, 2023
14 checks passed
@tlively tlively deleted the int-lattice branch October 25, 2023 18:55
radekdoulik pushed a commit to dotnet/binaryen that referenced this pull request Jul 12, 2024
Implement a generic lattice template for integral types ordered by `<`.
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.

3 participants