def notify(self, ground: List['Literal'], subs: 'Substitutions', parent: Union[Alfa, 'Beta']): from depysible.domain.definitions import Rule payload = (ground, subs) if payload not in self.memory: self.memory.append(payload) lit = self.rule.head.substitutes(subs) # if self.rule.type is RuleType.STRICT: # fact = Rule(lit, self.rule.type, []) # if fact not in self.agenda: # self.agenda.append(fact) rule = Rule(lit, self.rule.type, ground) if rule not in self.agenda: self.agenda.append(rule) self.root.notify(lit)
def visit_strict(self, node: Node, children: List) -> Rule: try: return Rule(children[0], RuleType.STRICT, children[1]) except IndexError: return Rule(children[0], RuleType.STRICT, [])
def visit_defeasible(self, node: Node, children: List) -> Rule: try: return Rule(children[0], RuleType.DEFEASIBLE, children[1]) except IndexError: return Rule(children[0], RuleType.DEFEASIBLE, [])