1 Introduction

In the present article we are concerned with a special class of algebraic-geometric codes [14] that are defined on toric varieties. Building on a work of S. Hansen [5], J. Hansen initiated the study of toric codes on polygons in [4]. This development quickly led to numerous new results on the algebraic-geometric codes that are constructed on higher dimensional toric varieties. The articles [9,10,11,12] amplified the importance of combinatorial approach in determining the parameters of the toric codes. Our goal in this article is to show that, the set of order polytopes form an interesting ground for the applications of such work.

Let P be a poset whose elements are listed as \(\varepsilon _1,\dots ,\varepsilon _m\). Let N denote the free \({{\mathbb {Z}}}\)-module on P, \(N:=\bigoplus _{i=1}^m{{\mathbb {Z}}}\varepsilon _i\). Let M denote the dual of N, that is \(M:={{\,\mathrm{Hom}\,}}_{{\mathbb {Z}}}(N,{{\mathbb {Z}}})\). The dual of the element \(\varepsilon _i\), \(i\in \{1,\dots ,m\}\), in M will be denoted by \(e_i\). Let \(2^P\) denote the set of all subsets of P. We define the function \(\rho :2^P\rightarrow N\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\) by \(W\mapsto \sum _{\varepsilon _i\in W}\varepsilon _i\). The order polytope of P, denoted by \(\mathbf {O}_P\), is the convex hull of the finite set

$$\begin{aligned} \{\rho (W):W \text { is an upper order ideal of } P\}. \end{aligned}$$

The face lattice of the polytope \(\mathbf {O}_P\) was first described by Geissinger [3], whose results were amplified by Stanley in [13]. A concrete description of the edges of \(\mathbf {O}_P\) can be found in [8]. Following [6], we now introduce a class of toric varieties that are closely related to the order polytopes. The set of all order ideals of P, denoted by J(P), is a distributive lattice with respect to inclusion. In particular, we have the joins (denoted by \(\vee \)) and the meets (denoted by \(\wedge \)) of the elements of J(P). Let \(Y:=\{y_\alpha :\alpha \in J(P)\}\) be a set of algebraically independent variables indexed by the order ideals. Then the Hibi toric scheme associated with P is the projective scheme \({{\,\mathrm{Proj}\,}}{k[Y]/I}\), where I is the homogeneous ideal

$$\begin{aligned} I=(y_\alpha y_\beta -y_{\alpha \wedge \beta }y_{ \alpha \vee \beta }:y_\alpha , y_\beta \in Y). \end{aligned}$$

It turns out that the fan of \(X_P\) is the normal fan of the order polytope \(\mathbf {O}_P\).

The purpose of our article is to investigate the parameters of the toric code of the defining polytope \(\mathbf {O}_P\) of \(X_P\). The parameters that we speak of are called the “length,” the “dimension,” and the “minimum distance.” Although our method applies to all finite posets, in this article we focus on the minimum distance computation for the order polytopes of the rooted trees only. Let \(P=\{\varepsilon _1,\dots ,\varepsilon _m\}\) be a rooted tree, where \(\varepsilon _1\) is the root. We view P as a connected, graded poset with the unique minimal element as the root. Our first main result (recorded as Theorem 4.4) states that minimum distance of the toric code \(\mathcal {C}_{\mathbf {O}_P}\) over a finite field \({{\mathbb {F}}}_q\), where \(q> 3\), is given by

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_P}) = (q-1)^a (q-2)^b,\end{aligned}$$

for some a and b such that \(a+b=m\). In fact, we know precisely what a and b are.

Let \(\mathbf {P}\) be a polytope. The length of the associated toric code \(\mathcal {C}_{\mathbf {P}}\) over \({{\mathbb {F}}}_q\) is given by \((q-1)^{\dim \mathbf {P}}\), where \(\dim \mathbf {P}\) is the dimension of the affine hull of \(\mathbf {P}\). Hence, in our case, the length is given by \((q-1)^{\dim \mathbf {O}_P}=(q-1)^m\), where m is the cardinality of the poset P. On the other hand, the dimension of a toric code of \(\mathbf {P}\) is given by the number of lattice points in \(\mathbf {P}\). Therefore, in our case, it is given by the number of (upper) order ideals of P. For a rooted tree with m vertices, this number (dimension) varies in the range \(m+1,\dots ,2^{m-1}+1\); it is equal to the number of order preserving maps \(\sigma :P\rightarrow \{0,1\}\). The unique rooted tree with m vertices that has \(m+1\) order ideals is the chain with m vertices. The unique rooted tree with m vertices that has \(2^{m-1}+1\) order ideals is the “m-th shrub” defined in Sect. 4.

Let Q be a graded poset with 2m elements (\(m\in {{\mathbb {Z}}}^+\)). If Q has m minimum elements, then we will call Q an (mm)-bipartite poset. The second infinite family of toric codes that we consider comes from the order polytopes of (mm)-bipartite posets. Our second main result (recorded as Theorem 5.3) states that the minimum distance of the toric code \(\mathcal {C}_{\mathbf {Q}}\) over a finite field \({{\mathbb {F}}}_q\), where \(q>3\), is given by

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_P}) = (q-1)^m (q-2)^m.\end{aligned}$$

The dimension of such a code varies in the range \(2^{m+1}-1,\dots , 3^m\).

Before closing this introduction, we want to mention a fact we inferred from our calculations. In general, a preferable linear error correcting code is the one that has a ratio of dimension/length fixed while the ratio minimum distance/length is as large as possible. It is natural to wonder if it is possible to increase these ratios for a toric code by switching to the polar polytope. In this article we pay a close attention to the polar of the order polytope of a graded poset. It turns out that, by a result of Hibi and Higashitani [7], the polar polytope of a suitable dilation of \(\mathbf {O}_P\), called the poset polytope of P, is reflexive and terminal. (We will explain these notions in the sequel.) These properties essentially imply that the number of lattice points of a poset polytope is much smaller compared to the number of lattice points of the order polytope. Hence, as far as the parameters of linear codes are concerned, the order polytopes are better than the poset polytopes.

The structure of our paper is as follows. In the next section we introduce our basic notation regarding posets, polytopes, and toric codes. In the same section we briefly review some results of Soprunov and Soprunova also. The purpose of Sect. 3 is to compare the structures of the order polytopes and poset polytopes. We prove our first main result about the toric codes defined by the rooted tree posets in Sect. 4. We prove our second main result about the toric codes defined by the (mm)-bipartite graphs in Sect. 5. In addition, in this section, we observe that (Lemma 5.1) the free sum of two order polytopes, \(\mathbf {O}_P\oplus \mathbf {O}_Q\), is equivalent to the order polytope \(\mathbf {O}_{P\oplus Q}\), where \(P\oplus Q\) stands for the ordinal sum of P and Q. Here, the equivalence is defined by the change of coordinates.

2 Preliminaries

In this article, by a poset we will always mean a finite poset. A lower order ideal in P is a subposet I such that for every \(y\in I\), if \(x\le y\) in P, then \(x\in I\). An upper order ideal in P is defined similarly where we replace the condition \(x\le y\) with \(y\le x\).

The set of all lower order ideals of P is denoted by J(P). This is a distributive lattice with respect to inclusion. The set of all upper order ideals also form a distributive lattice, which is isomorphic to \(J(P^{opp })\), where \(P^{opp }\) denotes the opposite poset to P. An order reversing bijection between two posets will be called an anti-isomorphism. If P and Q are two isomorphic (resp. anti-isomorphic) posets, then we will write \(P\cong Q\) (resp. \({P\cong _{a }Q}\)).

Let x and y be two elements from P. If \(x\le y\), and \(x\le z\le y\) implies that \(z=x\) or \(z=y\), then y is said to cover x. Customarily, the cover relation is denoted by \(x\lessdot y\). A chain is a poset \(C:=\{x_1,\dots ,x_n\}\) whose elements are linearly ordered, \(x_1\lneq x_2\lneq \ldots \lneq x_n\). A maximal chain in a poset P is a chain \(C\subseteq P\) such that C is not a subposet of any other chain in P. If \(C=\{x_1,\dots ,x_k\}\) is a chain, then the length of C is defined as \(k-1\). An antichain is a poset whose elements are all incomparable. The greatest possible size of an antichain in P is called the width of P. Dilworth’s theorem [2] states that the width is equal to the minimal number of chains that cover the set. A poset P is called a graded (or ranked) poset if every maximal chain in P has the same length. In this case, a function \(\ell :P\rightarrow {{\mathbb {Z}}}\) which has the property that \(\ell (y)=\ell (x)+1\) for every cover relation \(x\lessdot y\) in P is called a rank function for P. Without loss of generality we assume that \(\ell (x)=0\) whenever x is a minimal element. Then \(\ell \) is uniquely determined by P, so, we call it the rank function of P.

The Hasse diagram of a poset P is the directed graph whose vertex set is the set of elements of P such that for \(x,y\in P\) there is a directed edge from x to y if x is covered by y in P. A poset P is said to be connected if its Hasse diagram is connected. Clearly, if a finite poset possesses a top element (denoted by \(\hat{1}\)) or a bottom element (denoted by \(\hat{0}\)), then it is connected. A lattice is a poset L such that every pair of elements has a least upper bound and a greatest lower bound.

The polar (or dual) of a polytope \(\mathbf {P}\subset {{\mathbb {Q}}}^m\) is the polytope \(\mathbf {P}^\circ \) defined by

$$\begin{aligned}\mathbf {P}^\circ :=\{ y\in ({{\mathbb {Q}}}^m)^*:\langle x,y \rangle \le 1\text { for all }x \in \mathbf {P}\}.\end{aligned}$$

Here, \(\langle \,{\cdot }\,,\,{\cdot }\,\rangle \) is the canonical evaluation pairing between \({{\mathbb {Q}}}^m\) and \(({{\mathbb {Q}}}^m)^*\).

Let \(x_0\) be a point in \({{\mathbb {Q}}}^{m}\), and let H be a hyperplane in \({{\mathbb {Q}}}^m\) such that \(x_0\notin H\). Let \(\mathbf {P}\) be a polytope in H. The pyramid over \(\mathbf {P}\)with apex at \(x_0\) is the convex hull \({{\,\mathrm{conv}\,}}(\mathbf {P},x_0)\). We will denote a pyramid over \(\mathbf {P}\) by \({{\,\mathrm{pyr}\,}}\mathbf {P}\).

The vertex set of a polytope \(\mathbf {P}\) will be denoted by \(V(\mathbf {P})\). Let \(\mathbf {Q}\) and \(\mathbf {P}\) be two polytopes in \({{\mathbb {Q}}}^m\) and \({{\mathbb {Q}}}^n\), respectively. The direct product (or simply the product) of \(\mathbf {Q}\) and \(\mathbf {P}\), denoted by \(\mathbf {Q}\times \mathbf {P}\), is defined as the convex hull,

$$\begin{aligned} \mathbf {Q}\times \mathbf {P}:= {{\,\mathrm{conv}\,}}{\{ (a,b):a\in V(\mathbf {Q}), \, b\in V(\mathbf {P})\}}. \end{aligned}$$

We now assume that the origin of \({{\mathbb {Q}}}^m\) (resp. of \({{\mathbb {Q}}}^n\)) is contained in \(\mathbf {Q}\) (resp. in \(\mathbf {P}\)). The free sum of \(\mathbf {Q}\) and \(\mathbf {P}\), denoted by \(\mathbf {Q}\oplus \mathbf {P}\), is defined as follows:

$$\begin{aligned} \mathbf {Q}\oplus \mathbf {P}:= {{\,\mathrm{conv}\,}}{\bigl ( \mathbf {Q}\times \{0_{{{\mathbb {Q}}}^n}\}, \{0_{{{\mathbb {Q}}}^m}\} \times \mathbf {P}\bigr )}. \end{aligned}$$

2.1 Toric Codes

The purpose of this subsection is to introduce toric codes by circumventing much of the original definition of the algebraic-geometric codes. For a detailed introduction to this important subject, we recommend the textbook [14].

Let N be a free abelian group of rank m, and let M denote its dual group. Let \(\mathbf {P}\) be a full dimensional lattice polytope in \(M\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\). The lattice points in \(\mathbf {P}\cap M\) define monomials that are regarded as polynomial functions on the m-dimensional torus \(T_N:={{\,\mathrm{Hom}\,}}(N,\overline{{{\mathbb {F}}}_q^*})\). Let \(H^0(T_N({{\mathbb {F}}}_q),\mathbf {P})\) denote the \({{\mathbb {F}}}_q\)-vector space that is spanned by these monomials. The toric code of \(\mathbf {P}\) is then the image of the evaluation map

$$\begin{aligned} ev :H^0(T_N({{\mathbb {F}}}_q), \mathbf {P})\rightarrow ({{\mathbb {F}}}_q^*)^m,\qquad f\mapsto (f(x))_{x\in T_N({{\mathbb {F}}}_q)}. \end{aligned}$$

More generally, the algebraic-geometric code associated with an ample line bundle on a normal variety X that is defined over \(\overline{{{\mathbb {F}}}_q}\) is the image of the germ-evaluation map on a set of \({{\mathbb {F}}}_q\)-rational points \(S\subseteq X({{\mathbb {F}}}_q)\). The toric codes from lattice polytopes are defined by evaluating on the \({{\mathbb {F}}}_q\)-rational points of the open orbit of a normal toric variety.

Hereafter, we denote by \(\mathcal {C}_{\mathbf {P}}\) the toric code associated with a lattice polytope \(\mathbf {P}\). The length of \(\mathcal {C}_{\mathbf {P}}\) is defined as

$$\begin{aligned} length :=(q-1)^m, \end{aligned}$$

where m is the dimension of the toric variety. The dimension of \(\mathcal {C}_{\mathbf {P}}\) is defined as the vector space dimension of the space of sections,

$$\begin{aligned} \text {dimension} := \dim H^0(T_N({{\mathbb {F}}}_q), \mathbf {P}). \end{aligned}$$

This number is given by the number of lattice points \(\mathbf {P}\cap M\). Finally, the computation of the minimum distance for the toric codes associated with an order polytope is the main focus of the present article. It is calculated as follows. For a section \(f\in H^0(T_N({{\mathbb {F}}}_q),\mathbf {P})\), let Z(f) denote the number of points in \(({{\mathbb {F}}}_q^*)^m\) where f vanishes. Then the minimum distance of \(\mathcal {C}_{\mathbf {P}}\), denoted by \(d(\mathcal {C}_{\mathbf {P}})\), is given by

$$\begin{aligned} d(\mathcal {C}_{\mathbf {P}})=(q-1)^m\,-\!\max _{f\in H^0(T_N({{\mathbb {F}}}_q),\mathbf {P})\setminus \{0\}} Z(f). \end{aligned}$$

We will make use of the following results which are due to Soprunov and Soprunova.

Lemma 2.1

[12, Thm. 2.1]   Let \(\mathbf {P}\) and \(\mathbf {Q}\) be two lattice polytopes contained in the boxes \([0,q-2]^m\subseteq {{\mathbb {Q}}}^m\) and \([0,q-2]^n\subseteq {{\mathbb {Q}}}^n\), respectively. Then the minimum distance of the code of the product \(\mathbf {P}\times \mathbf {Q}\) is given by \(d(\mathcal {C}_{\mathbf {P}\times \mathbf {Q}})=d(\mathcal {C}_{\mathbf {P}})d(\mathcal {C}_{\mathbf {Q}})\).

Let \(K_q^n\) denote the n-dimensional cube \([0,q-2]^n\). Let \(\mathbf {Q}\) be an n-dimensional lattice polytope contained in \(K_q^n\). Then the unit pyramid over \(\mathbf {Q}\) is defined by \({{\,\mathrm{conv}\,}}{\{e_{n+1},(x,0):x\in \mathbf {Q}\}}\), where \(e_{n+1}\) is the unit vector \((0,\dots ,0,1)\in {{\mathbb {R}}}^{n+1}\).

Lemma 2.2

[12, Thm. 2.3]   Let \(\mathbf {Q}\) be a lattice polytope of \(\dim \mathbf {Q}\ge 1\). If \(\mathbf {P}\) denotes the unit pyramid over \(\mathbf {Q}\), then we have \(d(\mathcal {C}_{\mathbf {P}})=(q-1)d(\mathcal {C}_{\mathbf {Q}})\).

3 Order Polytopes, Poset Polytopes

Let \(P=\{\varepsilon _1,\dots ,\varepsilon _m\}\) be a finite poset and let N denote the free \({{\mathbb {Z}}}\)-module generated by P. Let \({\hat{P}}\) denote \(P\cup \{\hat{0},\hat{1}\}\), where \(\hat{0}\) (resp. \(\hat{1}\)) is such that \(\hat{0}\lneq \varepsilon _i\) (resp. \(\varepsilon _i\lneq \hat{1}\)) for every \(i\in \{1,\dots ,m\}\). Let M denote the dual of N, that is \(M:=Hom _{{\mathbb {Z}}}(N,{{\mathbb {Z}}})\), and let \(\{e_1,\dots ,e_m\}\) be the basis of M that is dual to P. Let us temporarily denote \(\hat{0}\) (resp. \(\hat{1}\)) by \(\varepsilon _0\) (resp. \(\varepsilon _{m+1}\)). Then for each covering relation \(\varepsilon _i\lessdot \varepsilon _j\) in \({\hat{P}}\), we introduce a vector \(\rho (\varepsilon _i,\varepsilon _j)\) in \(M\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\) as follows:

$$\begin{aligned} \rho (\varepsilon _i,\varepsilon _j):={\left\{ \begin{array}{ll} e_i &{} \text {if }\varepsilon _j=\hat{1},\\ e_i-e_j &{} \text {if }\varepsilon _i,\varepsilon _j \in P,\\ -e_j &{} \text {if }\varepsilon _i=\hat{0}. \end{array}\right. } \end{aligned}$$
(3.1)

The poset polytope of P, denoted by \({{\,\mathrm{\mathbf {H}}\,}}_P\), is the convex hull of points \(\rho (\varepsilon _i,\varepsilon _j)\), where \(\varepsilon _i\lessdot \varepsilon _j\) is a cover in \({\hat{P}}\). A systematic study of these polytopes has been initiated by Hibi and Higashitani in [7]. In this article, we construct linear error correcting codes by using (the polars of the) poset polytopes.

Next, we will discuss poset polytopes and their relationship to the order polytopes. Since it is already introduced (in the introduction), we will not repeat the definition of a poset polytope here. In [7], Hibi and Higashitani showed that these polytopes have some remarkable properties. We will summarize the relevant results from [7] in the form of a single lemma to ease our referencing.

Lemma 3.1

For every poset P, the following statements hold:

  1. (i)

    \({{\,\mathrm{\mathbf {H}}\,}}_P\) is a Fano polytope, that is, 0 is the unique integral interior point.

  2. (ii)

    \({{\,\mathrm{\mathbf {H}}\,}}_P\) is terminal, that is, each integral point on the boundary of \({{\,\mathrm{\mathbf {H}}\,}}_P\) is a vertex.

  3. (iii)

    \({{\,\mathrm{\mathbf {H}}\,}}_P\) is Gorenstein, that is, its dual polytope is integral.

  4. (iv)

    If P is a graded poset of length \(l-2\), then the polar polytope of \({{\,\mathrm{\mathbf {H}}\,}}_P\) is the dilated and translated order polytope \(l\mathbf {O}_P-v\), where v is the unique lattice point in \(l\mathbf {O}_P\).

The items (i)–(iv) are Lemmas 1.3, 1.4, 1.5, and Remark 1.6 of [7], respectively. The proof of (iv) follows from the definitions.

Remark 3.2

A Gorenstein and Fano polytope is known as the reflexive polytope. In particular, the dual of a reflexive polytope is reflexive. The normal fan of a reflexive polytope gives a “Gorenstein Fano toric variety” [1, Thm. 8.3.4]. (Such toric varieties are always normal.) In particular, a reflexive polytope is very ample in the sense of [1, Defn. 2.2.17].

Notation 3.3

If P is a graded poset of length \(l-2\), then the polytope \(l\mathbf {O}_P-v\), where v is the unique lattice point in \(l\mathbf {O}_P\), will be denoted by \(\mathbf {O}_P(l)\).

Fig. 1
figure 1

Bounding P

Example 3.4

Let P (resp. \(\hat{P}\)) be the poset whose Hasse diagram is on the left (resp. on the right) in Fig. 1. By fixing \(\{\varepsilon _1,\varepsilon _2,\varepsilon _3\}\) as a basis for \(N\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\), we will identify the elements of \(N\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\) with their coordinate vectors. Then, the vertex set of \(\mathbf {O}_P\) consists of the following vectors in \({{\mathbb {Q}}}^3\):

$$\begin{aligned} \rho (\emptyset )= (0,0,0), \qquad \rho (\{\varepsilon _2\})= \varepsilon _2 = (0,1,0), \qquad \rho (\{\varepsilon _3\})= \varepsilon _3 = (0,0,1), \\ \rho (\{\varepsilon _2,\varepsilon _3\})=\varepsilon _2+\varepsilon _3=(0,1,1),\qquad \rho (\{\varepsilon _1,\varepsilon _2,\varepsilon _3\})= \varepsilon _1+\varepsilon _2+\varepsilon _3=(1,1,1). \end{aligned}$$

In Fig. 2, we depicted the order polytope of P. Finally, let us consider the dual polytope for \(\mathbf {O}_P(3)\). It is easy to check that the vertices of the dual polytope \({{\,\mathrm{\mathbf {H}}\,}}_P\) are given by \(-e_1,e_1-e_2,e_1-e_3, e_2,e_3\). We notice that the convex hull of \(e_1-e_2,e_1-e_3, e_2,e_3\) is a rectangular plate, which we denote by A. Then \({{\,\mathrm{\mathbf {H}}\,}}_P\) is a pyramid over A with apex at \(-e_1\).

Fig. 2
figure 2

The order polytope of P

We close this subsection with two simple observations.

Lemma 3.5

Let P be a poset with connected components \(P_1,\dots , P_r\). Then we have

$$\begin{aligned}\mathbf {H}_P = \mathbf {H}_{P_1}\!\oplus \cdots \oplus \mathbf {H}_{P_r}.\end{aligned}$$

Proof

Let x be a vertex in \(\mathbf {H}_P\). Then there is a covering relation \(\varepsilon _i \lessdot \varepsilon _j\) in \(\hat{P}\) such that

$$\begin{aligned} x\in \{e_i,e_i-e_j,-e_j \}. \end{aligned}$$

Since every covering relation in \(\hat{P}\) is a covering relation in one of the posets \(\hat{P_i}\), \(i\in \{1,\dots , r\}\), we see that the vertex set of \(\mathbf {H}_P\) is a disjoint union,

$$\begin{aligned}V(\mathbf {H}_P) = V(\mathbf {H}_{P_1})\sqcup \ldots \sqcup V(\mathbf {H}_{P_r}).\end{aligned}$$

Note that the subpolytopes \(\mathbf {H}_{P_i}\) for \(i\in \{1,\dots , r\}\) are contained in skew subspaces in \({{\mathbb {Q}}}^m\). Nevertheless, they all share the origin of \({{\mathbb {Q}}}^m\). Therefore, we have

$$\begin{aligned} \mathbf {H}_{P}&={{\,\mathrm{conv}\,}}V( \mathbf {H}_P)={{\,\mathrm{conv}\,}}{(V( \mathbf {H}_{P_1}) \sqcup \ldots \sqcup V(\mathbf {H}_{P_r}))} \\&= {{\,\mathrm{conv}\,}}V( \mathbf {H}_{P_1})\sqcup \ldots \sqcup {{\,\mathrm{conv}\,}}V(\mathbf {H}_{P_r}). \end{aligned}$$

This finishes the proof of our assertion. \(\square \)

Our next observation is about the order polytopes.

Lemma 3.6

Let P be a poset with connected components \(P_1,\dots , P_r\). Then we have

$$\begin{aligned}\mathbf {O}_P = \mathbf {O}_{P_1} \times \cdots \times \mathbf {O}_{P_r}.\end{aligned}$$

Proof

Let x be a vertex in \(\mathbf {O}_P\subseteq {{\mathbb {Q}}}^m\), where m is the number of elements of P. Then there is an upper order ideal I in P such that \(x=\rho (I)\). Since P is the disjoint union \(P_1\sqcup \ldots \sqcup P_r\), we see that \(I=I_1\sqcup \ldots \sqcup I_r\), where \(I_i\), \(i\in \{1,\dots ,r\}\), is an upper order ideal in \(P_i\). It follows that x is of the form

$$\begin{aligned} x= x_1+\dots + x_r \in {{\mathbb {Q}}}^{m_1}\oplus \cdots \oplus {{\mathbb {Q}}}^{m_r}, \end{aligned}$$
(3.2)

where \(x_i = \rho (I_i)\), and \({{\mathbb {Q}}}^{m_i}\) is the vector subspace of \({{\mathbb {Q}}}^m\) that is spanned by the basis vectors corresponding to the elements of \(P_i\), \(i\in \{1,\dots , r\}\). The decomposition in (3.2) shows that the vertex set of \(\mathbf {O}_P\) is the product of the vertex sets of the order polytopes \(\mathbf {O}_{P_i}\),

$$\begin{aligned}V(\mathbf {O}_P) = V(\mathbf {O}_{P_1}) \times \cdots \times V(\mathbf {O}_{P_r}).\end{aligned}$$

This finishes the proof. \(\square \)

The decompositions that we observed in Lemmas 3.6 and 3.5 can be obtained from each other by induction and the well-known polarity correspondence between the free sums and direct products of polytopes.

Remark 3.7

As we mentioned in the introduction, a desirable code is the one with a high transmission rate, that is, dimension/length. The construction of \(\mathbf {H}_P\) uses the cover relations in P whereas the construction of \(\mathbf {O}_P\) uses all upper order ideals in P. In general the vertices of the latter polytope are much more numerous. Therefore, for a generic poset P, the transmission rate of \(\mathcal {C}_{\mathbf {H}_P}\) is very small compared to the transmission rate of \(\mathcal {C}_{\mathbf {O}_P}\).

4 Shrubs

We begin with a reduction result.

Proposition 4.1

Let P be a poset with r connected components \(P_1,\dots , P_r\). Let q be a prime power such that \(q>2\). Then the minimum distance of the toric code \(\mathcal {C}_{\mathbf {O}_P}\) is given by

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_P})= d(\mathcal {C}_{\mathbf {O}_{P_1}}) \cdot \ldots \cdot d(\mathcal {C}_{\mathbf {O}_{P_r}}).\end{aligned}$$

Proof

We know from Lemma 3.6 that \(\mathbf {O}_P\) decomposes as a direct product,

$$\begin{aligned}\mathbf {O}_P = \mathbf {O}_{P_1}\!\times \cdots \times \mathbf {O}_{P_r}.\end{aligned}$$

By applying induction with Lemma 2.1, we get \(d(\mathcal {C}_{\mathbf {O}_P})=d(\mathcal {C}_{\mathbf {O}_{P_1}}) \cdot \ldots \cdot d(\mathcal {C}_{\mathbf {O}_{P_r}})\). \(\square \)

Next, we focus on the connected posets.

Proposition 4.2

Let \(P=\{\varepsilon _1,\dots , \varepsilon _m\}\) be a connected poset with a unique minimal element, \(\varepsilon _1\). If \(P'\) is the poset obtained from P by removing \(\varepsilon _1\), then we have

$$\begin{aligned} d(\mathcal {C}_{\mathbf {O}_P})=(q-1)d(\mathcal {C}_{\mathbf {O}_{P'}}). \end{aligned}$$

Proof

Since \(\varepsilon _1\) is the smallest element in P, the upper order ideal generated by \(\varepsilon _1\) is the whole poset P. In particular, all coordinates of the corresponding vertex \(x_0:=\rho (P)\) in \({{\mathbb {Q}}}^m\) are 1,

$$\begin{aligned}x_0=(1,\dots , 1) \in {{\mathbb {Q}}}^m.\end{aligned}$$

For every other vertex \(x=(a_1,\dots ,a_m)\) of \(\mathbf {O}_P\) such that \(x\ne x_0\), we have \(a_1=0\). This means that the line segment between vertices \(x_0\) and x is an edge of the polytope \(\mathbf {O}_P\). (Note that this observation follows from [8, Lem. 1.1 (a)] as well.) It follows that \(\mathbf {O}_P\) is a pyramid over \(\mathbf {O}_{P'}\). Now, the rest of the proof follows from Lemma 2.2. \(\square \)

Let P be a poset. We call P a rooted tree poset if the following conditions hold:

  1. 1.

    the Hasse diagram of P is a rooted tree, where the smallest element of P is the root;

  2. 2.

    the leaves of P are the maximal elements of P.

If P is the rooted tree poset whose Hasse diagram is as in Fig. 3, then we call it the m-th shrub. The m-th shrub will be denoted by \(S_m\). If the number m is understood from the context, or if it is not relevant to the discussion, then we simply write “shrub” instead of writing “the m-th shrub.”

Fig. 3
figure 3

The m-th shrub, \(S_m\)

Let I be an upper order ideal in \(S_m\). If I contains the element \(\varepsilon _1\), then it is equal to \(S_m\). If \(\varepsilon _1 \notin I\), then I can be any subset of \(\{\varepsilon _2,\dots , \varepsilon _m\}\). Therefore, \(J(S_m^{opp })\) is isomorphic to \(B_{m-1}\oplus \hat{1}\), where \(B_{m-1}\) is the boolean algebra of rank \(m-1\). The proof of the following lemma is easy so we omit it.

Lemma 4.3

Let \(m\ge 2\). Then the order polytope of the shrub \(S_m\) is a pyramid over the unit cube of dimension \(m-1\).

Next, we introduce the notion of a shrubbery of a tree poset P. Clearly, every leaf in P belongs to a unique shrub in P. For example, consider the tree poset in Fig. 4. The tree poset in that figure has four subshrubs, whose Hasse diagrams are drawn in solid black lines. The shrubbery of P is the collection of subshrubs of P that contain the leaves of P.

Fig. 4
figure 4

The shrubbery of a tree

Theorem 4.4

Let \(P=\{\varepsilon _1,\dots , \varepsilon _m\}\) be a tree poset whose shrubbery consists of the shrubs, \(S_{m_1},\dots , S_{m_s}\). Then the minimum distance of the code \(\mathcal {C}_{\mathbf {O}_P}\) is given by

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_P}) = (q-1)^{m- \sum _{i=1}^s (m_i-1)} (q-2)^{\sum _{i=1}^s (m_i-1)}.\end{aligned}$$

Proof

By Proposition 4.2, the minimum distance \(\mathcal {C}_{\mathbf {O}_P}\) is equal to \((q-1)d(\mathcal {C}_{\mathbf {O}_{P'}})\), where \(P'\) is the rooted forest obtained from P by removing \(\varepsilon _1\). Let \(P_1,\dots ,P_r\) denote the connected components of \(P'\). Then each \(P_i\), \(i\in \{1,\dots ,r\}\), is a rooted tree. By repeatedly applying Propositions 4.1 and 4.2, we reach the shrubberies of the \(P_i\)’s for all \(i\in \{1,\dots ,r\}\). The union of the shrubberies of the \(P_i\)’s, \(i\in \{1,\dots , r\}\), is equal to the shrubbery of P, that is, \(S_{m_1},\dots ,S_{m_s}\). For \(l\in \{1,\dots ,s\}\), the index \(m_l\) is the number of vertices in the shrub \(S_{m_l}\). Let j denote the difference \(m- \sum _{l=1}^s m_l\), which is equal to the number of vertices that are removed from P to reach the shrubbery \(S_{m_1},\dots , S_{m_s}\). In particular, we have the following formula for the minimum distance,

$$\begin{aligned} d(\mathcal {C}_{\mathbf {O}_P} )= (q-1)^j d\bigl (\mathcal {C}_{\mathbf {O}_{S_{m_1}}}\bigr ) \ldots d\bigl (\mathcal {C}_{\mathbf {O}_{S_{m_s}}}\bigr ). \end{aligned}$$
(4.1)

We now observe that, for each \(l\in \{1,\dots ,s\}\), the order polytope \(\mathbf {O}_{S_{m_l}}\) is a pyramid over the unit cube of dimension \(m_l-1\). Therefore, by [12, Corr. 3.4], the minimum distance of the corresponding code is given by \((q-1)(q-2)^{m_l-1}\). Thus, by substituting these into (4.1) we obtain the asserted formula for the minimum distance \(\mathcal {C}_{\mathbf {O}_P}\). \(\square \)

5 A Lemma on Ordinal Sums

Let P and Q be two posets. The ordinal sum of Pand Q, denoted by \(P\oplus Q\), is the poset defined on the disjoint union \(P\sqcup Q\) as follows. Let a and b be two elements from \(P\sqcup Q\). Then

$$\begin{aligned} a\le b \iff {\left\{ \begin{array}{ll} \text {if both }a \text { and } b\text { are elements of } P ,\text { and } a\le b \text { in } P;\\ \text {if both }a\text { and }b\text { are elements of }Q,\text { and } a\le b\text { in } Q;\\ \text {if }a\in P \text { and }b\in Q. \end{array}\right. } \end{aligned}$$

The order polytope of the ordinal sum of two posets can be described in terms of the order polytope of the summands. This relationship is expressed by the action of the group of affine transformations of a lattice. To explain, let \({{\mathbb {Z}}}^k\) be a lattice, let u be an element of \({{\mathbb {Z}}}^k\), and let M an element of \(GL _k({{\mathbb {Z}}})\). The map \(T_{M,u}:{{\mathbb {Q}}}^k\rightarrow {{\mathbb {Q}}}^k\), defined by the formula \(T(v):=M\cdot v+u\) for \(v\in {{\mathbb {Z}}}^k\), is called an affine transformation of \({{\mathbb {Z}}}^k\). Now, two polytopes \(\mathbf {P}\) and \(\mathbf {Q}\) in \({{\mathbb {Z}}}^k\otimes _{{\mathbb {Z}}}{{\mathbb {Q}}}\cong {{\mathbb {Q}}}^k\) are called lattice equivalent if there exists an affine transformation \(T_{M,u}:{{\mathbb {Q}}}^k\rightarrow {{\mathbb {Q}}}^k\) such that \(T_{M,u}(\mathbf {P})=\mathbf {Q}\). Since the affine transformations form a group, the lattice equivalence is an equivalence relation on the collection of all polytopes in \({{\mathbb {Q}}}^k\). An important fact regarding the lattice equivalence is that two toric codes that are obtained from two lattice equivalent polytopes have the same parameters. For a detailed explanation of this fact, we refer the reader to [10, Sect. 4].

Lemma 5.1

Let P and Q be two posets. Then the order polytope of the ordinal sum \(P\oplus Q\) is lattice equivalent to the free sum of polytopes \(\mathbf {O}_P\oplus \mathbf {O}_{Q}\).

Proof

Let n and m denote the cardinalities of P and Q respectively. Then \(\mathbf {O}_P\subset {{\mathbb {Q}}}^n\) and \(\mathbf {O}_Q\subset {{\mathbb {Q}}}^m\). Let I (resp. \(I'\)) be an element of \(J(P^{opp })\) (resp. of \(J(Q^{opp })\)). By abuse of notation, we will use the same notation I (resp. \(I'\)) for the upper order ideal generated by I (resp. \(I'\)) in \(P\oplus Q\). In this notation, clearly, for every upper order ideal I of P we have \(Q\le I\) in \(J((P\oplus Q)^{opp })\). In terms of cartesian coordinates on \({{\mathbb {Q}}}^n\times {{\mathbb {Q}}}^m\), this fact amounts to the fact that \(\rho _{P\oplus Q}(I)\) has 1’s on its last m coordinates. In other words, in \({{\mathbb {Q}}}^n\times {{\mathbb {Q}}}^m\), the vector \(v_0:=(0,\dots ,0,1,\dots ,1)\) corresponds to both 1) the empty upper order ideal of P, and 2) the maximal upper order ideal of Q. We now consider the affine translate \(\mathbf {O}_{P\oplus Q}-v_0\) in \({{\mathbb {Q}}}^n\times {{\mathbb {Q}}}^m\). Under this translation, the vertices that correspond to the upper order ideal in P are mapped to the negatives of the lower order ideals in P. Therefore, we have the following equality of polytopes:

$$\begin{aligned} \mathbf {O}_{P\oplus Q} - v_0=(-\mathbf {O}_{P^{opp }})\oplus \mathbf {O}_{Q}. \end{aligned}$$

But the polytope \(-\mathbf {O}_{P^{opp }}\) is lattice equivalent to \(\mathbf {O}_P\), hence, we obtain the equivalence,

$$\begin{aligned} \mathbf {O}_{P\oplus Q} - v_0 \cong \mathbf {O}_{P}\oplus \mathbf {O}_{Q}. \end{aligned}$$

This finishes the proof of our assertion. \(\square \)

Recall that the minimum distance of the toric code that is obtained from the direct product of two polytopes \(\mathbf {P}\) (in \({{\mathbb {Q}}}^m\)) and \(\mathbf {Q}\) (in \({{\mathbb {Q}}}^n\)) is given by the product of the minimum distances of the codes that are associated with \(\mathbf {P}\) and \(\mathbf {Q}\) (Lemma 2.1). Let h be a polynomial from \(H^0(T_N({{\mathbb {F}}}_q),\mathbf {P})\). The weight of h, denoted wt(h), is the maximum number of nonzero coordinates in the image vector of the evaluation of h on the points of \(T_N({{\mathbb {F}}}_q)\). Let f be a polynomial from \(H^0(T_N({{\mathbb {F}}}_q),\mathbf {P})\) such that \(wt(f)=d(\mathcal {C}_{\mathbf {P}})\). Similarly, let g be a polynomial from \(H^0(T_{N'}({{\mathbb {F}}}_q),\mathbf {Q})\) such that \(wt(g)=d(\mathcal {C}_{\mathbf {Q}})\). In their proof of Lemma 2.1, Soprunov and Soprunova [12, Thm. 2.1] show that the weight of the polynomial fg is equal to \(d(\mathcal {C}_{\mathbf {P}\times \mathbf {Q}})\). Note that f and g separately belong also to the space of sections \(H^0(T_{N\times N'}({{\mathbb {F}}}_q),\mathbf {P}\oplus \mathbf {Q})\). This in particular gives us an upper bound for \(d(\mathcal {C}_{\mathbf {P}\oplus \mathbf {Q}})\) as follows. Clearly, the total number of points in \(T_{N\times N'}({{\mathbb {F}}}_q)\) (\(\cong ({{\mathbb {F}}}_q^*)^{m+n}\)) where f (resp. g) vanishes is given by \(Z(f)(q-1)^n\) (resp. by \(Z(g)(q-1)^m\)). Thus, we have

$$\begin{aligned} d(\mathcal {C}_{ \mathbf {P}\oplus \mathbf {Q}}) \le \max {\bigl \{ (q-1)^{m+n} - Z(f) (q-1)^n,(q-1)^{m+n} - Z(g) (q-1)^m\bigl \}}. \end{aligned}$$

Next, we apply this observation to an ordinal sum of posets.

Let m be a positive integer. Let us denote an antichain with m elements by \(A_m\). The order polytope of \(A_m\) is the m-dimensional unit cube. Note that an m-chain is given by \(A_1\oplus \cdots \oplus A_1\) (m copies), which we denote by \(C_m\).

Lemma 5.2

Let m be a positive integer. Then the minimum distance of the toric code associated with \(\mathbf {O}_{A_m\oplus A_m}\) is given by \((q-1)^{m}(q-2)^m\).

Proof

We begin with a slightly more general setup. Let \(m \le n\) be two positive integers. We consider the ordinal sum \(A_m\oplus A_n\). In the light of Lemma 5.1, we may assume that \(\mathbf {O}_{A_m\oplus A_n}=\mathbf {O}_{A_m}\!\oplus \mathbf {O}_{A_n}\). Let f be a polynomial in \(H^0(T_N({{\mathbb {F}}}_q),\mathbf {O}_{A_m})\) such that \(wt(f)=d(\mathcal {C}_{\mathbf {O}_{A_m}})\). Then we know that

$$\begin{aligned}Z(f) = (q-1)^m - d(\mathcal {C}_{\mathbf {O}_{A_m}})= (q-1)^m - (q-2)^m.\end{aligned}$$

Similarly, let g be a polynomial in \(H^0(T_{N'}({{\mathbb {F}}}_q), \mathbf {O}_{A_n})\) such that \(wt(g) = d(\mathcal {C}_{\mathbf {O}_{A_n}})\). Then we know that

$$\begin{aligned}Z(g) = (q-1)^n - d(\mathcal {C}_{\mathbf {O}_{A_n}})= (q-1)^n - (q-2)^n.\end{aligned}$$

Therefore, the minimum distance of \(\mathbf {O}_{A_m\oplus A_n}\) is bounded by

$$\begin{aligned} d(\mathcal {C}_{\mathbf {O}_{A_m}\oplus \mathbf {O}_{A_n}})&\le \max \,\bigl \{(q-1)^{m+n}-((q-1)^m-(q-2)^m)(q-1)^n,\\&\qquad \quad \qquad (q-1)^{m+n} - ((q-1)^n - (q-2)^n) (q-1)^m\bigr \}\\&= \max {\{ (q-2)^m (q-1)^n, (q-2)^n (q-1)^m \}}= (q-2)^m(q-1)^n. \end{aligned}$$

In particular, if \(m=n\), then we see that

$$\begin{aligned} d(\mathcal {C}_{ \mathbf {O}_{A_m}\oplus \mathbf {O}_{A_n}})\le (q-2)^m(q-1)^m. \end{aligned}$$
(5.1)

We notice that the poset \(A_m\oplus A_m\) is covered by m 2-chains, \(H_m:=\bigsqcup _{i=1}^mC_2\). It is easy to check the polytope containment

$$\begin{aligned}\mathbf {O}_{A_m\oplus A_m} \subseteq \mathbf {O}_{H_m}.\end{aligned}$$

This means that the space of sections of the line bundle determined by \(\mathbf {O}_{A_m\oplus A_m}\) is contained in the space of sections of the line bundle determined by \(\mathbf {O}_{H_m}\). Since these sections are evaluated on the same torus, the minimum distance of the code \(\mathcal {C}_{\mathbf {O}_{A_m}\oplus \mathbf {O}_{A_m}}\) is bounded from below by the minimum distance of \(\mathcal {C}_{\mathbf {O}_{H_m}}\), which is equal to \((q-1)^m(q-2)^m\). The rest of the proof follows from (5.1). \(\square \)

Theorem 5.3

Let m be a positive integer. The minimum distance of a toric code associated with an (mm)-bipartite poset is given by \((q-1)^m(q-2)^m\).

Proof

Let \(H_m\) denote \(\bigsqcup _{i=1}^m C_2\). By the proof of Lemma 5.2, we know that

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_{A_m\oplus A_m}}) = d(\mathcal {C}_{\mathbf {O}_{H_m}})=(q-1)^m (q-2)^m.\end{aligned}$$

It is easy to check (by computing the vertices of the order polytopes) that if P is an (mm)-bipartite poset, then \(\mathbf {O}_{A_m\oplus A_m}\subseteq \mathbf {O}_P\subseteq {\mathbf {O}_{H_m}}\). These inclusions give the following inequalities:

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_{A_m\oplus A_m}}) \ge d(\mathcal {C}_{\mathbf {O}_P})\ge d(\mathcal {C}_{\mathbf {O}_{H_m}}),\end{aligned}$$

which are actually equalities. This finishes the proof of our theorem. \(\square \)

Proposition 5.4

Let m be a positive integer. Then we have the following formulas for the dimensions of the toric codes associated with \(A_m\oplus A_m\) and \(H_m:=\bigsqcup _{i=1}^mC_2\):

  1. (i)

    \(\dim \mathcal {C}_{\mathbf {O}_{A_m\oplus A_m}} = 2^{m+1}-1\), and

  2. (ii)

    \(\dim \mathcal {C}_{\mathbf {O}_{H_m}}=3^m\).

Proof

The dimension of a toric code defined by an order polytope is equal to the number of vertices of the polytope. In the former case, we have the free sum of two m-dimensional cubes. Therefore, the dimension in this case is given by \(2^m+2^m-1=2^{m+1}-1\). In the latter case, the vertices of \(\mathbf {O}_{H_m}\) are given by the upper order ideals in \(H_m\). Any such ideal is uniquely determined by a minimal elements \(\hat{0}_{i_1},\dots ,\hat{0}_{i_a}\) in \(H_m\), and b maximal elements \(\hat{1}_{j_1},\dots ,\hat{1}_{j_b}\), where \(\hat{1}_{j_r}\), \(1\le r\le b\), does not cover any element from \(\{\hat{0}_{i_1},\dots ,\hat{0}_{i_a}\}\). Therefore, the total number of such upper order ideals is given by \(\sum _{a=0}^m\sum _{b=0}^{m-a}{m\atopwithdelims ()a}{m-a\atopwithdelims ()b}\). By using the binomial theorem, we see that this sum is equal to \(3^m\). \(\square \)

Table 1 The upper order ideals of \(P_1,P_2,P_3\)

Example 5.5

We consider the posets \(P_1\), \(P_2\), and \(P_3\) that are defined in Fig. 5. In Table 1 we listed their upper order ideals. The minimum distance of the toric code associated with the order polytope of \(P_i\), \(i\in \{1,2,3\}\), equals

$$\begin{aligned}d(\mathcal {C}_{\mathbf {O}_{P_i}}) = (q-1)^2 (q-2)^2.\end{aligned}$$
Fig. 5
figure 5

The posets \(P_1\), \(P_2\), and \(P_3\) (from left to right)