sign_vectors.functions

Functions for working with oriented matroids

Functions

closure(iterable)

Compute the closure of given sign vectors.

contraction(iterable, indices[, keep_components])

Return all sign vectors or vectors that are zero on given components.

deletion(iterable, indices)

Remove given components from an iterable of sign vectors or vectors.

plot_sign_vectors(iterable[, vertex_size, ...])

Plot the Hasse Diagram of sign vectors using the conformal relation.

sign_vectors.functions.closure(iterable) set[sign_vectors.sign_vectors.SignVector]

Compute the closure of given sign vectors.

INPUT:

  • iterable – an iterable of sign vectors

OUTPUT: Return the closure of iterable as a set of sign vectors.

Note

The sign vector \(X\) is in the closure of a set of sign vectors \(W\) if there exists \(Y \in W\) with \(X \leq Y\).

EXAMPLES:

We consider a list consisting of only one sign vector:

sage: from sign_vectors import *
sage: W = [sign_vector("+-0")]
sage: W
[(+-0)]
sage: closure(W)
{(000), (+00), (0-0), (+-0)}

Now, we consider a list of three sign vectors:

sage: W = [sign_vector("++-"), sign_vector("-00"), sign_vector("0--")]
sage: W
[(++-), (-00), (0--)]
sage: closure(W)
{(000), (-00), (00-), (0+0), (0+-), (+00), (+0-), (++0), (++-), (0-0), (0--)}

TESTS:

sage: closure([])
set()
sign_vectors.functions.contraction(iterable, indices: list[int], keep_components: bool = False) set

Return all sign vectors or vectors that are zero on given components.

INPUT:

  • iterable – an iterable of sign vectors or vectors

  • indices – a list of indices.

  • keep_components – a boolean

OUTPUT:

  • If keep_components is false, remove entries in indices. (default)

  • If keep_components is true, keep entries in indices.

EXAMPLES:

sage: from sign_vectors import *
sage: W = [sign_vector("++0"), sign_vector("-00"), sign_vector("00+")]
sage: W
[(++0), (-00), (00+)]

Only the third sign vector has a zero at the component with index 0. Removing this component leads to the following result:

sage: contraction(W, [0])
{(0+)}
sage: contraction(W, [1])
{(-0), (0+)}
sage: contraction(W, [2])
{(-0), (++)}

The second sign vector has zeros at positions 1 and 2:

sage: contraction(W, [1, 2])
{(-)}

We take the examples from before. With keep_components=True, we keep the zero components of the appropriate sign vectors:

sage: contraction(W, [0], keep_components=True)
{(00+)}
sage: contraction(W, [1], keep_components=True)
{(-00), (00+)}
sage: contraction(W, [2], keep_components=True)
{(-00), (++0)}
sage: contraction(W, [1, 2], keep_components=True)
{(-00)}

This function also works for matrices or lists of vectors:

sage: l = [vector([0, 0, 1]), vector([0, 2, 1]), vector([-1, 0, 1])]
sage: contraction(l, [0])
{(0, 1), (2, 1)}
sage: A = matrix([[1, 1, 0], [0, 1, 0]])
sage: contraction(A, [2])
{(0, 1), (1, 1)}
sign_vectors.functions.deletion(iterable, indices: list[int]) set

Remove given components from an iterable of sign vectors or vectors.

INPUT:

  • iterable – an iterable of sign vectors or vectors

  • indices – a list of indices

EXAMPLES:

sage: from sign_vectors import *
sage: W = [sign_vector("++0"), sign_vector("00-"), sign_vector("+00")]
sage: W
[(++0), (00-), (+00)]
sage: deletion(W, [0])
{(00), (+0), (0-)}

Duplicate sign vectors are removed if they would occur:

sage: deletion(W, [1])
{(+0), (0-)}
sage: deletion(W, [1, 2])
{(0), (+)}

This function also works for lists of vectors:

sage: l = [vector([0, 0, 1]), vector([0, 2, 1]), vector([-1, 0, 1])]
sage: deletion(l, [1])
{(-1, 1), (0, 1)}
sign_vectors.functions.plot_sign_vectors(iterable, vertex_size: int = 600, figsize: Optional[int] = None, aspect_ratio=None)

Plot the Hasse Diagram of sign vectors using the conformal relation.

INPUT:

  • iterable – an iterable of sign vectors

  • vertex_size – the size of the vertices in the plot (default: 600)

  • figsize – the size of the figure (default: None)

  • aspect_ratio – the aspect ratio of the plot (default: None)