Copyright | (C) 2017 ATS Advanced Telematic Systems GmbH |
---|---|

License | BSD-style (see the file LICENSE) |

Maintainer | Stevan Andjelkovic <stevan.andjelkovic@strath.ac.uk> |

Stability | provisional |

Portability | portable |

Safe Haskell | Safe |

Language | Haskell2010 |

This module contains Z-inspried combinators for working with relations. The idea is that they can be used to define concise and showable models. This module is an experiment and will likely change or move to its own package.

## Synopsis

- cons :: a -> [a] -> [a]
- union :: Eq a => [a] -> [a] -> [a]
- intersect :: Eq a => [a] -> [a] -> [a]
- isSubsetOf :: (Eq a, Show a) => [a] -> [a] -> Logic
- (~=) :: (Eq a, Show a) => [a] -> [a] -> Logic
- type Rel a b = [(a, b)]
- type Fun a b = Rel a b
- type (:<->) a b = Rel a b
- type (:->) a b = Fun a b
- type (:/->) a b = Fun a b
- empty :: Rel a b
- identity :: [a] -> Rel a a
- singleton :: a -> b -> Rel a b
- domain :: Rel a b -> [a]
- codomain :: Rel a b -> [b]
- compose :: Eq b => Rel b c -> Rel a b -> Rel a c
- fcompose :: Eq b => Rel a b -> Rel b c -> Rel a c
- inverse :: Rel a b -> Rel b a
- lookupDom :: Eq a => a -> Rel a b -> [b]
- lookupCod :: Eq b => b -> Rel a b -> [a]
- (<|) :: Eq a => [a] -> Rel a b -> Rel a b
- (|>) :: Eq b => Rel a b -> [b] -> Rel a b
- (<-|) :: Eq a => [a] -> Rel a b -> Rel a b
- (|->) :: Eq b => Rel a b -> [b] -> Rel a b
- image :: Eq a => Rel a b -> [a] -> [b]
- (<+) :: (Eq a, Eq b) => Rel a b -> Rel a b -> Rel a b
- (<**>) :: Eq a => Rel a b -> Rel a c -> Rel a (b, c)
- (<||>) :: Rel a c -> Rel b d -> Rel (a, b) (c, d)
- isTotalRel :: (Eq a, Show a) => Rel a b -> [a] -> Logic
- isSurjRel :: (Eq b, Show b) => Rel a b -> [b] -> Logic
- isTotalSurjRel :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic
- isPartialFun :: (Eq a, Eq b, Show b) => Rel a b -> Logic
- isTotalFun :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> Logic
- isPartialInj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> Logic
- isTotalInj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> Logic
- isPartialSurj :: (Eq a, Eq b, Show b) => Rel a b -> [b] -> Logic
- isTotalSurj :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic
- isBijection :: (Eq a, Eq b, Show a, Show b) => Rel a b -> [a] -> [b] -> Logic
- (!) :: (Eq a, Show a, Show b) => Fun a b -> a -> b
- (!?) :: Eq a => Fun a b -> a -> Maybe b
- (.%) :: (Eq a, Eq b, Show a, Show b) => (Fun a b, a) -> (b -> b) -> Fun a b
- (.!) :: Rel a b -> a -> (Rel a b, a)
- (.=) :: (Eq a, Eq b) => (Rel a b, a) -> b -> Rel a b

# Documentation

isSubsetOf :: (Eq a, Show a) => [a] -> [a] -> Logic infix 5 Source #

Subset.

`>>>`

True`boolean ([1, 2] `isSubsetOf` [3, 2, 1])`

(~=) :: (Eq a, Show a) => [a] -> [a] -> Logic infix 5 Source #

Set equality.

`>>>`

True`boolean ([1, 1, 2] ~= [2, 1])`

(<|) :: Eq a => [a] -> Rel a b -> Rel a b infixr 4 Source #

Domain restriction.

`>>>`

[('a',"apa")]`['a'] <| [ ('a', "apa"), ('b', "bepa") ]`

(|>) :: Eq b => Rel a b -> [b] -> Rel a b infixl 4 Source #

Codomain restriction.

`>>>`

[('a',"apa")]`[ ('a', "apa"), ('b', "bepa") ] |> ["apa"]`

(<-|) :: Eq a => [a] -> Rel a b -> Rel a b infixr 4 Source #

Domain substraction.

`>>>`

[('b',"bepa")]`['a'] <-| [ ('a', "apa"), ('b', "bepa") ]`

(|->) :: Eq b => Rel a b -> [b] -> Rel a b infixl 4 Source #

Codomain substraction.

`>>>`

[('b',"bepa"),('c',"cepa")]`[ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa"]`

`>>>`

[('b',"bepa")]`[ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa", "cepa"]`

`>>>`

[('b',"bepa")]`[ ('a', "apa"), ('b', "bepa"), ('c', "cepa") ] |-> ["apa"] |-> ["cepa"]`