Natural numbers

\begin{code}

{-# OPTIONS --without-K --exact-split --safe --auto-inline #-}

module Naturals.Properties where

open import MLTT.Universes
open import MLTT.NaturalNumbers
open import MLTT.Negation
open import MLTT.Id
open import MLTT.Empty
open import MLTT.Unit
open import MLTT.Unit-Properties

pred :   
pred 0 = 0
pred (succ n) = n

succ-lc : {i j : }  succ i  succ j  i  j
succ-lc = ap pred

positive-not-zero : (x : )  succ x  0
positive-not-zero x p = 𝟙-is-not-𝟘 (g p)
 where
  f :   𝓤₀ ̇
  f 0        = 𝟘
  f (succ x) = 𝟙

  g : succ x  0  𝟙  𝟘
  g = ap f

zero-not-positive : (x : )  0  succ x
zero-not-positive x p = positive-not-zero x (p ⁻¹)

succ-no-fp : (n : )  n  succ n
succ-no-fp zero     p = positive-not-zero 0 (p ⁻¹)
succ-no-fp (succ n) p = succ-no-fp n (succ-lc p)

ℕ-cases : {P :   𝓦 ̇ } (n : )
         (n  zero  P n)  ((m : )  n  succ m  P n)  P n
ℕ-cases {𝓦} {P} zero c₀ cₛ     = c₀ refl
ℕ-cases {𝓦} {P} (succ n) c₀ cₛ = cₛ n refl

\end{code}

Added 12/05/2022 by Andrew Sneap.

\begin{code}

succ-pred : (x : )  succ (pred (succ x))  succ x
succ-pred x = refl

succ-pred' : (x : )  ¬ (x  0)  succ (pred x)  x
succ-pred' zero     nz = 𝟘-elim (nz refl)
succ-pred' (succ n) _ = refl

pred-succ : (x : )  pred (succ x)  x
pred-succ x = refl

\end{code}