OpenCog

ImplicationLink

From OpenCog

An ImplicationLink is used by OpenCog to express if...then... relations. The structure of an ImplicationLink is a set of predicates to be anded together (disjunct normal form), followed by one or more implicands. ImplicationLinks may contain variables that are bound for the scope of the implication. They should be thought of as expressions in first-order logic; i.e. VariableNodes may only be grounded by nodes, not links; grounding by links is discussed below.

ImplicationLinks encode basic logical implication P->Q, i.e. if P then Q as:

ImplicationLink
  P
  Q 

where P is the predicate and Q is the implicand.

Contents

Example

An example might be:

# IF _subj(be,$var0) ^ _obj(be,$var1) THEN thing($var1, $var0)

which, when written out in OpenCog format, would be

ImplicationLink
   AndLink
      EvaluationLink
         PredicateNode "_subj"
         ListLink
            ConceptNode "be"
            VariableNode  "$var0"
      EvaluationLink
         PredicateNode "_obj"
         ListLink
            ConceptNode "be"
            VariableNode "$var1"
   EvaluationLink
      PredicateNode "thing"
      ListLink
         VariableNode "$var1"
         VariableNode "$var0"

Note that each triple was expressed in terms of EvaluationLinks. A perl script that will convert the first, short form, into the second, can be found in the source tree, at opencog/nlp/triples/rules-to-implications.pl. Additional documentation can be found in opencog/nlp/triples/README

Evaluation

OpenCog has both a chainer and a simple evaluator The chainer is PLN; see that page for details. The simple evaluator is implemented in the libquery module, whose source code is in opencog/query. The simple evaluator can be invoked from the scheme shell, as described on the VariableScopeLink page.

At this time, the simple evaluator uses "crisp boolean logic" to determine if the predicate is true. Thus, truth values must be set, and must be true. NotLink can be used to invert; thus, if a NotLink is present in the predicate, the indicated clause must be absent, or, if present, must evaluate to 'false'.

Callouts to C++/scheme code can be done by using ExecutionLinks.

Propagating Truth Values

Note that the overall structure of the ImplicationLink is of the form

  ImplicationLink
     P
     Q

and so can be thought of as being much like the expression P->Q from first-order logic. However, in OpenCog, truth values have far more complex structures; there are various ways in which a truth value on P should be propagated to Q.

The query implementation uses C++ callbacks to handle this. Currently, only two callbacks are implemented: one that ignores truth values, and one that implements crisp logic.

When the crisp-logic callback evaluates a grounding for P, it does not alter P 's truth value. However, when instantiating an instance Q, it does set its truth value based on the grounding for P.

More general callbacks could be developed that propagate truth values in other ways.

Second-Order Logic

ImplicationLinks should be thought of as expressions in first-order logic; i.e. VariableNodes may only be grounded by nodes, not links. The restriction to first-order logic is to avoid the infinitely recursive expressions that can appear in second-order logic, and thus avoid potential infinite loops that would occur when they're evaluated. Note that its impractical to determine when an expression might be recursive: this is equivalent to the Turing halting problem.

Note that this caveat doesn't apply to PLN.

See also