# PlusLink

From OpenCog

The

is a special case of an FunctionLink that knows how to add numbers together. For example
**PlusLink**

(cog-execute! (PlusLink (NumberNode 2) (NumberNode 3)))

will yield

(NumberNode "5.000000")

as a result.

The `PlusLink`

is a "clear-box" link (as opposed to a "black box" link), in that it is "obvious" what it does. Clear-box links can be reasoned about and reduced. The `cog-reduce!`

function can perform reduction on clear-box links. Thus, for example:

(cog-reduce! (PlusLink (VariableNode "$x") (NumberNode 2) (NumberNode 3)))

will return

(PlusLink (VariableNode "$x") (NumberNode 5)

PlusLink and TimesLink both use FoldLink to do reduction of repeated terms.

### More reduction examples

The code implementing reduction is incomplete, but the following should work.

(cog-reduce! (PlusLink (NumberNode 0) (VariableNode "$x")))

and also

(cog-reduce! (PlusLink (NumberNode 2) (VariableNode "$x") (NumberNode -2)))

will both return

(VariableNode "$x")

Multiple addition is reduced to multiplication:

(cog-reduce! (PlusLink (VariableNode "$x") (VariableNode "$x")))

will return

(TimesLink (VariableNode "$x") (NumberNode "2"))

The post-ordering of numbers after variables is a convention coded in the reduct code.