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

BUG: parseAtom does not preserve variable names #11

Open
shade-belisar opened this issue Jan 10, 2019 · 4 comments
Open

BUG: parseAtom does not preserve variable names #11

shade-belisar opened this issue Jan 10, 2019 · 4 comments

Comments

@shade-belisar
Copy link

When parsing the Atom "predicate(X)" with DlgpParser.parseAtom, the result is "predicate\1(I0)". I would expect it to be "predicate\1(X)". Is there a reason why the variable name is ignored, or is this a bug?

@sipi
Copy link
Contributor

sipi commented Jan 10, 2019

It's because in

p(X).
q(X).

the two X must be different. see http://graphik-team.github.io/graal/doc/dlgp

@shade-belisar
Copy link
Author

I see. Followup question: What is the use case of parsing an atom with variables if the names are not kept? And why does parseRule preserve the variable names?

@sipi
Copy link
Contributor

sipi commented Jan 10, 2019

It just asserts that there exists X such as p(X). But, in practice with Graal we usually put all facts in a same AtomSet so we can't assert that there exists X such as p(X) and q(X) which is more specific. So it's why the Graal's dlgp parser rewrites variable names to get "there exists IO, I1 such as p(I0), p(I1)" which is logically equivalent to (there exists X such as p(X)) and (there exists X such as p(X)).

To rules and queries, variable names remain local in Graal so no need to rewrite.

However, it's true that we should provide a way to disable this behavior.
What is your use case ?

@shade-belisar
Copy link
Author

I am working on importing Graal into VLog4J. While I am uncertain what the use case for Atoms with Variables is (if one wanted to use them in rules, one would simply create a rule via the parser), it is possible someone will do this. In that case, I want to be able to provide comprehensive documentation explaining what is happening.

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