PresentLink

From OpenCog
Jump to: navigation, search

The PresentLink is a proposed link type to be used with the pattern matcher. It has NOT been implemented! Or rather, its implementation is very incomplete; it is usable in a few very narrow situations, but will otherwise lead to failure.

The PresentLink is a link type that returns true if each atom in it's outgoing set is present in the atomspace; specifically, if these atoms can all be simultaneously grounded. This suggests that it is similar to a SatisfactionLink -- except that a SatisfactionLink binds its variables, while a PresentLink does not. That is, variable names "leak out" of a PresentLink, whereas they do not leak in a SatisfactionLink. This means that the PresentLink can be used inside of a BindLink or a GetLink or a SatisfactionLink to define complex graphs, using the boolean operators AndLink, OrLink, NotLink, etc. Unlike SatisfactionLink, a PresentLink cannot be used with the cog-bind function.

The PresentLink is closely related to the ChoiceLink, in the way that and and or are related: The PresentLink requires each atom in its outgoing set to be present in the atomspace, whereas the ChoiceLink requires that at least one (any one) of these be present.

PresentLink is meant to be conversee of AbsentLink, and thus, should behave like (NotLink (AbsentLink)). Likewise, AbsentLink should behave like (NotLink (PresentLink)). See link comparison for a tabular summary.

Proposal

The goal of proposing the PresentLink is to solve the fact that the pattern matcher has evolved into a system that does two related things: first, it searches for patterns; second, it evaluates expressions to see if the resulting match should be accepted or not. Thus, in the current pattern matcher, it can be ambiguous as to whether a pattern is being searched for, or whether it is being used as a predicate to asses the acceptance of a match. PresentLink is meant to be used to disambiguate this.

See this github discusssion for background motivation.

Usage

One possible usage might look like this:

GetLink
   AndLink
      PresentLink
         clause A
         clause B
         clause C
      EvaluationLink
         GPN Z

In this example, the three clauses clause A, B and C must all be present in the atomspace; thus PresentLink works like an AndLink for presence. Contrast this with ChoiceLink, which behaves like an (exclusive)-OrLink:

GetLink
   AndLink
      ChoiceLink
         clause A
         clause B
         clause C
      EvaluationLink
         GPN Z

The above is successful if any one of clause A, B or C appear in the atomspace.

In both cases, the EvaluationLink must also evaluate to true. The EvaluationLink here is a stand-in for any virtual link: it could be a GreaterThanLink, EqualLink, and so on.

The PresentLink can be emulated by using multiple arity-one ChoiceLink. This works today:

GetLink
   AndLink
      ChoiceLink
         clause A
      ChoiceLink
         clause B
      ChoiceLink
         clause C
      EvaluationLink
         GPN Z

The above will succeed only if clause A, B and C are present in the atomspace, since the ChoiceLink evaluates to true only if one of its arguments can be found.