The AndLink is a kind of Link used to conjoin truth values. The precise semantics depends on the context in which it is used. There are three basic ways in which AndLink is used in opencog:
- By PLN, during logical reasoning, to determine the truth or falsehood of something;
- By cog-evaluate! to evaluate the truth of expressions containing proceedural elements
- By the pattern matcher, to combine the presence or absence of subgraphs during a subgraph query. This may include evaluation as well.
The AndLink can sometimes be problematic for data representation. Because all links are immutable, terms can neither be added nor removed from the AndLink, once it is specified. Because the AndLink is an UnorderedLink, certain types of pattern matching can require n-factorial algorithms to explore all possible permutations. These issues are discussed in greater detail in the SetLink article.
If invoked by the evaluator, either directly with cog-evaluate, or indirectly, via pattern matching, the AndLink evaluates to true only if all the atoms in it's outgoing set evaluate to true. For sequential evaluation, the SequentialAndLink can be used. For parallel, multi-threaded evaluation, the ThreadJoinLink can be used.
AndLink can join N predicates or N concepts, but it can't join a concept with a predicate. For examples, see OpenCog Atom types.
In PLN the AndLink semantics corresponds to a fuzzy set intersection (accounting for confidence).
AndLink <TV> A B
where denotes the function associated to the fuzzy connector , usually .
Initially the AndLink is defined over concepts, but is overloaded to predicates as well, in that case the intersection is applied over the corresponding satisfying sets.
For instance one may express the AndLink between predicates like
AndLink <TV> PredicateNode "tasty" PredicateNode "colorful"
AndLink <TV> ConceptNode "tasty_things" ConceptNode "colorful_things"