# Lattice of subspaces of a finite field vector space

Let $V$ be a vector space over a finite field with $q$ elements and dimension $n$.

How one can obtain the lattice $L_{n,q}$ of subspaces of $V$ as a poset in Sage?

edit retag close merge delete

I do not have a good approach to this problem as my expierence with SAGE is very limited. I was hoping there is an existing command to obtain this poset via SAGE since SAGE contains many posets in the catalog, but I was not able to find this.

Sort by » oldest newest most voted

The question is similar to a previous question, as pointed out by @rburing.

Let us however go through a step by step guided exploration of the question.

In passing we will recall ways to explore the documentation.

Choose the size of the finite field, and the dimension of the vector space.

sage: q = 3
sage: d = 3


Create the finite field and the vector space.

sage: F = GF(q)
sage: V = F^d


Check what methods are available for V using V.[TAB] (ie press the tab key).

In particular we find:

sage: V.dimension()
3

sage: V.subspaces(dim=2)
<generator object FreeModule_generic_field.subspaces at 0x1eb45c650>


Check the inline documentation for the Poset and the LatticePoset constructors:

sage: Poset?
sage: LatticePoset?
sage: browse_sage_doc(Poset)
sage: browse_sage_doc(LatticePoset)


Or browse the posets page of the Sage documentation in your browser, using one of:

The documentation reveals one can create a poset from a dictionary of upper covers.

The "defaultdict" variant of a dictionary will be more convenient; import it:

sage: from collections import defaultdict


Now run through subspaces by decreasing dimension, and add each to the list of upper covers of its subspaces of the next dimension down:

sage: upper_covers = defaultdict(list)
sage: for d in range(V.dimension(), 0, -1):
....:     S = V.subspaces(dim=d)
....:     for B in S:
....:         for A in B.subspaces(dim=d-1):
....:             upper_covers[A].append(B)
....:
sage: P = LatticePoset(data=upper_covers)
sage: P
Finite poset containing 28 elements
sage: p = P.plot()
sage: p.show()
Launched png viewer for Graphics object consisting of 107 graphics primitives


Labels in the rendered view are too verbose, so create a poset using the basis matrix of each subspace:

sage: upper_covers = defaultdict(list)
sage: for d in range(V.dimension(), 0, -1):
....:     S = V.subspaces(dim=d)
....:     for B in S:
....:         for A in B.subspaces(dim=d-1):
....:             upper_covers[A.basis_matrix()].append(B.basis_matrix())
....:
sage: P = LatticePoset(data=upper_covers)
sage: P
Finite poset containing 28 elements


Adjust the shape and size of the nodes for plotting the graph:

sage: p = P.plot(element_shape='s', element_size=1500)
sage: p.show(figsize=20)
Launched png viewer for Graphics object consisting of 107 graphics primitives

more

Thank you. And sorry, I forgot I asked a similar question before. I forgot about it since I did not work much with those lattices as they get too big quickly for most experiments.