type-natural-0.4.0.0: Type-level natural and proofs of their properties.

Safe HaskellNone
LanguageHaskell2010

Data.Type.Natural.Builtin

Contents

Description

Coercion between Peano Numerals Nat and builtin naturals Nat

Synopsis

Sysnonym to avoid confusion

type Peano = Nat Source #

Type synonym for Nat to avoid confusion with built-in Nat.

Coercion between builtin type-level natural and peano numerals

type family FromPeano (n :: Nat) :: Nat where ... Source #

Equations

FromPeano Z = 0 
FromPeano (S n) = Succ (FromPeano n) 

type family ToPeano (n :: Nat) :: Nat where ... Source #

Equations

ToPeano 0 = Z 
ToPeano n = S (ToPeano (Pred n)) 

Properties of FromPeano and ToPeano.

fromPeanoInjective :: forall n m. (SingI n, SingI m) => (FromPeano n :=: FromPeano m) -> n :=: m Source #

Bijection

Algebraic isomorphisms

Peano and commutative ring axioms for built-in Nat

plusZR :: Sing n -> (n + 0) :~: n Source #

plusZL :: Sing n -> (0 + n) :~: n Source #

plusSuccR :: Sing n -> Sing m -> (n + Succ m) :~: Succ (n + m) Source #

plusSuccL :: Sing n -> Sing m -> (Succ n + m) :~: Succ (n + m) Source #

multZR :: Sing n -> (n * 0) :~: 0 Source #

multZL :: Sing n -> (0 * n) :~: 0 Source #

multSuccR :: Sing n -> Sing m -> (n * Succ m) :~: ((n * m) + n) Source #

multSuccL :: Sing n -> Sing m -> (Succ n * m) :~: ((n * m) + m) Source #

inductionNat :: forall p n. p 0 -> (forall m. p m -> p (m + 1)) -> Sing n -> p n Source #

Induction scheme for built-in Nat.

plusComm :: Sing n -> Sing m -> (n + m) :~: (m + n) Source #

multComm :: Sing n -> Sing m -> (n * m) :~: (m * n) Source #

plusAssoc :: Sing n -> Sing m -> Sing l -> ((n + m) + l) :~: (n + (m + l)) Source #

multAssoc :: Sing n -> Sing m -> Sing l -> ((n * m) * l) :~: (n * (m * l)) Source #

plusMultDistr :: Sing n -> Sing m -> Sing l -> ((n + m) * l) :~: ((n * l) + (m * l)) Source #

multPlusDistr :: Sing n -> Sing m -> Sing l -> (n * (m + l)) :~: ((n * m) + (n * l)) Source #