![]() | 1 | initial version |
I do not know whether there is such a builtin construction in Sage, so here is a possible construction.
Let S
be a set, e.g.:
sage: S = {'a','b','c','d'}
First, we define the list of partitions over S
, where each partition is a tuple and each atom of the partition is also a tuple. We do that because elements of a Poset must be hashable, so lists are not allowed:
sage: from sympy.utilities.iterables import multiset_partitions
sage: list(tuple([tuple(j) for j in i]) for i in multiset_partitions(S))
[(('a', 'b', 'c', 'd'),),
(('a', 'b', 'c'), ('d',)),
(('a', 'b', 'd'), ('c',)),
(('a', 'b'), ('c', 'd')),
(('a', 'b'), ('c',), ('d',)),
(('a', 'c', 'd'), ('b',)),
(('a', 'c'), ('b', 'd')),
(('a', 'c'), ('b',), ('d',)),
(('a', 'd'), ('b', 'c')),
(('a',), ('b', 'c', 'd')),
(('a',), ('b', 'c'), ('d',)),
(('a', 'd'), ('b',), ('c',)),
(('a',), ('b', 'd'), ('c',)),
(('a',), ('b',), ('c', 'd')),
(('a',), ('b',), ('c',), ('d',))]
Second, we define a function that decides whether one partition refines another one:
sage: refine = lambda p,q : all(any(set(i).issubset(set(j)) for j in q) for i in p)
sage: refine(((1,), (2, 3)), ((1,), (2,), (3,)))
False
sage: refine(((1,), (2,), (3,)), ((1,), (2, 3)))
True
With both the list of partitions and the refinment order, we can construct the poset:
sage: P = Poset((list(tuple([tuple(j) for j in i]) for i in multiset_partitions(S)), refine))
sage: P
Finite poset containing 15 elements
sage: P.plot()
![]() | 2 | No.2 Revision |
I do not know whether there is such a builtin construction in Sage, so here is a possible construction.
Let S
be a set, e.g.:
sage: S = {'a','b','c','d'}
First, we define the list of partitions over S
, where each partition is a tuple and each atom of the partition is also a tuple. We do that because elements of a Poset must be hashable, so lists are not allowed:
sage: from sympy.utilities.iterables import multiset_partitions
sage: list(tuple([tuple(j) for j in i]) for i in multiset_partitions(S))
[(('a', : sage: list(SetPartitions(S))
[{{'a',
'b', 'c', 'd'),),
(('a', 'd'}},
{{'a', 'b', 'c'), ('d',)),
(('a', 'c'}, {'d'}},
{{'a', 'b', 'd'), ('c',)),
(('a', 'b'), ('c', 'd')),
(('a', 'b'), ('c',), ('d',)),
(('a', 'd'}, {'c'}},
{{'a', 'b'}, {'c', 'd'}},
{{'a', 'b'}, {'c'}, {'d'}},
{{'a', 'c', 'd'), ('b',)),
(('a', 'c'), ('b', 'd')),
(('a', 'c'), ('b',), ('d',)),
(('a', 'd'), ('b', 'c')),
(('a',), ('b', 'd'}, {'b'}},
{{'a', 'c'}, {'b', 'd'}},
{{'a', 'c'}, {'b'}, {'d'}},
{{'a', 'd'}, {'b', 'c'}},
{{'a'}, {'b', 'c', 'd')),
(('a',), ('b', 'c'), ('d',)),
(('a', 'd'), ('b',), ('c',)),
(('a',), ('b', 'd'), ('c',)),
(('a',), ('b',), ('c', 'd')),
(('a',), ('b',), ('c',), ('d',))]
'd'}},
{{'a'}, {'b', 'c'}, {'d'}},
{{'a', 'd'}, {'b'}, {'c'}},
{{'a'}, {'b', 'd'}, {'c'}},
{{'a'}, {'b'}, {'c', 'd'}},
{{'a'}, {'b'}, {'c'}, {'d'}}]
Second, we define a function that decides whether one partition refines another one:
sage: refine = lambda p,q : all(any(set(i).issubset(set(j)) for j in q) for i in p)
sage: refine(((1,), (2, 3)), ((1,), (2,), (3,)))
False
sage: refine(((1,), (2,), (3,)), ((1,), (2, 3)))
True
With both the list of partitions and the refinment order, we can construct the poset:
sage: P = Poset((list(tuple([tuple(j) for j in i]) for i in multiset_partitions(S)), Poset((list(SetPartitions(S)), refine))
sage: P
sage: P
Finite poset containing 15 elements
sage: P.plot()
![]() | 3 | No.3 Revision |
I do not know whether there is such a builtin construction in Sage, so here is a possible construction.
Let S
be a set, e.g.:
sage: S = {'a','b','c','d'}
First, we define the list of partitions over S
:
sage: list(SetPartitions(S))
[{{'a', 'b', 'c', 'd'}},
{{'a', 'b', 'c'}, {'d'}},
{{'a', 'b', 'd'}, {'c'}},
{{'a', 'b'}, {'c', 'd'}},
{{'a', 'b'}, {'c'}, {'d'}},
{{'a', 'c', 'd'}, {'b'}},
{{'a', 'c'}, {'b', 'd'}},
{{'a', 'c'}, {'b'}, {'d'}},
{{'a', 'd'}, {'b', 'c'}},
{{'a'}, {'b', 'c', 'd'}},
{{'a'}, {'b', 'c'}, {'d'}},
{{'a', 'd'}, {'b'}, {'c'}},
{{'a'}, {'b', 'd'}, {'c'}},
{{'a'}, {'b'}, {'c', 'd'}},
{{'a'}, {'b'}, {'c'}, {'d'}}]
Second, we define a function that decides whether one a partition refines another one:
sage: refine = lambda p,q : all(any(set(i).issubset(set(j)) for j in q) for i in p)
sage: refine(((1,), (2, 3)), ((1,), (2,), (3,)))
False
sage: refine(((1,), (2,), (3,)), ((1,), (2, 3)))
True
With both the list of partitions and the refinment order, we can construct the poset:
sage: P = Poset((list(SetPartitions(S)), refine))
sage: P
sage: P
Finite poset containing 15 elements
sage: P.plot()
![]() | 4 | No.4 Revision |
I do not know whether there is such a builtin construction in Sage, so here is a possible construction.
Let S
be a set, e.g.:
sage: S = {'a','b','c','d'}
First, we define the list of partitions over S
:
sage: list(SetPartitions(S))
[{{'a', 'b', 'c', 'd'}},
{{'a', 'b', 'c'}, {'d'}},
{{'a', 'b', 'd'}, {'c'}},
{{'a', 'b'}, {'c', 'd'}},
{{'a', 'b'}, {'c'}, {'d'}},
{{'a', 'c', 'd'}, {'b'}},
{{'a', 'c'}, {'b', 'd'}},
{{'a', 'c'}, {'b'}, {'d'}},
{{'a', 'd'}, {'b', 'c'}},
{{'a'}, {'b', 'c', 'd'}},
{{'a'}, {'b', 'c'}, {'d'}},
{{'a', 'd'}, {'b'}, {'c'}},
{{'a'}, {'b', 'd'}, {'c'}},
{{'a'}, {'b'}, {'c', 'd'}},
{{'a'}, {'b'}, {'c'}, {'d'}}]
Second, we define a function that decides whether a partition refines another one:
sage: refine = lambda p,q : all(any(set(i).issubset(set(j)) for j in q) for i in p)
sage: refine(((1,), (2, 3)), ((1,), (2,), (3,)))
False
sage: refine(((1,), (2,), (3,)), ((1,), (2, 3)))
True
With both the list of partitions and the refinment order, we can construct the poset:
sage: P = Poset((list(SetPartitions(S)), refine))
sage: P
sage: P
Finite poset containing 15 elements
sage: P.is_lattice()
True
sage: P.plot()
![]() | 5 | No.5 Revision |
I do not know whether there is such a builtin construction in Sage, so here is a possible construction.
Let S
be a set, e.g.:
sage: S = {'a','b','c','d'}
First, we define the list of partitions over S
:
sage: list(SetPartitions(S))
[{{'a', 'b', 'c', 'd'}},
{{'a', 'b', 'c'}, {'d'}},
{{'a', 'b', 'd'}, {'c'}},
{{'a', 'b'}, {'c', 'd'}},
{{'a', 'b'}, {'c'}, {'d'}},
{{'a', 'c', 'd'}, {'b'}},
{{'a', 'c'}, {'b', 'd'}},
{{'a', 'c'}, {'b'}, {'d'}},
{{'a', 'd'}, {'b', 'c'}},
{{'a'}, {'b', 'c', 'd'}},
{{'a'}, {'b', 'c'}, {'d'}},
{{'a', 'd'}, {'b'}, {'c'}},
{{'a'}, {'b', 'd'}, {'c'}},
{{'a'}, {'b'}, {'c', 'd'}},
{{'a'}, {'b'}, {'c'}, {'d'}}]
Second, we define a function that decides whether a partition refines another one:
sage: refine = lambda p,q : all(any(set(i).issubset(set(j)) for j in q) for i in p)
sage: refine(((1,), (2, 3)), ((1,), (2,), (3,)))
False
sage: refine(((1,), (2,), (3,)), ((1,), (2, 3)))
True
With both the list of partitions and the refinment order, we can construct the poset:
sage: P = Poset((list(SetPartitions(S)), refine))
sage: P
sage: P
Finite poset containing 15 elements
sage: P.is_lattice()
True
sage: P.plot()