Real numbers

Uses Rational numbers.

Many programming languages use the label "real numbers" for Floating-point numbers. In Leibniz, real numbers are the real numbers defined in mathematics. Real numbers cannot be represented in a computer, because the information content of a real number is, in general, infinite. Only well-defined subsets, such as the Rational numbers, can be represented as a finite sequence of bits. However, Leibniz is not a programming language, but a specification language. Even if you cannot compute with real numbers, you can still talk about real numbers and define axioms and rules in terms of real numbers.

The sort describes the real numbers. The rational numbers are a subsort: .

There is a subsort ℝ.nz for the non-zero real numbers, with ℚ.nzℝ.nz.

Another subsort, ℝ.nn, describes the non-negative real numbers. The non-negative rational number are a subsort: ℚ.nnℝ.nn.

The positive real numbers, ℝ.p, are both non-zero (ℝ.pℝ.nz) and non-negative (ℝ.pℝ.nn). The positive rational number are a subsort: ℚ.pℝ.p.

Arithmetic

Addition

The sum of two real numbers is a real number:
+ :

Important special cases are:
ℝ.p + ℝ.p : ℝ.p
ℝ.nn + ℝ.nn : ℝ.nn

Addition is commutative:
x:, y:, x + y = y + x
and associative:
x:, y:, z:, (x + y) + z = x + (y + z)

Rules:

Eliminate zeros:
(x:) + (zero:zero)x
(zero:zero) + (x:)x

Subtraction

The difference of two real numbers is a real number:
- :

The negative of a real number is a real number:
-() :

Rules

Eliminate zeros:
(x:) - (zero:zero)x
(zero:zero) - (x:) ⇒ -(x)

Multiplication

The product of two real numbers is a real number:
× :

Important special cases are:
ℝ.p × ℝ.p : ℝ.p
ℝ.nn × ℝ.nn : ℝ.nn
ℝ.nz × ℝ.nz : ℝ.nz

Multiplication is commutative:
x:, y:, x × y = y × x
and associative:
x:, y:, z:, (x × y) × z = x × (y × z)

Addition is distributive over multiplication:
x:, y:, z:, x × (y + z) = (x × y) + (x × z)

Rules:

Eliminate zeros:
(x:) × (zero:zero) ⇒ 0
(zero:zero) × (x:) ⇒ 0

Eliminate ones:
(one:one) × (x:)x
(x:) × (one:one)x

Division

The quotient of a real number and a non-zero real number is a real number:
÷ ℝ.nz :

Important special cases are:
ℝ.nz ÷ ℝ.nz : ℝ.nz
ℝ.p ÷ ℝ.p : ℝ.p
ℝ.nn ÷ ℝ.p : ℝ.nn

Rules:

Elimination of zeros and ones:
(z:zero) ÷ (x:ℝ.nz) ⇒ 0
(x:) ÷ (one:one)x

Exponentiation

Exponentiation is defined for non-zero real number to any integer power:
ℝ.nzℤ.nz : ℝ.nz
ℝ.nzzero : ℕ.nz

The case of zero has already been defined in Integers.

Positive real numbers can be taken to any non-zero real power:
ℝ.pℝ.nz : ℝ.p

Non-negative real numbers can be taken to any positive real power:
ℝ.nnℝ.p : ℝ.nn

Rules:

Eliminate zeros:
(x:ℝ.nz)z:zero ⇒ 1

Eliminate ones:
(x:ℝ.nz)one:onex

Comparison

< : 𝔹
> : 𝔹
: 𝔹
: 𝔹