Open Access
This article is

- freely available
- re-usable

*Algorithms*
**2019**,
*12*(10),
219;
https://doi.org/10.3390/a12100219

Article

On Finding Two Posets that Cover Given Linear Orders

^{1}

Department of Computer Science, University of the Philippines Diliman, Quezon City 1101, Philippines

^{2}

Department of Information Sytems and Computer Science, Ateneo De Manila University, Quezon City 1108, Philippines

^{*}

Author to whom correspondence should be addressed.

Received: 13 August 2019 / Accepted: 17 October 2019 / Published: 19 October 2019

## Abstract

**:**

The Poset Cover Problem is an optimization problem where the goal is to determine a minimum set of posets that covers a given set of linear orders. This problem is relevant in the field of data mining, specifically in determining directed networks or models that explain the ordering of objects in a large sequential dataset. It is already known that the decision version of the problem is NP-Hard while its variation where the goal is to determine only a single poset that covers the input is in P. In this study, we investigate the variation, which we call the 2-Poset Cover Problem, where the goal is to determine two posets, if they exist, that cover the given linear orders. We derive properties on posets, which leads to an exact solution for the 2-Poset Cover Problem. Although the algorithm runs in exponential-time, it is still significantly faster than a brute-force solution. Moreover, we show that when the posets being considered are tree-posets, the running-time of the algorithm becomes polynomial, which proves that the more restricted variation, which we called the 2-Tree-Poset Cover Problem, is also in P.

Keywords:

partial order; poset; linear extensions; algorithm; complexity## 1. Introduction

A poset is a fundamental concept in mathematics that formalizes the notion of ordering in a collection of objects. Formally, a poset $P=(V,{\le}_{P})$ is a pair consisting of a finite set V and a binary relation ${\le}_{P}\subseteq V\times V$ that is reflexive, antisymmetric and transitive. In this paper, we only consider strict posets, written here as $P=(V,{<}_{P})$, where the binary relation is antisymmetric and transitive but irreflexive. An example of a strict poset is shown in Figure 1a. From here on, all posets being discussed refer to strict posets.

Every poset $P=(V,{<}_{P})$ also corresponds to a directed acyclic graph (DAG) $G=(V,A)$ having the vertex set V and the edge set $A=\left\{(u,v)\right|(u,v)\in {<}_{P}\}$. However, a poset is more commonly illustrated using a Hasse diagram that corresponds to the transitive reduction of the DAG. Figure 1b shows the Hasse diagram $H\left(P\right)$ of the poset P defined in Figure 1a.

The binary relation in a poset is called a partial order since not all pairs need to be related. For the case wherein all pairs are related, the binary relation is called a total order, and the poset is said to be a totally ordered set or a linear order. Formally, a linear order $L=(V,{<}_{L})$ is a poset where for all distinct elements $u,v\in V$, either $u{<}_{L}v$ or $v{<}_{L}u$. Basically, we can treat a linear order as a permutation of the elements in V. Moreover, a linear order $L=(V,{<}_{L})$ is said to be a linear extension of poset P if and only if ${<}_{P}\subseteq {<}_{L}$. The set of all linear extensions of P is denoted by $\mathcal{L}\left(P\right)$. For example, Figure 1c shows the set of linear extensions of the poset P in Figure 1a.

Generating the linear extension of a poset, which is also equivalent to getting all the topological sorting of a directed acyclic graph, is a well studied problem. Algorithms [1,2] on this show that we can generate each successive linear extension or topological sorting in polynomial-time. The reverse problem where the given is a set of linear extensions, or more technically a set of linear orders, and the goal is to determine the set of posets that generate the given linear orders is the Poset Cover Problem. Formally, the Poset Cover Problem is defined as follows [3]:

- Poset Cover Problem
- Instance: A set $\mathrm{Y}=\{{L}_{1},{L}_{2},\dots ,{L}_{m}\}$ of linear orders over the set $V=\{1,2,3,\dots ,n\}$.
- Solution: A set ${P}^{*}=\{{P}_{1},{P}_{2},\dots ,{P}_{k}\}$ of posets where ${\bigcup}_{{P}_{i}\in {P}^{*}}\mathcal{L}\left({P}_{i}\right)$ $=\mathrm{Y}$ and k is minimum.

The Poset Cover Problem finds application in data mining where there is a massive set of sequential data and the goal is to determine directed networks that explain the ordering of objects in the sequential data. A simple example of this is in marketing, when the business wants to generate a directed process model from the logs of customers’ purchases of their products. The logs can be treated as linear orders of the products. Determining directed process models, which explains the purchasing behavior of the customers, can then be represented as getting a set of posets that generate the linear orders (logs). The process model can then be used to predict other customers’ future purchases, and the business could develop marketing campaigns from it. Similar to this kind of data mining, the problem is also relevant in other areas such as in neuroscience [4], chemical engineering [5], epidemiology [6], paleontology [7,8], and systems biology [9].

The decision version of the Poset Cover Problem has been shown to be NP-Hard [3]. To deepen the knowledge about the Poset Cover Problem, efforts in the past have focused on studying constrained cases of the problem and trying to draw boundaries of the cases that are in P and cases that are NP-Hard. There are essentially two ways in which the problem can be restricted or constrained. The first is to consider only a specific number of posets, say k. The problem when $k=1$, or the 1-Poset Cover Problem, is in P [10]. The computational complexity of the problem when $k=2$, or the 2-Poset Cover Problem, is not yet known. What have been devised are heuristics for the 2-Poset Cover Problem [11]. The other way of restricting the problem is to consider only a specific class of posets according to their Hasse diagram, such as a tree-poset. The poset in Figure 1 is an example of a tree-poset since its Hasse diagram is a tree. The restricted cases of the Poset Cover Problem are similarly important as there may also be instances wherein the class of posets to be reconstructed are known. For example in paleontology, the goal is to construct evolutionary ordering of fossil sites from sequential data about the taxa that occur in each site [7,8]. Evolutionary orderings are usually expressed using trees because evolution starts with an origin and branches out to descendants. Other classes of posets that have been studied are hammock posets and leveled posets [10]. The 2-Tree-Poset Cover Problem then is a contrained variation where the goal is to determine if there exist two tree-posets that cover exactly all of the given set of linear orders.

In our study, we derived properties on posets, which lead to an exact solution for the 2-Poset Cover Problem. The algorithm runs in exponential time. However, if the posets to be considered are tree-posets, the running time of the algorithm becomes polynomial. This proves that the 2-Tree-Poset Cover Problem is also in P.

## 2. Definitions

We first define here the terms and notations used in the discussion of results.

**Definition**

**1.**

**ancestors(v,P)**

Given a poset $P=(V,{<}_{P})$ and $v\in V$, the $ancestors(v,P)$ is the set of elements in poset P that precedes v, i.e., $ancestors(v,P)=\{a\in V|a{<}_{P}v\}$.

**Definition**

**2.**

**descendants(v,P)**

Given a poset $P=(V,{<}_{P})$ and $v\in V$, the $descendants(v,P)$ is the set of elements in poset P that succeeds v, i.e., $descendants(v,P)=\{d\in V|v{<}_{P}d\}$.

**Definition**

**3.**

**cover relation ${\prec}_{P}$**

Given a poset $P=(V,{<}_{P})$, its cover relation is ${\prec}_{P}=\left\{(u,v)\right|u{<}_{P}v$ and there is no $w\in V$ where $u{<}_{P}w{<}_{P}v\}$.

**Definition**

**4.**

**cover**

The term cover is used in many instances for different objects in the discussion.

Given two elements $u,v\in V$ of poset P, we say that u covers v if and only if $u{\prec}_{P}v$. In this instance, $(u,v)$ are also said to be cover pairs in P.

Given a set of linear orders Y and poset P, we say that P covers Y if and only if $\mathcal{L}\left(P\right)=\mathrm{Y}$.

Given a set of linear orders Y and a set of posets ${P}^{*}$, we say that ${P}^{*}$ covers Y if and only if ${\bigcup}_{{P}_{i}\in {P}^{*}}\mathcal{L}\left({P}_{i}\right)=\mathrm{Y}$.

**Definition**

**5.**

**Hasse Diagram of Poset $H\left(P\right)$**

A poset $P=(V,{<}_{P})$ corresponds to a Hasse diagram $H\left(P\right)$, which is a directed acyclic graph G with the elements in V as nodes and pairs in the cover relation of P as edges, i.e., $G=(V,{\prec}_{P})$.

**Definition**

**6.**

**Tree Poset**

A tree-poset $P=(V,{<}_{P})$ is a poset whose Hasse diagram is a rooted directed tree with each non-root node being covered by exactly one node.

**Definition**

**7.**

**parent(v,P)**

Given a tree-poset $P=(V,{<}_{P})$ and $v\in V$ such that v is not the root node, $parent(v,P)$ is the element u that covers v, i.e., $parent(v,P)=u$ if and only if $u{\prec}_{P}v$.

**Definition**

**8.**

**2-Poset Cover Problem**

Instance: A set $\mathrm{Y}=\{{L}_{1},{L}_{2},\dots ,{L}_{m}\}$ of linear orders over the set $V=\{1,2,3,\dots ,n\}$.

Question: Does there exist a pair of distinct posets ${P}_{1}=(V,{<}_{{P}_{1}})$ and ${P}_{2}=(V,{<}_{{P}_{2}})$ such that $\mathcal{L}\left({P}_{1}\right)\cup \mathcal{L}\left({P}_{2}\right)=\mathrm{Y}$ and $\mathcal{L}\left({P}_{1}\right)$ is neither a subset nor a superset of $\mathcal{L}\left({P}_{2}\right)$?

**Definition**

**9.**

**2-Tree-Poset Cover Problem**

Instance: A set $\mathrm{Y}=\{{L}_{1},{L}_{2},\dots ,{L}_{m}\}$ of linear orders over the set $V=\{1,2,3,\dots ,n\}$.

Question: Does there exist a pair of distinct tree-posets ${P}_{1}=(V,{<}_{{P}_{1}})$ and ${P}_{2}=(V,{<}_{{P}_{2}})$ such that $\mathcal{L}\left({P}_{1}\right)\cup \mathcal{L}\left({P}_{2}\right)=\mathrm{Y}$ and $\mathcal{L}\left({P}_{1}\right)$ is neither a subset nor a superset of $\mathcal{L}\left({P}_{2}\right)$?

**Definition**

**10.**

**comparable and incomparable**

Given a poset $P=(V,{<}_{P})$ and elements $u,v\in V$, u and v are comparable, denoted by $u\perp v$ if $u{<}_{P}v$ or $v{<}_{P}u$. Otherwise, u and v are incomparable, denoted by $u{\left|\right|}_{P}v$.

## 3. Theoretical Bases

Before we discuss the algorithms, we present the following lemmas and theorems that serve as bases in devising the algorithms.

**Lemma**

**1.**

Given posets ${P}_{1}=(V,{<}_{{P}_{1}})$ and ${P}_{2}=(V,{<}_{{P}_{2}})$, if ${<}_{{P}_{1}}\subseteq {<}_{{P}_{2}}$, then $\mathcal{L}\left({P}_{2}\right)\subseteq \mathcal{L}\left({P}_{1}\right)$.

**Proof.**

Let the linear order L be a linear extension of ${P}_{2}$, i.e., $L\in \mathcal{L}\left({P}_{2}\right)$. By definition of linear extension, ${<}_{{P}_{2}}\subseteq {<}_{L}$. Since ${<}_{{P}_{1}}\subseteq {<}_{{P}_{2}}$, then by transitivity, ${<}_{{P}_{1}}\subseteq {<}_{L}$. This implies that $L\in \mathcal{L}\left({P}_{1}\right)$. Hence, $\mathcal{L}\left({P}_{2}\right)\subseteq \mathcal{L}\left({P}_{1}\right)$. □

Given a pair that is incomparable in P, say ${a\Vert}_{P}b$, we know that there are some linear extensions where $a<b$ while $b<a$ in the remaining ones. In other words, we can partition $\mathrm{Y}$ into ${\mathrm{Y}}_{1}=\{L\in \mathcal{L}\left(P\right)|a{<}_{L}b\}$ and ${\mathrm{Y}}_{2}=\{L\in \mathcal{L}\left(P\right)|b{<}_{L}a\}$. The next theorem shows that there exists posets ${P}_{1}=(V,{<}_{{P}_{1}})$, ${P}_{2}=(V,{<}_{{P}_{2}})$ that cover ${\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{2}$, respectively. Moreover, we can derive the relationship of ${<}_{{P}_{1}}$ and ${<}_{{P}_{2}}$ from ${<}_{P}$, which is also given in the following theorem.

**Theorem**

**1.**

Consider a poset $P=(V,{<}_{P})$ and distinct elements $a,b\in V$ where ${a\left|\right|}_{P}b$. Let ${\mathrm{Y}}_{1}=\{L\in \mathcal{L}\left(P\right)|a{<}_{L}b\}$ and ${\mathrm{Y}}_{2}=\{L\in \mathcal{L}\left(P\right)|b{<}_{L}a\}$. Moreover, let

$${<}_{A}=\left\{(x,y)\right|x\in \left\{a\right\}\cup ancestors(a,P),y\in \left\{b\right\}\cup descendants(b,P)\}$$

$${<}_{B}=\left\{(x,y)\right|x\in \left\{b\right\}\cup ancestors(b,P),y\in \left\{a\right\}\cup descendants(a,P)\}$$

Then, there exist posets ${P}_{1}=(V,{<}_{{P}_{1}})$ and ${P}_{2}=(V,{<}_{{P}_{2}})$ where ${<}_{{P}_{1}}={<}_{P}\cup {<}_{A}$ and ${<}_{{P}_{2}}={<}_{P}\cup {<}_{B}$ such that $\mathcal{L}\left({P}_{1}\right)={\mathrm{Y}}_{1}$ and $\mathcal{L}\left({P}_{2}\right)={\mathrm{Y}}_{2}$. Moreover, in terms of cover relation,

$${\prec}_{{P}_{1}}=\left\{(a,b)\right\}\cup {\prec}_{P}\backslash (\{(u,b)\in {\prec}_{P}|u{<}_{P}a\}\cup \{(a,v)\in {\prec}_{P}|b{<}_{P}v\})$$

$${\prec}_{{P}_{2}}=\left\{(b,a)\right\}\cup {\prec}_{P}\backslash (\{(u,a)\in {\prec}_{P}|u{<}_{P}b\}\cup \{(b,v)\in {\prec}_{P}|a{<}_{P}v\}).$$

To illustrate the theorem, consider the posets P, ${P}_{1}$ and ${P}_{2}$ with Hasse diagrams in Figure 2. Since ${3\left|\right|}_{P}4$, let us take elements 3 and 4 as a and b in the theorem, respectively. If we generate $\mathcal{L}\left(P\right)$, we have the following linear extensions.

We can partition $\mathcal{L}\left(P\right)$ into two - ${\mathrm{Y}}_{1}=\{L\in \mathcal{L}\left(P\right)|3{<}_{L}4\}$ and ${\mathrm{Y}}_{2}=\{L\in \mathcal{L}\left(P\right)|4{<}_{L}3\}$. Clearly, ${\mathrm{Y}}_{1}$ contains all the linear extensions in the left column while ${\mathrm{Y}}_{2}$ contains those in the right column. From the theorem, there exist posets ${P}_{1}$ and ${P}_{2}$ that cover ${\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{2}$, respectively. In our example, they are the posets ${P}_{1}=(V,{<}_{{P}_{1}})$ and ${P}_{2}=(V,{<}_{{P}_{2}})$ in Figure 2. Verify that $\mathcal{L}\left({P}_{1}\right)={\mathrm{Y}}_{1}$ and $\mathcal{L}\left({P}_{2}\right)={\mathrm{Y}}_{2}$. Moreover,

$$\begin{array}{ccc}\hfill {<}_{{P}_{1}}& =\hfill & \hfill {<}_{P}\cup \phantom{\rule{10.0pt}{0ex}}\left\{(x,y)\right|x\in \left\{3\right\}\cup ancestors(3,P),y\in \left\{4\right\}\cup descendants(4,P)\}\phantom{\rule{60.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6),(1,5),(1,6),(2,5),(2,6\left)\right\}\phantom{\rule{10.0pt}{0ex}}\cup \phantom{\rule{85.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& \phantom{\rule{1.em}{0ex}}\hfill & \hfill \left\{\right(3,4),(3,6),(1,4),(1,6),(2,4),(2,6\left)\right\}\phantom{\rule{200.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6),(1,5),(1,6),(2,5),(2,6),(3,4),(1,4\left)\right\}\phantom{\rule{50.0pt}{0ex}}\end{array}$$

$$\begin{array}{ccc}\hfill {<}_{{P}_{2}}& =\hfill & \hfill {<}_{P}\cup \phantom{\rule{10.0pt}{0ex}}\left\{(x,y)\right|x\in \left\{4\right\}\cup ancestors(4,P),y\in \left\{3\right\}\cup descendants(3,P)\}\phantom{\rule{60.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6),(1,5),(1,6),(2,5),(2,6\left)\right\}\phantom{\rule{10.0pt}{0ex}}\cup \phantom{\rule{85.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& \phantom{\rule{1.em}{0ex}}\hfill & \hfill \left\{\right(4,3),(4,5),(4,6),(2,3),(2,5),(2,6\left)\right\}\phantom{\rule{200.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6),(1,5),(1,6),(2,5),(2,6),(4,3),(4,5\left)\right\}\phantom{\rule{50.0pt}{0ex}}\end{array}$$

In terms of cover relation, which is the transitive reduction of ${<}_{{P}_{1}}$ and ${<}_{{P}_{2}}$, we have the following:

$$\begin{array}{ccc}\hfill {\prec}_{{P}_{1}}& =\hfill & \hfill \left\{(3,4)\right\}\phantom{\rule{10.0pt}{0ex}}\cup {\prec}_{P}\backslash \phantom{\rule{10.0pt}{0ex}}(\{(u,4)\in {\prec}_{P}|u{<}_{P}3\}\cup \{(3,v)\in {\prec}_{P}|4{<}_{P}v\})\phantom{\rule{250.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(3,4\left)\right\}\phantom{\rule{5.0pt}{0ex}}\cup \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6\left)\right\}\backslash \left(\right\{(2,4)\}\cup \{(3,6)\left\}\right)\phantom{\rule{232.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(3,4),(1,3),(2,3),(3,5),(4,6\left)\right\}\phantom{\rule{400.0pt}{0ex}}\end{array}$$

$$\begin{array}{ccc}\hfill {\prec}_{{P}_{2}}& =\hfill & \hfill \left\{(4,3)\right\}\phantom{\rule{10.0pt}{0ex}}\cup {\prec}_{P}\backslash \phantom{\rule{10.0pt}{0ex}}(\{(u,3)\in {\prec}_{P}|u{<}_{P}4\}\backslash \{(4,v)\in {\prec}_{P}|3{<}_{P}v\})\phantom{\rule{250.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(4,3\left)\right\}\phantom{\rule{5.0pt}{0ex}}\cup \left\{\right(1,3),(2,3),(2,4),(3,5),(3,6),(4,6\left)\right\}\backslash \left(\right\{(2,3)\}\cup \{(4,6)\left\}\right)\phantom{\rule{232.0pt}{0ex}}\\ \hfill \phantom{\rule{1.em}{0ex}}& =\hfill & \hfill \left\{\right(4,3),(1,3),(2,4),(3,5),(3,6\left)\right\}\phantom{\rule{400.0pt}{0ex}}\end{array}$$

**Proof.**

We first show that ${P}_{1}=(V,{<}_{{P}_{1}})$ where ${<}_{{P}_{1}}={<}_{P}\cup {<}_{A}$ is a poset. Since P is a poset, then we know that ${<}_{P}$ is irreflexive, antisymmetric and transitive. We also know that a and b are distinct elements. An element x cannot be both in $ancestors(a,P)$ and $descendants(b,P)$, otherwise, a and b are related in ${<}_{P}$. Hence, we can say that ${<}_{A}$ is also irreflexive and antisymmetric. To show that ${<}_{{P}_{1}}$ is transitive, suppose $(x,y),(y,z)\in {<}_{{P}_{1}}$, then we have the following cases:

- $(x,y)\in {<}_{P}$ and $(y,z)\in {<}_{P}$By transitive property of poset P, $(x,z)\in {<}_{P}$. Hence, $(x,z)\in {<}_{{P}_{1}}$
- $(x,y)\in A$ and $(y,z)\in A$By the definition of A, $y\in \left\{a\right\}\cup ancestors(a,P)$ and $y\in \left\{b\right\}\cup descendants(b,P)$. It cannot be that $y=a$ or $y=b$ because of the assumption that a and b are distinct. It cannot also be that $y\in ancestors(a,P)$ and $y\in descendants(b,P)$, otherwise the assumption that ${a\left|\right|}_{P}b$ is violated. Hence, we can say that this case is not possible.
- $(x,y)\in {<}_{P}$ and $(y,z)\in A$By the definition of A, $y\in \left\{a\right\}\cup ancestors(a,P)$ and $z\in \left\{b\right\}\cup descendants(b,P)$. If $y=a$, then $x\in ancestors(a,P)$. Hence $(x,z)\in A$ and thus, $(x,z)\in {<}_{{P}_{1}}$. On the other hand, if $y\in ancestors(a,P)$, then $(y,a)\in {<}_{P}$. By the transitive property of ${<}_{P}$, $(x,a)\in {<}_{P}$. In other words, $x\in ancestors(a,P)$. Hence, $(x,z)\in A$ and thus, $(x,z)\in {<}_{{P}_{1}}$.
- $(x,y)\in {<}_{A}$ and $(y,z)\in {<}_{P}$By the definition of A, $x\in \left\{a\right\}\cup ancestors(a,P)$ and $y\in \left\{b\right\}\cup descendants(b,P)$. If $y=b$, then $z\in descendants(b,P)$. Hence $(x,z)\in A$ and thus, $(x,z)\in {<}_{{P}_{1}}$. On the other hand, if $y\in descendants(b,P)$, then $(b,y)\in {<}_{P}$. By the transitive property of ${<}_{P}$, $(b,z)\in {<}_{P}$. In other words, $z\in descendants(b,P)$. Hence $(x,z)\in A$ and thus, $(x,z)\in {<}_{{P}_{1}}$.

From these cases, we can say that ${<}_{{P}_{1}}$ is transitive. Hence, ${<}_{{P}_{1}}$ is a poset. In a similar way, we can also show that ${<}_{{P}_{2}}$ is a poset.

Next, we show that $\mathcal{L}\left({P}_{1}\right)={\mathrm{Y}}_{1}$ by showing that $\mathcal{L}\left({P}_{1}\right)\subseteq {\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{1}\subseteq \mathcal{L}\left({P}_{1}\right)$.

To prove the first direction, suppose $L\in \mathcal{L}\left({P}_{1}\right)$. Then ${<}_{{P}_{1}}\subseteq {<}_{L}$. This implies that $a{<}_{L}b$. Since ${<}_{P}\subseteq {<}_{{P}_{1}}$, then we can also say that ${<}_{P}\subseteq {<}_{L}$. This means, $L\in \mathcal{L}\left(P\right)$. Hence, $L\in {\mathrm{Y}}_{1}$.

To prove the other direction, suppose $L\in {\mathrm{Y}}_{1}$. Then, $L\in \mathcal{L}\left(P\right)$ and $a{<}_{L}b$. Now, let $x{<}_{{P}_{1}}y$. It suffices to show that $x{<}_{L}y$. This clearly holds if $x{<}_{P}y$, since $L\in \mathcal{L}\left(P\right)$. Otherwise, $x{<}_{A}y$, which implies that ($x=a$ or $x{<}_{P}a$) and ($b=y$ or $b{<}_{P}y$), whence ($x=a$ or $x{<}_{L}a$) and ($b=y$ or $b{<}_{L}y$). In any case, since $a{<}_{L}b$, we get $x{<}_{L}y$ by transitivity.

In a similar way, it can also be shown that $\mathcal{L}\left({P}_{2}\right)={\mathrm{Y}}_{2}$.

Now, let us determine the cover relation ${\prec}_{{P}_{1}}\subseteq {<}_{{P}_{1}}$. We first determine which pairs $(x,y)\in {<}_{A}$ are cover pairs in ${P}_{1}$. If $(x,y)=(a,b)$, we know that by definition of ${<}_{A}$, there exists no $w\in V$ such that $(a,w)\in {<}_{A}$ and $(w,b)\in {<}_{A}$, otherwise $a{<}_{P}b$. Since ${a\Vert}_{P}b$, then we also know that there exists no $w\in V$ such that $(a,w)\in {<}_{A}$ and $(w,b)\in {<}_{A}$. Hence, $(a,b)\in {\prec}_{{P}_{1}}$. On the other hand, any other value of $(x,y)$ in ${<}_{A}$ will lead to ($x{<}_{{P}_{1}}a{<}_{{P}_{1}}b{<}_{{P}_{1}}y$), ($x=a{<}_{{P}_{1}}b{<}_{{P}_{1}}y$) or ($x{<}_{{P}_{1}}a{<}_{{P}_{1}}b=y$), which all imply that $(x,y)\notin {\prec}_{{P}_{1}}$. Hence, the only pair in ${<}_{A}$ that is covered in ${P}_{1}$ is $(a,b)$. Now, we know that ${<}_{P}$ corresponds to ${\prec}_{P}$. Hence, ${\prec}_{{P}_{1}}$ is the transitive reduction of $\left\{(a,b)\right\}\cup {\prec}_{P}$. To get the transitive reduction, we have to elimate pairs in ${\prec}_{P}$ that are not in ${\prec}_{{P}_{1}}$ because the addition of $(a,b)$ no longer makes them covered. These are the following:

- $u{\prec}_{P}b$ where $u{<}_{P}a$In this case $u{<}_{{P}_{1}}a{<}_{{P}_{1}}b$, hence, $(u,b)\notin {\prec}_{{P}_{1}}$.
- $\left(a{\prec}_{P}v\right)$ where $b{<}_{P}v$In this case $a{<}_{{P}_{1}}b{<}_{{P}_{1}}v$, hence, $(a,v)\notin {\prec}_{{P}_{1}}$

Hence, ${\prec}_{{P}_{1}}=\left\{(a,b)\right\}\cup {\prec}_{P}\backslash \{\{(u,b)\in {\prec}_{P}|u{<}_{P}a\}\cup \{(a,v)\in {\prec}_{P}|b{<}_{P}v\}\}$. In a similar way, we can derive the formula for ${\prec}_{{P}_{2}}$. □

**Corollary**

**1.**

If the poset $P=(V,{<}_{P})$ in Theorem 1 is a tree-poset, then Equations (3) and (4) become Equations (5) and (6), respectively.

$${\prec}_{{P}_{1}}=\left\{\begin{array}{cc}\left\{(a,b)\right\}\cup {\prec}_{P},\hfill & {\mathit{if}\phantom{\rule{5.0pt}{0ex}}\mathit{parent}(b,P)\phantom{\rule{5.0pt}{0ex}}\left|\right|}_{P}\phantom{\rule{5.0pt}{0ex}}a\hfill \\ \left\{(a,b)\right\}\cup {\prec}_{P}\backslash \left\{(parent(b,P),b)\right\},\hfill & \mathit{if}\phantom{\rule{5.0pt}{0ex}}parent(b,P)\phantom{\rule{5.0pt}{0ex}}{<}_{P}\phantom{\rule{5.0pt}{0ex}}a\hfill \end{array}\right.$$

$${\prec}_{{P}_{2}}=\left\{\begin{array}{cc}\left\{(b,a)\right\}\cup {\prec}_{P},\hfill & {\mathit{if}\phantom{\rule{5.0pt}{0ex}}parent(a,P)\phantom{\rule{5.0pt}{0ex}}\left|\right|}_{P}\phantom{\rule{5.0pt}{0ex}}b\hfill \\ \left\{(b,a)\right\}\cup {\prec}_{P}\backslash \left\{(parent(a,P),a)\right\},\hfill & \mathit{if}\phantom{\rule{5.0pt}{0ex}}parent(a,P)\phantom{\rule{5.0pt}{0ex}}{<}_{P}\phantom{\rule{5.0pt}{0ex}}b\hfill \end{array}\right.$$

**Proof.**

From Theorem 1, ${\prec}_{{P}_{1}}=\left\{(a,b)\right\}\cup {\prec}_{P}\backslash (\{(u,b)\in {\prec}_{P}|u{<}_{P}a\}\cup \{(a,v)\in {\prec}_{P}|b{<}_{P}v\})$. First, we show that $\{(a,v)\in {\prec}_{P}|b{<}_{P}v\}=\varnothing $ if P is a tree-poset. Suppose there exists such v where $a{\prec}_{P}v$ and $b{<}_{P}v$. Since, every non-root node in a tree-poset is covered by only one element, then only a covers v. Then it must be that $b{<}_{P}a$, so that $b{<}_{P}v$. This is a contradiction to the assumption that ${a\left|\right|}_{P}b$. Hence, $\{(a,v)\in {\prec}_{P}|b{<}_{P}v\}=\varnothing $.

Next, we examine the set $\{(u,b)\in {\prec}_{P}|u{<}_{P}a\}$. If P is a tree-poset, then there exists only one possible u that covers b, which is $parent(b,P)$. Hence, we have two possibilities. If $parent(b,P){<}_{P}a$ then ${\prec}_{{P}_{1}}=\left\{(a,b)\right\}\cup {\prec}_{P}\backslash \left\{(parent(b,P),b)\right\}$. Note that $a{\nless}_{P}parent(b,P)$, otherwise $a{<}_{P}b$. Hence, the only other condition is when ${parent(b,P)\left|\right|}_{P}u$. With this condition, Equation (3) then becomes ${\prec}_{{P}_{1}}={\prec}_{P}\cup \left\{(a,b)\right\}$.

We can prove Equation (6) in a similar way. □

## 4. Algorithm for the 2-Poset Cover Problem

As mentioned earlier, there is already a polynomial-time solution for the 1-Poset Cover Problem [10]. We can determine in $O\left(m{n}^{2}\right)$ time, where m is the number of linear orders over a base set of n elements, the poset that covers a given set of linear orders. Let us denote the algorithm for the 1-Poset Cover Problem as GeneratePoset. The input to GeneratePoset is a set of linear orders and it returns a poset, if there exists such, that covers the input; otherwise it returns null. Now, for the 2-Poset Cover Problem with input $\mathrm{Y}$, a brute-force algorithm is then to determine ${\mathrm{Y}}_{1}$, ${\mathrm{Y}}_{2}$⊆$\mathrm{Y}$ such that ${\mathrm{Y}}_{1}\cup {\mathrm{Y}}_{2}=\mathrm{Y}$ and then use GeneratePoset to determine if there is a poset that covers ${\mathrm{Y}}_{1}$ and a poset that covers ${\mathrm{Y}}_{2}$. Since there are ${3}^{m}$ possibilities for values of ${\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{2}$, the brute-force algorithm entails a running time of $O\left({3}^{m}m{n}^{2}\right)$.

Theorem 1 suggests a strategy of partitioning $\mathrm{Y}$. Given a pair $(a,b)\in V\times V$, we can partition $\mathrm{Y}$ into ${\mathrm{Y}}_{1}=\{L\in \mathrm{Y}|a{<}_{L}b\}$ and ${\mathrm{Y}}_{2}=\{L\in \mathrm{Y}|b{<}_{L}a\}$. Suppose there exist two posets, say $P=(V,{<}_{P})$ and ${P}^{\prime}=(V,{<}_{{P}^{\prime}})$ that cover $\mathrm{Y}$. If $(a,b)\in {<}_{P}$ and $(b,a)\in {<}_{{P}^{\prime}}$, then we just have partitioned $\mathrm{Y}$ perfectly because ${\mathrm{Y}}_{1}=\mathcal{L}\left(P\right)$ and ${\mathrm{Y}}_{2}=\mathcal{L}\left({P}^{\prime}\right)$. Hence, we can determine P and ${P}^{\prime}$ using GeneratePoset with ${\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{2}$ as inputs, respectively. This is executed in Lines 7 and 8 of Algorithm 1. However, such a pair does not always exist. There can be also instances where $a{\perp}_{P}b$ and ${a\left|\right|}_{{P}^{\prime}}b$ and vice versa—there also exists a different pair, say $(c,d)$ where ${c\left|\right|}_{P}d$ and $c{\perp}_{{P}^{\prime}}d$. Without lost of generality on $a{\perp}_{P}b$, suppose $a{<}_{P}b$. Then, if we apply the same partitioning strategy, ${\mathrm{Y}}_{1}=\mathcal{L}\left(P\right)\cup \{L\in \mathcal{L}\left({P}^{\prime}\right)|a{<}_{L}b\}$ and ${\mathrm{Y}}_{2}=\{L\in \mathcal{L}\left({P}^{\prime}\right)|b{<}_{L}a\}$. We are not sure if there exists a poset that covers ${\mathrm{Y}}_{1}$, however, we are sure from Theorem 1 that there exists a poset that covers ${\mathrm{Y}}_{2}$, say ${P}_{2}$. Moreover, with the use of the equations in the Theorem, we can determine or reconstruct the relation of ${P}^{\prime}$ from ${P}_{2}$. These are executed in Lines 22–32. We can also determine P in a similar way with the pair $(c,d)$. This is executed in Lines 10–20 in the Algorithm.

**Theorem**

**2.**

Algorithm 1 produces a solution to the 2-Poset Cover Problem in $O({2}^{n}mn+m{n}^{4}+{m}^{2})$ time.

**Proof.**

Let P and ${P}^{\prime}$ be the two different posets that cover $\mathrm{Y}$, i.e., $\mathcal{L}\left(P\right)\cup \mathcal{L}\left({P}^{\prime}\right)=\mathrm{Y}$. In the following, we want to show that P and ${P}^{\prime}$, if there exist such, can be determined and generated by the 2-Poset Cover Algorithm.

With the assumption that $P\ne {P}^{\prime}$ means also that ${<}_{P}\ne {<}_{{P}^{\prime}}$, then there must exist, without loss of generality, at least one $(a,b)$ such that $(a,b)\in {<}_{P}$ but $(a,b)\notin {<}_{{P}^{\prime}}$. On the other hand, there must also exist $(c,d)$ such that $(c,d)\in {<}_{{P}^{\prime}}$ but $(c,d)\notin {<}_{P}$, otherwise, ${<}_{{P}^{\prime}}\subset {<}_{P}$ and by Lemma 1, $\mathrm{Y}$ can be covered by a single poset ${P}^{\prime}$.

Let us first take the case where $(a,b)\in {<}_{P}$ but $(a,b)\notin {<}_{{P}^{\prime}}$. With this, we have two further cases.

- $(b,a)\in {<}_{{P}^{\prime}}$In this case, ${\mathrm{Y}}_{1}=\mathcal{L}\left(P\right)$ and ${\mathrm{Y}}_{2}=\mathcal{L}\left({P}^{\prime}\right)$. Hence, posets ${P}_{1}=P$ and ${P}_{2}={P}^{\prime}$ can be generated in Lines 5 and 6, respectively and are returned in Line 8.
- $(b,a)\notin {<}_{{P}^{\prime}}$In this case, ${a\left|\right|}_{{P}^{\prime}}b$. Hence, there exist linear extensions of ${P}^{\prime}$ where $a<b$ and linear extensions where $b>a$. Let $E=\{L\in \mathcal{L}\left({P}^{\prime}\right)|a{<}_{L}b\}$ and $F=\{L\in \mathcal{L}\left({P}^{\prime}\right)|b{<}_{L}a\}$. This implies that ${\mathrm{Y}}_{1}=\mathcal{L}\left(P\right)\cup E$ and ${\mathrm{Y}}_{2}=F$. Let ${P}_{1}$ and ${P}_{2}$ be the return of GeneratePoset for ${\mathrm{Y}}_{1}$ and ${\mathrm{Y}}_{2}$ in Lines 4 and 5, respectively.We know that ${P}_{2}$ is not null because from Theorem 1 there exists a poset that covers ${\mathrm{Y}}_{2}$. Moreover, we can also reconstruct ${P}^{\prime}$ from ${P}_{2}$ using Equation (4), i.e., ${\prec}_{{P}^{\prime}}={\prec}_{{P}_{2}}\backslash \left\{(b,a)\right\}\cup \{C\cup D\}$ where $C=\{(u,a)\in {\prec}_{{P}^{\prime}}|u{<}_{{P}^{\prime}}b\}$ and $D=\{(b,v)\in {\prec}_{{P}^{\prime}}|a{<}_{{P}^{\prime}}v\}$.In reconstructing ${P}^{\prime}$ from ${P}_{2}$, let ${P}_{3}$ be our working poset. First, we let ${\prec}_{{P}_{3}}={\prec}_{{P}^{\prime}}\backslash \left\{(b,a)\right\}$ and if $\mathcal{L}\left({P}_{3}\right)\subset \mathrm{Y}$, then we can already disregard the components $\{C\cup D\}$ of ${\prec}_{{P}^{\prime}}$. This is because ${\prec}_{{P}_{2}}\backslash \left\{(b,a)\right\}\subset {\prec}_{{P}_{2}}\backslash \left\{(b,a)\right\}\cup \{C\cup D\}$. With Lemma 1, whatever set of linear orders that are covered by the poset with the later cover relation can be already covered by the poset with the former cover relation. These are executed with the “If” condition in Lines 23–24. Otherwise (the else part), we have to determine C and D. However, in the Algorithm, what we have only generated and know is the relation of ${P}_{2}$. We do not know ${P}^{\prime}$ yet hence we also do not know C and D. However, we know that $C\subseteq \{(u,b)\in {<}_{{P}^{\prime}}\}$ and $D\subseteq \{(a,v)\in {<}_{{P}^{\prime}}\}$, and with Equation (2), $(u,b)\in {<}_{{P}_{2}}$ and $(a,v)\in {<}_{{P}_{2}}$. Hence, $C\subseteq A$ where $A=\{(u,b)\in {<}_{{P}_{2}}\}$ and $D\subseteq B$ where $B=\{(a,v)\in {<}_{{P}_{2}}\}$. Hence, we can try all possible subsets of A and B for ${\prec}_{{P}_{3}}$. This is what we have done in Lines 26–32. Every possible poset from each combination is a candidate poset and added to ${P}^{*}$.

Algorithm 1: 2-Poset Cover Algorithm |

We can also do the same in determining P when the iteration evaluates the pair $(c,d)$ where $(c,d)\notin {<}_{P}$ but $(c,d)\in {<}_{{P}^{\prime}}$.

Lastly, to get P and ${P}^{\prime}$ in ${P}^{*}$, we can try all possible pairs of posets that exactly cover $\mathrm{Y}$ in Lines 33–35.

Now, we determine the running time complexity of the algorithm.

The first and outermost for-loop iterates in $O\left({n}^{2}\right)$. One dominating execution inside it is the call to GeneratePoset, which runs in $O\left(m{n}^{2}\right)$ [10]. Another dominating part is the two inner for-loops, in Lines 16–20 or Lines 28–32, that iterates through all the pairwise combinations of subsets A and subsets of B. Note that an element cannot be both an ancestor and descendant of a or b. Hence $|A+B|<n$. If $\left|A\right|=t$, then $\left|B\right|$ is at most $n-t$. Hence, there are ${2}^{t}\times {2}^{n-t}$ $={2}^{n}$ pairs of their subsets. Inside the two inner for-loops is a statement that gets all linear extensions of poset, i.e., $\mathcal{L}\left({P}_{3}\right)$. This can be done in $O\left(mn\right)$ by using the algorithm of Pruesse and Ruskey [1]. Hence, the total running time of the first outermost for-loop is $O(m{n}^{4}+mn{2}^{n})$.

For the second outermost for-loop, $|{P}^{*}|\in O\left(m\right)$ since the smallest posets (with respect to the number of linear extensions) are the linear orders themselves. Thus, the second for-loop iterates in $O\left({m}^{2}\right)$. Inside it is a set equality testing that can be performed in constant time [12]. Hence, the second for-loop runs in $O\left({m}^{2}\right)$.

Thus, the total running time of the algorithm is $O({2}^{n}mn+m{n}^{4}+{m}^{2})$. □

The running time of the solution for the 2-Poset Cover Problem is still exponential. But there is now an improvement from the running time of a brute-force solution, i.e. from a base of 3 to a base of 2 and from exponents in terms of $m=\left|\mathrm{Y}\right|$ to exponent in terms of $n=\left|V\right|$. Hence, we can say that for a large m, Algorithm 1 is much more efficient than a brute-force solution.

In the following, we show that when the posets are tree-posets, the running time of the algorithm becomes polynomial.

## 5. Algorithm for the 2-Tree-Poset Cover Problem

From Theorem 2, the part of Algorithm 1 that makes its running-time exponential is determining the latter components of Equations (3) or (4). However, with Corollary 1, the said components become simpler if the posets are tree-posets. Hence, we can then modify Algorithm 1 to specifically consider only tree-posets. The resulting algorithm is Algorithm 2. Consequently, the running time of the algorithm becomes polynomial. With these results, we can then say that the 2-Tree-Poset Cover Problem is in P.

**Corollary**

**2.**

Algorithm 2 produces a solution to the 2-Tree-Poset Cover Problem in $O({n}^{5}+m{n}^{4}+{m}^{2})$.

**Proof.**

The theoretical bases of Algorithm 2 is the same as Algorithm 1 for the 2-Poset Cover Problem except that we use Equations (5) and (6) for tree-posets as given in Corollary 1 instead of Equations (3) and (4) for general posets. Consequently, the running time then of the Algorithm differs on the following points.

- B is empty and there is only one element in A that could cover v or u. This follows from Corollary 1. Hence, $\left|A\right|=O\left(n\right)$
- There is a need to check if the poset is a tree-poset. This can be done in $O\left({n}^{2}\right)$

Hence, the inner for-loops runs in $O\left(n(mn+{n}^{2})\right)=O(m{n}^{2}+{n}^{3})$. The first outermost for-loop then run in $O\left({n}^{2}(m{n}^{2}+{n}^{3})\right)=O(m{n}^{4}+{n}^{5})$. The running time of the second-outermost for loop remains the same, i.e., $O\left({m}^{2}\right)$. The running time then of the algorithm is $O({n}^{5}+m{n}^{4}+{m}^{2})$. □

Algorithm 2: 2-Tree-Poset Cover Algorithm |

## 6. Conclusions

In this study, we explored the Poset Cover Problem, a hard problem that is relevant in the field of data mining. It is already known that we can determine a single poset that covers a given set of linear orders in polynomial time. In this paper, we extended the knowledge on the problem by investigating the hardness of the case where we want to determine two posets, if they exist, that cover a set of linear orders, which we called the 2-Poset Cover Problem.

We discovered properties on posets that lead to an exact solution for the 2-Poset Cover Problem. The algorithm runs in $O({2}^{n}mn+m{n}^{4}+{m}^{2})$ where m is the number of linear orders over a based set of n elements. When $m>n$, the algorithm is significantly faster than a brute-force solution, which runs in $O\left({3}^{m}m{n}^{2}\right)$. Since the algorithm runs in exponential time, the complexity class that the 2-Poset Cover Problem belongs to remains unknown. However, when the posets to be considered are tree posets, which can be treated as combinatorial models for evolutionary orderings, the running time of the algorithm becomes polynomial. Hence, this proves that the more restricted case, which we called 2-Tree-Poset Cover Problem, belongs to the computational complexity class P.

## Author Contributions

Conceptualization, I.O. and P.F.J.; Formal analysis, I.O.; Investigation, I.O., P.F.J. and H.A.; Supervision, H.A.; Writing—original draft, I.O.; Writing—review and editing, P.F.J. and H.A.

## Funding

This research was supported by Department of Science and Technology - Engineering Research and Development for Technology (DOST-ERDT).

## Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript, or in the decision to publish the results.

## References

- Pruesse, G.; Ruskey, F. Generating linear extensions fast. SIAM J. Comput.
**1994**, 23, 373–386. [Google Scholar] [CrossRef] - Kalvin, A.D.; Varol, Y.L. On the generation of all topological sortings. J. Algorithms
**1983**, 4, 150–162. [Google Scholar] [CrossRef] - Heath, L.S.; Nema, A.K. The poset cover problem. Open J. Discret. Math.
**2013**, 3, 101–111. [Google Scholar] [CrossRef] - Lee, A.; Wilson, M. A combinatorial method for analyzing sequential firing patterns involving an arbitrary number of neurons based on relative time order. J. Neurophysiol.
**2005**, 92, 2555–2573. [Google Scholar] [CrossRef] [PubMed] - Wiggins, C.; Nemenman, I. Process pathway via time series analysis. Exp. Mech.
**2003**, 43, 361–370. [Google Scholar] [CrossRef] - Unnikrishnan, K.; Ramakrishnan, N.; Sastry, P.; Uthurusamy, R. Network reconstruction from dynamic data. ACM Sigkdd Explor. Newsl.
**2006**, 8, 90–91. [Google Scholar] [CrossRef] - Puolamäki, K.; Fortelius, M.; Mannila, H. Seriation in paleontological data: Using markov chain monte carlo methods. PLoS Comput. Biol.
**2006**, 2, e6. [Google Scholar] [CrossRef] [PubMed] - Mannila, H. Finding total and partial orders from data for seriation. Lect. Notes Comput. Sci.
**2008**, 5255, 16–25. [Google Scholar] - Arkin, A.; Sheng, P.; Ross, J. A test case of correlation metric construction of a reaction pathway from measurements. Science
**1997**, 277, 1275–1279. [Google Scholar] [CrossRef] - Fernandez, P.L.; Heath, L.S.; Ramakrishnan, N.; Tan, M.; Vergara, J.P. Mining posets from linear orders. Discret. Math. Algorithms Appl.
**2013**, 5, 1350030. [Google Scholar] [CrossRef] - Sanchez, G.A.; Fernandez, P.L.; Vergara, J.P. Some heuristics for the 2-poset cover problem. Philipp. Comput. J.
**2014**, 9, 26–32. [Google Scholar] - Yellin, D. Representing sets with constant time equality testing. J. Algorithms
**1992**, 13, 353–373. [Google Scholar] [CrossRef]

© 2019 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).