EqualLink is a kind of virtual link that evaluates to true when its two arguments, when executed, result in the same atom. If not, it evaluates to false.
EqualLink is used to test for semantic equality. To test if two atoms are really the same atom (i.e. syntactic equality), use IdenticalLink. As a general rule, testing for syntactic equality will always be faster.
The primary use of
EqualLink is during pattern matching, when one or both of its arguments contain variables to be grounded. Thus, when the pattern matcher grounds the variables with actual values, the
EqualLink can be evaluated to see if equality holds or not (with the pattern match being accepted or rejected as a result).
They can be evaluated with the
Syntactic vs. Semantic equality
The following tests syntactic equality, when used in the pattern matcher:
EqualLink ConceptNode "foo" VariableLink "$x"
Depending on the grounding assigned to the variable, the expression will evaluate to true or false. Specifically, it will evaluate to true if and only if the variable is grounded by
ConceptNode "foo". The above is an excellent example where using IdenticalLink would be a better design choice.
The following tests semantic equality:
EqualLink ConceptNode "foo" PutLink VariableLink "$x" ConceptNode "foo"
Syntactically, the above could never be identical, because a ConceptNode is just-plain different from a PutLink. However, if the PutLink is evaluated, then the result of that evaluation will be
ConceptNode "foo", and equality will hold. This is an example where, when evaluated, the EqualLink will return true, whereas an IdenticalLink will return false.