The nonpositive integers

Content created by Fredrik Bakke and malarbol.

Created on 2024-03-28.
Last modified on 2024-03-28.

module elementary-number-theory.nonpositive-integers where
open import elementary-number-theory.integers
open import elementary-number-theory.natural-numbers

open import foundation.action-on-identifications-functions
open import foundation.coproduct-types
open import foundation.decidable-subtypes
open import foundation.decidable-types
open import foundation.dependent-pair-types
open import foundation.empty-types
open import foundation.equivalences
open import foundation.function-types
open import foundation.identity-types
open import foundation.propositions
open import foundation.retractions
open import foundation.sections
open import foundation.sets
open import foundation.subtypes
open import foundation.transport-along-identifications
open import foundation.unit-type
open import foundation.universe-levels


The integers are defined as a disjoint sum of three components. A single element component containing the integer zero, and two copies of the natural numbers, one copy for the negative integers and one copy for the positive integers. Arranged on a number line, we have

  ⋯  -4  -3  -2  -1   0   1   2   3   4   ⋯
  <---+---+---+---]   |   [---+---+---+--->

The nonpositive integers are zero-ℤ and the negative component of the integers.


Nonnpositive integers

is-nonpositive-ℤ :   UU lzero
is-nonpositive-ℤ (inl k) = unit
is-nonpositive-ℤ (inr (inl x)) = unit
is-nonpositive-ℤ (inr (inr x)) = empty

is-prop-is-nonpositive-ℤ : (x : )  is-prop (is-nonpositive-ℤ x)
is-prop-is-nonpositive-ℤ (inl x) = is-prop-unit
is-prop-is-nonpositive-ℤ (inr (inl x)) = is-prop-unit
is-prop-is-nonpositive-ℤ (inr (inr x)) = is-prop-empty

subtype-nonpositive-ℤ : subtype lzero 
subtype-nonpositive-ℤ x = (is-nonpositive-ℤ x , is-prop-is-nonpositive-ℤ x)

nonpositive-ℤ : UU lzero
nonpositive-ℤ = type-subtype subtype-nonpositive-ℤ

is-nonpositive-eq-ℤ :
  {x y : }  x  y  is-nonpositive-ℤ x  is-nonpositive-ℤ y
is-nonpositive-eq-ℤ = tr is-nonpositive-ℤ

module _
  (p : nonpositive-ℤ)

  int-nonpositive-ℤ : 
  int-nonpositive-ℤ = pr1 p

  is-nonpositive-int-nonpositive-ℤ : is-nonpositive-ℤ int-nonpositive-ℤ
  is-nonpositive-int-nonpositive-ℤ = pr2 p

Nonpositive constants

zero-nonpositive-ℤ : nonpositive-ℤ
zero-nonpositive-ℤ = (zero-ℤ , star)

neg-one-nonpositive-ℤ : nonpositive-ℤ
neg-one-nonpositive-ℤ = (neg-one-ℤ , star)


Nonpositivity is decidable

is-decidable-is-nonpositive-ℤ : is-decidable-fam is-nonpositive-ℤ
is-decidable-is-nonpositive-ℤ (inl x) = inl star
is-decidable-is-nonpositive-ℤ (inr (inl x)) = inl star
is-decidable-is-nonpositive-ℤ (inr (inr x)) = inr id

decidable-subtype-nonpositive-ℤ : decidable-subtype lzero 
decidable-subtype-nonpositive-ℤ x =
  ( is-nonpositive-ℤ x ,
    is-prop-is-nonpositive-ℤ x ,
    is-decidable-is-nonpositive-ℤ x)

The nonpositive integers form a set

is-set-nonpositive-ℤ : is-set nonpositive-ℤ
is-set-nonpositive-ℤ =
    ( emb-subtype subtype-nonpositive-ℤ)
    ( is-set-ℤ)

The only nonpositive integer with a nonpositive negative is zero

is-zero-is-nonpositive-neg-is-nonpositive-ℤ :
  {x : }  is-nonpositive-ℤ x  is-nonpositive-ℤ (neg-ℤ x)  is-zero-ℤ x
is-zero-is-nonpositive-neg-is-nonpositive-ℤ {inr (inl star)} nonneg nonpos =

The predecessor of a nonpositive integer is nonpositive

is-nonpositive-pred-is-nonpositive-ℤ :
  {x : }  is-nonpositive-ℤ x  is-nonpositive-ℤ (pred-ℤ x)
is-nonpositive-pred-is-nonpositive-ℤ {inl x} H = H
is-nonpositive-pred-is-nonpositive-ℤ {inr (inl x)} H = H

pred-nonpositive-ℤ : nonpositive-ℤ  nonpositive-ℤ
pred-nonpositive-ℤ (x , H) = pred-ℤ x , is-nonpositive-pred-is-nonpositive-ℤ H

The canonical equivalence between natural numbers and positive integers

nonpositive-int-ℕ :   nonpositive-ℤ
nonpositive-int-ℕ = rec-ℕ zero-nonpositive-ℤ  _  pred-nonpositive-ℤ)

nat-nonpositive-ℤ : nonpositive-ℤ  
nat-nonpositive-ℤ (inl x , H) = succ-ℕ x
nat-nonpositive-ℤ (inr x , H) = zero-ℕ

eq-nat-nonpositive-pred-nonpositive-ℤ :
  (x : nonpositive-ℤ) 
  nat-nonpositive-ℤ (pred-nonpositive-ℤ x)  succ-ℕ (nat-nonpositive-ℤ x)
eq-nat-nonpositive-pred-nonpositive-ℤ (inl x , H) = refl
eq-nat-nonpositive-pred-nonpositive-ℤ (inr (inl x) , H) = refl

is-section-nat-nonpositive-ℤ :
  (x : nonpositive-ℤ)  nonpositive-int-ℕ (nat-nonpositive-ℤ x)  x
is-section-nat-nonpositive-ℤ (inl zero-ℕ , H) = refl
is-section-nat-nonpositive-ℤ (inl (succ-ℕ x) , H) =
  ap pred-nonpositive-ℤ (is-section-nat-nonpositive-ℤ (inl x , H))
is-section-nat-nonpositive-ℤ (inr (inl x) , H) = refl

is-retraction-nat-nonpositive-ℤ :
  (n : )  nat-nonpositive-ℤ (nonpositive-int-ℕ n)  n
is-retraction-nat-nonpositive-ℤ zero-ℕ = refl
is-retraction-nat-nonpositive-ℤ (succ-ℕ n) =
  eq-nat-nonpositive-pred-nonpositive-ℤ (nonpositive-int-ℕ n) 
  ap succ-ℕ (is-retraction-nat-nonpositive-ℤ n)

is-equiv-nonpositive-int-ℕ : is-equiv nonpositive-int-ℕ
pr1 (pr1 is-equiv-nonpositive-int-ℕ) = nat-nonpositive-ℤ
pr2 (pr1 is-equiv-nonpositive-int-ℕ) = is-section-nat-nonpositive-ℤ
pr1 (pr2 is-equiv-nonpositive-int-ℕ) = nat-nonpositive-ℤ
pr2 (pr2 is-equiv-nonpositive-int-ℕ) = is-retraction-nat-nonpositive-ℤ

equiv-nonpositive-int-ℕ :   nonpositive-ℤ
pr1 equiv-nonpositive-int-ℕ = nonpositive-int-ℕ
pr2 equiv-nonpositive-int-ℕ = is-equiv-nonpositive-int-ℕ

See also

Recent changes