The PresentLink is used to search for a pattern, in it's literal form (i.e. without evaluating the pattern after finding a grounding). It is normally used with the pattern matcher. By preventing the subsequent evaluation of the grounded pattern, it can be thought of as a form of quotation (see also QuoteLink). It can also be thought of as a kind of "there exists" link (see ExistsLink), asking that the indicated patterns must exist within the AtomSpace.
Unlike the ExistsLink, the PresentLink does not bind it's variables, leaving them as free variables. This allows the PresentLink to be composed with other patterns having the same variable names, so as to form more complex patterns.
The PresentLink indicates a pattern that becomes true when each atom in it's outgoing set is present in the AtomSpace; that is, when the entire term, including all variables in it, 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, any variable names in PresentLink are free; they "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.
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 converse of AbsentLink, and thus, behaves like
(NotLink (AbsentLink)). Likewise, AbsentLink should behave like
The "for-all" analog of PresentLink is AlwaysLink; the AlwaysLink requies that the indicated pattern always be present in any grounding. Mathematically speaking, "there exists" and "for all" are the left and right adjoint functors to a relation.
See link comparison for a tabular summary of these various properties.
The pattern matcher, as originally implemented, used a syntax that conflated together two different ideas: one was a search for patterns, the other was the evaluation of predicates to see if the resulting match should be accepted or not. This works fine, as long as one does not want to search for a pattern that just happens to look like a predicate. PresentLink is meant to be used to disambiguate this.
Earlier attempts to fix this problem focused on using QuoteLinks; however, this proved inadequate, as it was not clear how deeply the quote should extend. This in turn forced the use of the UnquoteLink, which then introduces additional difficulties and confusion when the results need to be reported. By contrast, the PresentLink provides a clean, unambiguous semantics. The PresentLink simply says: "just search for this as written, and do nothing more than the search."
A typical 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.
The PresentLink can be emulated by using multiple arity-one ChoiceLinks. For example:
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.