-
Notifications
You must be signed in to change notification settings - Fork 86
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
AllBottom.composeWith is broken #37
Comments
Unfortunately I do not think your suggestion is valid. In IDE, edge functions are composed before they are evaluated. Composition happens in step 1 of the algorithm, evaluation in step 2. Hence it would be invalid to do as you propose: this would intertwine composition and evaluation. I wonder: what gave you the idea that the current implementation could be incorrect? |
@ericbodden Apologies, my initial post was a bit misleading. Let me try to clarify. The defining identity of function composition is this: for appropriate f, g, and x
(In words, the composition of f and g applied to x is the same as f applied to g applied to x). Insofar as the f.composeWith(g).computeTarget(x) == g.computeTarget(f.computeTarget(x)) And indeed, if AllBottom<T> allBot = new AllBottom(bot); the following does hold: allBot.composeWith(f).computeTarget(x) == f.computeTarget(allBottom.computeTarget(x)) However, if @Test
public void test_compose() {
final Object top = new Object(); // top of the lattice
final Object bot = new Object(); // bottom of the lattice
final Object ele1 = new Object(); // some element in the lattice
final Object ele2 = new Object(); // some other element in the lattice
final AllTop<Object> allTop = new AllTop<Object>(top);
final AllBottom<Object> allBot = new AllBottom<Object>(bot);
final EdgeFunction<Object> func = new EdgeFunction<Object>(){
@Override
public EdgeFunction<Object> meetWith(EdgeFunction<Object> otherFunction) {
return null;
}
@Override
public boolean equalTo(EdgeFunction<Object> other) {
return null;
}
@Override
public Object computeTarget(Object source) {
if (source == bot) {
return ele2;
}
return ele1;
}
@Override
public EdgeFunction<Object> composeWith(EdgeFunction<Object> secondFunction) {
return null;
}
};
Assert.assertTrue("", allBot.composeWith(func).computeTarget(ele2).equals(func.computeTarget(allBot.computeTarget(ele2))));
} However, from your comments on #36, it sounds like you might not expect this to work. In this case, I think there should either be a comment at the top of |
Hi again. I have given this some more thought. The current implementation does make sense in the context in which it is used - the IFDS solver - but only there. However, I agree with you that it would make sense to make this class usable also in other contexts. In this case, your original suggestion makes a lot of sense, actually (generating a constant function). I will see whether this is possible without too large a change. |
Hmm, as you already foresaw, I am struggling a bit. Please have a look here... The problem seems to be within |
@langston-barrett do you have any more input on this? If not then I'd go the route of not actually opening up those classes after all, but rather documenting that they are for internal use only, and that one would need customized classes for a custom value domain. |
No, apologies, the project I was working on ended and I am no longer using Heros |
It is currently implemented like this:
https://github.com/Sable/heros/blob/1a0a5be37bc321b0745c3e080e3e70543f5f04b4/src/heros/edgefunc/AllBottom.java#L28-L32
The
if
case is right, but theelse
case is wrong. The value should not besecondFunction
, but a constant function that returns the the valuesecondFunction.computeTarget(bottomElement)
.Unfortunately, this is not easy to fix: there is no generic way to construct a constant edge function since the user can supply their own lattice and edge functions. Something to this effect would have be added to the
EdgeFunction
interface or something.The text was updated successfully, but these errors were encountered: