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

Lattice Parameterization Inconsistency #15

Closed
DIvanov503 opened this issue Dec 6, 2017 · 5 comments
Closed

Lattice Parameterization Inconsistency #15

DIvanov503 opened this issue Dec 6, 2017 · 5 comments

Comments

@DIvanov503
Copy link

In the file GenericLattices.scala the powerset lattice is parameterized by a characteristic function ch:
class PowersetLattice[A](ch: A => Boolean) extends Lattice
At the same time, the reverse powerset lattice has Set(A) as a parameter:
class ReversePowersetLattice[A](s: Set[A]) extends Lattice
Probably, the class PowersetLattice should be changed as follows:
class PowersetLattice[A](s: Set[A]) extends Lattice

@algobardo
Copy link
Contributor

I think the right change would rather be on the ReversePowersetLattice.
Note that the approach of using the characteristic function still allows you to pass a Set to construct the lattice as Set[A] extends (A) => Boolean: http://www.scala-lang.org/api/2.12.3/scala/collection/Set.html

@DIvanov503
Copy link
Author

I take your point. On the other hand, Idea doesn't seem to recognize the type A if I just replace s: Set[A] by ch: A => Boolean in the ReversePowersetLattice, e.g., it complains about the AvailableExpAnalysis and doesn't compile. Adding asInstanceOf operators fix the problem but it doesn't seem to be a good style. However, I'm a Scala novice and might have missed an elegant way of solving it.

By the way, I'm curious whether there exists a use case where defining a lattice over a subset of a type, that itself does not form a type, is needed.

@DIvanov503
Copy link
Author

Quickfix: replacing s: Set[A] by ch: A => Boolean works well for my reaching definitions analysis implementation. However, there are still typing warnings from Idea that can be eliminated by asInstanceOf. And it requires explicit construction of the bottom element in the ReversePowersetLattice.

@algobardo
Copy link
Contributor

  • As for the use case, having something to pass when constructing the object save us from annotating the generic type. Moreover if you want to be pedantic/defensive the powerset lattice implementation coud check that the lub operation is performed on sets that are subset of the one denoted by ch

  • As for the Idea warnings, Idea scala plugin is not as clever as the scala compiler. You have to live with them. I think there is some work going on for making a Language Server for giving the editors compiler info, but I guess we have to wait for that.

@DIvanov503
Copy link
Author

  • Thank you! The lub return was one of my concerns as well.
  • Thanks for clarification!

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

No branches or pull requests

2 participants