on extensions, linear extensions, upsets and downsets of ordered sets

18
Discrete Mathematics 295 (2005) 13 – 30 www.elsevier.com/locate/disc On extensions, linear extensions, upsets and downsets of ordered sets Ricardo C. Corrêa a , 1 , Jayme L. Szwarcfiter b, 2 a Universidade Federal do Ceará, Departamento de Computação, Campus do Pici, Bloco 910, 60455-760 Fortaleza, CE, Brazil b Universidade Federal do Rio de Janeiro, Instituto de Matemática, NCE and COPPE, Caixa Postal 2324, 20001-970 Rio de Janeiro, RJ, Brazil Received 11 June 2003; received in revised form 9 November 2004; accepted 8 December 2004 Available online 19 April 2005 Abstract We consider the problem of characterizing the set (P ) of all extensions of an order P on a set of elements E, where |E|= n, |P |= m and is the number of extensions of the order. Initially, we describe two distinct characterizations of (P ). The first characterization is a one-to-one corre- spondence between extensions of P and pairs of upsets and downsets of certain suborders of P . The second one characterizes the extensions of P in terms of linear extensions and sequences of downsets. Both characterizations lead to algorithms that generate all the extensions of P . Further, we discuss the notion of passive pairs of an order. Based on it, we describe a third characterization of (P ) and an algorithm that generates all the extensions of P in O(n) amortized time per extension. © 2005 Published by Elsevier B.V. Keywords: Ordered sets; Extensions; Enumeration E-mail addresses: [email protected] (R.C. Corrêa), [email protected] (J.L. Szwarcfiter). 1 Partially supported by the Conselho Nacional de Desenvolvimento Científico e Tecnológico, CNPq, Brazil. 2 Partially supported by the Conselho Nacional de Desenvolvimento Científico e Tecnológico, CNPq, and Fundação de Amparo à Pesquisa do Estado do Rio de Janeiro, FAPERJ, Brazil. 0012-365X/$ - see front matter © 2005 Published by Elsevier B.V. doi:10.1016/j.disc.2004.12.007

Upload: ufrj

Post on 19-Nov-2023

1 views

Category:

Documents


0 download

TRANSCRIPT

Discrete Mathematics 295 (2005) 13–30www.elsevier.com/locate/disc

On extensions, linear extensions, upsetsand downsets of ordered sets

Ricardo C. Corrêaa,1, Jayme L. Szwarcfiterb,2

aUniversidade Federal do Ceará, Departamento de Computação, Campus do Pici, Bloco 910,60455-760 Fortaleza, CE, Brazil

bUniversidade Federal do Rio de Janeiro, Instituto de Matemática, NCE and COPPE, Caixa Postal 2324,20001-970 Rio de Janeiro, RJ, Brazil

Received 11 June 2003; received in revised form 9 November 2004; accepted 8 December 2004Available online 19 April 2005

Abstract

We consider the problem of characterizing the set�(P ) of all extensions of an orderP on a setof elementsE, where|E| = n, |P | = m and� is the number of extensions of the order. Initially,we describe two distinct characterizations of�(P ). The first characterization is a one-to-one corre-spondence between extensions ofP and pairs of upsets and downsets of certain suborders ofP . Thesecond one characterizes the extensions ofP in terms of linear extensions and sequences of downsets.Both characterizations lead to algorithms that generate all the extensions ofP . Further, we discussthe notion ofpassive pairsof an order. Based on it, we describe a third characterization of�(P ) andan algorithm that generates all the extensions ofP in O(n) amortized time per extension.© 2005 Published by Elsevier B.V.

Keywords:Ordered sets; Extensions; Enumeration

E-mail addresses:[email protected](R.C. Corrêa),[email protected](J.L. Szwarcfiter).1 Partially supported by the Conselho Nacional de Desenvolvimento Científico e Tecnológico, CNPq, Brazil.2 Partially supported by the Conselho Nacional de Desenvolvimento Científico e Tecnológico, CNPq, and

Fundação de Amparo à Pesquisa do Estado do Rio de Janeiro, FAPERJ, Brazil.

0012-365X/$ - see front matter © 2005 Published by Elsevier B.V.doi:10.1016/j.disc.2004.12.007

14 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

1. Introduction

Let E be a finite set of elementsei , i ∈ {1,2, . . . , n} andE2 = E × E. LetP ⊆ E2 bea binary relation onE, with |P | = m. When the relationP is reflexive, anti-symmetric andtransitive then it is anorder on E. In this case, distinct elementsei andej of E are said tobecomparableif eiej or ej ei is a pair ofP . Otherwise they areincomparable. The familyof all incomparable pairs is theincomparable setof P , denoted byI (P ). For the sake ofconvenience, we may write simplyI , instead ofI (P ). An orderP ′ is ageneral extension(or simplyextension, if its meaning is clear from the context) ofP whenP ′ ⊇ P . Denoteby �(P ) the set of all extensions ofP , and by� the cardinality of�(P ). In the special casewhenP ′ ∈ �(P ) and every two elements ofE are related inP ′, the extensionP ′ is a linearextension of P. Therefore a linear extension is completely determined by a sequence of theelements ofE. The problem considered in this paper involves orders, and their general andlinear extensions.

Before stating the problem considered in the sequel, we introduce some more notation.If w ∈ P thenw is an ordered paireiej and writew = eiej . Forei ∈ E, denote

E−P (ei) = {ej ∈ E | ej ei ∈ P andei �= ej }

for the set of incoming elements. Similarly, the outgoing elements ofei are denoted by

E+P (ei) = {ej ∈ E | eiej ∈ P andei �= ej }.

Both notions of incoming and outgoing elements can be extended to a set of elements. So,for S ⊆ E, denoteE−

P (S) = ⋃ei∈S E

−P (ei) andE+

P (S) = ⋃ei∈S E

+P (ei). DefineE−

P [ei] =E−

P (ei) ∪ {ei} andE−P [S] = E−

P (S) ∪ {ei}. Similarly, defineE+P [ei] andE+

P [S]. Whenconvenient, we may drop the indexP of these notations. IfE−

P (ei) = ∅ or E+P (ei) = ∅, say

that ei is a minimal or maximalelement, respectively. Denote byM−P andM+

P the set ofminimal and maximal elements ofP , respectively. Finally, adownsetof P is a setE′ ⊆ E

satisfyingei ∈ E′ andej ei ∈ P impliesej ∈ E′. Similarly, whenE′ satisfiesei ∈ E′ andeiej ∈ P impliesej ∈ E′ thenE′ is aupsetof P.

In the present work, we consider the problem of characterizing the set�(P ) of extensionsof an orderP . Three distinct characterizations are described. First, we show that extensionsof P relate to convenient sequences of upsets and downsets. In the sequel, a differentapproach is taken. We characterize the extensions ofP in terms of linear extensions andsequences of downsets. Further, we discuss the notion ofpassive pairsof P and we describea partition of�(P ) according to these passive pairs. All characterizations proposed in thepresent paper lead to algorithms for generating all the extensions ofP. In the particular caseof the third characterization, we propose a backtracking algorithm whose time complexityis O(m + n�).

The problem of establishing correspondences between extensions of a given orderP andits structure has been investigated by several authors. Baldy et al.[1] have proved a one-to-one correspondence between the extensions ofP and the set of maximal height sub-latticesof the lattice of downsets ofP . This extends a classical theorem by Bonnet and Pouzet[3], which establishes a one-to-one correspondence between linear extensions ofP andthe maximal chains of the lattice of downsets of the order. Besides, other correspondences

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 15

involving extensions of special kinds have been formulated by Habib et al.[6] and by Felsneret al.[5].

The problem of generating the extensions of an order has been considered in the litera-ture for special kinds of extensions. For example, algorithms for generating all the linearextensions have been described by Knuth and Szwarcfiter[8],Varol and Rotem[14], Kalvinand Varol[7] and Pruesse and Ruskey[10]. Among these, the algorithm in[10] requires nomore than constant amortized time, per linear extension. On the other hand, an algorithmfor generating all minimal interval extensions has been formulated by Morvan and Nourine[9]. Besides its interest in ordered sets, extensions generation may have applications toother areas. For example, Corrêa and Ferreira[4] have shown their connection withmultiprocessor scheduling problems.

The following notation is adopted in the next sections. LetP be a relation onE andP ′ ⊆ P a relation onE′ ⊆ E. Wheneiej ∈ P implieseiej ∈ P ′, for ei, ej ∈ E′, writeP ′ = P [E′]. If P is an order inE andP ′ an order inE′, thenP ′ is asuborderof P . WhenadditionallyP ′ = P [E′], thenP ′ is thesuborder induced byE′ in P. On the other hand,P − E′ denotes the relationP [E\E′], while for e ∈ E, P − e meansP − {e}. In general,if Sis any set andsan element of it, writeS + s andS − s with the meaning ofS ∪ {s} andS\{s}, respectively.

The rest of the paper is organized as follows. Section 2 contains a description of theone-to-one correspondence between extensions ofP and pairs of upsets and downsets ofsub-orders ofP . Another one-to-one correspondence, involving extensions, linear exten-sions and downsets, is described in Section 3. Based on these correspondences, recursivemethods for enumerating the extensions ofP are presented, in Section 4. Section 5 dis-cusses the concept of passive pairs and its relations to the extensions of an ordered set. Thecomputation of passive pairs can be performed using the results described in Section 6.These developments lead to an algorithm for extensions generation, whose details appearin Section 7. Finally, some remarks form the last section.

2. Upsets, downsets and general extensions

A first characterization of�(P ) is described in this section, consisting of a convenientcorrespondence between extensions, upsets and downsets. Before stating this correspon-dence, we need some more definitions on the orderP defined onE (the example inFig. 1 will be used to illustrate the definitions that follow). Thefocusof a subsetE′ ⊆ E

in P is the subsetFP (E′) ⊆ E, defined as follows. IfE′ = ∅ thenFP (E

′) = E, otherwiseFP (E

′) = ⋂ei∈E′ E+

P (ei). Let L be the linear extensione1, . . . , en of P. An augmentationof P, relative to Lis a binary relationAn, defined by the following recurrence:

A0 = ∅, (1)

Ai = Ai−1 ∪ {eiei} ∪ {eqei | eq ∈ Si} ∪ {eieq | eq ∈ Ti} (2)

for all 1� i�n, whereSi is a downset ofAi−1 containingE−P (ei) andTi is an upset of

Ai−1[FAi−1(Si)]. An example of augmentation is shown inFig. 2. The theorem belowrelates extensions and augmentations.

16 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

Fig. 1. OrderP , with n = 12, for the examples in Figs.2 and4.

Theorem 1. Let P be an order on E and L a linear extension of it. There exists a one-to-onecorrespondence between general extensions of P and augmentations, relative to L.

Proof. ConsiderPas defined in the theorem and a linear extensionL given bye1, e2, . . . , en.DenoteE0 = P0 = ∅, Ei = {e1, e2, . . . , ei} andPi = P [Ei],1� i�n. By induction oni,we show that there exists a one-to-one correspondence between general extensions ofPi

and augmentations ofPi relative toe1, e2, . . . , ei . Wheni = 0, there is nothing to prove.For i >0, assume thatAi−1, as computed by (1)–(2), is an order ofEi−1 and a generalextension ofPi−1. We have to prove thatPi extends toAi . First, we prove thatAi is anorder onEi . Clearly, it is reflexive. Suppose that it is not anti-symmetric. Then there aredistinct elementsej , ek ∈ Ei satisfyingej ek, ekej ∈ Ai . SinceAi−1 is an order, it followsthat ei = ej or ei = ek. Without loss of generality, we may assumeei = ek. From thedefinitions ofSi andTi , it follows thatej ∈ Si ∩ Ti . Using the definition of focus, we knowthatSi ∩ Ti =∅, which contradicts the latter assertion. Consequently,Ai is anti-symmetric.It remains to prove that it is transitive.As before, it suffices to examine the transitivities atei .Letek, ej ∈ Ei−1 andek �= ej . Consider the following alternatives, all of them illustrated inFig. 3.

Case1 (ekej ∈ Ai, ej ei ∈ Ai): We know thatej ∈ Si . On the other hand,ekej ∈ Ai

meansekej ∈ Ai−1. BecauseSi is a downset ofAi−1 it follows ek ∈ Si . Consequently,ekei ∈ Ai , meaning that transitivity holds.

Case2 (ekei ∈ Ai, eiej ∈ Ai): Thenek ∈ Si andej ∈ Ti . From the hypothesis, weconclude thatej ∈ FAi−1(Si). Consequently,ekej ∈ Ai−1. The latter impliesekej ∈ Ai , asrequired.

Case3 (eiek ∈ Ai, ekej ∈ Ai): First, examineSi . If Si = ∅ thenFP ′i−1

(Si) = Ei−1.Consequently,Ti is an upset ofAi−1. Becauseeiek ∈ Ai , we know thatek ∈ Ti . Inaddition,Ti being an upset ofAi−1 impliesej ∈ Ti . Thereforeeiej ∈ Ai and transitivityholds. Now, consider the situation whereSi �= ∅, and selectet ∈ Si . SinceTi ⊆ FAi−1(Si)

andek ∈ Ti , it follows thatet ek ∈ Ai−1. On the other hand,ekej ∈ Ai impliesekej ∈ Ai−1.By the transitivity ofAi−1, it follows et ej ∈ Ai−1. Henceej ∈ FAi−1(Si). Becauseek ∈ Ti

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 17

e2

A2

S3 = {e1 , e2} S4 = {e1 , e2} S5 = {e5}

FA2(S3) = 0 FA3

(S4) = {e3} FA4(S5) = {e3 , e4}

A4 A5

e2 e2

e4

e3e5

e1 e1

e3

e8

e6e7

e3

e5 e4

e1

e9

e8

e3

e6

e7

e10e11

e4

e2 e1

A12

A8

e12

e3e4

e

T3 = 0 T4 = {e3} T5 = {e3}

S8 = {e1 , … , e5}

FA7(S8) = {e6 , e7}

T8 = {e7}

Fig. 2. Construction of an augmentation of the orderP in Fig. 1, relative toL = {e1, e2, . . . , e12}. For everyAi

not shown in the figure,Si is the minimum downset inAi−1 containingE−P(ei ) andTi = ∅.

andTi is an upset ofAi−1[FAi−1(Si)], we conclude thatej ∈ Ti . Consequently,eiej ∈ Ai ,preserving transitivity.

From the above three cases we conclude thatAi is indeed transitive. Consequently,Ai

is an order onEi . It remains to show thatAi is an extension ofPi . Let ekej ∈ Pi . Ifek, ej �= ei thenekej ∈ Ai−1 andekej ∈ Ai . If ek = ei thenej = ei becauseei is maximalin Pi , meaning thatekej ∈ Ai . Finally, whenek �= ei andej = ei, E−

P (ei) ⊆ Si impliesek ∈ Si and consequentlyekej ∈ Ai . Therefore,Ai is an extension ofPi .

Conversely, letP ′ be a general extension ofP . We show thatP ′ is also an augmentationAn of P, relative toL, which would prove the theorem. Again, employ induction. For

18 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

Ai Ai

Ai

Ai−1 Ai−1

Ai−1

eiei

ei

ej ej

ej

ek ek

ek

Case 1 Case 2

Case 3

Fig. 3. Cases in the proof of Theorem 1.

i >0, letP ′i−1 = P ′[Ei−1] and assume thatP ′

i−1 is an augmentation ofPi−1, relative toe1, e2, . . . , ei−1. We prove that the same applies toP ′

i . That is, we obtainP ′i from P ′

i−1,using (1)–(2). At first, look for a pair of subsetsSi, Ti , as required by (1)–(2). ChooseSi = E−

P ′i

(ei) andTi = E+P ′i

(ei) and examine the conditions (1)–(2). Clearly,Si, Ti ⊆ Ei .

Also, we know thatSi is a downset ofP ′i−1. SinceP ′

i is an extension ofPi, E−P ′i

(ei) ⊇E−

Pi(ei) and thereforeSi containsE−

Pi(ei). In addition, the linear extensionL given by

e1, . . . , en yields thatE−Pi(ei) = E−

P (ei). Consequently,Si containsE−P (ei). In the sequel,

examineTi . If Ti = ∅, there is no need for further arguments. Otherwise, selectej ∈ Ti andconsider the two possible alternatives regardingSi . If Si = ∅ thenFP ′

i−1(Si) = Ei−1 and

let ej eq ∈ P ′i−1. Then,eiej ∈ P ′

i and by transitivityeieq ∈ P ′i . That is,eq ∈ Ti , meaning

thatTi is an upset ofP ′i−1[FP ′

i−1(Si)], as required. It remains to analyze the situation where

Si �= ∅. In such a case, chooseeq ∈ Si . Sinceeqei, eiej ∈ P ′i , it follows eqej ∈ P ′

i ,that is,eqej ∈ P ′

i−1.Consequently,ej ∈ FP ′i−1

(Si) andTi ⊆ FP ′i−1

(Si). At last, we need

to show thatTi is an upset ofP ′i−1[FP ′

i−1(Si)]. Let ek ∈ FP ′

i−1(Si) such thatek �= ej and

ej ek ∈ P ′i−1. Thenej ek ∈ P ′

i . Becauseeiej ∈ P ′i , by transitivityeiek ∈ P ′

i . That is,ek ∈ Ti .Consequently,Ti is an upset ofP ′

i−1[FP ′i−1

(Si)], completing the proof. �

3. Downsets, general extensions and linear extensions

In this section,�(P ) is related to sequences of downsets and linear extensions. In orderto formulate this second characterization, we need some more notation. LetP be an orderonE, while L andL′ are linear extensions of it, whereL is the sequencee1, . . . , en of theelements ofE. A lexicographic augmentation of P, relative to(L,L′), is a binary relationBn, obtained by the following recurrence:

B0 = ∅, (3)

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 19

e5 e5 e5

e4 e4 e4

e2 e2 e2e1 e1 e1

B12B7B5

e3 e3 e3

e6 e6

e7 e9 e8 e7

e12 e11 e10

S5 = {e1 , … , e4} S7 = {e1 , … , e4 , e6}

MB4 = {e3 , e4}

+MB6

= {e5 , e6}+

Fig. 4. Construction of a lexicographic augmentation of the orderP in Fig. 1, relative toL = {e1, e2, . . . , e12}andL′ = {e1, e2, e5, e3, e4, e7, e8, e9, e6, e10, e11, e12}. For everyBi not shown in the figure,Si is the minimumdownset inAi−1 containingE−

P(ei ).

Bi = Bi−1 ∪ {eiei} ∪ {eqei | eq ∈ Si} (4)

for all 1� i�n, whereSi is a downset ofBi−1, containingE−P (ei) andE−

Bi−1[M+

Bi−1∩

E+L′(ei)]. An example of lexicographic augmentation is given inFig. 4. Lexicographic

augmentations and extensions are related as follows.

Theorem 2. Let P be an order on E andL′ a fixed linear extension of it. There exists aone-to-one correspondence between extensions of P and pairs(L, Bn), where L is a linearextension of P andBn is a lexicographic augmentation of P, relative to(L,L′).

Proof. Let L be the linear extensione1, e2, . . . , en of P andBn a lexicographic augmen-tation ofP , relative to(L,L′). DefineE0, P0, Ei andPi as in the proof of Theorem 1. Inaddition, denoteLi =e1, . . . , ei . By induction, we show that there exists a one-to-one corre-spondence between extensionsP ′

i of Pi and lexicographic augmentationsBi of Pi , relativeto (Li, L

′[Ei]). The case wherei = 0 is trivially valid. Fori >0, we have to prove thatBi ,as computed by (3)–(4), is an extension ofPi , given thatBi−1 is an order onEi−1 and anextension ofPi−1. First, we prove thatBi is an order onEi . Clearly, it is reflexive. BecauseBi−1 is anti-symmetric andei is a maximal element ofBi it follows thatBi preserves anti-symmetry. It remains to show that it is transitive. For this purpose, it suffices to examinethe transitivities atei . Becauseei is a maximal element, the only case is to verify whetherej ek, ekei ∈ Bi impliesej ei ∈ Bi for all ei, ej , ek ∈ Ei . If ei, ej , ek are not distinct, thelatter condition holds. Assumeei, ej , ek to be distinct. Thenej ek ∈ Bi−1. Sinceekei ∈ Bi

it follows ek ∈ Si ∪ S′i , whereSi is a downset ofBi−1 andS′

i = E−Bi−1

[M+Bi−1

∩ E+L′(ei)].

20 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

ei ei

ei

ei ei

ei

ej

ej ej

ej

ej ej

ek ek

ek ekel el

Situations with respect to L Situations with respect to L

… …

…………

Fig. 5. Procedure to prove that the correspondence stated in Theorem 2 is injective.

We know thatSi ∪S′i is also a downset ofBi−1. Consequently,ek ∈ Si ∪S′

i andej ek ∈ Bi−1imply ej ∈ Si ∪ S′

i . That is,ej ei ∈ Bi , meaning thatBi is transitive. The conclusion is thatBi is an order onEi . It remains to verify whetherBi is an extension ofPi . This is clearlytrue, becauseBi−1 is an extension ofPi−1 andSi ⊇ E−

P (ei).Conversely, letP ′ be an extension ofP . We show thatP ′ is also a lexicographic

augmentationBn of P, relative to (L,L′), whereL is the linear extensione1, . . . , enof P obtained as follows. Fori = n, . . . ,1 chooseei as to be the maximal element ofP ′\{en, . . . , ei+1} which lies rightmost inL′. DenoteP ′

i = P ′[Ei] and use induction. Fori >0, assume thatP ′

i−1=Bi−1, whereBi−1 is a lexicographic augmentation ofPi−1, relativeto (Li−1, L

′[Ei−1]). We prove that the same applies toP ′i . That is, we show thatP ′

i = Bi ,whereBi is obtained fromBi−1, using (3)–(4). Once more, letS′

i =E−Bi−1

[M+Bi−1

∩E+L′(ei)],

and defineSi = (E−P ′i

(ei)\S′i ) ∪ E−

Pi(ei). We need to show thatE−

P ′i

(ei) = Si ∪ S′i . Clearly,

E−P ′i

(ei) ⊆ Si ∪ S′i , by construction. Letej ∈ Si ∪ S′

i for somej < i. If ej ∈ Si then

ej ∈ [E−P ′i

(ei) ∪ E−Pi(ei)] = E−

P ′i

(ei), becauseP ′i is an extension ofPi . If ej ∈ S′

i , first

considerej ∈ M+Bi−1

∩ E+L′(ei). In this situation,ej ∈ E−

P ′i

(ei), otherwise there exists a

maximal element inP ′i which lies to the right ofei in L′, a contradiction. On the other hand,

ej ∈ E−Bi−1

[M+Bi−1

∩ E+L′(ei)] also impliesej ∈ E−

P ′i

(ei), by transitivity. Consequently,

E−P ′i

(ei) = Si ∪ S′i , meaning thatP ′

i = Bi .

The last step is to show that there is noL �= L such thatP ′ = Bn, whereL is a linearextension ofP andBn is a lexicographic augmentation ofP , relative to(L, L′). This showsthat the correspondence is injective. By contradiction, assume thatP ′ = Bn, for some linearextensionL �= L of Pand for some lexicographic augmentationBn ofP , relative to(L, L′).The arguments used in the sequel are illustrated inFig. 5. SinceL �= L, then there existstwo elementsei andej satisfying the conditions of the following claim.

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 21

Claim 3. Let ei andej be two elements of E such that the following conditions hold:

(1) eiej ∈ L andei ∈ M+Bj

, whereBj is the lexicographic augmentation ofP [Ej ] leadingto Bn; and

(2) ej ei ∈ L.

Then, there exists an elementek such thatekei ∈ L andej ek ∈ P ′.

Proof. First observe that botheiej /∈P ′ andej ei /∈P ′, this becauseeiej ∈ L, ej ei ∈ L andBn = Bn. A consequence of this fact and of the conditionei ∈ M+

Bjis thatej ei /∈L′, which

is equivalent to say thateiej ∈ L′. It follows that ifej ∈ M+Bi

, whereBi is the lexicographic

augmentation ofP [E−L

[ei]] leading toBn, thenej ei ∈ P ′ by (4). Since this is not the case,

i.e.ej ei /∈P ′, thenej /∈M+Bi

, which means that there exists an elementek that lies between

ej andei in L andej ek ∈ M+Bi

. Finally, ej ek ∈ P ′ becauseBi ⊆ Bn = P ′. �

Using this claim, takeek ∈ M+Bi

. It follows from ej ek ∈ P ′ that eiek ∈ L. Again, we

can apply the claim, but this time exchanging the roles ofL andL, and replacingei by ekandej by ei . Consequently, there existsj < l < k such thatelek ∈ L andeiel ∈ P ′. Thisprocedure should be repeated indefinitely. However, given thatE is finite, a contradictionwill arise, meaning thatP ′ �= Bn and completing the proof of the theorem.�

4. Enumerating the augmentations

Theorem 1 leads directly to the formulation of the algorithm AUGMENTATION shownin Fig. 6 for generating all the extensionsP ′

i of the induced subordersPi, i = 1, . . . , n,of a given orderP on E, given a linear extensionL = e1, . . . , en of P. This includes allthe extensions ofP . For i >0, generate recursively all the extensionsP ′

i from P ′i−1 as

follows. DefineA = ⋃ejE−

P ′i−1

[ej ], for all ej ∈ E−Pi(ei) and then generate each downset

Si of P ′i−1[Ei−1\A]. It follows thatSi ∪ A is a downset ofP ′

i−1 containingE−Pi(ei). In the

sequel, find the focusF of Si in P ′i−1. Generate each upsetTi of P ′

i−1[F ]. At this point,we

Fig. 6. Generating all the augmentations based on Theorem 1.

22 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

are ready to introduceei in the order, as follows: defineE−P ′(ei)=Si andE+

P ′(ei)=Ti . Theexternal call is AUGMENTATION(∅,1).

The above process requires the generation of all the downsets (upsets) of an order. Withthis purpose, we have to employ algorithms for downset generation. Such algorithms havebeen formulated by Steiner[13], Pruesse and Ruskey[10], Barbosa and Szwarcfiter[2] andSquire[12]. The algorithm proposed in[12] requires no more than logarithmic amortizedtime per downset generated (c.f.[11]).

We evaluate the complexity of the algorithm as follows. The recursion describes a treeT whose nodes correspond to the extensions of the subordersPi of P . The leaves ofTcorrespond to the extensions ofP . The internal nodes ofT are divided into two types,namely those having exactly one child and the remaining possessing at least two. The formernodes correspond to the computations AUGMENTATION(P ′

i−1, i), whereEi−1 = E−Pi(ei).

In this case,Ei−1 = A which meansSi = A andTi = ∅. It is simple to implement thissituation, so that each of these computations AUGMENTATION(P ′

i−1, i) is terminated withina constant number of steps. We can cover all internal nodes ofT of this type, as follows. Allcomputations corresponding to nodes with a single child and belonging to a same root-leafpath ofT are charged to the extension corresponding to the leaf of this path. Since the heightof T is n + 1 it is required no more thanO(n) time per extension ofP , to cover all singlechild nodes. As for the nodes with more than one child, their number is less than the numberof leaves ofT . That is, we can charge all the computations corresponding to these nodes todifferent extensions ofP . The dominating operation in such calls EXTENSION(P ′

i−1, i) isfinding the focusF , which may requireO(n2) time. Therefore the overall time bound forgenerating all the extensions of all subordersPi, i = 1, . . . , n, of P is O(n2�).

Theorem 2 leads to a recursive method for enumerating all extensions of all sub-ordersP [Eij ], where 1�j �n, Eij is the subset{ei1, . . . , eij } of E andei1, . . . , ein is a linearextension ofP. It employs the enumeration of linear extensions and downsets. The methodpartitions the general extensions ofP into equivalence classes, each of them containingexactly one linear extension ofP . LetL′ be a fixed linear extension. For each linear extensionL of P , compute all lexicographic augmentations, relative to(L,L′), using (3)–(4). Again,the downsetsSi can be generated with one of the algorithms described in[2,11–13]. Thereis no difficulty to implement this method in timeO(n2�).

5. Passive pairs and general extensions

Let P be an order onE and I its incomparable set. We define the concept of passivepairs and describe some related properties. They constitute a central point in our thirdcharacterization of�(P ), which will follow. A pair w ∈ I is calledpassivewhenP + w isan order. Notice that any extensionP ′ of Pcontains a passive pair ofP . Denote byW(P ) theset of passive pairs ofP . Again, we may use simplyW , instead ofW(P ). For example, inthe order ofFig. 7, W = {e1e3, e3e4}, meaning that the incomparable pairse3e1, e2e3, e3e2ande4e3 are not passive. In this section, we describe how passive pairs will be employedin the enumeration of extensions of an order.

Let R ⊆ I . Denote by�(P,R) the set of all extensions ofP , having no pairs belongingto R. That is,P ′ ∈ �(P,R) if and only if P ′ is an order onE, satisfyingP ′ ⊇ P and

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 23

e1

e3

e4

e2

Fig. 7. Passive pairs.

P ′ ∩ R = ∅. Therefore,�(P,∅) is the set of all extensions ofP . The following theoremdescribes a method for computing�(P,∅).

Theorem 4. Let P be an order onE, I (P ) its incomparable set, R ⊆ I (P ),W the set ofpassive pairs of P and�(P,R) the set of all extensions of P, forbidding the pairs of R. Then

�(P,R) = {P }, whenW ⊆ R. (5)

Otherwise,

�(P,R) = {P }⋃

q=1,...,

�(P + wq,R ∪ {w1, . . . , wq−1}), (6)

whereW\R = {w1, . . . , w }. Moreover, the subsets in(6) form a partition of�(P,R).

Proof. We show a one-to-one correspondence between�(P,R)and (5)–(6). Clearly,�(P,R)

and (5) correspond exactly whenW ⊆ R. SupposeW ′ =W\R = {w1, . . . , w } �= ∅. First,note that any member of (6) is necessarily an extension ofP . The reason is that,wq beinga passive pair ofP implies thatP + wq is an extension ofP .

Conversely, we show that any extensionP ′ ∈ �(P,R) belongs to precisely one of the + 1 subsets of the union{P }⋃q=1,..., �(P + wq,R ∪ {w1, . . . , wq−1}). This assertionis trivial whenP ′ = P . ConsiderP ′ �= P . Initially, we show thatP ′ must contain somepassive pair ofP . LetS=P ′\P . Clearly,|S|>0. Use induction. If|S|=1 then the sole pairforming S must be passive, by definition. When|S|>1, assume the assertion true for allextensions containing at most|S| − 1 incomparable pairs ofP. Choose any paireiej ∈ S.EitherP ′′ = P ′ − eiej is an order or not. In the first alternative, the induction hypothesisimplies thatP ′ must contain some passive pair ofP . WhenP ′′ is not an order it follows thatit must fail transitivity, sinceP ′′ is both reflexive and anti-symmetric. That is, there existsan elementek ∈ E, such thateiek, ekej ∈ P ′′. Clearly,eiek or ekej , at least one of them,belongs toS, otherwiseP would also fail transitivity. Without loss of generality, assumethateiek ∈ S. In the sequel, repeat the argument, by choosing the paireiek instead ofeiej ,

24 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

to be removed fromP ′′, and so on iteratively. No pair can be chosen twice, otherwiseP ′would not be anti-symmetric. SinceSis finite, we conclude thatP ′ contains a paireset ∈ S,such thatP ′ − eset is an order. Consequently,P ′ indeed contains a passive pair ofP .

The last step is to show that the subsets�(P+wq,R∪{w1, . . . , wq−1}), q=1, . . . , , forma partition of�(P,R)\{P }. Denote byj the smallest index of the pairwj ∈ {w1, . . . , w −1},such thatwj ∈ P ′. ThenP ′ ∈ �(P + wj ,R ∪ {w1, . . . , wj−1}). It remains to show thatP ′ /∈ �(P + wk,R ∪ {w1, . . . , wk−1}), for any k �= j . If k < j this fact is true, by theminimality of j.Whenk > j , it follows thatwj is a forbidden pair.That is,P ′ /∈ �(P+wk,R∪{w1, . . . , wk−1}), becausewj ∈ P ′. Consequently, the subsets in (6) form a partition of�(P,R). �

A straightforward implementation of Theorem 4 leads to a basic algorithm for extensionenumeration, as follows. At each recursive step for computing�(P,R), verify if W ⊆ R.In the affirmative case, the answer isP . When negative, again outputP and recursively call�(P+wq,R∪{w1, . . . , wq−1}), whereW ′={w1, . . . , w }. Such an algorithm would requirethe computation ofW(P ), for the current orderP , at each enumeration of an extension.This will be done using the results described in the next section.

6. Computing passive pairs

In what follows, we describe some properties related to passive pairs, which will constitutea central point in our algorithm for enumerating the extensions ofP based on Theorem 4.These properties will allow us to establish suitable methods for computing passive pairs.

Let P be an order onE andI its incomparable set. Letei, ej , ek be distinct elements ofE, with eiej ∈ I . Say thatek is anactive element foreiej in P when either

ej ek ∈ P and eiek ∈ I, or (7)

ekej ∈ I and ekei ∈ P . (8)

These two cases are illustrated inFig. 8. Denote byAij (P ) the set of all active elementsfor eiej in P. The meaning ofek ∈ Aij (P ) is thatP + eiej fails transitivity atek. The nextlemma relates active elements and passive pairs.

Lemma 5. Let P be an order on E, I its incomparable set andeiej ∈ I .Theneiej is passiveif and only ifAij (P ) = ∅.

ek ekei ei

ej ej

Fig. 8. Conditions (7) and (8).

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 25

et = ek

es = ei es = ek

et = ej

ej ei

Fig. 9. Conditions (9) and (10).

Proof. Let eiej ∈ I be a passive pair inP and denoteP ′ = P + eiej . We know thatP ′ isan order. SupposeAij (P ) �= ∅ and chooseej ∈ Aij (P ). Thenk �= i, j and either (7) or (8)is satisfied. In the first situation,P ′ is not transitive, becauseeiej , ej ek ∈ P ′ andeiek /∈P ′.In the second alternative,P ′ is not transitive becauseekej /∈P ′. Consequently,P ′ is not anorder, a contradiction. ThenAij (P ) = ∅.

Conversely, by hypothesisAij (P )=∅. Suppose thateiej is not passive. LetP ′=P +eiej .ThenP ′ is not an order. Clearly,P ′ is reflexive, becauseP is so. In addition, sinceP isanti-symmetric andeiej ∈ I it follows thatP + eiej is also anti-symmetric. Consequently,P ′ not being an order implies that it is not transitive. That is, there are distinct elementsea, eb, ec ∈ E, such thateaeb, ebec ∈ P ′ andeaec /∈P ′. We know thatecea ∈ I , otherwiseP ′ is not anti-symmetric. BecauseP is transitive, it follows that either eaeb = eiej orebec = eiej . In the first situation, ec is active foreiej in P. In the second alternative,ea isactive foreiej . Consequently,Aij (P ) �= ∅, a contradiction. Henceeiej is a passive pair.

The aim of the next two lemmas is to describe how the sets of active elements change,asP changes toP + eset . The lemma below identifies those active elements inP which arenot active inP + eset , for some passive paireset .

Lemma 6. Let P be an order on E, eset a passive pair in P, eiej an incomparable pair inP + eset andek ∈ E. Thenek ∈ Aij (P )\Aij (P + eset ) if and only if

es = ei, et = ek and ej ek ∈ P, or (9)

es = ek, et = ej and ekei ∈ P . (10)

Proof. First, we prove that the conditions shown inFig. 9 are necessary. Leteset be apassive pair inP, eiej an incomparable pair inP + eset and ek ∈ E. By hypothesis,ek ∈ Aij (P )\Aij (P + eset ). The conditionek ∈ Aij (P ) implies that either (7) or (8) holdsfor P . On the other hand,ek /∈Aij (P + eset ) means that neither (7) nor (8) are satisfiedfor P + eset . From these two situations together, we conclude that{es, et } ⊆ {ei, ej , ek}.Examine the alternatives for fulfilling the latter condition.

Case1: es = ei andet = ej , or es = ej andet = ei .Theneiej is comparable inP + eset , a contradiction.Case2: es = ei andet = ek.

26 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

Verify the comparabilities amongei, ej , ek. Clearly,eiej , eiek ∈ I (P ). In this situation,becauseek ∈ Aij (P ) either (7) or (8) must be satisfied. If (7) is satisfied thenej ek ∈ P

andek /∈Aij (P + eset ), meaning that (9) holds. On the other hand, (8) cannot be satisfied,sinceekei ∈ I (P ).

Case3: es = ek andet = ei .Theneiek ∈ I (P ). Again ek ∈ Aij (P ) implies that (7) or (8) is verified. In the first

alternative, we conclude thatej ek ∈ P . However, the latter situation implies thateset isnot a passive pair inP. That is,ej ∈ Ast (P ), a contradiction. The alternative that (8) holdsdoes not occur, because it would contradicteiek ∈ I (P ).

Case4: es = ej andet = ek.Thenej ek ∈ I (P ). Again (7) or (8) has to be satisfied. This is not possible for (7), since

it contradictsej ek ∈ I (P ). Then (8) is satisfied, implyingekei ∈ P . The latter means thateset is not passive, becauseekei ∈ P andej ei ∈ I (P ) imply ei ∈ Ast (P ). Consequently,the present case also leads to a contradiction.

Case5: es = ek andet = ej .Thenekei ∈ I (P ). Becauseek ∈ Aij (P )apply (7) or (8). Condition (7) cannot hold, since

eset ∈ I (P ), but (8) leads to conclude thatekei ∈ P . The latter agrees withek /∈Aij (P +eset ). Then (10) holds.

Examining the above cases, we conclude that (9) or (10) is satisfied. This completes theproof of necessity.

Conversely, the hypothesis is that (9) or (10) holds. Consider the elementsei, ej , ek ∈E. Suppose that (9) holds. Clearly,es = ei and et = ek mean thateiek ∈ I (P ). Sinceeiej , eiek ∈ I (P ) andej ek ∈ P , from (7) we conclude thatek ∈ Aij (P ). In P + eset thesituation changes, aseiek becomes a comparable pair. In the new situation,ek is no longeran active element foreiej in P + eset . Consequently,ek ∈ Aij (P )\Aij (P + eset ).

Consider the remaining alternative that (10) holds. Examining the comparabilities amongei, ej , ek, we conclude thateiej , ekej ∈ I (P ) andekei ∈ P . Therefore, (8) is satisfied, andit follows thatek ∈ Aij (P ). As before, neither (7) nor (8) are satisfied forP + eset . Thatis, ek /∈Aij (P + eset ). �

The lemma that follows describes the elements ofE which are active inP + eset and notin P. The conditions stated in the lemma are shown inFig. 10.

et = ei et = ek

es = ek es = ejej ei

Fig. 10. Conditions (11) and (12).

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 27

Lemma 7. Let P be an order, eset a passive pair in P, eiej an incomparable pair inP+esetandek ∈ E. Thenek ∈ Aij (P + eset )\Aij (P ) if and only if

es = ek, et = ei and ekej ∈ I (P ), or (11)

es = ej , ej = ek and eiek ∈ I (P ). (12)

Proof. The conditionek ∈ Aij (P + eset )\Aij (P ) implies that{es, et } ⊆ {ei, ej , ek}.Examine the following alternatives:

Case1: es = ei andet = ej or es = ej andet = ei .Contradictseiej to be an incomparable pair inP + eset .Case2: es = ei andet = ek.Theneiek ∈ P + eset , while eiej ∈ I (P ). There is no way in whichek ∈ Aij (P + eset )

can be satisfied. Hence this case does not occur.Case3: es = ek andet = ei .The conditionek ∈ Aij (P + eset ) implies thatekej ∈ I (P ), leading to conclude that

(11) holds.Case4: es = ej andet = ek.The hypothesis leads to conclude thateiek ∈ I (P ), which satisfies (12).Case5: es = ek andet = ej .The conditionek ∈ Aij (P + eset ) can not be met, a contradiction.The conclusion is that (11) or (12) is satisfied.Conversely, condition (11) implies (8) inP +eset . Similarly, (12) implies (7) inP +eset .

However, neither (7) nor (8) are satisfied inP , in any case. Consequently,ek ∈ Aij (P +eset )\Aij (P ), as required. �

7. Enumerating all the extensions using passive pairs

The basic algorithm for generating all extensions of an order described in Section 5 canbe improved using the lemmas of the last section. The central point is still the recurrence(5)–(6), which determines the set�(P, F ) of all extensions of an orderP , not containingany pair belonging to a specified setF ⊆ I . However, the computation of the set of passivepairs considered in each recursive call is performed as detailed next.

Let wq ∈ W(P ) be theqth pair in an arbitrary ordering of the set of passive pairs ofP.GivenW(P ) andwq , the following simple process computesW(P + wq). First, considerW1=W(P )\W(P +wq) andW2=W(P +wq)\W(P ). Clearly, we can obtainW(P +wq)

fromW(P ) by adding to it the pairs ofW2, while removing those ofW1. Besides,wq itselfand its symmetric pairwq cannot be part ofW(P + wq), as they are not incomparablepairs ofP + wq . It remains to describe a method for findingW1 andW2. Lemmas 5–7 areused with this purpose. LetAij (P ) be the set of active elements for an incomparable paireiej ∈ I (P ), whileaij =|Aij (P )|. The values ofaij , for eacheiej ∈ I , are to be maintainedthrough the process. Lemma 5 asserts that the passive pairs ofP are exactly those pairseiejsatisfyingaij = 0. Lemma 6 describes the conditions foraij to decrease, asP changes toP + wq . In particular, ifaij drops to zero theneiej is a candidate to be included inW2.

28 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

Fig. 11. An algorithm that enumerates all extensions ofP not containing forbidden pairs.

Similarly, Lemma 7 determines whenaij increases. In this case, if the increase is from zeroto one theneiej is a candidate to be included inW1.

It should be mentioned that Lemmas 6 and 7 imply that|W1| and|W2| are bothO(n).This means that although|W(P + wq)| = O(n2),W(P + wq) can be constructed fromW(P ) in O(n) steps.

As for a setR ⊆ I of forbidden pairs, observe that any forbidden pair remains so, whenP is transformed intoP + wq . This suggests a very simple method for handling unwantedextensions. At each step of the computation, for each orderP and setR, the current setW ′(P ) = {w1, . . . , wl}, or simplyW ′, would be the set of passive pairs ofP , except thosebelonging toR. That is,W ′ =W\R. Then any paireiej would be included inW2 preciselywhenaij dropped to zero andeiej /∈R.

The method is detailed by the algorithm shown inFig. 11. Algorithm EXT enumeratesall extensions ofP , not containing pairs ofR. Letwq ∈ W ′ andW ′

1,W′2 ⊆ I , be such that

(W ′\W ′1) ∪ W ′

2 is precisely the set of passive pairs ofP + wq , not inR. The computationof W ′

1 andW ′2 is performed by the call COMPUTE(W ′

1,W′2, wq). It should be noticed that

{w1, . . . , wq−1} ⊆ R when this call is performed. The data structures employed are stan-dard:P andRaren× n matrices, whereasW ′,W ′

1,W′2 are lists. The matrix that represents

P would also representI.Procedure COMPUTEis described inFig. 12. Given a passive pairwq ∈ W ′, it constructs

the setsW1 andW2, such thatW ′(P +wq)= [W ′(P )\W1] ∪W2. Basically, it is an imple-mentation of Lemmas 5–7. The initialization of the process is formulated in the algorithmshown inFig. 13. The computation of the valuesaij can be done directly, using (7)–(8), forall pairseiej ∈ I . Notice that, for the sake of simplicity, bothwq and its symmetric pairwq

are considered as members ofW1.The complexity of the algorithm can be evaluated as follows.The computation(W ′\W1)∪

W2 and restoringW ′ requireO(n) time. Adding or removing a pair toP or Rcan be done in

R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30 29

Fig. 12. An algorithm that constructs the setsW1 andW2 to be used in Ext.

Fig. 13. An algorithm that enumerates the extensions of an order.

constant time. The same applies to verifying whether a pair belongs toP,R or I. Each call ofCOMPUTE, as well as restoring the values ofaij , terminates inO(n) time. On the other hand,each call of EXT corresponds to the enumeration of an extension ofP . The computationR\W requiresO(m) time, wherem=|I |. However, because there is a recursive call for eachwq ∈ W , the removal ofwq from Rcan be charged to the call of EXT corresponding to theextensionP + wq . Consequently, all computationsR\W ′ require no more than amortizedconstant time. In the initialization of the process, finding all values ofaij requiresO(nm)

steps. However, the number� of extensions ofP is�(m). Consequently, the entire algorithmrequiresO(m + n�). It needsO(n2) space, while the delay complexity isO(nm).

8. Conclusions

Let |E| = n, |P | = m and� the total number of extensions ofP . We have described twodistinct characterizations of the set�(P ) of extensions ofP in terms of one-to-one corre-spondences between extensions ofP and pairs of upsets and downsets of certain suborders

30 R.C. Corrêa, J.L. Szwarcfiter / Discrete Mathematics 295 (2005) 13–30

ofP . Both characterizations lead to algorithms that generate all the extensions ofP . Further,we have described a third characterization of�(P ) based on the concept of passive pairs andan algorithm for generating all the extensions ofP whose time complexity isO(m + n�).

Acknowledgements

The authors would like to thank the anonymous referee for the careful reading and usefulsuggestions.

References

[1] P. Baldy, M. Morvan, E. Thierry, Extending a partially ordered set: links with the lattice of ideals, Order 16(1999) 305–312.

[2] V.C. Barbosa, J.L. Szwarcfiter, Generating all the acyclic orientations of an undirected graph, Inform. Process.Lett. 72 (1999) 71–74.

[3] R. Bonnnet, M. Pouzet, Extensions et stratifications d’ensembles dispersés, C. R.Acad. Sci. Ser.A 268 (1969)1512–1515.

[4] R. Corrêa,A. Ferreira,A polynomial branching procedure for the multiprocessor scheduling problem, LectureNotes in Computer Science, Proceedings EUROPAR’99, vol. 1685, Springer, Berlin, 1999, pp. 272–279.

[5] S. Felsner, J. Gustedt, M. Morvan, Interval reductions and extensions of orders: bijections to chains in lattices,Order 15 (1999) 221–246.

[6] M. Habib, M. Morvan, M. Pouzet, J.-X. Rampon, Extensions intervallaires minimales, C. R. Acad. Sci. ParisSer. I 313 (1991) 893–898.

[7] A.D. Kalvin, Y.L. Varol, On the generation of topological sortings, J. Algorithms 4 (1983) 150–162.[8] D.E. Knuth, J.L. Szwarcfiter, A structured program to generate all topological sorting arrangements, Inform.

Process. Lett. 2 (1974) 153–157.[9] M. Morvan, L. Nourine, Generating minimal interval extensions, Rapport de Recherche 92-05, Laboratoire

d’Informatique, Robotique et Microéléctronique, Université de Montpellier II, 1992.[10] G. Pruesse, F. Ruskey, Generating linear extensions fast, SIAM J. Comput. 23 (1994) 373–386.[11] M.B. Squire, Generating the acyclic orientations of a graph, J. Algorithms 26 (1998) 275–290.[12] M.B. Squire, Enumerating the ideals of a poset, manuscript.[13] G. Steiner, An algorithm to generate the ideals of a partial order, Oper. Res. Lett. 5 (1986) 317–320.[14] Y.L. Varol, D. Rotem, An algorithm to generate all topological arrangements, Comput. J. 24 (1981) 83–84.