-
Notifications
You must be signed in to change notification settings - Fork 18
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
Map Lattice #56
Comments
I think we can add that. But I'm curious, wouldn't that be isomorphic to pulling out the What I mean is: If you have lattice foo(A, Map<B, C>); wouldn't that be isomorphic to lattice foo(A, B, C); ? It looks like the former is the curried form of the latter. Maybe there is something I'm missing here though, as I haven't thought about it much. |
There are some differences, but you're right. Taking the view of (lattice) relations as lattice-valued functions, what you describe is exactly the analogue of currying. More specifically, it's like Of course, what currying gives us is higher-order lattice relations. We can store those Higher-order lattice relations have similar benefits to higher-order functions in allowing common logic to be abstracted. As a mildly silly example:
|
Ah, you are absolutely right. In fact, that is exactly what we did in the BYODS paper (see section 5.6). There, we defined a If I'm not mistaken, the |
I may make a PR for this, but, in addition to the
Set
lattice, another natural instance is for (a wrapper around)BTreeMap
/HashMap
. Mathematically, functions into a lattice form a lattice pointwise. We can view a map as a partial function from keys to (lattice) values and then make it total by mapping intoOption
which we view as freely adding a bottom element (and this is how the trait implementation forOption
behaves).The upshot is the obvious implementation where we union/intersect the keys and use join/meet for any keys in both maps is a lattice corresponding to the mathematical description above. Indeed, the
Set
lattice is exactly thisMap
lattice with the values being the()
lattice. A nice consequence of this is tries with values in lattices become a lattice too "automatically".That is,
has a simple
Lattice
implementation that just delegates to its interior type.(A bit of an aside, egglog takes the view that maps/partial functions into a lattice rather than relations are the primitive notion with relations being viewed as maps into
()
. I find this perspective, which could perhaps be supported by alternative notation, e.g.lattice shortest_path(i64, i64) := Dual<u32>;
, to be more self-explanatory.)The text was updated successfully, but these errors were encountered: