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 constrains not enforced on input in ascent_run #26

Open
B-Lorentz opened this issue Dec 15, 2023 · 2 comments
Open

Lattice constrains not enforced on input in ascent_run #26

B-Lorentz opened this issue Dec 15, 2023 · 2 comments

Comments

@B-Lorentz
Copy link

The following fails in 0.5.0:

 assert_eq!(ascent_run! {
        lattice a(i64) = vec![(0,),(1,)];
    }.a, vec![(1,)]);

Presumably because the lattice joins are not executed on the incoming vector, as it is seen as 'input'
I think it would make sense to generate an intermediate input relation, so the lattice's rules are upheld.

@s-arash
Copy link
Owner

s-arash commented Dec 16, 2023

I see! The issue (or one issue) with trying to "fix" this is that Ascent never removes elements from input vectors, and I think modifying this behavior is probably not worth it to get the above program to behave as you would expect.

Note that you could easily achieve what you are looking for by doing something like this:

ascent! {
  relation a_proto(i64) = vec![(0,), (1,)];
  lattice a(i64);
  a(x) <-- a_proto(x);
}

Or this:

ascent! {
  lattice a(i64);
  a(x) <-- for x in vec![0, 1];
}

@B-Lorentz
Copy link
Author

@s-arash
Thanks. I'm aware of the workarounds. What if ascent just refused programs where lattices are direct input relations, in order to prevent the user being surprised (as either her input facts disappearing or the lattice rules not being obeyed can be surprising)?
This wouldn't remove any expressive power, as you have shown easy workarounds exist.

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