Copyright | Guillaume Sabbagh 2022 |
---|---|
License | GPL-3 |
Maintainer | guillaumesabbagh@protonmail.com |
Stability | experimental |
Portability | portable |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Pure sets are nested sets which only contain other sets all the way down. They allow to explore basic set theory.
Every mathematical object is a set, usual constructions such as Von Neumann numbers and Kuratowski pairs are implemented.
It is a tree where the order of the branches does not matter.
Functions with the same name as pure set functions are suffixed with the letter P
for pure to avoid name collision.
Synopsis
- data PureSet = PureSet (Set PureSet)
- pureSet :: [PureSet] -> PureSet
- emptySet :: PureSet
- singleton :: PureSet -> PureSet
- pair :: PureSet -> PureSet -> PureSet
- first :: PureSet -> PureSet
- second :: PureSet -> PureSet
- maybeFirst :: PureSet -> Maybe PureSet
- maybeSecond :: PureSet -> Maybe PureSet
- cartesianProduct :: PureSet -> PureSet -> PureSet
- numberToSet :: (Num a, Eq a) => a -> PureSet
- (||||) :: PureSet -> PureSet -> PureSet
- (&&&&) :: PureSet -> PureSet -> PureSet
- isInP :: PureSet -> PureSet -> Bool
- isIncludedInP :: PureSet -> PureSet -> Bool
- card :: PureSet -> Int
- powerSetP :: PureSet -> PureSet
- prettify :: PureSet -> String
- formatPureSet :: PureSet -> String
PureSet
datatype
Mathematical constructions using sets
pair :: PureSet -> PureSet -> PureSet Source #
Construct an ordered pair from two sets according to Kuratowski's definition of a tuple.
first :: PureSet -> PureSet Source #
Return the first element of a pair according to Kuratowski's definition of a tuple.
second :: PureSet -> PureSet Source #
Return the second element of a pair according to Kuratowski's definition of a tuple.
maybeFirst :: PureSet -> Maybe PureSet Source #
Return the first element of a pair if possible.
maybeSecond :: PureSet -> Maybe PureSet Source #
Return the second element of a pair if possible.
cartesianProduct :: PureSet -> PureSet -> PureSet Source #
Construct the cartesian product of two sets.
numberToSet :: (Num a, Eq a) => a -> PureSet Source #
Transform a number into its Von Neumann construction
isIncludedInP :: PureSet -> PureSet -> Bool Source #
Return wether a pure set is included in another one.
Formatting functions
formatPureSet :: PureSet -> String Source #
Format pure sets such that if numbers are recognized, they are transformed into integer and if pairs are recognized, they are transformed into pairs.