# Math.Arithmetic.Negative

It is the tag for the expression representing the negative value of its unique subexpression.

## Definition

It is the tag for the expression representing the arithemtic negative value of its unique subexpression.

Please note that the logic negation has a different tag, it is Logic.Negate.

## Behavior

This expression should have exactly one subexpression.

### Visualization

There could be several visualizations. The most common is showing the minus sign (-) before the expression, like

### Edition

The most common edition is the creation of a new negative expression containing as its unique child the currently selected expression.

### Reduction

There should be a few reducers associated with this expression, see below.

# Known implementations

## The Standard arithmetic package

### Visualization

This package contains only one visualization that draws the minus sign (-) at at the left of its unique subexpression. The minus sign is aligned with the horizontal baseline of its unique subexpression. The resulting expression has the same vertical baselinea than the subexpression, like the following example:

If the visualization of it unique child belongs to the category Parentheses as operator, this visualization automatically shows its child between parentheses, in the following example, the child is an Math.Arithmetic.Addition which belongs to this category:

This visualization belongs to the category Parentheses as super/subscripted. In the following example, the Math.Arithmetic.Exponentiation visualization shows in parentheses any child (base and/or exponent) if it belongs to that category (the negative expression):

### Edition

There are two editions in this package:

#### Edition 1. Creating a negative expression

This edition inconditinally creates a new **Math.Arithmetic.Negative** expression and attaches the currently selected expression as its unique child, it takes its place and it becames the new selected expression.

#### Edition 2. Changing the sign

If the currently selected expression or its parent expression is already a **Math.Arithmetic.Negative** expression, removes it, otherwise it works like the previous edition. It means that this edition works like an change sign, that commutes between negative and non-negative expression.

#### Examples

Example | Edition performed | Result |
---|---|---|

creating a negative | ||

changing the sign | ||

creating a negative | ||

changing the sign | ||

changing the sign |

### Reduction

#### Reducer 1. Negative of zero

In this case the negative expression is eliminated

#### Reducer 2. Negative of a negative expression

In this case both negative expression are cancelled:

Since the reduction engine tries until no reducer can be applied, the following works: