ASKSAGE: Sage Q&A Forum - Individual question feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 16 Aug 2020 13:48:50 -0500Lattice of subspaces of a finite field vector spacehttps://ask.sagemath.org/question/53067/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?Sun, 16 Aug 2020 11:22:51 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/Comment by rburing for <p>Let $V$ be a vector space over a finite field with $q$ elements and dimension $n$.</p>
<p>How one can obtain the lattice $L_{n,q}$ of subspaces of $V$ as a poset in Sage?</p>
https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53071#post-id-53071See https://ask.sagemath.org/question/49380/lattices-via-sage/?answer=49445#post-id-49445Sun, 16 Aug 2020 12:04:31 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53071#post-id-53071Comment by klaaa for <p>Let $V$ be a vector space over a finite field with $q$ elements and dimension $n$.</p>
<p>How one can obtain the lattice $L_{n,q}$ of subspaces of $V$ as a poset in Sage?</p>
https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53070#post-id-53070I 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.Sun, 16 Aug 2020 11:37:22 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53070#post-id-53070Comment by slelievre for <p>Let $V$ be a vector space over a finite field with $q$ elements and dimension $n$.</p>
<p>How one can obtain the lattice $L_{n,q}$ of subspaces of $V$ as a poset in Sage?</p>
https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53069#post-id-53069What have you tried?Sun, 16 Aug 2020 11:30:23 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53069#post-id-53069Answer by slelievre for <p>Let $V$ be a vector space over a finite field with $q$ elements and dimension $n$.</p>
<p>How one can obtain the lattice $L_{n,q}$ of subspaces of $V$ as a poset in Sage?</p>
https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?answer=53074#post-id-53074The 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 local copy of the documentation on your computer
- the online documentation:
[https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html](https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html)
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 primitivesSun, 16 Aug 2020 13:39:51 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?answer=53074#post-id-53074Comment by klaaa for <p>The question is similar to a previous question, as pointed out by <a href="/users/24971/rburing/">@rburing</a>.</p>
<p>Let us however go through a step by step guided exploration of the question.</p>
<p>In passing we will recall ways to explore the documentation.</p>
<p>Choose the size of the finite field, and the dimension of the vector space.</p>
<pre><code>sage: q = 3
sage: d = 3
</code></pre>
<p>Create the finite field and the vector space.</p>
<pre><code>sage: F = GF(q)
sage: V = F^d
</code></pre>
<p>Check what methods are available for <code>V</code> using <code>V.[TAB]</code> (ie press the tab key).</p>
<p>In particular we find:</p>
<pre><code>sage: V.dimension()
3
sage: V.subspaces(dim=2)
<generator object FreeModule_generic_field.subspaces at 0x1eb45c650>
</code></pre>
<p>Check the inline documentation for the <code>Poset</code> and the <code>LatticePoset</code> constructors:</p>
<pre><code>sage: Poset?
sage: LatticePoset?
sage: browse_sage_doc(Poset)
sage: browse_sage_doc(LatticePoset)
</code></pre>
<p>Or browse the posets page of the Sage documentation in your browser, using one of:</p>
<ul>
<li>the local copy of the documentation on your computer</li>
<li>the online documentation:
<a href="https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html">https://doc.sagemath.org/html/en/reference/combinat/sage/combinat/posets/posets.html</a></li>
</ul>
<p>The documentation reveals one can create a poset from a dictionary of upper covers.</p>
<p>The "defaultdict" variant of a dictionary will be more convenient; import it:</p>
<pre><code>sage: from collections import defaultdict
</code></pre>
<p>Now run through subspaces by decreasing dimension, and add each to the
list of upper covers of its subspaces of the next dimension down:</p>
<pre><code>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
</code></pre>
<p>Labels in the rendered view are too verbose, so create a poset
using the basis matrix of each subspace:</p>
<pre><code>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
</code></pre>
<p>Adjust the shape and size of the nodes for plotting the graph:</p>
<pre><code>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
</code></pre>
https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53075#post-id-53075Thank 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.Sun, 16 Aug 2020 13:48:50 -0500https://ask.sagemath.org/question/53067/lattice-of-subspaces-of-a-finite-field-vector-space/?comment=53075#post-id-53075