Greetings!
I recently started using pytholog and had a few issues when trying to test out some facts and rules. I was wondering if the observations below are valid based on how pytholog works?
Thanks.
In Pytholog 2.4.1, modifying a fact in the knowledge base that invalidates a rule does not update the query results as expected. This leads to incorrect results where the query returns YES even though the condition for the rule is no longer satisfied.
Steps to Reproduce
Define a knowledge base with the following facts and rule:
import pytholog as pl
kb = pl.KnowledgeBase("singing")
kb([
"listeningToMusic(dany)",
"singing(ed)",
"singing(dany):- listeningToMusic(dany)"
])
print(kb.query(pl.Expr("singing(dany)"))) # Expected: YES
Modify the fact to invalidate the rule:
kb = pl.KnowledgeBase("singing")
kb([
"listeningToMusic(ed)", # Changed from dany to ed
"singing(ed)",
"singing(dany):- listeningToMusic(dany)"
])
print(kb.query(pl.Expr("singing(dany)"))) # Expected: NO
Expected Behavior
When listeningToMusic(dany) exists, the query singing(dany) should return YES.
When listeningToMusic(dany) is removed or replaced (e.g., listeningToMusic(ed)), the query singing(dany) should return NO.
Observed Behavior
In version 2.4.1:
the query singing(dany) returns YES even after replacing listeningToMusic(dany) with listeningToMusic(ed).
In version 2.3.1:
the behavior is correct:
Returns YES when listeningToMusic(dany) is present.
Returns NO when the condition is no longer satisfied.
Environment
Pytholog Version: 2.4.1
Python Version: Python 3.10.7
Operating System: Windows 11
Greetings!
I recently started using pytholog and had a few issues when trying to test out some facts and rules. I was wondering if the observations below are valid based on how pytholog works?
Thanks.
In Pytholog 2.4.1, modifying a fact in the knowledge base that invalidates a rule does not update the query results as expected. This leads to incorrect results where the query returns YES even though the condition for the rule is no longer satisfied.
Steps to Reproduce
Define a knowledge base with the following facts and rule:
Modify the fact to invalidate the rule:
Expected Behavior
When listeningToMusic(dany) exists, the query singing(dany) should return YES.
When listeningToMusic(dany) is removed or replaced (e.g., listeningToMusic(ed)), the query singing(dany) should return NO.
Observed Behavior
In version 2.4.1:
the query singing(dany) returns YES even after replacing listeningToMusic(dany) with listeningToMusic(ed).
In version 2.3.1:
the behavior is correct:
Returns YES when listeningToMusic(dany) is present.
Returns NO when the condition is no longer satisfied.
Environment
Pytholog Version: 2.4.1
Python Version: Python 3.10.7
Operating System: Windows 11