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

Add support for nullary predicates #130

Open
aannleax opened this issue Feb 1, 2023 · 2 comments
Open

Add support for nullary predicates #130

aannleax opened this issue Feb 1, 2023 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@aannleax
Copy link
Member

aannleax commented Feb 1, 2023

For now, rules with nullary predicates are not handled correctly (or at all, it'll probably just crash). This would be rule sets like

trigger() :- a(x, x) .
result(x, z) :- b(x, y), c(y, z), trigger() .

On first glance, a good approach would to implement nullary predicates in the logical layer in the TableManager and not have empty tables in the DatabaseInstance. The data structure for rules would then split nullary atoms into its own list, which would allow the TableManager to check the presence of the required "tables" before executing the rule. This would handle cases where the nullary atom appears in the body.

Nullary atoms in the head need a special execution strategy that does not return a Trie but rather a bool that indicates whether there is one match for the body. We have a special materialization function scan_is_empty that would need to be used. One thing to keep in mind is rules with multiple head atoms

same(x), trigger() :- a(x, x) .

It seems like you want to materialize the same(x) table and derive trigger(). But don't forget that results are sometimes not materialized, so here

b(x, y), trigger(), :- a(x, y) .

the table for b would just be a reference to the table for a and we would still need to derive trigger.

Implementing the above should make it trivial to support boolean conjunctive queries (assuming #126 is implemented).

@aannleax aannleax added the enhancement New feature or request label Feb 1, 2023
@mkroetzsch
Copy link
Member

mkroetzsch commented Apr 14, 2023

In the absence of a fully engineered solution for "Boolean tries" and "Boolean tables", one could also emulate this by replacing nullary atoms like trigger() with unary ones such as trigger(0) (with 0 an int type without a dictionary entry). This should work in body and head. This translation should happen at the intersection of logical and physical layer.

Another primary task here seems to be that the parser needs to be updated to read this at all. Right now, there are errors when trying such programs.

@mmarx mmarx added this to nemo Apr 26, 2023
@github-project-automation github-project-automation bot moved this to Todo in nemo Apr 26, 2023
@mmarx mmarx added this to the Beyond the first release milestone Apr 26, 2023
@aannleax aannleax self-assigned this Jul 26, 2023
@aannleax aannleax modified the milestones: Release 0.5.0, Release 0.6.0 Mar 27, 2024
@aannleax aannleax changed the title Add support for nullary predicates and BCQs Add support for nullary predicates Aug 28, 2024
@aannleax
Copy link
Member Author

Might potentially be solved by #512.

@monsterkrampe monsterkrampe removed this from the Release 0.6.0 milestone Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Todo
Development

No branches or pull requests

4 participants