combinat-0.2.10.1: Generate and manipulate various combinatorial objects.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Math.Combinat.Sets.VennDiagrams

Description

Venn diagrams. See https://en.wikipedia.org/wiki/Venn_diagram

TODO: write a more efficient implementation (for example an array of size 2^n)

Synopsis

Documentation

newtype VennDiagram a Source #

Venn diagrams of n sets. Each possible zone is annotated with a value of type a. A typical use case is to annotate with the cardinality of the given zone.

Internally this is representated by a map from [Bool], where True means element of the set, False means not.

TODO: write a more efficient implementation (for example an array of size 2^n)

Constructors

VennDiagram 

Fields

Instances

Instances details
Show a => Show (VennDiagram a) Source # 
Instance details

Defined in Math.Combinat.Sets.VennDiagrams

Show a => DrawASCII (VennDiagram a) Source # 
Instance details

Defined in Math.Combinat.Sets.VennDiagrams

Methods

ascii :: VennDiagram a -> ASCII Source #

Eq a => Eq (VennDiagram a) Source # 
Instance details

Defined in Math.Combinat.Sets.VennDiagrams

Ord a => Ord (VennDiagram a) Source # 
Instance details

Defined in Math.Combinat.Sets.VennDiagrams

vennDiagramNumberOfSets :: VennDiagram a -> Int Source #

How many sets are in the Venn diagram

vennDiagramNumberOfZones :: VennDiagram a -> Int Source #

How many zones are in the Venn diagram

vennDiagramNumberOfZones v == 2 ^ (vennDiagramNumberOfSets v)

vennDiagramNumberOfNonemptyZones :: VennDiagram Int -> Int Source #

How many nonempty zones are in the Venn diagram

isTrivialVennDiagram :: VennDiagram Int -> Bool Source #

We call venn diagram trivial if all the intersection zones has zero cardinality (that is, the original sets are all disjoint)

vennDiagramSetCardinalities :: VennDiagram Int -> [Int] Source #

Given a Venn diagram of cardinalities, we compute the cardinalities of the original sets (note: this is slow!)

enumerateVennDiagrams :: [Int] -> [VennDiagram Int] Source #

Given the cardinalities of some finite sets, we list all possible Venn diagrams.

Note: we don't include the empty zone in the tables, because it's always empty.

Remark: if each sets is a singleton set, we get back set partitions:

> [ length $ enumerateVennDiagrams $ replicate k 1 | k<-[1..8] ]
[1,2,5,15,52,203,877,4140]

> [ countSetPartitions k | k<-[1..8] ]
[1,2,5,15,52,203,877,4140]

Maybe this could be called multiset-partitions?

Example:

autoTabulate RowMajor (Right 6) $ map ascii $ enumerateVennDiagrams [2,3,3]