graal
                                
                                 graal copied to clipboard
                                
                                    graal copied to clipboard
                            
                            
                            
                        BUG: parseAtom does not preserve variable names
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?
It's because in
p(X).
q(X).
the two X must be different. see http://graphik-team.github.io/graal/doc/dlgp
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?
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 ?
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.