Open daisylab opened 1 year ago
It's related to:
https://ibm.github.io/LNN/education/examples/reasoning.html#more-complex-reasoning-example
the code is:
from lnn import (Predicate, Variable, Join, And, Exists, Implies, Forall, Model, Fact, World) model = Model() # Instantiate a model. x, y, z, w = map(Variable, ['x', 'y', 'z', 'w']) # Define and add predicates to the model. owns = model['owns'] = Predicate('owns', 2) # binary predicate missile = model['missile'] = Predicate('missile') american = model['american'] = Predicate('american') enemy = model['enemy'] = Predicate('enemy', 2) hostile = model['hostile'] = Predicate('hostile') criminal = model['criminal'] = Predicate('criminal') weapon = model['weapon'] = Predicate('weapon') sells = model['sells'] = Predicate('sells', 3) # ternary predicate # Define and add the background knowledge to the model. america_enemies = ( Forall(x, Implies(enemy(x, (y, 'America')), hostile(x), ), world=World.AXIOM) ) model.add_knowledge(america_enemies) # Define queries query = Exists(x, criminal(x)) model.add_knowledge(query) # Add facts to model. model.set_facts({ owns: {('Nono', 'M1'): Fact.TRUE}, missile: {'M1': Fact.TRUE}, american: {'West': Fact.TRUE}, enemy: {('Nono', 'America'): Fact.TRUE}, }) model.infer() print(model[query].true_groundings)
and it says
Traceback (most recent call last): File "/home/sungjin/home/lnn-examples/complex2.py", line 1, in <module> from lnn import (Predicate, Variable, Join, And, ImportError: cannot import name 'Join' from 'lnn' (/home/sungjin/.virtualenvs/lnn/lib/python3.10/site-packages/lnn/__init__.py)
It's related to:
https://ibm.github.io/LNN/education/examples/reasoning.html#more-complex-reasoning-example
the code is:
and it says