The type of natural numbers

Content created by Egbert Rijke, Fredrik Bakke, Jonathan Prieto-Cubides, Elisabeth Stenholm and Elif Uskuplu.

Created on 2022-01-26.
Last modified on 2023-10-22.

module elementary-number-theory.natural-numbers where
open import foundation.dependent-pair-types
open import foundation.universe-levels

open import foundation-core.empty-types
open import foundation-core.identity-types
open import foundation-core.injective-maps
open import foundation-core.negation


The natural numbers is an inductively generated type by the zero element and the successor function. The induction principle for the natural numbers works to construct sections of type families over the natural numbers.


The inductive definition of the type of natural numbers

data  : UU lzero where
  zero-ℕ : 
  succ-ℕ :   


Useful predicates on the natural numbers

These predicates can of course be asserted directly without much trouble. However, using the defined predicates ensures uniformity, and helps naming definitions.

is-zero-ℕ :   UU lzero
is-zero-ℕ n = (n  zero-ℕ)

is-zero-ℕ' :   UU lzero
is-zero-ℕ' n = (zero-ℕ  n)

is-successor-ℕ :   UU lzero
is-successor-ℕ n = Σ   y  n  succ-ℕ y)

is-nonzero-ℕ :   UU lzero
is-nonzero-ℕ n = ¬ (is-zero-ℕ n)

is-one-ℕ :   UU lzero
is-one-ℕ n = (n  1)

is-one-ℕ' :   UU lzero
is-one-ℕ' n = (1  n)

is-not-one-ℕ :   UU lzero
is-not-one-ℕ n = ¬ (is-one-ℕ n)

is-not-one-ℕ' :   UU lzero
is-not-one-ℕ' n = ¬ (is-one-ℕ' n)


The induction principle of ℕ

ind-ℕ :
  {l : Level} {P :   UU l} 
  P 0  ((n : )  P n  P (succ-ℕ n))  ((n : )  P n)
ind-ℕ p-zero p-succ 0 = p-zero
ind-ℕ p-zero p-succ (succ-ℕ n) = p-succ n (ind-ℕ p-zero p-succ n)

The recursion principle of ℕ

rec-ℕ : {l : Level} {A : UU l}  A  (  A  A)  (  A)
rec-ℕ = ind-ℕ

The successor function on ℕ is injective

is-injective-succ-ℕ : is-injective succ-ℕ
is-injective-succ-ℕ refl = refl

Successors are nonzero

is-nonzero-succ-ℕ : (x : )  is-nonzero-ℕ (succ-ℕ x)
is-nonzero-succ-ℕ x ()

is-nonzero-is-successor-ℕ : {x : }  is-successor-ℕ x  is-nonzero-ℕ x
is-nonzero-is-successor-ℕ (x , refl) ()

is-successor-is-nonzero-ℕ : {x : }  is-nonzero-ℕ x  is-successor-ℕ x
is-successor-is-nonzero-ℕ {zero-ℕ} H = ex-falso (H refl)
pr1 (is-successor-is-nonzero-ℕ {succ-ℕ x} H) = x
pr2 (is-successor-is-nonzero-ℕ {succ-ℕ x} H) = refl

has-no-fixed-points-succ-ℕ : (x : )  ¬ (succ-ℕ x  x)
has-no-fixed-points-succ-ℕ x ()

Basic nonequalities

is-nonzero-one-ℕ : is-nonzero-ℕ 1
is-nonzero-one-ℕ ()

is-not-one-zero-ℕ : is-not-one-ℕ zero-ℕ
is-not-one-zero-ℕ ()

is-nonzero-two-ℕ : is-nonzero-ℕ 2
is-nonzero-two-ℕ ()

is-not-one-two-ℕ : is-not-one-ℕ 2
is-not-one-two-ℕ ()

See also

Recent changes