oalg-base-3.0.0.0: Algebraic structures on oriented entities and limits as a tool kit to solve algebraic problems.
Copyright(c) Erich Gut
LicenseBSD3
Maintainerzerich.gut@gmail.com
Safe HaskellNone
LanguageHaskell2010

OAlg.Entity.Natural

Description

natural numbers promotable to type-level. They serve to parameterize the length of finite lists on type-level (see OAlg.Entity.FinList).

Note We need the language extension UndecidableInstances for type checking the definition

N0 * m = N0
S n * m = m + n * m

for the type family *.

Using UndecidableInstances could cause the type checker to not terminate, but this will obviously not happen for the given definition (we also use the same definition for the multiplicative structure of N').

Synopsis

Natrual Numbers

data N' Source #

natural number promotable to type-level.

Constructors

N0 
S N' 

Instances

Instances details
Enum N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

succ :: N' -> N' #

pred :: N' -> N' #

toEnum :: Int -> N' #

fromEnum :: N' -> Int #

enumFrom :: N' -> [N'] #

enumFromThen :: N' -> N' -> [N'] #

enumFromTo :: N' -> N' -> [N'] #

enumFromThenTo :: N' -> N' -> N' -> [N'] #

Show N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

showsPrec :: Int -> N' -> ShowS #

show :: N' -> String #

showList :: [N'] -> ShowS #

Eq N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

(==) :: N' -> N' -> Bool #

(/=) :: N' -> N' -> Bool #

Ord N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

compare :: N' -> N' -> Ordering #

(<) :: N' -> N' -> Bool #

(<=) :: N' -> N' -> Bool #

(>) :: N' -> N' -> Bool #

(>=) :: N' -> N' -> Bool #

max :: N' -> N' -> N' #

min :: N' -> N' -> N' #

LengthN N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

lengthN :: N' -> N Source #

Validable N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

valid :: N' -> Statement Source #

Additive N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

zero :: Root N' -> N' Source #

(+) :: N' -> N' -> N' Source #

ntimes :: N -> N' -> N' Source #

Distributive N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Fibred N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

root :: N' -> Root N' Source #

EqRoot N' Source # 
Instance details

Defined in OAlg.Entity.Natural

ShowRoot N' Source # 
Instance details

Defined in OAlg.Entity.Natural

SingletonRoot N' Source # 
Instance details

Defined in OAlg.Entity.Natural

TypeableRoot N' Source # 
Instance details

Defined in OAlg.Entity.Natural

ValidableRoot N' Source # 
Instance details

Defined in OAlg.Entity.Natural

FibredOriented N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Commutative N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Multiplicative N' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

one :: Point N' -> N' Source #

(*) :: N' -> N' -> N' Source #

npower :: N' -> N -> N' Source #

Oriented N' Source # 
Instance details

Defined in OAlg.Entity.Natural

EqPoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

OrdPoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

ShowPoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

SingletonPoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

TypeablePoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

ValidablePoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

XStandardPoint N' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Root N' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Root N' = Orientation ()
type Point N' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Point N' = ()
type N0 * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type N0 * m = N0
type N0 + (n :: N') Source # 
Instance details

Defined in OAlg.Entity.Natural

type N0 + (n :: N') = n
type ('S n :: N') * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type ('S n :: N') * m = m + (n * m)
type ('S n) + (m :: N') Source # 
Instance details

Defined in OAlg.Entity.Natural

type ('S n) + (m :: N') = 'S (n + m)

toN' :: N -> N' Source #

mapping a natural number in N to N'.

type family (n :: N') + (m :: k) :: N' infixr 6 Source #

addition of natural numbers.

Instances

Instances details
type N0 + (n :: N') Source # 
Instance details

Defined in OAlg.Entity.Natural

type N0 + (n :: N') = n
type n + 0 Source # 
Instance details

Defined in OAlg.Entity.Natural

type n + 0 = n
type n + 1 Source # 
Instance details

Defined in OAlg.Entity.Natural

type n + 1 = 'S n
type n + 2 Source # 
Instance details

Defined in OAlg.Entity.Natural

type n + 2 = 'S ('S n)
type n + 3 Source # 
Instance details

Defined in OAlg.Entity.Natural

type n + 3 = 'S ('S ('S n))
type ('S n) + (m :: N') Source # 
Instance details

Defined in OAlg.Entity.Natural

type ('S n) + (m :: N') = 'S (n + m)

type family (n :: k) * (m :: N') :: N' infixr 7 Source #

multiplication of natural numbers.

Instances

Instances details
type N0 * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type N0 * m = N0
type 0 * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type 0 * m = N0
type 1 * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type 1 * m = m
type 2 * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type 2 * m = m + m
type ('S n :: N') * m Source # 
Instance details

Defined in OAlg.Entity.Natural

type ('S n :: N') * m = m + (n * m)

Ordering

data (n :: N') :<=: (m :: N') where infix 4 Source #

ordering relation for naturals N'.

Constructors

Add :: forall (n :: N') (d :: N'). Any n -> Any d -> n :<=: (n + d) 

Instances

Instances details
Show (n :<=: m) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

showsPrec :: Int -> (n :<=: m) -> ShowS #

show :: (n :<=: m) -> String #

showList :: [n :<=: m] -> ShowS #

nodAnyFst :: forall (i :: N') (n :: N'). (i :<=: n) -> Any i Source #

the induced witness of the first component.

nodAnySnd :: forall (i :: N') (n :: N'). (i :<=: n) -> Any n Source #

the induced witness of the second component.

nodRefl :: forall (n :: N'). Any n -> n :<=: n Source #

for any n holds that (:<=:) is reflexive.

nodPred :: forall (n :: N') (m :: N'). ((n + 1) :<=: m) -> n :<=: m Source #

if n + 1 is smaler or equal to m then n is also smaler of equal to m.

Attest

class Typeable n => Attestable (n :: N') where Source #

attest for any natural number.

Methods

attest :: W n Source #

Instances

Instances details
Attestable N0 Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

attest :: W N0 Source #

Attestable n => Attestable ('S n) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

attest :: W ('S n) Source #

data Ats (n :: N') where Source #

witness of being attestable.

Constructors

Ats :: forall (n :: N'). Attestable n => Ats n 

ats :: forall (n :: N'). Any n -> Ats n Source #

any natural n is also attestable.

atsSucc :: forall (n :: N'). Ats n -> Ats (n + 1) Source #

if n is attestable then also n + 1 is.

nValue :: forall (n :: N') p. Attestable n => p n -> N Source #

the corresponding natural number in N of a type parameterized by n.

data W (n :: N') where Source #

witness for a natural number and serves for inductively definable elements (see induction).

Constructors

W0 :: W 'N0 
SW :: forall (n1 :: N'). W n1 -> W (n1 + 1) 

Instances

Instances details
Show (W n) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

showsPrec :: Int -> W n -> ShowS #

show :: W n -> String #

showList :: [W n] -> ShowS #

Eq (W n) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

(==) :: W n -> W n -> Bool #

(/=) :: W n -> W n -> Bool #

LengthN (W n) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

lengthN :: W n -> N Source #

Validable (W n) Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

valid :: W n -> Statement Source #

cmpW :: forall (n :: N') (m :: N'). W n -> W m -> Ordering Source #

comparing of two witnesses.

(++) :: forall (n :: N') (m :: N'). W n -> W m -> W (n + m) infixr 6 Source #

addition of witnesses.

(**) :: forall (n :: N') (m :: N'). W n -> W m -> W (n * m) infixr 7 Source #

multiplication of witnesses.

data W' Source #

union of all witnesses, which is isomorphic to N and N'.

Constructors

W' (W n) 

Instances

Instances details
Enum W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

succ :: W' -> W' #

pred :: W' -> W' #

toEnum :: Int -> W' #

fromEnum :: W' -> Int #

enumFrom :: W' -> [W'] #

enumFromThen :: W' -> W' -> [W'] #

enumFromTo :: W' -> W' -> [W'] #

enumFromThenTo :: W' -> W' -> W' -> [W'] #

Show W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

showsPrec :: Int -> W' -> ShowS #

show :: W' -> String #

showList :: [W'] -> ShowS #

Eq W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

(==) :: W' -> W' -> Bool #

(/=) :: W' -> W' -> Bool #

Ord W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

compare :: W' -> W' -> Ordering #

(<) :: W' -> W' -> Bool #

(<=) :: W' -> W' -> Bool #

(>) :: W' -> W' -> Bool #

(>=) :: W' -> W' -> Bool #

max :: W' -> W' -> W' #

min :: W' -> W' -> W' #

LengthN W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

lengthN :: W' -> N Source #

Validable W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

valid :: W' -> Statement Source #

Additive W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

zero :: Root W' -> W' Source #

(+) :: W' -> W' -> W' Source #

ntimes :: N -> W' -> W' Source #

Distributive W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Fibred W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

root :: W' -> Root W' Source #

EqRoot W' Source # 
Instance details

Defined in OAlg.Entity.Natural

ShowRoot W' Source # 
Instance details

Defined in OAlg.Entity.Natural

SingletonRoot W' Source # 
Instance details

Defined in OAlg.Entity.Natural

TypeableRoot W' Source # 
Instance details

Defined in OAlg.Entity.Natural

ValidableRoot W' Source # 
Instance details

Defined in OAlg.Entity.Natural

FibredOriented W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Commutative W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Multiplicative W' Source # 
Instance details

Defined in OAlg.Entity.Natural

Methods

one :: Point W' -> W' Source #

(*) :: W' -> W' -> W' Source #

npower :: W' -> N -> W' Source #

Oriented W' Source # 
Instance details

Defined in OAlg.Entity.Natural

EqPoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

OrdPoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

ShowPoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

SingletonPoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

TypeablePoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

ValidablePoint W' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Root W' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Root W' = Orientation ()
type Point W' Source # 
Instance details

Defined in OAlg.Entity.Natural

type Point W' = ()

toW' :: N -> W' Source #

mapping a natural value in N to W'.

data SomeNatural where Source #

witnesse of some natural.

Constructors

SomeNatural :: forall (n :: N'). Attestable n => W n -> SomeNatural 

Instances

Instances details
Show SomeNatural Source # 
Instance details

Defined in OAlg.Entity.Natural

Eq SomeNatural Source # 
Instance details

Defined in OAlg.Entity.Natural

Validable SomeNatural Source # 
Instance details

Defined in OAlg.Entity.Natural

succSomeNatural :: SomeNatural -> SomeNatural Source #

successor of some natural number.

someNatural :: N -> SomeNatural Source #

mapping N to SomeNatural.

Note The implementation of this mapping is quite inefficent for high values of N.

naturals :: [SomeNatural] Source #

the infinite list of some naturals.

Induction

induction :: forall (n :: N') f. Any n -> f N0 -> (forall (i :: N'). f i -> f (i + 1)) -> f n Source #

induction for general type functions.

Propositions

The following propositions are based - for the most part - on induction. To ensure that the proofs yield a terminal value, i.e. Refl, we used in the proof of the induction hypothesis only propositions which are proofed before. So: if these propositions terminate, then also the hypothesis will terminate.

type Any = W Source #

predicate for any natural number.

type Some = W' Source #

some witness.

Some basic Lemmas

refl :: forall (x :: N'). Any x -> x :~: x Source #

reflexivity.

lemma1 :: forall {k1} {k2} (x :: k1) (y :: k1) (f :: k1 -> k2). (x :~: y) -> f x :~: f y Source #

well definition of parameterized types.

sbstAdd :: forall {k} (a :: N') (a' :: N') (b :: k) (b' :: k). (a :~: a') -> (b :~: b') -> (a + b) :~: (a' + b') Source #

substitution rule for addition.

Some abbreviations

prpAdd0 :: forall (a :: N'). (a + 0) :~: a Source #

0 is right neural for the addition.

prpAdd1 :: forall (a :: N'). (a + 1) :~: 'S a Source #

adding 1 is equal to the successor.

prpAdd2 :: forall (a :: N'). (a + 2) :~: 'S ('S a) Source #

adding 2 is equal to the successor of the successor.

Equivalence of Any

prpEqlAny :: forall (n :: N') (m :: N'). (Any n :~: Any m) -> n :~: m Source #

equality of the underlying natural number.

prpEqlAny' :: forall (n :: N') (m :: N'). (n :~: m) -> Any n :~: Any m Source #

Any is as parameterized type is well defined.

Injectivity of the Successor

prpSuccInjective :: forall (n :: N') (m :: N'). ('S n :~: 'S m) -> n :~: m Source #

successor is injective.

Addition

Neutral Element

N0 is the neutral element of +.

prpAddNtrlL :: forall p (a :: N'). p a -> (N0 + a) :~: a Source #

N0 is left neutral for the addition.

prpAddNtrlR :: forall (a :: N'). Any a -> (a + N0) :~: a Source #

N0 is the right neutral for the addition.

Associativity

prpAddAssoc :: forall (a :: N') (b :: N') (c :: N'). Any a -> Any b -> Any c -> ((a + b) + c) :~: (a + (b + c)) Source #

addition is associative.

Commutativity

lemmaAdd1 :: forall (a :: N') (b :: N'). Any a -> Any b -> ('S a + b) :~: (a + 'S b) Source #

lemma 1 for the addition.

prpAddComm :: forall (a :: N') (b :: N'). Any a -> Any b -> (a + b) :~: (b + a) Source #

addition is commutative.

Multiplication

Neutral Element

N1 = S N0 is the neutral element of *.

prpMltNtrlL :: forall (a :: N'). Any a -> (N1 * a) :~: a Source #

N1 is left neutral for the multiplication.

prpMltNtrlR :: forall (a :: N'). Any a -> (a * N1) :~: a Source #

N1 is right neutral for the multiplication.

Distributivity on the left

prpDstrL :: forall (a :: N') (b :: N') (c :: N'). Any a -> Any b -> Any c -> ((a + b) * c) :~: ((a * c) + (b * c)) Source #

law of left distributivity holds.

Associativity

prpMltAssoc :: forall (a :: N') (b :: N') (c :: N'). Any a -> Any b -> Any c -> ((a * b) * c) :~: (a * (b * c)) Source #

multiplication is associative.

Distributivity on the right

lemmaMlt1 :: forall (a :: N'). Any a -> (a * N0) :~: N0 Source #

right multiplication of N0 is N0.

lemmaAdd2 :: forall (a :: N') (b :: N') (c :: N'). Any a -> Any b -> Any c -> (a + (b + c)) :~: (b + (a + c)) Source #

lemma 2 for addition.

prpDstrR :: forall (a :: N') (b :: N') (c :: N'). Any a -> Any b -> Any c -> (a * (b + c)) :~: ((a * b) + (a * c)) Source #

law of right distributivity holds.

Commutativity

prpMltComm :: forall (a :: N') (b :: N'). Any a -> Any b -> (a * b) :~: (b * a) Source #

multiplication is commutative.

Some attests

generating the Haskell code and interface for witnesses.

codeW :: N -> N -> String Source #

codeW n m generates the haskell code for the witnesses W of N' from n to m.

itfW :: N -> N -> String Source #

itfW n m generates the haskell interface for the witnesses W from n to m.

type N0 = 'N0 Source #

0.

type N1 = 'S N0 Source #

1.

type N2 = 'S N1 Source #

2.

type N3 = 'S N2 Source #

3.

type N4 = 'S N3 Source #

4.

type N5 = 'S N4 Source #

5.

type N6 = 'S N5 Source #

6.

type N7 = 'S N6 Source #

7.

type N8 = 'S N7 Source #

8.

type N9 = 'S N8 Source #

9.

type N10 = 'S N9 Source #

10.

X

xSomeNatural :: X N -> X SomeNatural Source #

the induced random variable for some natural number.