Absolute value

Uses Real numbers

The absolute value of any real number is a non-negative real number:
abs() : ℝ.nn

Special cases for the rational numbers and the integers:
abs() : ℚ.nn
abs() :

Special cases for the non-zero numbers are also useful:
abs(ℝ.nz) : ℝ.p
abs(ℚ.nz) : ℚ.p
abs(ℤ.nz) : ℕ.nz

Simplification rules

The absolute value of a non-negative number is the number itself:
abs(x:ℝ.nn) ⇒ x
abs(x:) ⇒ x | x 0

For a negative number, it is the negative:
abs(x:) ⇒ -(x) | x < 0

Examples

Given:
example aPositiveNumber : ℝ.p
example aNegativeNumber : with example aNegativeNumber < 0 ⇒ ⊤
example anUnknownNumber :

We find:
example abs(aPositiveNumber) ⇒ aPositiveNumber
example abs(aNegativeNumber) ⇒ -(aNegativeNumber)
example abs(anUnknownNumber) ⇒ abs(anUnknownNumber)

For literals:
example abs(2) ⇒ 2
example abs(-2/3) ⇒ 2/3