We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi Team,
I am working on a rule that doesn't seem to give expected results. The data and rule are as below:
Friends.add_data({ ("P", "A"): Fact.TRUE, ("P", "B"): Fact.TRUE, ("Q", "C"): Fact.TRUE, ("Q", "D"): Fact.TRUE }) Popular.add_data({ "A": Fact.TRUE, "B": Fact.FALSE, "C": Fact.FALSE, "D": Fact.FALSE })
Rule: P is a Star only if ALL friends of P are popular.
Here is the code:
from lnn import Predicate, Variable, Forall, Fact, Model, And, Implies, World
Friends = Predicate('Friends', arity=2) Popular = Predicate('Popular') Star = Predicate('Star')
x, y = Variable('x'), Variable('y')
Friends.add_data({ ("P", "A"): Fact.TRUE, ("P", "B"): Fact.TRUE, ("Q", "C"): Fact.TRUE, ("Q", "D"): Fact.TRUE })
Popular.add_data({ "A": Fact.TRUE, "B": Fact.FALSE, "C": Fact.FALSE, "D": Fact.FALSE })
rule = Forall(x, Implies(Forall(y, And(Friends(x, y), Popular(y))), Star(x)))
model = Model() model.add_knowledge(Friends, Popular, Star, rule)
model.infer()
The result here gives me Star("P") True and Star("Q") = True for all values of popular of a person.
Expected result from above: Star("P") False and Star("Q") = False ( Since only A is popular)
If both A and B are popular: Star("P") True and Star("Q") = False
If all are popular: Star("P") True and Star("Q") = True
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Hi Team,
I am working on a rule that doesn't seem to give expected results. The data and rule are as below:
Friends.add_data({
("P", "A"): Fact.TRUE,
("P", "B"): Fact.TRUE,
("Q", "C"): Fact.TRUE,
("Q", "D"): Fact.TRUE
})
Popular.add_data({
"A": Fact.TRUE,
"B": Fact.FALSE,
"C": Fact.FALSE,
"D": Fact.FALSE
})
Rule: P is a Star only if ALL friends of P are popular.
rule = Forall(x, Implies(Forall(y, And(Friends(x, y), Popular(y))), Star(x)))
Here is the code:
from lnn import Predicate, Variable, Forall, Fact, Model, And, Implies, World
Friends = Predicate('Friends', arity=2)
Popular = Predicate('Popular')
Star = Predicate('Star')
x, y = Variable('x'), Variable('y')
Friends.add_data({
("P", "A"): Fact.TRUE,
("P", "B"): Fact.TRUE,
("Q", "C"): Fact.TRUE,
("Q", "D"): Fact.TRUE
})
Popular.add_data({
"A": Fact.TRUE,
"B": Fact.FALSE,
"C": Fact.FALSE,
"D": Fact.FALSE
})
rule = Forall(x, Implies(Forall(y, And(Friends(x, y), Popular(y))), Star(x)))
model = Model()
model.add_knowledge(Friends, Popular, Star, rule)
model.infer()
model.print()
The result here gives me Star("P") True and Star("Q") = True for all values of popular of a person.
Expected result from above:
Star("P") False and Star("Q") = False ( Since only A is popular)
If both A and B are popular:
Star("P") True and Star("Q") = False
If all are popular:
Star("P") True and Star("Q") = True
The text was updated successfully, but these errors were encountered: