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

Lute/reification step4 testing ast #39

Merged
merged 7 commits into from
Oct 3, 2022

Conversation

lute47lillo
Copy link
Collaborator

SymbolicTerm to Function Transformer.

Tests still needed to verify all working.

@lute47lillo
Copy link
Collaborator Author

@jorgefandinno Okay, I've found some problems with how we are parsing strong negated and negated atoms when using reification. I just realized the issue of using "-" + name on the reify strong negation. Now, the expected program is an UnaryOperator, but the parsed program returns a function of name "-a" which I believe is incorrect.

I believe that I'll have to make some changes on top of the previous reification changes to do it correctly, and to test for equal programs instead of strings.

@jorgefandinno
Copy link
Owner

jorgefandinno commented Sep 9, 2022 via email

Comment on lines +54 to +56
if self.reification:
return ast.UnaryOperation(location, 0, atom)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've finally solved that issue when using reification. The problem was the declaration of the name "-a" of the Function when it should have been an UnaryOperation that had an ast.Function as argument with the name "a".

Comment on lines +52 to +53
sorted_program = sorted(program)
expected_program.sort()
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But, now I'm trying to figure out some issues for the asserting case of the lists being equal. While they are equal, they are being ordered in the wrong order and that is causing tests to fail. I'll look into it tomorrow

Comment on lines 109 to 113
def test_epistemic_atom_with_default_negation(self):
self.assert_equal_program(
parse_program(":- &k{ not a}."),
":- k(not1(u(a))). not1(u(a)) :- not u(a). {k(not1(u(a)))} :- not1(u(a)).",
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specially, I've seen it happening here. The tests with a #Fail above are the ones facing this issue. The rest of the tests are passing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are each of them ordered?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screen Shot 2022-09-13 at 10 20 50 AM

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There you can see how the sorted program (which is the reference correctly parsed program) first has the rule not1(u(a)) :- ... while the expected program (The one we are parsing from the expected string) has the conditional Literal first

@lute47lillo
Copy link
Collaborator Author

The first part of the tests that were failing due to the bug are now failing.

However, I'm having some issues with these ones:

def test_weighted_rules(self):
self.assert_equal_program(
parse_program(":-{a} = 0."),
":-{u(a)} = 0."
)
def test_parameters01(self):
self.assert_equal_program(
parse_program("a(1..n).", ["n"], "parametrized"),
"#program parametrized(n). u(a(1..n)).",
)
def test_parameters02(self):
self.assert_equal_program(
parse_program("a(1..n).", ["n"], "base"), "#program base(n). u(a(1..n))."
)
def test_heuristic(self):
self.assert_equal_program(
parse_program("#heuristic a. [1,sign]", [], "base"),
"#heuristic u(a). [1,sign]",
)
'''

I'll check them later, but it may have something to do with the newly introduced transformer.

Pylint is also failing, but I do not see where the error is.

@lute47lillo
Copy link
Collaborator Author

For the tests:

def test_parameters01(self):
self.assert_equal_program(
parse_program("a(1..n).", ["n"], "parametrized"),
"#program parametrized(n). u(a(1..n)).",
)

 def test_parameters02(self): 
     self.assert_equal_program( 
         parse_program("a(1..n).", ["n"], "base"), "#program base(n). u(a(1..n))." 
     ) 

I'm getting another error, which the sorted program evaluates the Interval 1..n, as being Symbolic term of number 1 and another Symbolic term of a clingo Function with name 'n'.

However, the way the Transformer is set, is that the 2nd Symbolic term is being transformed to an AST.Function of name 'n' and therefore failing the test.

@lute47lillo
Copy link
Collaborator Author

For the tests:

def test_parameters01(self): self.assert_equal_program( parse_program("a(1..n).", ["n"], "parametrized"), "#program parametrized(n). u(a(1..n)).", )

 def test_parameters02(self): 
     self.assert_equal_program( 
         parse_program("a(1..n).", ["n"], "base"), "#program base(n). u(a(1..n))." 
     ) 

I'm getting another error, which the sorted program evaluates the Interval 1..n, as being Symbolic term of number 1 and another Symbolic term of a clingo Function with name 'n'.

However, the way the Transformer is set, is that the 2nd Symbolic term is being transformed to an AST.Function of name 'n' and therefore failing the test.

The idea I've had is to create another visit_Interval after this Transformer is being parsed and re-do the conversion of the interval components to Symbolic Terms,

would that work?

@lute47lillo lute47lillo merged commit 0775e59 into lute/reificationStep4 Oct 3, 2022
@lute47lillo lute47lillo deleted the lute/reificationStep4_testingAST branch October 5, 2022 19:26
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

Successfully merging this pull request may close these issues.

2 participants