Tom de Jong
Reboot: 22 January 2021
Earlier version: 18 September 2020

We construct the type of integers with the aim of using them in constructing the
circle as the type of ā„¤-torsors, as described in "Construction of the circle in
UniMath" by Bezem, Buchholtz, Grayson and Shulman
(doi:10.1016/j.jpaa.2021.106687).

See Integers-Properties and Integers-SymmetricInduction for (more) properties of
the type of integers.

\begin{code}

{-# OPTIONS --safe --without-K #-}

open import MLTT.Spartan

module Circle.Integers where

ā„¤ : š“¤ā‚€ Ģ‡
ā„¤ = šŸ™ + ā„• + ā„•

pattern šŸŽ     = inl ā‹†
pattern pos i = inr (inl i)
pattern neg i = inr (inr i)

ā„•-to-ā„¤ā‚Š : ā„• ā†’ ā„¤
ā„•-to-ā„¤ā‚Š 0        = šŸŽ
ā„•-to-ā„¤ā‚Š (succ n) = pos n

ā„•-to-ā„¤ā‚‹ : ā„• ā†’ ā„¤
ā„•-to-ā„¤ā‚‹ 0        = šŸŽ
ā„•-to-ā„¤ā‚‹ (succ n) = neg n

ā„¤-induction : {š“¤ : Universe} (P : ā„¤ ā†’ š“¤ Ģ‡ )
            ā†’ P šŸŽ
            ā†’ ((n : ā„•) ā†’ P (ā„•-to-ā„¤ā‚Š n) ā†’ P (ā„•-to-ā„¤ā‚Š (succ n)))
            ā†’ ((n : ā„•) ā†’ P (ā„•-to-ā„¤ā‚‹ n) ā†’ P (ā„•-to-ā„¤ā‚‹ (succ n)))
            ā†’ (z : ā„¤) ā†’ P z
ā„¤-induction {š“¤} P pā‚€ pā‚Š pā‚‹ šŸŽ       = pā‚€
ā„¤-induction {š“¤} P pā‚€ pā‚Š pā‚‹ (pos i) = h (succ i)
 where
  Pā‚Š : ā„• ā†’ š“¤ Ģ‡
  Pā‚Š = P āˆ˜ ā„•-to-ā„¤ā‚Š
  h : (n : ā„•) ā†’ Pā‚Š n
  h = ā„•-induction pā‚€ pā‚Š
ā„¤-induction {š“¤} P pā‚€ pā‚Š pā‚‹ (neg i) = h (succ i)
 where
  Pā‚‹ : ā„• ā†’ š“¤ Ģ‡
  Pā‚‹ = P āˆ˜ ā„•-to-ā„¤ā‚‹
  h : (n : ā„•) ā†’ Pā‚‹ n
  h = ā„•-induction pā‚€ pā‚‹

\end{code}