IBM / LNN

A `Neural = Symbolic` framework for sound and complete weighted real-value logic
https://IBM.github.io/LNN/
Apache License 2.0
226 stars 438 forks source link

Downward inference from fully quantified universal #80

Open NaweedAghmad opened 1 year ago

NaweedAghmad commented 1 year ago

@KyleErwin the code below seems to have two issues

  1. Setting the truth of the universal quantifier doesn't directly update the proposition
  2. Downward inference from the universal seems to break
from lnn import *
x = Variable('x')
cry = Predicate('Cry')
sad = Predicate('Sad')
rule = Forall(x, Implies(cry(x), sad(x)))

model = Model()
model.add_knowledge(rule, cry)
model.add_data({
    cry: {
        'John': Fact.TRUE,
        'Bob': Fact.TRUE,
    },
    rule: Fact.TRUE,
})

model.print()
model.infer()
model.print()
File "lnn/symbolic/logic/unary_operator.py", line 165, in downward
  return self._fully_quantified_downward()
File "lnn/symbolic/logic/unary_operator.py", line 270, in _fully_quantified_downward
  return operand.neuron.aggregate_bounds(groundings, bounds[..., 0])
IndexError: index 0 is out of bounds for dimension 1 with size 0