First, note that your list U
is not a list of vectors but a list of lists. So, the first thing to do is to transform it into a list of vectors (forget about the immutable=True
for now):
sage: V = [vector(u, immutable=True) for u in U]
sage: V
[(1, 0, 0, 0, 0),
(0, 0, 0, 1, 1),
(1, 1, 0, 0, 0),
(0, 0, 1, 0, 0),
(0, 0, 0, 1, 0),
(0, 1, 0, 0, 1),
(1, 0, 1, 0, 0),
(0, 0, 0, 0, 1),
(1, 0, 1, 1, 0),
(0, 1, 0, 0, 0),
(0, 0, 1, 1, 1),
(1, 1, 1, 1, 1)]
Now, if you look at the Poset
constructor documentation:
sage: Poset?
you will see that the second way to build a poset is to provide a pair (E,f)
where E
are the elements of the poset and f(x,y)
is a function that returns True
when x<=y
in the poset. This corresponds to your description.
So we can do:
sage: P = Poset((V, lambda v,w: w-v in V))
where lambda v,w: w-v in V
is a Python way to describe "the map that, given v and w, returns whether w-v belongs to V".
You can check that you have the expected poset by drawing it:
sage: P.show()
Remark: everything seems to be very natural (we just translated your question into Sage/Python), except perhaps the immutable=True
. This is due to the fact that, if the elements of V
are mutable, you will get the following error:
sage: V = [vector(u) for u in U]
sage: P = Poset((V, lambda v,w: w-v in V))
TypeError: mutable vectors are unhashable