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

Cannot import Join from lnn. #85

Open
daisylab opened this issue Mar 11, 2023 · 0 comments
Open

Cannot import Join from lnn. #85

daisylab opened this issue Mar 11, 2023 · 0 comments

Comments

@daisylab
Copy link

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)
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

No branches or pull requests

1 participant